]> git.lizzy.rs Git - rust.git/blob - src/etc/licenseck.py
rollup merge of #17355 : gamazeps/issue17210
[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 license1 = """// Copyright """
12 license2 = """ The Rust Project Developers. See the COPYRIGHT
13 // file at the top-level directory of this distribution and at
14 // http://rust-lang.org/COPYRIGHT.
15 //
16 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
17 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
18 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
19 // option. This file may not be copied, modified, or distributed
20 // except according to those terms.
21 """
22
23 license3 = """# Copyright """
24 license4 = """ The Rust Project Developers. See the COPYRIGHT
25 # file at the top-level directory of this distribution and at
26 # http://rust-lang.org/COPYRIGHT.
27 #
28 # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
29 # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
30 # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
31 # option. This file may not be copied, modified, or distributed
32 # except according to those terms.
33 """
34
35 exceptions = [
36     "rt/rust_android_dummy.cpp", # BSD, chromium
37     "rt/rust_android_dummy.h", # BSD, chromium
38     "rt/isaac/randport.cpp", # public domain
39     "rt/isaac/rand.h", # public domain
40     "rt/isaac/standard.h", # public domain
41     "libsync/mpsc_queue.rs", # BSD
42     "libsync/spsc_queue.rs", # BSD
43     "libsync/mpmc_bounded_queue.rs", # BSD
44     "libsync/mpsc_intrusive.rs", # BSD
45     "test/bench/shootout-binarytrees.rs", # BSD
46     "test/bench/shootout-chameneos-redux.rs", # BSD
47     "test/bench/shootout-fannkuch-redux.rs", # BSD
48     "test/bench/shootout-fasta.rs", # BSD
49     "test/bench/shootout-k-nucleotide.rs", # BSD
50     "test/bench/shootout-mandelbrot.rs", # BSD
51     "test/bench/shootout-meteor.rs", # BSD
52     "test/bench/shootout-nbody.rs", # BSD
53     "test/bench/shootout-regex-dna.rs", # BSD
54     "test/bench/shootout-reverse-complement.rs", # BSD
55     "test/bench/shootout-spectralnorm.rs", # BSD
56     "test/bench/shootout-threadring.rs", # BSD
57 ]
58
59 def check_license(name, contents):
60     # Whitelist check
61     for exception in exceptions:
62         if name.endswith(exception):
63             return True
64
65     # Xfail check
66     firstlineish = contents[:100]
67     if firstlineish.find("ignore-license") != -1:
68         return True
69
70     # License check
71     boilerplate = contents[:500]
72     if (boilerplate.find(license1) == -1 or boilerplate.find(license2) == -1) and \
73        (boilerplate.find(license3) == -1 or boilerplate.find(license4) == -1):
74         return False
75     return True