@@ -358,37 +358,37 @@ impl Config {
358
358
. collect ( ) ;
359
359
}
360
360
"CFG_MUSL_ROOT" if value. len ( ) > 0 => {
361
- self . musl_root = Some ( PathBuf :: from ( value) ) ;
361
+ self . musl_root = Some ( parse_configure_path ( value) ) ;
362
362
}
363
363
"CFG_MUSL_ROOT_X86_64" if value. len ( ) > 0 => {
364
364
let target = "x86_64-unknown-linux-musl" . to_string ( ) ;
365
365
let target = self . target_config . entry ( target)
366
366
. or_insert ( Target :: default ( ) ) ;
367
- target. musl_root = Some ( PathBuf :: from ( value) ) ;
367
+ target. musl_root = Some ( parse_configure_path ( value) ) ;
368
368
}
369
369
"CFG_MUSL_ROOT_I686" if value. len ( ) > 0 => {
370
370
let target = "i686-unknown-linux-musl" . to_string ( ) ;
371
371
let target = self . target_config . entry ( target)
372
372
. or_insert ( Target :: default ( ) ) ;
373
- target. musl_root = Some ( PathBuf :: from ( value) ) ;
373
+ target. musl_root = Some ( parse_configure_path ( value) ) ;
374
374
}
375
375
"CFG_MUSL_ROOT_ARM" if value. len ( ) > 0 => {
376
376
let target = "arm-unknown-linux-musleabi" . to_string ( ) ;
377
377
let target = self . target_config . entry ( target)
378
378
. or_insert ( Target :: default ( ) ) ;
379
- target. musl_root = Some ( PathBuf :: from ( value) ) ;
379
+ target. musl_root = Some ( parse_configure_path ( value) ) ;
380
380
}
381
381
"CFG_MUSL_ROOT_ARMHF" if value. len ( ) > 0 => {
382
382
let target = "arm-unknown-linux-musleabihf" . to_string ( ) ;
383
383
let target = self . target_config . entry ( target)
384
384
. or_insert ( Target :: default ( ) ) ;
385
- target. musl_root = Some ( PathBuf :: from ( value) ) ;
385
+ target. musl_root = Some ( parse_configure_path ( value) ) ;
386
386
}
387
387
"CFG_MUSL_ROOT_ARMV7" if value. len ( ) > 0 => {
388
388
let target = "armv7-unknown-linux-musleabihf" . to_string ( ) ;
389
389
let target = self . target_config . entry ( target)
390
390
. or_insert ( Target :: default ( ) ) ;
391
- target. musl_root = Some ( PathBuf :: from ( value) ) ;
391
+ target. musl_root = Some ( parse_configure_path ( value) ) ;
392
392
}
393
393
"CFG_DEFAULT_AR" if value. len ( ) > 0 => {
394
394
self . rustc_default_ar = Some ( value. to_string ( ) ) ;
@@ -397,7 +397,7 @@ impl Config {
397
397
self . rustc_default_linker = Some ( value. to_string ( ) ) ;
398
398
}
399
399
"CFG_GDB" if value. len ( ) > 0 => {
400
- self . gdb = Some ( PathBuf :: from ( value) ) ;
400
+ self . gdb = Some ( parse_configure_path ( value) ) ;
401
401
}
402
402
"CFG_RELEASE_CHANNEL" => {
403
403
self . channel = value. to_string ( ) ;
@@ -417,40 +417,40 @@ impl Config {
417
417
"CFG_LLVM_ROOT" if value. len ( ) > 0 => {
418
418
let target = self . target_config . entry ( self . build . clone ( ) )
419
419
. or_insert ( Target :: default ( ) ) ;
420
- let root = PathBuf :: from ( value) ;
420
+ let root = parse_configure_path ( value) ;
421
421
target. llvm_config = Some ( push_exe_path ( root, & [ "bin" , "llvm-config" ] ) ) ;
422
422
}
423
423
"CFG_JEMALLOC_ROOT" if value. len ( ) > 0 => {
424
424
let target = self . target_config . entry ( self . build . clone ( ) )
425
425
. or_insert ( Target :: default ( ) ) ;
426
- target. jemalloc = Some ( PathBuf :: from ( value) ) ;
426
+ target. jemalloc = Some ( parse_configure_path ( value) ) ;
427
427
}
428
428
"CFG_ARM_LINUX_ANDROIDEABI_NDK" if value. len ( ) > 0 => {
429
429
let target = "arm-linux-androideabi" . to_string ( ) ;
430
430
let target = self . target_config . entry ( target)
431
431
. or_insert ( Target :: default ( ) ) ;
432
- target. ndk = Some ( PathBuf :: from ( value) ) ;
432
+ target. ndk = Some ( parse_configure_path ( value) ) ;
433
433
}
434
434
"CFG_ARMV7_LINUX_ANDROIDEABI_NDK" if value. len ( ) > 0 => {
435
435
let target = "armv7-linux-androideabi" . to_string ( ) ;
436
436
let target = self . target_config . entry ( target)
437
437
. or_insert ( Target :: default ( ) ) ;
438
- target. ndk = Some ( PathBuf :: from ( value) ) ;
438
+ target. ndk = Some ( parse_configure_path ( value) ) ;
439
439
}
440
440
"CFG_I686_LINUX_ANDROID_NDK" if value. len ( ) > 0 => {
441
441
let target = "i686-linux-android" . to_string ( ) ;
442
442
let target = self . target_config . entry ( target)
443
443
. or_insert ( Target :: default ( ) ) ;
444
- target. ndk = Some ( PathBuf :: from ( value) ) ;
444
+ target. ndk = Some ( parse_configure_path ( value) ) ;
445
445
}
446
446
"CFG_AARCH64_LINUX_ANDROID_NDK" if value. len ( ) > 0 => {
447
447
let target = "aarch64-linux-android" . to_string ( ) ;
448
448
let target = self . target_config . entry ( target)
449
449
. or_insert ( Target :: default ( ) ) ;
450
- target. ndk = Some ( PathBuf :: from ( value) ) ;
450
+ target. ndk = Some ( parse_configure_path ( value) ) ;
451
451
}
452
452
"CFG_LOCAL_RUST_ROOT" if value. len ( ) > 0 => {
453
- let path = PathBuf :: from ( value) ;
453
+ let path = parse_configure_path ( value) ;
454
454
self . rustc = Some ( push_exe_path ( path. clone ( ) , & [ "bin" , "rustc" ] ) ) ;
455
455
self . cargo = Some ( push_exe_path ( path, & [ "bin" , "cargo" ] ) ) ;
456
456
}
@@ -460,6 +460,29 @@ impl Config {
460
460
}
461
461
}
462
462
463
+ #[ cfg( not( windows) ) ]
464
+ fn parse_configure_path ( path : & str ) -> PathBuf {
465
+ path. into ( )
466
+ }
467
+
468
+ #[ cfg( windows) ]
469
+ fn parse_configure_path ( path : & str ) -> PathBuf {
470
+ // on windows, configure produces unix style paths e.g. /c/some/path but we
471
+ // only want real windows paths
472
+
473
+ use build_helper;
474
+
475
+ // '/' is invalid in windows paths, so we can detect unix paths by the presence of it
476
+ if !path. contains ( '/' ) {
477
+ return path. into ( ) ;
478
+ }
479
+
480
+ let win_path = build_helper:: output ( Command :: new ( "cygpath" ) . arg ( "-w" ) . arg ( path) ) ;
481
+ let win_path = win_path. trim ( ) ;
482
+
483
+ win_path. into ( )
484
+ }
485
+
463
486
fn set < T > ( field : & mut T , val : Option < T > ) {
464
487
if let Some ( v) = val {
465
488
* field = v;
0 commit comments