Skip to content

Commit 3d3e2e3

Browse files
generate-copyright: Now generates a library file too.
We only run reuse once, so the output has to be filtered to find only the files that are relevant to the library tree. Outputs COPYRIGHT.html and COPYRIGHT-library.html. The license-metadata.json file is also now in the tree. We need a CI tool to check that it's correct.
1 parent e6c1e14 commit 3d3e2e3

File tree

5 files changed

+394
-40
lines changed

5 files changed

+394
-40
lines changed

license-metadata.json

+204
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
{
2+
"files": {
3+
"children": [
4+
{
5+
"children": [
6+
{
7+
"children": [
8+
{
9+
"license": {
10+
"copyright": [
11+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
12+
],
13+
"spdx": "Apache-2.0 OR MIT"
14+
},
15+
"name": "noscript.css",
16+
"type": "file"
17+
},
18+
{
19+
"license": {
20+
"copyright": [
21+
"Nicolas Gallagher and Jonathan Neal"
22+
],
23+
"spdx": "MIT"
24+
},
25+
"name": "normalize.css",
26+
"type": "file"
27+
}
28+
],
29+
"license": {
30+
"copyright": [
31+
"2016 Ike Ku, Jessica Stokes and Leon Guan",
32+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
33+
],
34+
"spdx": "Apache-2.0 OR MIT"
35+
},
36+
"name": "src/librustdoc/html/static/css",
37+
"type": "directory"
38+
},
39+
{
40+
"children": [
41+
{
42+
"license": {
43+
"copyright": [
44+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
45+
],
46+
"spdx": "Apache-2.0 OR MIT"
47+
},
48+
"name": "README.txt",
49+
"type": "file"
50+
},
51+
{
52+
"directories": [],
53+
"files": [
54+
"FiraSans-LICENSE.txt",
55+
"FiraSans-Medium.woff2",
56+
"FiraSans-Regular.woff2"
57+
],
58+
"license": {
59+
"copyright": [
60+
"2014, Mozilla Foundation",
61+
"2014, Telefonica S.A"
62+
],
63+
"spdx": "OFL-1.1"
64+
},
65+
"type": "group"
66+
},
67+
{
68+
"directories": [],
69+
"files": [
70+
"NanumBarunGothic-LICENSE.txt",
71+
"NanumBarunGothic.ttf.woff2"
72+
],
73+
"license": {
74+
"copyright": [
75+
"2010 NAVER Corporation"
76+
],
77+
"spdx": "OFL-1.1"
78+
},
79+
"type": "group"
80+
}
81+
],
82+
"license": {
83+
"copyright": [
84+
"2010, 2012, 2014-2023, Adobe Systems Incorporated"
85+
],
86+
"spdx": "OFL-1.1"
87+
},
88+
"name": "src/librustdoc/html/static/fonts",
89+
"type": "directory"
90+
},
91+
{
92+
"license": {
93+
"copyright": [
94+
"2003-2019 University of Illinois at Urbana-Champaign",
95+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
96+
],
97+
"spdx": "Apache-2.0 WITH LLVM-exception AND (Apache-2.0 OR MIT)"
98+
},
99+
"name": "compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp",
100+
"type": "file"
101+
},
102+
{
103+
"children": [],
104+
"license": {
105+
"copyright": [
106+
"2014 Alex Crichton",
107+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
108+
],
109+
"spdx": "Apache-2.0 OR MIT"
110+
},
111+
"name": "library/backtrace",
112+
"type": "directory"
113+
},
114+
{
115+
"license": {
116+
"copyright": [
117+
"1991-2022 Unicode, Inc. All rights reserved"
118+
],
119+
"spdx": "Unicode-DFS-2016"
120+
},
121+
"name": "library/core/src/unicode/unicode_data.rs",
122+
"type": "file"
123+
},
124+
{
125+
"children": [],
126+
"license": {
127+
"copyright": [
128+
"2019 The Crossbeam Project Developers",
129+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
130+
],
131+
"spdx": "Apache-2.0 OR MIT"
132+
},
133+
"name": "library/std/src/sync/mpmc",
134+
"type": "directory"
135+
},
136+
{
137+
"license": {
138+
"copyright": [
139+
"2016 The Fuchsia Authors",
140+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
141+
],
142+
"spdx": "BSD-2-Clause AND (Apache-2.0 OR MIT)"
143+
},
144+
"name": "library/std/src/sys/sync/mutex/fuchsia.rs",
145+
"type": "file"
146+
},
147+
{
148+
"license": {
149+
"copyright": [
150+
"NONE"
151+
],
152+
"spdx": "NONE"
153+
},
154+
"name": "qnx_build.sh",
155+
"type": "file"
156+
},
157+
{
158+
"children": [],
159+
"license": {
160+
"copyright": [
161+
"Rust on Embedded Devices Working Group",
162+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
163+
],
164+
"spdx": "Apache-2.0 OR CC-BY-SA-4.0 OR MIT"
165+
},
166+
"name": "src/doc/embedded-book",
167+
"type": "directory"
168+
},
169+
{
170+
"children": [],
171+
"license": {
172+
"copyright": [
173+
"2014 Jorge Aparicio",
174+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
175+
],
176+
"spdx": "Apache-2.0 OR MIT"
177+
},
178+
"name": "src/doc/rust-by-example",
179+
"type": "directory"
180+
},
181+
{
182+
"license": {
183+
"copyright": [
184+
"2014-2021 Knut Sveidqvist"
185+
],
186+
"spdx": "MIT"
187+
},
188+
"name": "src/doc/rustc-dev-guide/mermaid.min.js",
189+
"type": "file"
190+
}
191+
],
192+
"license": {
193+
"copyright": [
194+
"The Rust Project Developers (see https://thanks.rust-lang.org)"
195+
],
196+
"spdx": "Apache-2.0 OR MIT"
197+
},
198+
"name": ".",
199+
"type": "directory"
200+
}
201+
],
202+
"type": "root"
203+
}
204+
}

