@@ -189,7 +189,7 @@ fn switch(configure: &mut Command, feature: &str, name: &str) {
189
189
configure. arg ( arg. to_string ( ) + name) ;
190
190
}
191
191
192
- fn build ( ) -> io:: Result < ( ) > {
192
+ fn build ( target_os : & str ) -> io:: Result < ( ) > {
193
193
let source_dir = source ( ) ;
194
194
195
195
// Command's path is not relative to command's current_dir
@@ -217,10 +217,7 @@ fn build() -> io::Result<()> {
217
217
"--arch={}" ,
218
218
env:: var( "CARGO_CFG_TARGET_ARCH" ) . unwrap( )
219
219
) ) ;
220
- configure. arg ( format ! (
221
- "--target_os={}" ,
222
- env:: var( "CARGO_CFG_TARGET_OS" ) . unwrap( )
223
- ) ) ;
220
+ configure. arg ( format ! ( "--target_os={}" , target_os) ) ;
224
221
}
225
222
226
223
// control debug build
@@ -379,6 +376,18 @@ fn build() -> io::Result<()> {
379
376
Ok ( ( ) )
380
377
}
381
378
379
+ fn os_from_triple ( triple : & str ) -> & str {
380
+ let platform = triple. splitn ( 2 , '-' ) . nth ( 1 ) . expect ( "bad triple" ) ;
381
+ platform
382
+ . trim_start_matches ( "unknown-" )
383
+ . trim_start_matches ( "pc-" )
384
+ . trim_start_matches ( "wrs-" )
385
+ . trim_start_matches ( "uwp-" )
386
+ . split ( '-' )
387
+ . next ( )
388
+ . unwrap ( )
389
+ }
390
+
382
391
#[ cfg( not( target_env = "msvc" ) ) ]
383
392
fn try_vcpkg ( _statik : bool ) -> Option < Vec < PathBuf > > {
384
393
None
@@ -633,7 +642,8 @@ fn link_to_libraries(statik: bool, target_os: &str) {
633
642
634
643
fn main ( ) {
635
644
let statik = env:: var ( "CARGO_FEATURE_STATIC" ) . is_ok ( ) ;
636
- let target_os = env:: var ( "CARGO_CFG_TARGET_OS" ) . unwrap ( ) ;
645
+ let target = env:: var ( "TARGET" ) . unwrap ( ) ;
646
+ let target_os = os_from_triple ( & target) ; // it's different than Rust's target_os! but ./configure likes these better
637
647
638
648
let include_paths: Vec < PathBuf > = if env:: var ( "CARGO_FEATURE_BUILD" ) . is_ok ( ) {
639
649
println ! (
@@ -644,7 +654,7 @@ fn main() {
644
654
if fs:: metadata ( & search ( ) . join ( "lib" ) . join ( "libavutil.a" ) ) . is_err ( ) {
645
655
fs:: create_dir_all ( & output ( ) ) . expect ( "failed to create build directory" ) ;
646
656
fetch ( ) . unwrap ( ) ;
647
- build ( ) . unwrap ( ) ;
657
+ build ( & target_os ) . unwrap ( ) ;
648
658
}
649
659
650
660
// Check additional required libraries.
@@ -730,7 +740,7 @@ fn main() {
730
740
. include_paths
731
741
} ;
732
742
733
- if statik && target_os == "macos " {
743
+ if statik && target_os == "darwin " {
734
744
let frameworks = vec ! [
735
745
"AppKit" ,
736
746
"AudioToolbox" ,
0 commit comments