@@ -48,31 +48,33 @@ type ExceptionList = &'static [(&'static str, &'static str)];
48
48
/// * Optionally a tuple of:
49
49
/// * A list of crates for which dependencies need to be explicitly allowed.
50
50
/// * The list of allowed dependencies.
51
+ /// * Submodules required for the workspace.
51
52
// FIXME auto detect all cargo workspaces
52
- pub ( crate ) const WORKSPACES : & [ ( & str , ExceptionList , Option < ( & [ & str ] , & [ & str ] ) > ) ] = & [
53
+ pub ( crate ) const WORKSPACES : & [ ( & str , ExceptionList , Option < ( & [ & str ] , & [ & str ] ) > , & [ & str ] ) ] = & [
53
54
// The root workspace has to be first for check_rustfix to work.
54
- ( "." , EXCEPTIONS , Some ( ( & [ "rustc-main" ] , PERMITTED_RUSTC_DEPENDENCIES ) ) ) ,
55
+ ( "." , EXCEPTIONS , Some ( ( & [ "rustc-main" ] , PERMITTED_RUSTC_DEPENDENCIES ) ) , & [ ] ) ,
55
56
// Outside of the alphabetical section because rustfmt formats it using multiple lines.
56
57
(
57
58
"compiler/rustc_codegen_cranelift" ,
58
59
EXCEPTIONS_CRANELIFT ,
59
60
Some ( ( & [ "rustc_codegen_cranelift" ] , PERMITTED_CRANELIFT_DEPENDENCIES ) ) ,
61
+ & [ ] ,
60
62
) ,
61
63
// tidy-alphabetical-start
62
- ( "compiler/rustc_codegen_gcc" , EXCEPTIONS_GCC , None ) ,
64
+ ( "compiler/rustc_codegen_gcc" , EXCEPTIONS_GCC , None , & [ ] ) ,
63
65
//("library/backtrace", &[], None), // FIXME uncomment once rust-lang/backtrace#562 has been synced back to the rust repo
64
66
//("library/portable-simd", &[], None), // FIXME uncomment once rust-lang/portable-simd#363 has been synced back to the rust repo
65
67
//("library/stdarch", EXCEPTIONS_STDARCH, None), // FIXME uncomment once rust-lang/stdarch#1462 has been synced back to the rust repo
66
- ( "src/bootstrap" , EXCEPTIONS_BOOTSTRAP , None ) ,
67
- ( "src/ci/docker/host-x86_64/test-various/uefi_qemu_test" , EXCEPTIONS_UEFI_QEMU_TEST , None ) ,
68
- ( "src/etc/test-float-parse" , EXCEPTIONS , None ) ,
69
- ( "src/tools/cargo" , EXCEPTIONS_CARGO , None ) ,
68
+ ( "src/bootstrap" , EXCEPTIONS_BOOTSTRAP , None , & [ ] ) ,
69
+ ( "src/ci/docker/host-x86_64/test-various/uefi_qemu_test" , EXCEPTIONS_UEFI_QEMU_TEST , None , & [ ] ) ,
70
+ ( "src/etc/test-float-parse" , EXCEPTIONS , None , & [ ] ) ,
71
+ ( "src/tools/cargo" , EXCEPTIONS_CARGO , None , & [ "src/tools/cargo" ] ) ,
70
72
//("src/tools/miri/test-cargo-miri", &[], None), // FIXME uncomment once all deps are vendored
71
73
//("src/tools/miri/test_dependencies", &[], None), // FIXME uncomment once all deps are vendored
72
- ( "src/tools/rust-analyzer" , EXCEPTIONS_RUST_ANALYZER , None ) ,
73
- ( "src/tools/rustbook" , EXCEPTIONS_RUSTBOOK , None ) ,
74
- ( "src/tools/rustc-perf" , EXCEPTIONS_RUSTC_PERF , None ) ,
75
- ( "src/tools/x" , & [ ] , None ) ,
74
+ ( "src/tools/rust-analyzer" , EXCEPTIONS_RUST_ANALYZER , None , & [ ] ) ,
75
+ ( "src/tools/rustbook" , EXCEPTIONS_RUSTBOOK , None , & [ "src/doc/book" ] ) ,
76
+ ( "src/tools/rustc-perf" , EXCEPTIONS_RUSTC_PERF , None , & [ "src/tools/rustc-perf" ] ) ,
77
+ ( "src/tools/x" , & [ ] , None , & [ ] ) ,
76
78
// tidy-alphabetical-end
77
79
] ;
78
80
@@ -531,16 +533,8 @@ const PERMITTED_CRANELIFT_DEPENDENCIES: &[&str] = &[
531
533
pub fn check ( root : & Path , cargo : & Path , bad : & mut bool ) {
532
534
let mut checked_runtime_licenses = false ;
533
535
534
- let submodules = build_helper:: util:: parse_gitmodules ( root) ;
535
- for & ( workspace, exceptions, permitted_deps) in WORKSPACES {
536
- // Skip if it's a submodule, not in a CI environment, and not initialized.
537
- //
538
- // This prevents enforcing developers to fetch submodules for tidy.
539
- if submodules. contains ( & workspace. into ( ) )
540
- && !CiEnv :: is_ci ( )
541
- // If the directory is empty, we can consider it as an uninitialized submodule.
542
- && read_dir ( root. join ( workspace) ) . unwrap ( ) . next ( ) . is_none ( )
543
- {
536
+ for & ( workspace, exceptions, permitted_deps, submodules) in WORKSPACES {
537
+ if has_missing_submodule ( root, submodules) {
544
538
continue ;
545
539
}
546
540
@@ -573,6 +567,17 @@ pub fn check(root: &Path, cargo: &Path, bad: &mut bool) {
573
567
assert ! ( checked_runtime_licenses) ;
574
568
}
575
569
570
+ /// Used to skip a check if a submodule is not checked out, and not in a CI environment.
571
+ ///
572
+ /// This helps prevent enforcing developers to fetch submodules for tidy.
573
+ pub fn has_missing_submodule ( root : & Path , submodules : & [ & str ] ) -> bool {
574
+ !CiEnv :: is_ci ( )
575
+ && submodules. iter ( ) . any ( |submodule| {
576
+ // If the directory is empty, we can consider it as an uninitialized submodule.
577
+ read_dir ( root. join ( submodule) ) . unwrap ( ) . next ( ) . is_none ( )
578
+ } )
579
+ }
580
+
576
581
/// Check that all licenses of runtime dependencies are in the valid list in `LICENSES`.
577
582
///
578
583
/// Unlike for tools we don't allow exceptions to the `LICENSES` list for the runtime with the sole
0 commit comments