diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs index 4b48d0901e8a9..ecd63a397e50d 100644 --- a/src/bootstrap/src/core/build_steps/run.rs +++ b/src/bootstrap/src/core/build_steps/run.rs @@ -209,11 +209,10 @@ impl Step for GenerateCopyright { } fn run(self, builder: &Builder<'_>) -> Self::Output { - // let license_metadata = builder.ensure(CollectLicenseMetadata); - let license_metadata = builder.out.join("license-metadata.json"); + let license_metadata = builder.ensure(CollectLicenseMetadata); // Temporary location, it will be moved to the proper one once it's accurate. - let dest = builder.out.join("COPYRIGHT.md"); + let dest = builder.out.join("COPYRIGHT.html"); let mut cmd = builder.tool_cmd(Tool::GenerateCopyright); cmd.env("LICENSE_METADATA", &license_metadata); diff --git a/src/tools/generate-copyright/src/main.rs b/src/tools/generate-copyright/src/main.rs index 05f741e18d753..35b47082fb1a8 100644 --- a/src/tools/generate-copyright/src/main.rs +++ b/src/tools/generate-copyright/src/main.rs @@ -5,6 +5,33 @@ use std::path::{Path, PathBuf}; mod cargo_metadata; +static TOP_BOILERPLATE: &'static str = r##" + + +
+ +This file describes the copyright and licensing information for the source +code within The Rust Project git tree, and the third-party dependencies used +when building the Rust toolchain (including the Rust Standard Library).
+ +The following licenses cover the in-tree source files that were used in this release:
"# )?; - writeln!(buffer)?; render_tree_recursive(&collected_tree_metadata.files, &mut buffer, 0, &mut license_set)?; - writeln!(buffer)?; - - writeln!(buffer, "## Out-of-tree files")?; - writeln!(buffer)?; writeln!( buffer, - "The following licenses cover the out-of-tree crates that were used in this release:" + r#"The following licenses cover the out-of-tree crates that were used in this release:
"# )?; - writeln!(buffer)?; render_deps(collected_cargo_metadata.iter(), &mut buffer, &mut license_set)?; + writeln!(buffer, "{}", BOTTOM_BOILERPLATE)?; + std::fs::write(&dest_file, &buffer)?; Ok(()) @@ -79,8 +88,7 @@ fn render_tree_recursive( depth: usize, license_set: &mut BTreeSetExceptions:
")?; for child in children { - writeln!(buffer, "{prefix}")?; render_tree_recursive(child, buffer, depth + 1, license_set)?; } } } Node::CondensedDirectory { name, licenses } => { - render_tree_license( - &prefix, - std::iter::once(name), - licenses.iter(), - buffer, - license_set, - )?; + render_tree_license(std::iter::once(name), licenses.iter(), buffer, license_set)?; } Node::Group { files, directories, license } => { render_tree_license( - &prefix, directories.iter().chain(files.iter()), std::iter::once(license), buffer, @@ -124,7 +117,6 @@ fn render_tree_recursive( } Node::File { name, license } => { render_tree_license( - &prefix, std::iter::once(name), std::iter::once(license), buffer, @@ -132,18 +124,19 @@ fn render_tree_recursive( )?; } } + writeln!(buffer, "File/Directory: ")?;
for name in names {
- writeln!(buffer, "{prefix}**`{name}`** ")?;
+ writeln!(buffer, "{name}
")?;
}
- for spdx in spdxs.iter() {
- writeln!(buffer, "{prefix}License: `{spdx}` ")?;
+ writeln!(buffer, "
License: ")?; + for (i, spdx) in spdxs.iter().enumerate() { + let suffix = if i == spdxs.len() - 1 { "" } else { ", " }; + writeln!(buffer, "{spdx}{suffix}")?; } - for (i, copyright) in copyrights.iter().enumerate() { - let suffix = if i == copyrights.len() - 1 { "" } else { " " }; - writeln!(buffer, "{prefix}Copyright: {copyright}{suffix}")?; + writeln!(buffer, "
")?; + + for copyright in copyrights.iter() { + writeln!(buffer, "Copyright: {copyright}
")?; } Ok(()) @@ -175,30 +174,25 @@ fn render_deps<'a, 'b>( license_set: &mut BTreeSet{}
", escape_html(&authors_list))?; + writeln!(buffer, "{}
", escape_html(&dep.license))?; license_set.insert(dep.license.clone()); for (name, contents) in &dep.notices { writeln!(buffer)?; - writeln!(buffer, "#### {}", name.to_string_lossy())?; + writeln!(buffer, "\n{}\n", contents)?; writeln!(buffer, "