src/bootstrap/src/core/build_steps/run.rs

+12-13
Original file line numberDiff line numberDiff line change
@@ -177,18 +177,16 @@ impl Step for CollectLicenseMetadata {
177177
}
178178

179179
fn run(self, builder: &Builder<'_>) -> Self::Output {
180-
let Some(reuse) = &builder.config.reuse else {
181-
panic!("REUSE is required to collect the license metadata");
182-
};
183-
184-
// Temporary location, it will be moved to src/etc once it's accurate.
185-
let dest = builder.out.join("license-metadata.json");
186-
187-
let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata);
188-
cmd.env("REUSE_EXE", reuse);
189-
cmd.env("DEST", &dest);
190-
cmd.run(builder);
191-
180+
let dest = PathBuf::from("license-metadata.json");
181+
if !std::fs::exists(&dest).expect("Checking for license metadata") {
182+
let Some(reuse) = &builder.config.reuse else {
183+
panic!("REUSE is required to collect the license metadata");
184+
};
185+
let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata);
186+
cmd.env("REUSE_EXE", reuse);
187+
cmd.env("DEST", &dest);
188+
cmd.run(builder);
189+
}
192190
dest
193191
}
194192
}
@@ -211,12 +209,13 @@ impl Step for GenerateCopyright {
211209
fn run(self, builder: &Builder<'_>) -> Self::Output {
212210
let license_metadata = builder.ensure(CollectLicenseMetadata);
213211

214-
// Temporary location, it will be moved to the proper one once it's accurate.
215212
let dest = builder.out.join("COPYRIGHT.html");
213+
let dest_libstd = builder.out.join("COPYRIGHT-library.html");
216214

217215
let mut cmd = builder.tool_cmd(Tool::GenerateCopyright);
218216
cmd.env("LICENSE_METADATA", &license_metadata);
219217
cmd.env("DEST", &dest);
218+
cmd.env("DEST_LIBSTD", &dest_libstd);
220219
cmd.env("OUT_DIR", &builder.out);
221220
cmd.env("CARGO", &builder.initial_cargo);
222221
cmd.run(builder);

src/tools/generate-copyright/src/cargo_metadata.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,13 @@ pub struct PackageMetadata {
5252
/// assume `reuse` has covered it already.
5353
pub fn get_metadata_and_notices(
5454
cargo: &Path,
55-
dest: &Path,
55+
vendor_path: &Path,
5656
root_path: &Path,
5757
manifest_paths: &[&Path],
5858
) -> Result<BTreeMap<Package, PackageMetadata>, Error> {
5959
let mut output = get_metadata(cargo, root_path, manifest_paths)?;
6060

6161
// Now do a cargo-vendor and grab everything
62-
let vendor_path = dest.join("vendor");
6362
println!("Vendoring deps into {}...", vendor_path.display());
6463
run_cargo_vendor(cargo, &vendor_path, manifest_paths)?;
6564

0 commit comments

Comments
 (0)