Skip to content

Commit d8e8fc5

Browse files
committed
Keep list of submodules close to list of vendored workspaces
This moves the list of submodules needed to vendor close to the list of cargo workspaces with the intent to help ensure they keep up-to-date and in sync.
1 parent 16550d9 commit d8e8fc5

File tree

2 files changed

+27
-24
lines changed

2 files changed

+27
-24
lines changed

src/bootstrap/src/core/build_steps/dist.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1026,7 +1026,7 @@ impl Step for PlainSourceTarball {
10261026
let mut cmd = command(&builder.initial_cargo);
10271027
cmd.arg("vendor").arg("--versioned-dirs");
10281028

1029-
for p in default_paths_to_vendor(builder) {
1029+
for (p, _) in default_paths_to_vendor(builder) {
10301030
cmd.arg("--sync").arg(p);
10311031
}
10321032

src/bootstrap/src/core/build_steps/vendor.rs

+26-23
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,26 @@ use crate::core::build_steps::tool::SUBMODULES_FOR_RUSTBOOK;
44
use crate::core::builder::{Builder, RunConfig, ShouldRun, Step};
55
use crate::utils::exec::command;
66

7-
/// List of default paths used for vendoring for `x vendor` and dist tarballs.
8-
pub fn default_paths_to_vendor(builder: &Builder<'_>) -> Vec<PathBuf> {
9-
let mut paths = vec![];
10-
for p in [
11-
"src/tools/cargo/Cargo.toml",
12-
"src/tools/rust-analyzer/Cargo.toml",
13-
"compiler/rustc_codegen_cranelift/Cargo.toml",
14-
"compiler/rustc_codegen_gcc/Cargo.toml",
15-
"library/Cargo.toml",
16-
"src/bootstrap/Cargo.toml",
17-
"src/tools/rustbook/Cargo.toml",
18-
"src/tools/rustc-perf/Cargo.toml",
19-
"src/tools/opt-dist/Cargo.toml",
20-
] {
21-
paths.push(builder.src.join(p));
22-
}
23-
24-
paths
7+
/// Returns the cargo workspaces to vendor for `x vendor` and dist tarballs.
8+
///
9+
/// Returns a `Vec` of `(path_to_manifest, submodules_required)` where
10+
/// `path_to_manifest` is the cargo workspace, and `submodules_required` is
11+
/// the set of submodules that must be available.
12+
pub fn default_paths_to_vendor(builder: &Builder<'_>) -> Vec<(PathBuf, Vec<&'static str>)> {
13+
[
14+
("src/tools/cargo/Cargo.toml", vec!["src/tools/cargo"]),
15+
("src/tools/rust-analyzer/Cargo.toml", vec![]),
16+
("compiler/rustc_codegen_cranelift/Cargo.toml", vec![]),
17+
("compiler/rustc_codegen_gcc/Cargo.toml", vec![]),
18+
("library/Cargo.toml", vec![]),
19+
("src/bootstrap/Cargo.toml", vec![]),
20+
("src/tools/rustbook/Cargo.toml", SUBMODULES_FOR_RUSTBOOK.into()),
21+
("src/tools/rustc-perf/Cargo.toml", vec!["src/tools/rustc-perf"]),
22+
("src/tools/opt-dist/Cargo.toml", vec![]),
23+
]
24+
.into_iter()
25+
.map(|(path, submodules)| (builder.src.join(path), submodules))
26+
.collect()
2527
}
2628

2729
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
@@ -56,15 +58,16 @@ impl Step for Vendor {
5658
cmd.arg("--versioned-dirs");
5759
}
5860

61+
let to_vendor = default_paths_to_vendor(builder);
5962
// These submodules must be present for `x vendor` to work.
60-
for submodule in
61-
SUBMODULES_FOR_RUSTBOOK.iter().chain(["src/tools/cargo", "src/tools/rustc-perf"].iter())
62-
{
63-
builder.build.require_submodule(submodule, None);
63+
for (_, submodules) in &to_vendor {
64+
for submodule in submodules {
65+
builder.build.require_submodule(submodule, None);
66+
}
6467
}
6568

6669
// Sync these paths by default.
67-
for p in default_paths_to_vendor(builder) {
70+
for (p, _) in &to_vendor {
6871
cmd.arg("--sync").arg(p);
6972
}
7073

0 commit comments

Comments
 (0)