about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorThom Chiovoloni <thom@shift.click>2022-06-30 15:50:48 -0700
committerThom Chiovoloni <thom@shift.click>2022-06-30 15:50:48 -0700
commit79f8dc0b898b0a387df684a539cd97446a0f964f (patch)
tree2fca5bacb515443dbe602d1a7355407a1e2e2114 /src
parent7425fb293f510a6f138e82a963a3bc599a5b9e1c (diff)
downloadrust-79f8dc0b898b0a387df684a539cd97446a0f964f.tar.gz
rust-79f8dc0b898b0a387df684a539cd97446a0f964f.zip
Add a `--build-dir` flag to rustbuild
Diffstat (limited to 'src')
-rw-r--r--src/bootstrap/bootstrap.py3
-rw-r--r--src/bootstrap/config.rs2
-rw-r--r--src/bootstrap/flags.rs8
3 files changed, 11 insertions, 2 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 8000e60f64d..6ead79ef040 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -866,6 +866,7 @@ def bootstrap(help_triggered):
 
     parser = argparse.ArgumentParser(description='Build rust')
     parser.add_argument('--config')
+    parser.add_argument('--build-dir')
     parser.add_argument('--build')
     parser.add_argument('--color', choices=['always', 'never', 'auto'])
     parser.add_argument('--clean', action='store_true')
@@ -915,7 +916,7 @@ def bootstrap(help_triggered):
 
     build.check_vendored_status()
 
-    build_dir = build.get_toml('build-dir', 'build') or 'build'
+    build_dir = args.build_dir or build.get_toml('build-dir', 'build') or 'build'
     build.build_dir = os.path.abspath(build_dir)
 
     with open(os.path.join(build.rust_root, "src", "stage0.json")) as f:
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 14607741932..2fc18c9e79e 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -857,7 +857,7 @@ impl Config {
         let build = toml.build.unwrap_or_default();
 
         set(&mut config.initial_rustc, build.rustc.map(PathBuf::from));
-        set(&mut config.out, build.build_dir.map(PathBuf::from));
+        set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from)));
         // NOTE: Bootstrap spawns various commands with different working directories.
         // To avoid writing to random places on the file system, `config.out` needs to be an absolute path.
         if !config.out.is_absolute() {
diff --git a/src/bootstrap/flags.rs b/src/bootstrap/flags.rs
index 9d4bb978bdc..7ebae55efc1 100644
--- a/src/bootstrap/flags.rs
+++ b/src/bootstrap/flags.rs
@@ -51,6 +51,7 @@ pub struct Flags {
     pub host: Option<Vec<TargetSelection>>,
     pub target: Option<Vec<TargetSelection>>,
     pub config: Option<PathBuf>,
+    pub build_dir: Option<PathBuf>,
     pub jobs: Option<u32>,
     pub cmd: Subcommand,
     pub incremental: bool,
@@ -174,6 +175,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
         opts.optflagmulti("v", "verbose", "use verbose output (-vv for very verbose)");
         opts.optflag("i", "incremental", "use incremental compilation");
         opts.optopt("", "config", "TOML configuration file for build", "FILE");
+        opts.optopt(
+            "",
+            "build-dir",
+            "Build directory, overrides `build.build-dir` in `config.toml`",
+            "DIR",
+        );
         opts.optopt("", "build", "build target of the stage0 compiler", "BUILD");
         opts.optmulti("", "host", "host targets to build", "HOST");
         opts.optmulti("", "target", "target targets to build", "TARGET");
@@ -649,6 +656,7 @@ Arguments:
                 None
             },
             config: matches.opt_str("config").map(PathBuf::from),
+            build_dir: matches.opt_str("build-dir").map(PathBuf::from),
             jobs: matches.opt_str("jobs").map(|j| j.parse().expect("`jobs` should be a number")),
             cmd,
             incremental: matches.opt_present("incremental"),