Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit cf1e94f

Browse files
committed
fix: improve handling of -o flag
1 parent 0c76822 commit cf1e94f

File tree

2 files changed

+19
-11
lines changed

2 files changed

+19
-11
lines changed

compiler/codegen/src/linker/link.rs

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use std::ascii;
2+
use std::cell::OnceCell;
23
use std::char;
34
use std::env;
45
use std::ffi::OsString;
56
use std::fmt;
67
use std::fs;
78
use std::io;
8-
use std::cell::OnceCell;
99
use std::path::{Path, PathBuf};
1010
use std::process::{Output, Stdio};
1111
use std::str;
@@ -89,13 +89,12 @@ pub fn link_binary(
8989

9090
// `output_dir` is not necessarily the parent of `output_file`, such as with
9191
// `--output-dir _build --output bin/myapp`
92-
let output_file_parent = output_file.parent().with_context(|| {
93-
format!(
94-
"{} does not have a parent directory",
95-
output_file.as_display()
96-
)
97-
})?;
98-
fs::create_dir_all(output_file_parent).with_context(|| {
92+
let output_file_parent = if output_file.is_absolute() {
93+
output_file.parent().unwrap().to_path_buf()
94+
} else {
95+
output_dir.clone()
96+
};
97+
fs::create_dir_all(output_file_parent.as_path()).with_context(|| {
9998
format!(
10099
"Could not create parent directories ({}) of file ({})",
101100
output_file_parent.as_display(),
@@ -168,7 +167,7 @@ pub fn link_binary(
168167
// about all dynamic library dependencies that they're not linked in.
169168
fn link_staticlib<'a>(
170169
options: &'a Options,
171-
_diagnostics: &DiagnosticsHandler,
170+
diagnostics: &DiagnosticsHandler,
172171
project_type: ProjectType,
173172
codegen_results: &CodegenResults,
174173
output_file: &Path,
@@ -190,6 +189,11 @@ fn link_staticlib<'a>(
190189

191190
ab.build();
192191

192+
diagnostics.success(
193+
"Linker",
194+
format!("generated static library to {}", output_file.display()),
195+
);
196+
193197
Ok(())
194198
}
195199

@@ -239,7 +243,7 @@ fn link_natively(
239243
}
240244

241245
if options.debugging_opts.print_link_args {
242-
println!("{:?}", &cmd);
246+
diagnostics.notice("Linker", format!("{:?}", &cmd));
243247
}
244248

245249
// May have not found libraries in the right formats.
@@ -366,6 +370,11 @@ fn link_natively(
366370
}
367371
}
368372

373+
diagnostics.success(
374+
"Linker",
375+
format!("generated executable to {}", output_file.display()),
376+
);
377+
369378
Ok(())
370379
}
371380

compiler/driver/src/argparser.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ fn compile_command<'a, 'b>() -> App<'a, 'b> {
115115
.help("Specify the version of the Erlang application being built")
116116
.long("app-version")
117117
.takes_value(true)
118-
.possible_values(&["lib", "bin"])
119118
)
120119
.arg(
121120
Arg::with_name("app")

0 commit comments

Comments
 (0)