]> git.lizzy.rs Git - rust.git/blob - src/etc/licenseck.py
Auto merge of #29325 - alexcrichton:revert-trait-accessibility, r=nrc
[rust.git] / src / etc / licenseck.py
1 # Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2 # file at the top-level directory of this distribution and at
3 # http://rust-lang.org/COPYRIGHT.
4 #
5 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 # option. This file may not be copied, modified, or distributed
9 # except according to those terms.
10
11 import re
12
13 license_re = re.compile(
14 u"""(#|//) Copyright .* The Rust Project Developers. See the COPYRIGHT
15 \\1 file at the top-level directory of this distribution and at
16 \\1 http://rust-lang.org/COPYRIGHT.
17 \\1
18 \\1 Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
19 \\1 http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
20 \\1 <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
21 \\1 option. This file may not be copied, modified, or distributed
22 \\1 except according to those terms.""")
23
24 exceptions = [
25     "libstd/sync/mpsc/mpsc_queue.rs", # BSD
26     "libstd/sync/mpsc/spsc_queue.rs", # BSD
27     "test/bench/shootout-binarytrees.rs", # BSD
28     "test/bench/shootout-chameneos-redux.rs", # BSD
29     "test/bench/shootout-fannkuch-redux.rs", # BSD
30     "test/bench/shootout-fasta.rs", # BSD
31     "test/bench/shootout-fasta-redux.rs", # BSD
32     "test/bench/shootout-k-nucleotide.rs", # BSD
33     "test/bench/shootout-mandelbrot.rs", # BSD
34     "test/bench/shootout-meteor.rs", # BSD
35     "test/bench/shootout-nbody.rs", # BSD
36     "test/bench/shootout-regex-dna.rs", # BSD
37     "test/bench/shootout-reverse-complement.rs", # BSD
38     "test/bench/shootout-spectralnorm.rs", # BSD
39     "test/bench/shootout-threadring.rs", # BSD
40 ]
41
42 def check_license(name, contents):
43     # Whitelist check
44     if any(name.endswith(e) for e in exceptions):
45         return True
46
47     # Xfail check
48     firstlineish = contents[:100]
49     if "ignore-license" in firstlineish:
50         return True
51
52     # License check
53     boilerplate = contents[:500]
54     return bool(license_re.search(boilerplate))