Skip to content

Commit f9c1699

Browse files
dist: Re-work how we describe the licence of Rust in our distributions
) add COPYRIGHT*.html files to the rustc binary distribution ) add contents of LICENSE folder to dist tarballs, because some of our in-tree licences will require that the license text is reproduced. ) The wording of COPYRIGHT is adjusted to not include license text (`reuse` ensures that it's in the LICENSE folder) ) A blanket copyright notice is added to LICENCE-MIT as required by the text. The general approach is that the license statements are now compiled using a tool in CI (generate-copyright), and you get either: * the source code (COPYRIGHT, LICENCE-APACHE, LICENCE-MIT, REUSE.toml and the LICENCES folder), or * the compiled version (COPYRIGHT.html, COPYRIGHT-library.html and the LICENCES folder).
1 parent 9b4d7c6 commit f9c1699

File tree

6 files changed

+77
-395
lines changed

6 files changed

+77
-395
lines changed

COPYRIGHT

+21-371
Large diffs are not rendered by default.

LICENSE-MIT

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Copyright (c) The Rust Project Contributors
2+
13
Permission is hereby granted, free of charge, to any
24
person obtaining a copy of this software and associated
35
documentation files (the "Software"), to deal in the

src/bootstrap/src/core/build_steps/dist.rs

+17-8
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,22 @@ impl Step for Rustc {
503503
// Debugger scripts
504504
builder.ensure(DebuggerScripts { sysroot: image.to_owned(), host });
505505

506-
// Misc license info
507-
let cp = |file: &str| {
508-
builder.install(&builder.src.join(file), &image.join("share/doc/rust"), 0o644);
506+
// HTML copyright files
507+
let file_list = builder.ensure(super::run::GenerateCopyright);
508+
for file in file_list {
509+
builder.install(&file, &image.join("share/doc/rust"), 0o644);
510+
}
511+
512+
// README
513+
builder.install(&builder.src.join("README.md"), &image.join("share/doc/rust"), 0o644);
514+
515+
// The REUSE-managed license files
516+
let license = |path: &Path| {
517+
builder.install(path, &image.join("share/doc/rust/licences"), 0o644);
509518
};
510-
cp("COPYRIGHT");
511-
cp("LICENSE-APACHE");
512-
cp("LICENSE-MIT");
513-
cp("README.md");
519+
for entry in t!(std::fs::read_dir(builder.src.join("LICENSES"))).flatten() {
520+
license(&entry.path());
521+
}
514522
}
515523
}
516524
}
@@ -986,14 +994,15 @@ impl Step for PlainSourceTarball {
986994
"CONTRIBUTING.md",
987995
"README.md",
988996
"RELEASES.md",
997+
"REUSE.toml",
989998
"configure",
990999
"x.py",
9911000
"config.example.toml",
9921001
"Cargo.toml",
9931002
"Cargo.lock",
9941003
".gitmodules",
9951004
];
996-
let src_dirs = ["src", "compiler", "library", "tests"];
1005+
let src_dirs = ["src", "compiler", "library", "tests", "LICENSES"];
9971006

