8
8
# option. This file may not be copied, modified, or distributed
9
9
# except according to those terms.
10
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
11
+ license1 = """// Copyright """
12
+ license2 = """ The Rust Project Developers. See the COPYRIGHT
25
13
// file at the top-level directory of this distribution and at
26
14
// http://rust-lang.org/COPYRIGHT.
27
15
//
32
20
// except according to those terms.
33
21
"""
34
22
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
23
+ license3 = """# Copyright """
24
+ license4 = """ The Rust Project Developers. See the COPYRIGHT
49
25
# file at the top-level directory of this distribution and at
50
26
# http://rust-lang.org/COPYRIGHT.
51
27
#
56
32
# except according to those terms.
57
33
"""
58
34
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
35
exceptions = [
74
36
"rt/rust_android_dummy.cpp" , # BSD, chromium
75
37
"rt/rust_android_dummy.h" , # BSD, chromium
82
44
]
83
45
84
46
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
-
47
+ # Whitelist check
93
48
for exception in exceptions :
94
49
if name .endswith (exception ):
95
50
return True
96
51
52
+ # Xfail check
97
53
firstlineish = contents [:100 ]
98
54
if firstlineish .find ("xfail-license" ) != - 1 :
99
55
return True
100
56
101
- return False
57
+ # License check
58
+ boilerplate = contents [:500 ]
59
+ if (boilerplate .find (license1 ) == - 1 or boilerplate .find (license2 ) == - 1 ) and \
60
+ (boilerplate .find (license3 ) == - 1 or boilerplate .find (license4 ) == - 1 ):
61
+ return False
62
+ return True
0 commit comments