]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
1 | # Copyright 2013 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 | license0 = """\ | |
12 | // Copyright 2012-2013 The Rust Project Developers. See the | |
13 | // COPYRIGHT 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 | license1 = """\ | |
24 | // Copyright 2012 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 | license2 = """\ | |
36 | // Copyright 2013 The Rust Project Developers. See the COPYRIGHT | |
37 | // file at the top-level directory of this distribution and at | |
38 | // http://rust-lang.org/COPYRIGHT. | |
39 | // | |
40 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
41 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
42 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
43 | // option. This file may not be copied, modified, or distributed | |
44 | // except according to those terms. | |
45 | """ | |
46 | ||
47 | license3 = """\ | |
48 | # Copyright 2013 The Rust Project Developers. See the COPYRIGHT | |
49 | # file at the top-level directory of this distribution and at | |
50 | # http://rust-lang.org/COPYRIGHT. | |
51 | # | |
52 | # Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
53 | # http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
54 | # <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
55 | # option. This file may not be copied, modified, or distributed | |
56 | # except according to those terms. | |
57 | """ | |
58 | ||
59 | license4 = """\ | |
60 | // Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT | |
61 | // file at the top-level directory of this distribution and at | |
62 | // http://rust-lang.org/COPYRIGHT. | |
63 | // | |
64 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
65 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
66 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
67 | // option. This file may not be copied, modified, or distributed | |
68 | // except according to those terms. | |
69 | """ | |
70 | ||
71 | licenses = [license0, license1, license2, license3, license4] | |
72 | ||
73 | exceptions = [ | |
74 | "rt/rust_android_dummy.cpp", # BSD, chromium | |
75 | "rt/rust_android_dummy.h", # BSD, chromium | |
76 | "rt/isaac/randport.cpp", # public domain | |
77 | "rt/isaac/rand.h", # public domain | |
78 | "rt/isaac/standard.h", # public domain | |
79 | ] | |
80 | ||
81 | def check_license(name, contents): | |
82 | valid_license = False | |
83 | for a_valid_license in licenses: | |
84 | if contents.startswith(a_valid_license): | |
85 | valid_license = True | |
86 | break | |
87 | if valid_license: | |
88 | return True | |
89 | ||
90 | for exception in exceptions: | |
91 | if name.endswith(exception): | |
92 | return True | |
93 | ||
94 | firstlineish = contents[:100] | |
95 | if firstlineish.find("xfail-license") != -1: | |
96 | return True | |
97 | ||
98 | return False |