Skip to content

Commit

Permalink
Fixed argument parsing on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
FractalFir committed Sep 14, 2024
1 parent 1f63f9d commit bdcb38c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions cilly/src/bin/linker/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,20 @@ fn file_stem(file: &str) -> String {
.unwrap()
.to_owned()
}

#[cfg(any(target_os = "linux", target_os = "darwin"))]
fn get_out_path(args: &[&str]) -> &str {
&args[1 + args
.iter()
.position(|arg| arg == "-o")
.expect(&format!("No output file! {args:?}"))]
}
#[cfg(target_os = "windows")]
fn get_out_path<'a>(args: &'a [&str]) -> &'a str {
args.iter()
.filter_map(|arg| arg.strip_suffix("/OUT:"))
.next()
.expect(&format!("No output file! {args:?}"))
}
fn main() {
// Parse command line arguments

Expand All @@ -148,10 +161,7 @@ fn main() {
.collect();

//ar_to_link.extend(link_dir_files(args));
let output_file_path = &args[1 + args
.iter()
.position(|arg| arg == "-o")
.expect(&format!("No output file! {args:?}"))];
let output_file_path = get_out_path(args);
// Configs

let cargo_support = args.iter().any(|arg| arg.contains("--cargo-support"));
Expand Down

0 comments on commit bdcb38c

Please sign in to comment.