]> git.lizzy.rs Git - rust.git/blob - src/etc/licenseck.py
auto merge of #10863 : cadencemarseille/rust/patch-handle-ENOENT, r=alexcrichton
[rust.git] / src / etc / licenseck.py
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     "libstd/rt/mpsc_queue.rs", # BSD
80     "libstd/rt/spsc_queue.rs", # BSD
81     "libstd/rt/mpmc_bounded_queue.rs", # BSD
82 ]
83
84 def check_license(name, contents):
85     valid_license = False
86     for a_valid_license in licenses:
87         if contents.startswith(a_valid_license):
88             valid_license = True
89             break
90     if valid_license:
91         return True
92
93     for exception in exceptions:
94         if name.endswith(exception):
95             return True
96
97     firstlineish = contents[:100]
98     if firstlineish.find("xfail-license") != -1:
99         return True
100
101     return False