@@ -1429,52 +1429,56 @@ impl Config {
1429
1429
1430
1430
// Infer the rest of the configuration.
1431
1431
1432
- // Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary,
1433
- // running on a completely different machine from where it was compiled.
1434
- let mut cmd = helpers:: git ( None ) ;
1435
- // NOTE: we cannot support running from outside the repository because the only other path we have available
1436
- // is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally.
1437
- // We still support running outside the repository if we find we aren't in a git directory.
1438
-
1439
- // NOTE: We get a relative path from git to work around an issue on MSYS/mingw. If we used an absolute path,
1440
- // and end up using MSYS's git rather than git-for-windows, we would get a unix-y MSYS path. But as bootstrap
1441
- // has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path.
1442
- cmd. arg ( "rev-parse" ) . arg ( "--show-cdup" ) ;
1443
- // Discard stderr because we expect this to fail when building from a tarball.
1444
- let output = cmd
1445
- . as_command_mut ( )
1446
- . stderr ( std:: process:: Stdio :: null ( ) )
1447
- . output ( )
1448
- . ok ( )
1449
- . and_then ( |output| if output. status . success ( ) { Some ( output) } else { None } ) ;
1450
- if let Some ( output) = output {
1451
- let git_root_relative = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
1452
- // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes,
1453
- // and to resolve any relative components.
1454
- let git_root = env:: current_dir ( )
1455
- . unwrap ( )
1456
- . join ( PathBuf :: from ( git_root_relative. trim ( ) ) )
1457
- . canonicalize ( )
1458
- . unwrap ( ) ;
1459
- let s = git_root. to_str ( ) . unwrap ( ) ;
1460
-
1461
- // Bootstrap is quite bad at handling /? in front of paths
1462
- let git_root = match s. strip_prefix ( "\\ \\ ?\\ " ) {
1463
- Some ( p) => PathBuf :: from ( p) ,
1464
- None => git_root,
1465
- } ;
1466
- // If this doesn't have at least `stage0`, we guessed wrong. This can happen when,
1467
- // for example, the build directory is inside of another unrelated git directory.
1468
- // In that case keep the original `CARGO_MANIFEST_DIR` handling.
1469
- //
1470
- // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside
1471
- // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1.
1472
- if git_root. join ( "src" ) . join ( "stage0" ) . exists ( ) {
1473
- config. src = git_root;
1474
- }
1432
+ if let Some ( src) = flags. src {
1433
+ config. src = src
1475
1434
} else {
1476
- // We're building from a tarball, not git sources.
1477
- // We don't support pre-downloaded bootstrap in this case.
1435
+ // Infer the source directory. This is non-trivial because we want to support a downloaded bootstrap binary,
1436
+ // running on a completely different machine from where it was compiled.
1437
+ let mut cmd = helpers:: git ( None ) ;
1438
+ // NOTE: we cannot support running from outside the repository because the only other path we have available
1439
+ // is set at compile time, which can be wrong if bootstrap was downloaded rather than compiled locally.
1440
+ // We still support running outside the repository if we find we aren't in a git directory.
1441
+
1442
+ // NOTE: We get a relative path from git to work around an issue on MSYS/mingw. If we used an absolute path,
1443
+ // and end up using MSYS's git rather than git-for-windows, we would get a unix-y MSYS path. But as bootstrap
1444
+ // has already been (kinda-cross-)compiled to Windows land, we require a normal Windows path.
1445
+ cmd. arg ( "rev-parse" ) . arg ( "--show-cdup" ) ;
1446
+ // Discard stderr because we expect this to fail when building from a tarball.
1447
+ let output = cmd
1448
+ . as_command_mut ( )
1449
+ . stderr ( std:: process:: Stdio :: null ( ) )
1450
+ . output ( )
1451
+ . ok ( )
1452
+ . and_then ( |output| if output. status . success ( ) { Some ( output) } else { None } ) ;
1453
+ if let Some ( output) = output {
1454
+ let git_root_relative = String :: from_utf8 ( output. stdout ) . unwrap ( ) ;
1455
+ // We need to canonicalize this path to make sure it uses backslashes instead of forward slashes,
1456
+ // and to resolve any relative components.
1457
+ let git_root = env:: current_dir ( )
1458
+ . unwrap ( )
1459
+ . join ( PathBuf :: from ( git_root_relative. trim ( ) ) )
1460
+ . canonicalize ( )
1461
+ . unwrap ( ) ;
1462
+ let s = git_root. to_str ( ) . unwrap ( ) ;
1463
+
1464
+ // Bootstrap is quite bad at handling /? in front of paths
1465
+ let git_root = match s. strip_prefix ( "\\ \\ ?\\ " ) {
1466
+ Some ( p) => PathBuf :: from ( p) ,
1467
+ None => git_root,
1468
+ } ;
1469
+ // If this doesn't have at least `stage0`, we guessed wrong. This can happen when,
1470
+ // for example, the build directory is inside of another unrelated git directory.
1471
+ // In that case keep the original `CARGO_MANIFEST_DIR` handling.
1472
+ //
1473
+ // NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside
1474
+ // the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1.
1475
+ if git_root. join ( "src" ) . join ( "stage0" ) . exists ( ) {
1476
+ config. src = git_root;
1477
+ }
1478
+ } else {
1479
+ // We're building from a tarball, not git sources.
1480
+ // We don't support pre-downloaded bootstrap in this case.
1481
+ }
1478
1482
}
1479
1483
1480
1484
if cfg ! ( test) {
0 commit comments