]> git.lizzy.rs Git - rust.git/blob - src/etc/licenseck.py
complete openbsd support for `std::env`
[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     "rt/rust_android_dummy.cpp", # BSD, chromium
26     "rt/rust_android_dummy.h", # BSD, chromium
27     "rt/isaac/randport.cpp", # public domain
28     "rt/isaac/rand.h", # public domain
29     "rt/isaac/standard.h", # public domain
30     "libstd/sync/mpsc/mpsc_queue.rs", # BSD
31     "libstd/sync/mpsc/spsc_queue.rs", # BSD
32     "test/bench/shootout-binarytrees.rs", # BSD
33     "test/bench/shootout-chameneos-redux.rs", # BSD
34     "test/bench/shootout-fannkuch-redux.rs", # BSD
35     "test/bench/shootout-fasta.rs", # BSD
36     "test/bench/shootout-fasta-redux.rs", # BSD
37     "test/bench/shootout-k-nucleotide.rs", # BSD
38     "test/bench/shootout-mandelbrot.rs", # BSD
39     "test/bench/shootout-meteor.rs", # BSD
40     "test/bench/shootout-nbody.rs", # BSD
41     "test/bench/shootout-regex-dna.rs", # BSD
42     "test/bench/shootout-reverse-complement.rs", # BSD
43     "test/bench/shootout-spectralnorm.rs", # BSD
44     "test/bench/shootout-threadring.rs", # BSD
45 ]
46
47 def check_license(name, contents):
48     # Whitelist check
49     if any(name.endswith(e) for e in exceptions):
50         return True
51
52     # Xfail check
53     firstlineish = contents[:100]
54     if "ignore-license" in firstlineish:
55         return True
56
57     # License check
58     boilerplate = contents[:500]
59     return bool(license_re.search(boilerplate))