Skip to content

Commit 85c87f6

Browse files
committed
Add bootstrap to tidy check
1 parent 9cde0f7 commit 85c87f6

File tree

2 files changed

+106
-4
lines changed

2 files changed

+106
-4
lines changed

src/bootstrap/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ impl Build {
549549
];
550550
for s in rust_submodules {
551551
build.update_submodule(Path::new(s));
552-
}
552+
}
553553

554554
build.verbose("learning about cargo");
555555
metadata::build(&mut build);

src/tools/tidy/src/deps.rs

+105-3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ const EXCEPTIONS_CRANELIFT: &[(&str, &str)] = &[
6363
("target-lexicon", "Apache-2.0 WITH LLVM-exception"),
6464
];
6565

66+
const EXCEPTIONS_BOOTSTRAP: &[(&str, &str)] = &[
67+
("ryu", "Apache-2.0 OR BSL-1.0"), // through serde
68+
];
69+
6670
/// These are the root crates that are part of the runtime. The licenses for
6771
/// these and all their dependencies *must not* be in the exception list.
6872
const RUNTIME_CRATES: &[&str] = &["std", "core", "alloc", "test", "panic_abort", "panic_unwind"];
@@ -96,7 +100,6 @@ const PERMITTED_DEPENDENCIES: &[&str] = &[
96100
"chalk-ir",
97101
"chalk-solve",
98102
"chrono",
99-
"cmake",
100103
"compiler_builtins",
101104
"cpufeatures",
102105
"crc32fast",
@@ -290,6 +293,82 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
290293
"winapi-x86_64-pc-windows-gnu",
291294
];
292295

296+
const PERMITTED_BOOTSTRAP_DEPENDENCIES: &[&str] = &[
297+
"aho-corasick",
298+
"autocfg",
299+
"ansi_term",
300+
"block-buffer",
301+
"bitflags",
302+
"bstr",
303+
"core-foundation-sys",
304+
"cc",
305+
"cfg-if",
306+
"crossbeam-utils",
307+
"cmake",
308+
"cpufeatures",
309+
"crossbeam-channel",
310+
"crossbeam-deque",
311+
"crossbeam-epoch",
312+
"crypto-common",
313+
"ctor",
314+
"diff",
315+
"digest",
316+
"either",
317+
"filetime",
318+
"fnv",
319+
"getopts",
320+
"generic-array",
321+
"globset",
322+
"hermit-abi",
323+
"hex",
324+
"ignore",
325+
"itoa",
326+
"lazy_static",
327+
"libc",
328+
"log",
329+
"lzma-sys",
330+
"memchr",
331+
"memoffset",
332+
"ntapi",
333+
"num_cpus",
334+
"once_cell",
335+
"opener",
336+
"output_vt100",
337+
"pkg-config",
338+
"pretty_assertions",
339+
"proc-macro2",
340+
"quote",
341+
"rayon",
342+
"rayon-core",
343+
"redox_syscall",
344+
"regex",
345+
"regex-automata",
346+
"regex-syntax",
347+
"ryu",
348+
"same-file",
349+
"scopeguard",
350+
"serde",
351+
"serde_derive",
352+
"serde_json",
353+
"sha2",
354+
"syn",
355+
"sysinfo",
356+
"tar",
357+
"thread_local",
358+
"toml",
359+
"typenum",
360+
"unicode-ident",
361+
"unicode-width",
362+
"version_check",
363+
"walkdir",
364+
"winapi",
365+
"winapi-i686-pc-windows-gnu",
366+
"winapi-util",
367+
"winapi-x86_64-pc-windows-gnu",
368+
"xattr",
369+
"xz2",
370+
];
371+
293372
const FORBIDDEN_TO_HAVE_DUPLICATES: &[&str] = &[
294373
// These two crates take quite a long time to build, so don't allow two versions of them
295374
// to accidentally sneak into our dependency graph, in order to ensure we keep our CI times
@@ -309,7 +388,13 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
309388
let metadata = t!(cmd.exec());
310389
let runtime_ids = compute_runtime_crates(&metadata);
311390
check_exceptions(&metadata, EXCEPTIONS, runtime_ids, bad);
312-
check_dependencies(&metadata, PERMITTED_DEPENDENCIES, RESTRICTED_DEPENDENCY_CRATES, bad);
391+
check_dependencies(
392+
&metadata,
393+
"main workspace",
394+
PERMITTED_DEPENDENCIES,
395+
RESTRICTED_DEPENDENCY_CRATES,
396+
bad,
397+
);
313398
check_crate_duplicate(&metadata, FORBIDDEN_TO_HAVE_DUPLICATES, bad);
314399
check_rustfix(&metadata, bad);
315400

@@ -323,11 +408,27 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
323408
check_exceptions(&metadata, EXCEPTIONS_CRANELIFT, runtime_ids, bad);
324409
check_dependencies(
325410
&metadata,
411+
"cranelift",
326412
PERMITTED_CRANELIFT_DEPENDENCIES,
327413
&["rustc_codegen_cranelift"],
328414
bad,
329415
);
330416
check_crate_duplicate(&metadata, &[], bad);
417+
418+
let mut cmd = cargo_metadata::MetadataCommand::new();
419+
cmd.cargo_path(cargo)
420+
.manifest_path(root.join("src/bootstrap/Cargo.toml"))
421+
.features(cargo_metadata::CargoOpt::AllFeatures);
422+
let metadata = t!(cmd.exec());
423+
let runtime_ids = HashSet::new();
424+
check_exceptions(&metadata, EXCEPTIONS_BOOTSTRAP, runtime_ids, bad);
425+
check_dependencies(
426+
&metadata,
427+
"bootstrap",
428+
PERMITTED_BOOTSTRAP_DEPENDENCIES,
429+
&["bootstrap"],
430+
bad,
431+
);
331432
}
332433

333434
/// Check that all licenses are in the valid list in `LICENSES`.
@@ -409,6 +510,7 @@ fn check_exceptions(
409510
/// Specifically, this checks that the dependencies are on the `PERMITTED_DEPENDENCIES`.
410511
fn check_dependencies(
411512
metadata: &Metadata,
513+
descr: &str,
412514
permitted_dependencies: &[&'static str],
413515
restricted_dependency_crates: &[&'static str],
414516
bad: &mut bool,
@@ -438,7 +540,7 @@ fn check_dependencies(
438540
}
439541

440542
if !unapproved.is_empty() {
441-
tidy_error!(bad, "Dependencies not explicitly permitted:");
543+
tidy_error!(bad, "Dependencies for {} not explicitly permitted:", descr);
442544
for dep in unapproved {
443545
println!("* {dep}");
444546
}

0 commit comments

Comments
 (0)