Skip to content

Commit e7b9694

Browse files
committed
Add a separate licenses list for licenses that are fine in tools only
With this the only remaining license exceptions are for licenses that are to copyleft to varying degrees.
1 parent 8510865 commit e7b9694

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

src/tools/tidy/src/deps.rs

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ const LICENSES: &[&str] = &[
5454
// tidy-alphabetical-end
5555
];
5656

57+
/// These are licenses that are allowed for rustc, tools, etc. But not for the runtime!
58+
#[rustfmt::skip]
59+
const LICENSES_TOOLS: &[&str] = &[
60+
// tidy-alphabetical-start
61+
"(Apache-2.0 OR MIT) AND BSD-3-Clause",
62+
"Apache-2.0 AND ISC",
63+
"Apache-2.0 OR BSL-1.0", // BSL is not acceptble, but we use it under Apache-2.0
64+
"BSD-2-Clause",
65+
"BSD-3-Clause",
66+
"CC0-1.0",
67+
"Zlib",
68+
// tidy-alphabetical-end
69+
];
70+
5771
type ExceptionList = &'static [(&'static str, &'static str)];
5872

5973
#[derive(Clone, Copy)]
@@ -175,11 +189,8 @@ pub(crate) const WORKSPACES: &[WorkspaceInfo<'static>] = &[
175189
#[rustfmt::skip]
176190
const EXCEPTIONS: ExceptionList = &[
177191
// tidy-alphabetical-start
178-
("arrayref", "BSD-2-Clause"), // rustc
179192
("colored", "MPL-2.0"), // rustfmt
180-
("foldhash", "Zlib"), // rustc
181193
("option-ext", "MPL-2.0"), // cargo-miri (via `directories`)
182-
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0 // cargo/... (because of serde)
183194
// tidy-alphabetical-end
184195
];
185196

@@ -196,39 +207,22 @@ const EXCEPTIONS_STDLIB: ExceptionList = &[
196207

197208
const EXCEPTIONS_CARGO: ExceptionList = &[
198209
// tidy-alphabetical-start
199-
("arrayref", "BSD-2-Clause"),
200210
("bitmaps", "MPL-2.0+"),
201-
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
202-
("foldhash", "Zlib"),
203211
("im-rc", "MPL-2.0+"),
204-
("libz-rs-sys", "Zlib"),
205-
("ring", "Apache-2.0 AND ISC"),
206-
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0
207212
("sized-chunks", "MPL-2.0+"),
208-
("subtle", "BSD-3-Clause"),
209-
("zlib-rs", "Zlib"),
210213
// tidy-alphabetical-end
211214
];
212215

213216
const EXCEPTIONS_RUST_ANALYZER: ExceptionList = &[
214217
// tidy-alphabetical-start
215-
("foldhash", "Zlib"),
216-
("notify", "CC0-1.0"),
217218
("option-ext", "MPL-2.0"),
218-
("ryu", "Apache-2.0 OR BSL-1.0"), // BSL is not acceptble, but we use it under Apache-2.0
219-
// tidy-alphabetical-end
219+
// tidy-alphabetical-end
220220
];
221221

222222
const EXCEPTIONS_RUSTC_PERF: ExceptionList = &[
223223
// tidy-alphabetical-start
224-
("alloc-no-stdlib", "BSD-3-Clause"),
225-
("alloc-stdlib", "BSD-3-Clause"),
226-
("encoding_rs", "(Apache-2.0 OR MIT) AND BSD-3-Clause"),
227224
("inferno", "CDDL-1.0"),
228225
("option-ext", "MPL-2.0"),
229-
("ryu", "Apache-2.0 OR BSL-1.0"),
230-
("snap", "BSD-3-Clause"),
231-
("subtle", "BSD-3-Clause"),
232226
// tidy-alphabetical-end
233227
];
234228

@@ -238,15 +232,10 @@ const EXCEPTIONS_RUSTBOOK: ExceptionList = &[
238232
("cssparser-macros", "MPL-2.0"),
239233
("dtoa-short", "MPL-2.0"),
240234
("mdbook", "MPL-2.0"),
241-
("ryu", "Apache-2.0 OR BSL-1.0"),
242235
// tidy-alphabetical-end
243236
];
244237

245-
const EXCEPTIONS_CRANELIFT: ExceptionList = &[
246-
// tidy-alphabetical-start
247-
("foldhash", "Zlib"),
248-
// tidy-alphabetical-end
249-
];
238+
const EXCEPTIONS_CRANELIFT: ExceptionList = &[];
250239

251240
const EXCEPTIONS_GCC: ExceptionList = &[
252241
// tidy-alphabetical-start
@@ -255,9 +244,7 @@ const EXCEPTIONS_GCC: ExceptionList = &[
255244
// tidy-alphabetical-end
256245
];
257246

258-
const EXCEPTIONS_BOOTSTRAP: ExceptionList = &[
259-
("ryu", "Apache-2.0 OR BSL-1.0"), // through serde. BSL is not acceptble, but we use it under Apache-2.0
260-
];
247+
const EXCEPTIONS_BOOTSTRAP: ExceptionList = &[];
261248

262249
const EXCEPTIONS_UEFI_QEMU_TEST: ExceptionList = &[];
263250

@@ -824,7 +811,7 @@ fn check_license_exceptions(
824811
}
825812
}
826813
}
827-
if LICENSES.contains(license) {
814+
if LICENSES.contains(license) || LICENSES_TOOLS.contains(license) {
828815
check.error(format!(
829816
"dependency exception `{name}` is not necessary. `{license}` is an allowed license"
830817
));
@@ -852,7 +839,7 @@ fn check_license_exceptions(
852839
continue;
853840
}
854841
};
855-
if !LICENSES.contains(&license.as_str()) {
842+
if !LICENSES.contains(&license.as_str()) && !LICENSES_TOOLS.contains(&license.as_str()) {
856843
check.error(format!(
857844
"invalid license `{}` for package `{}` in workspace `{workspace}`",
858845
license, pkg.id

0 commit comments

Comments
 (0)