9981007
copy_src_dirs(builder, &builder.src, &src_dirs, &[], plain_dst_src);
9991008

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ impl Step for CollectLicenseMetadata {
196196
pub struct GenerateCopyright;
197197

198198
impl Step for GenerateCopyright {
199-
type Output = PathBuf;
199+
type Output = Vec<PathBuf>;
200200
const ONLY_HOSTS: bool = true;
201201

202202
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
@@ -220,7 +220,7 @@ impl Step for GenerateCopyright {
220220
cmd.env("CARGO", &builder.initial_cargo);
221221
cmd.run(builder);
222222

223-
dest
223+
vec![dest, dest_libstd]
224224
}
225225
}
226226

src/tools/generate-copyright/templates/COPYRIGHT-library.html

+17-6
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,31 @@
88

99
<h1>Copyright notices for The Rust Standard Library</h1>
1010

11-
<p>This file describes the copyright and licensing information for the Rust
12-
Standard Library source code within The Rust Project git tree, and the
13-
third-party dependencies used when building the Rust Standard Library.</p>
14-
1511
<h2>Table of Contents</h2>
1612
<ul>
13+
<li><a href="#short-version">Short version for non-lawyers</a></li>
14+
<li><a href="#longer-version">Longer version</a></li>
1715
<li><a href="#in-tree-files">In-tree files</a></li>
1816
<li><a href="#out-of-tree-dependencies">Out-of-tree dependencies</a></li>
1917
</ul>
2018

19+
<h2 id="short-version">Short version for non-lawyers</h2>
20+
21+
The Rust Standard Library is dual-licensed under Apache 2.0 and MIT terms.
22+
23+
<h2 id="longer-version">Longer version</h2>
24+
25+
<p>Copyrights in the Rust Standard Library are retained by their contributors. No copyright assignment is required to contribute to the Rust project.</p>
26+
27+
<p>Some files include explicit copyright notices and/or license notices. For full authorship information, see the version control history or <a href="https://thanks.rust-lang.org">https://thanks.rust-lang.org</a>.</p>
28+
29+
<p>Except as otherwise noted (below and/or in individual files), the Rust Standard Library is licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> or the <a href="http://opensource.org/licenses/MIT">MIT</a> license, at your option.</p>
30+
31+
<p>This file describes the copyright and licensing information for the source code within The Rust Project git tree related to the Rust Standard Library, and the third-party dependencies used when building the Rust Standard Library.</p>
32+
2133
<h2 id="in-tree-files">In-tree files</h2>
2234

23-
<p>The following licenses cover the in-tree source files that were used in this
24-
release:</p>
35+
<p>The following licenses cover the in-tree source files that were used in this release:</p>
2536

2637
{{ in_tree|safe }}
2738

src/tools/generate-copyright/templates/COPYRIGHT.html

+18-8
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,37 @@
88

99
<h1>Copyright notices for The Rust Toolchain</h1>
1010

11-
<p>This file describes the copyright and licensing information for the source
12-
code within The Rust Project git tree, and the third-party dependencies used
13-
when building the Rust toolchain (including the Rust Standard Library).</p>
14-
1511
<h2>Table of Contents</h2>
1612
<ul>
13+
<li><a href="#short-version">Short version for non-lawyers</a></li>
14+
<li><a href="#longer-version">Longer version</a></li>
1715
<li><a href="#in-tree-files">In-tree files</a></li>
1816
<li><a href="#out-of-tree-dependencies">Out-of-tree dependencies</a></li>
1917
</ul>
2018

19+
<h2 id="short-version">Short version for non-lawyers</h2>
20+
21+
The Rust Project is dual-licensed under Apache 2.0 and MIT terms.
22+
23+
<h2 id="longer-version">Longer version</h2>
24+
25+
<p>Copyrights in the Rust project are retained by their contributors. No copyright assignment is required to contribute to the Rust project.</p>
26+
27+
<p>Some files include explicit copyright notices and/or license notices. For full authorship information, see the version control history or <a href="https://thanks.rust-lang.org">https://thanks.rust-lang.org</a>.</p>
28+
29+
<p>Except as otherwise noted (below and/or in individual files), Rust is licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> or the <a href="http://opensource.org/licenses/MIT">MIT</a> license, at your option.</p>
30+
31+
<p>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).</p>
32+
2133
<h2 id="in-tree-files">In-tree files</h2>
2234

23-
<p>The following licenses cover the in-tree source files that were used in this
24-
release:</p>
35+
<p>The following licenses cover the in-tree source files that were used in this release:</p>
2536

2637
{{ in_tree|safe }}
2738

2839
<h2 id="out-of-tree-dependencies">Out-of-tree dependencies</h2>
2940

30-
<p>The following licenses cover the out-of-tree crates that were used in this
31-
release:</p>
41+
<p>The following licenses cover the out-of-tree crates that were used in this release:</p>
3242

3343
{% for (key, value) in dependencies %}
3444
<h3>📦 {{key.name}}-{{key.version}}</h3>

0 commit comments

Comments
 (0)