Skip to content

Commit 2d1cd45

Browse files
Fix generate-copyright tool.
LLVM copyrights are now condensed to those reported in the .reuse/dep5 file.
1 parent daf6121 commit 2d1cd45

File tree

4 files changed

+54
-32
lines changed

4 files changed

+54
-32
lines changed

Diff for: .reuse/dep5

+29-17
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# WARNING: this metadata is currently incomplete, do not rely on it yet.
22

33
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
4-
Files-Excluded:
5-
src/llvm-project
64

75
# Note that we're explicitly listing the individual files at the root of the
86
# repository rather than just having `Files: *`. This is explicitly done to
@@ -39,13 +37,8 @@ Files: compiler/*
3937
Copyright: The Rust Project Developers (see https://thanks.rust-lang.org)
4038
License: MIT or Apache-2.0
4139

42-
Files: compiler/rustc_codegen_cranelift/src/cranelift_native.rs
43-
Copyright: The Cranelift Project Developers
44-
The Rust Project Developers (see https://thanks.rust-lang.org)
45-
License: Apache-2.0 WITH LLVM-exception AND (Apache-2.0 OR MIT)
46-
4740
Files: compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp
48-
Copyright: LLVM authors
41+
Copyright: 2003-2019 University of Illinois at Urbana-Champaign.
4942
The Rust Project Developers (see https://thanks.rust-lang.org)
5043
License: Apache-2.0 WITH LLVM-exception AND (Apache-2.0 OR MIT)
5144

@@ -85,19 +78,38 @@ Files: src/librustdoc/html/static/css/normalize.css
8578
Copyright: Nicolas Gallagher and Jonathan Neal
8679
License: MIT
8780

88-
Files: src/librustdoc/html/static/css/themes/ayu.css
89-
Copyright: Ike Ku, Jessica Stokes, Leon Guan
81+
Files: src/librustdoc/html/static/css/rustdoc.css
82+
Copyright: 2016 Ike Ku
9083
The Rust Project Developers (see https://thanks.rust-lang.org)
9184
License: MIT OR Apache-2.0
9285

9386
Files: src/doc/rustc-dev-guide/mermaid.min.js
94-
Copyright: Knut Sveidqvist
87+
Copyright: 2014-2021 Knut Sveidqvist
9588
License: MIT
9689

97-
# Note that the LLVM submodule here only specifies the NCSA as the license for
98-
# LLVM, even though LLVM is in the process of a relicensing to Apache 2.0 with
99-
# the LLVM Exception. That's because relicensed files have a SPDX header with
100-
# the correct license, so it will automatically be included here.
90+
Files: library/backtrace/*
91+
Copyright: 2014 Alex Crichton
92+
The Rust Project Developers (see https://thanks.rust-lang.org)
93+
License: MIT OR Apache-2.0
94+
95+
Files: src/doc/embedded-book/*
96+
Copyright: Rust on Embedded Devices Working Group
97+
The Rust Project Developers (see https://thanks.rust-lang.org)
98+
License: MIT OR Apache-2.0 OR CC-BY-SA-4.0
99+
100+
Files: src/doc/rust-by-example/*
101+
Copyright: 2014 Jorge Aparicio
102+
The Rust Project Developers (see https://thanks.rust-lang.org)
103+
License: MIT OR Apache-2.0
104+
105+
# Reuse cannot process the LLVM source tree, and so the copyrights for the LLVM
106+
# submodule are written out here manually. The collect-licence-metadata tool
107+
# has a specific exception coded within it to ignore ./src/llvm-project so
108+
# any time LLVM is updated, please revisit this section. The copyrights are
109+
# taken from the relevant LLVM sub-folders: llvm, lld, lldb, compiler-rt and libunwind.
110+
101111
Files: src/llvm-project/*
102-
Copyright: The LLVM Authors
103-
License: NCSA
112+
Copyright: 2003-2019 by the contributors listed in [CREDITS.TXT](https://github.com/rust-lang/llvm-project/blob/7738295178045041669876bf32b0543ec8319a5c/llvm/CREDITS.TXT)
113+
2010 Apple Inc
114+
2003-2019 University of Illinois at Urbana-Champaign.
115+
License: NCSA OR Apache-2.0 WITH LLVM-exception

Diff for: src/tools/collect-license-metadata/src/main.rs

+10
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,16 @@ use crate::licenses::LicensesInterner;
66
use anyhow::Error;
77
use std::path::PathBuf;
88

9+
// Some directories have too many slight license differences that'd result in a
10+
// huge report, and could be considered a standalone project anyway. Those
11+
// directories are "condensed" into a single licensing block for ease of
12+
// reading, merging the licensing information.
13+
//
14+
// For every `(dir, file)``, every file in `dir` is considered to have the
15+
// license info of `file`.
16+
const CONDENSED_DIRECTORIES: &[(&str, &str)] =
17+
&[("./src/llvm-project/", "./src/llvm-project/README.md")];
18+
919
fn main() -> Result<(), Error> {
1020
let reuse_exe: PathBuf = std::env::var_os("REUSE_EXE").expect("Missing REUSE_EXE").into();
1121
let dest: PathBuf = std::env::var_os("DEST").expect("Missing DEST").into();

Diff for: src/tools/collect-license-metadata/src/path_tree.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ use crate::licenses::{License, LicenseId, LicensesInterner};
77
use std::collections::{BTreeMap, BTreeSet};
88
use std::path::{Path, PathBuf};
99

10-
// Some directories have too many slight license differences that'd result in a huge report, and
11-
// could be considered a standalone project anyway. Those directories are "condensed" into a single
12-
// licensing block for ease of reading, merging the licensing information.
13-
const CONDENSED_DIRECTORIED: &[&str] = &["./src/llvm-project/"];
14-
1510
#[derive(serde::Serialize)]
1611
#[serde(rename_all = "kebab-case", tag = "type")]
1712
pub(crate) enum Node<L> {
@@ -310,12 +305,17 @@ pub(crate) fn build(mut input: Vec<(PathBuf, LicenseId)>) -> Node<LicenseId> {
310305
let mut condensed_directories = BTreeMap::new();
311306
'outer: for (path, license) in input {
312307
// Files in condensed directories are handled separately.
313-
for directory in CONDENSED_DIRECTORIED {
314-
if path.starts_with(directory) {
315-
condensed_directories
316-
.entry(*directory)
317-
.or_insert_with(BTreeSet::new)
318-
.insert(license);
308+
for (condensed_directory, allowed_file) in super::CONDENSED_DIRECTORIES {
309+
if path.starts_with(condensed_directory) {
310+
if path.as_path() == Path::new(allowed_file) {
311+
// The licence on our allowed file is used to represent the entire directory
312+
condensed_directories
313+
.entry(*condensed_directory)
314+
.or_insert_with(BTreeSet::new)
315+
.insert(license);
316+
} else {
317+
// don't add the file
318+
}
319319
continue 'outer;
320320
}
321321
}
@@ -338,9 +338,9 @@ pub(crate) fn build(mut input: Vec<(PathBuf, LicenseId)>) -> Node<LicenseId> {
338338
name: path.file_name().unwrap().into(),
339339
licenses: licenses.iter().copied().collect(),
340340
};
341-
for name in path.parent().unwrap_or_else(|| Path::new(".")).components().rev() {
341+
for component in path.parent().unwrap_or_else(|| Path::new(".")).components().rev() {
342342
node = Node::Directory {
343-
name: name.as_os_str().into(),
343+
name: component.as_os_str().into(),
344344
children: vec![node],
345345
license: None,
346346
};

Diff for: src/tools/generate-copyright/src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn render_recursive(node: &Node, buffer: &mut Vec<u8>, depth: usize) -> Result<(
2727
}
2828
}
2929
Node::Directory { name, children, license } => {
30-
render_license(&prefix, std::iter::once(name), std::iter::once(license), buffer)?;
30+
render_license(&prefix, std::iter::once(name), license.iter(), buffer)?;
3131
if !children.is_empty() {
3232
writeln!(buffer, "{prefix}")?;
3333
writeln!(buffer, "{prefix}*Exceptions:*")?;
@@ -94,7 +94,7 @@ struct Metadata {
9494
#[serde(rename_all = "kebab-case", tag = "type")]
9595
pub(crate) enum Node {
9696
Root { children: Vec<Node> },
97-
Directory { name: String, children: Vec<Node>, license: License },
97+
Directory { name: String, children: Vec<Node>, license: Option<License> },
9898
CondensedDirectory { name: String, licenses: Vec<License> },
9999
File { name: String, license: License },
100100
Group { files: Vec<String>, directories: Vec<String>, license: License },

0 commit comments

Comments
 (0)