Skip to content

Commit 79f8dc0

Browse files
committed
Add a --build-dir flag to rustbuild
1 parent 7425fb2 commit 79f8dc0

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/bootstrap/bootstrap.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,7 @@ def bootstrap(help_triggered):
866866

867867
parser = argparse.ArgumentParser(description='Build rust')
868868
parser.add_argument('--config')
869+
parser.add_argument('--build-dir')
869870
parser.add_argument('--build')
870871
parser.add_argument('--color', choices=['always', 'never', 'auto'])
871872
parser.add_argument('--clean', action='store_true')
@@ -915,7 +916,7 @@ def bootstrap(help_triggered):
915916

916917
build.check_vendored_status()
917918

918-
build_dir = build.get_toml('build-dir', 'build') or 'build'
919+
build_dir = args.build_dir or build.get_toml('build-dir', 'build') or 'build'
919920
build.build_dir = os.path.abspath(build_dir)
920921

921922
with open(os.path.join(build.rust_root, "src", "stage0.json")) as f:

src/bootstrap/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ impl Config {
857857
let build = toml.build.unwrap_or_default();
858858

859859
set(&mut config.initial_rustc, build.rustc.map(PathBuf::from));
860-
set(&mut config.out, build.build_dir.map(PathBuf::from));
860+
set(&mut config.out, flags.build_dir.or_else(|| build.build_dir.map(PathBuf::from)));
861861
// NOTE: Bootstrap spawns various commands with different working directories.
862862
// To avoid writing to random places on the file system, `config.out` needs to be an absolute path.
863863
if !config.out.is_absolute() {

src/bootstrap/flags.rs

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub struct Flags {
5151
pub host: Option<Vec<TargetSelection>>,
5252
pub target: Option<Vec<TargetSelection>>,
5353
pub config: Option<PathBuf>,
54+
pub build_dir: Option<PathBuf>,
5455
pub jobs: Option<u32>,
5556
pub cmd: Subcommand,
5657
pub incremental: bool,
@@ -174,6 +175,12 @@ To learn more about a subcommand, run `./x.py <subcommand> -h`",
174175
opts.optflagmulti("v", "verbose", "use verbose output (-vv for very verbose)");
175176
opts.optflag("i", "incremental", "use incremental compilation");
176177
opts.optopt("", "config", "TOML configuration file for build", "FILE");
178+
opts.optopt(
179+
"",
180+
"build-dir",
181+
"Build directory, overrides `build.build-dir` in `config.toml`",
182+
"DIR",
183+
);
177184
opts.optopt("", "build", "build target of the stage0 compiler", "BUILD");
178185
opts.optmulti("", "host", "host targets to build", "HOST");
179186
opts.optmulti("", "target", "target targets to build", "TARGET");
@@ -649,6 +656,7 @@ Arguments:
649656
None
650657
},
651658
config: matches.opt_str("config").map(PathBuf::from),
659+
build_dir: matches.opt_str("build-dir").map(PathBuf::from),
652660
jobs: matches.opt_str("jobs").map(|j| j.parse().expect("`jobs` should be a number")),
653661
cmd,
654662
incremental: matches.opt_present("incremental"),

0 commit comments

Comments
 (0)