diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-11-27 08:13:48 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-27 08:13:48 +0100 |
| commit | 04d633366d163f12c7639dfefd22dc27e29f2a08 (patch) | |
| tree | c866e37bd4dfa532a3d9e0b1e2d779caaabda2d5 /src/bootstrap | |
| parent | dcebc5eddd4dccc444d68eae8d5d321d63d2c06f (diff) | |
| parent | db71194416700d2c1365ae1ee7f882aa3a055a67 (diff) | |
| download | rust-04d633366d163f12c7639dfefd22dc27e29f2a08.tar.gz rust-04d633366d163f12c7639dfefd22dc27e29f2a08.zip | |
Rollup merge of #133453 - ferrocene:check-license-metadata, r=Kobzol
Commit license-metadata.json to git and check it's correct in CI This PR adds `license-metadata.json` to the root of the git repo, and changes `mingw-check` to check that the file is still up-to-date. By committing this file, we remove the need for developers to a) have reuse installed or b) run an expensive ~90 second analysis of the files on disk when they want generate the COPYRIGHT.html files which depend on this license metadata. The file will need updating whenever `REUSE.toml` changes, or when git submodules are added, or when git submodules change their license information (as detected by REUSE). You can now run: * `./x run collect-license-metadata` to update the `./license-metadata.json` file * `./x test collect-license-metadata` to test the `./license-metadata.json` file for correctness The comparison is done with two `serde_json::Value` objects, so the map objects they contain should ignore differences in ordering.
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/run.rs | 6 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/test.rs | 32 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder/mod.rs | 1 |
3 files changed, 35 insertions, 4 deletions
diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 1a0a90564e6..c76504761be 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -181,8 +181,7 @@ impl Step for CollectLicenseMetadata { panic!("REUSE is required to collect the license metadata"); }; - // Temporary location, it will be moved to src/etc once it's accurate. - let dest = builder.out.join("license-metadata.json"); + let dest = builder.src.join("license-metadata.json"); let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata); cmd.env("REUSE_EXE", reuse); @@ -209,8 +208,7 @@ impl Step for GenerateCopyright { } fn run(self, builder: &Builder<'_>) -> Self::Output { - let license_metadata = builder.ensure(CollectLicenseMetadata); - + let license_metadata = builder.src.join("license-metadata.json"); let dest = builder.out.join("COPYRIGHT.html"); let dest_libstd = builder.out.join("COPYRIGHT-library.html"); diff --git a/src/bootstrap/src/core/build_steps/test.rs b/src/bootstrap/src/core/build_steps/test.rs index b5c2b1692b4..dd967bca867 100644 --- a/src/bootstrap/src/core/build_steps/test.rs +++ b/src/bootstrap/src/core/build_steps/test.rs @@ -3670,3 +3670,35 @@ impl Step for TestFloatParse { cargo_run.into_cmd().run(builder); } } + +#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)] +pub struct CollectLicenseMetadata; + +impl Step for CollectLicenseMetadata { + type Output = PathBuf; + const ONLY_HOSTS: bool = true; + + fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { + run.path("src/tools/collect-license-metadata") + } + + fn make_run(run: RunConfig<'_>) { + run.builder.ensure(CollectLicenseMetadata); + } + + fn run(self, builder: &Builder<'_>) -> Self::Output { + let Some(reuse) = &builder.config.reuse else { + panic!("REUSE is required to collect the license metadata"); + }; + + let dest = builder.src.join("license-metadata.json"); + + let mut cmd = builder.tool_cmd(Tool::CollectLicenseMetadata); + cmd.env("REUSE_EXE", reuse); + cmd.env("DEST", &dest); + cmd.env("ONLY_CHECK", "1"); + cmd.run(builder); + + dest + } +} diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index d59e0fa7288..e6902bb8cee 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -915,6 +915,7 @@ impl<'a> Builder<'a> { test::HtmlCheck, test::RustInstaller, test::TestFloatParse, + test::CollectLicenseMetadata, // Run bootstrap close to the end as it's unlikely to fail test::Bootstrap, // Run run-make last, since these won't pass without make on Windows |
