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