Skip to content

Commit 9b0634a

Browse files
feat: IOS cross compilation (#85)
1 parent b12f234 commit 9b0634a

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

build.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ fn switch(configure: &mut Command, feature: &str, name: &str) {
187187
configure.arg(arg.to_string() + name);
188188
}
189189

190+
fn get_ffmpet_target_os() -> String {
191+
let cargo_target_os = env::var("CARGO_CFG_TARGET_OS").unwrap();
192+
match cargo_target_os.as_str() {
193+
"ios" => "darwin".to_string(),
194+
_ => cargo_target_os,
195+
}
196+
}
197+
190198
fn build() -> io::Result<()> {
191199
let source_dir = source();
192200

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

218226
let compiler = cc.get_compiler();
219227
let compiler = compiler.path().file_stem().unwrap().to_str().unwrap();
220-
let suffix_pos = compiler.rfind('-').unwrap(); // cut off "-gcc"
221-
let prefix = compiler[0..suffix_pos].trim_end_matches("-wr"); // "wr-c++" compiler
222-
223-
configure.arg(format!("--cross-prefix={}-", prefix));
228+
if let Some(suffix_pos) = compiler.rfind('-') {
229+
let prefix = compiler[0..suffix_pos].trim_end_matches("-wr"); // "wr-c++" compiler
230+
configure.arg(format!("--cross-prefix={}-", prefix));
231+
}
224232
configure.arg(format!(
225233
"--arch={}",
226234
env::var("CARGO_CFG_TARGET_ARCH").unwrap()
227235
));
228-
configure.arg(format!(
229-
"--target_os={}",
230-
env::var("CARGO_CFG_TARGET_OS").unwrap()
231-
));
236+
configure.arg(format!("--target_os={}", get_ffmpet_target_os()));
232237
}
233238

234239
// control debug build

0 commit comments

Comments
 (0)