Skip to content

Commit 6a6d20f

Browse files
committed
bootstrap: allow setting --jobs in config.toml
1 parent 03983fb commit 6a6d20f

File tree

4 files changed

+26
-0
lines changed

4 files changed

+26
-0
lines changed

Diff for: config.example.toml

+4
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,10 @@
414414
# Specify the location of the Android NDK. Used when targeting Android.
415415
#android-ndk = "/path/to/android-ndk-r26d"
416416

417+
# Number of parallel jobs to be used for building and testing. If set to `0` or
418+
# omitted, it will be automatically determined.
419+
#jobs = 0
420+
417421
# =============================================================================
418422
# General install configuration options
419423
# =============================================================================

Diff for: src/bootstrap/src/core/config/config.rs

+8
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,7 @@ define_config! {
891891
metrics: Option<bool> = "metrics",
892892
android_ndk: Option<PathBuf> = "android-ndk",
893893
optimized_compiler_builtins: Option<bool> = "optimized-compiler-builtins",
894+
jobs: Option<u32> = "jobs",
894895
}
895896
}
896897

@@ -1511,6 +1512,7 @@ impl Config {
15111512
metrics: _,
15121513
android_ndk,
15131514
optimized_compiler_builtins,
1515+
jobs,
15141516
} = toml.build.unwrap_or_default();
15151517

15161518
if let Some(file_build) = build {
@@ -1621,6 +1623,12 @@ impl Config {
16211623
// Verbose flag is a good default for `rust.verbose-tests`.
16221624
config.verbose_tests = config.is_verbose();
16231625

1626+
if let Some(jobs) = jobs {
1627+
if jobs > 0 {
1628+
config.jobs = Some(jobs);
1629+
}
1630+
}
1631+
16241632
if let Some(install) = toml.install {
16251633
let Install { prefix, sysconfdir, docdir, bindir, libdir, mandir, datadir } = install;
16261634
config.prefix = prefix.map(PathBuf::from);

Diff for: src/bootstrap/src/core/config/tests.rs

+9
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ fn override_toml() {
122122
"--set=rust.deny-warnings=false".to_owned(),
123123
"--set=build.gdb=\"bar\"".to_owned(),
124124
"--set=build.tools=[\"cargo\"]".to_owned(),
125+
"--set=build.jobs=1".to_owned(),
125126
"--set=llvm.build-config={\"foo\" = \"bar\"}".to_owned(),
126127
"--set=target.x86_64-unknown-linux-gnu.runner=bar".to_owned(),
127128
"--set=target.x86_64-unknown-linux-gnu.rpath=false".to_owned(),
@@ -139,6 +140,7 @@ deny-warnings = true
139140
[build]
140141
gdb = "foo"
141142
tools = []
143+
jobs = 2
142144
143145
[llvm]
144146
download-ci-llvm = false
@@ -171,6 +173,7 @@ runner = "x86_64-runner"
171173
Some(["cargo".to_string()].into_iter().collect()),
172174
"setting list value"
173175
);
176+
assert_eq!(config.jobs, Some(1));
174177
assert_eq!(
175178
config.llvm_build_config,
176179
[("foo".to_string(), "bar".to_string())].into_iter().collect(),
@@ -352,3 +355,9 @@ fn parse_rust_std_features_empty() {
352355
fn parse_rust_std_features_invalid() {
353356
parse("rust.std-features = \"backtrace\"");
354357
}
358+
359+
#[test]
360+
fn parse_jobs_zero() {
361+
assert_eq!(parse("build.jobs = 0").jobs, None);
362+
assert_eq!(parse("build.jobs = 1").jobs, Some(1));
363+
}

Diff for: src/bootstrap/src/utils/change_tracker.rs

+5
Original file line numberDiff line numberDiff line change
@@ -275,4 +275,9 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
275275
severity: ChangeSeverity::Info,
276276
summary: "New option `./x setup editor` added, replacing `./x setup vscode` and adding support for vim, emacs and helix.",
277277
},
278+
ChangeInfo {
279+
change_id: 131838,
280+
severity: ChangeSeverity::Info,
281+
summary: "Allow setting `--jobs` in config.toml with `build.jobs`.",
282+
},
278283
];

0 commit comments

Comments
 (0)