Skip to content

Commit

Permalink
fix: IOS cross compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmtrKovalenko committed Aug 30, 2024
1 parent b12f234 commit 5cea8c0
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ fn switch(configure: &mut Command, feature: &str, name: &str) {
configure.arg(arg.to_string() + name);
}

fn get_ffmpet_target_os() -> String {
let cargo_target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
match cargo_target_os.as_str() {
"ios" => "darwin".to_string(),
_ => cargo_target_os,
}
}

fn build() -> io::Result<()> {
let source_dir = source();

Expand Down Expand Up @@ -217,18 +225,15 @@ fn build() -> io::Result<()> {

let compiler = cc.get_compiler();
let compiler = compiler.path().file_stem().unwrap().to_str().unwrap();
let suffix_pos = compiler.rfind('-').unwrap(); // cut off "-gcc"
let prefix = compiler[0..suffix_pos].trim_end_matches("-wr"); // "wr-c++" compiler

configure.arg(format!("--cross-prefix={}-", prefix));
if let Some(suffix_pos) = compiler.rfind('-') {
let prefix = compiler[0..suffix_pos].trim_end_matches("-wr"); // "wr-c++" compiler
configure.arg(format!("--cross-prefix={}-", prefix));
}
configure.arg(format!(
"--arch={}",
env::var("CARGO_CFG_TARGET_ARCH").unwrap()
));
configure.arg(format!(
"--target_os={}",
env::var("CARGO_CFG_TARGET_OS").unwrap()
));
configure.arg(format!("--target_os={}", get_ffmpet_target_os()));
}

// control debug build
Expand Down

0 comments on commit 5cea8c0

Please sign in to comment.