2014-02-07 13:08:32 -06:00
|
|
|
# Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
|
2013-01-18 01:28:42 -06:00
|
|
|
# file at the top-level directory of this distribution and at
|
|
|
|
# http://rust-lang.org/COPYRIGHT.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
# <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
# option. This file may not be copied, modified, or distributed
|
|
|
|
# except according to those terms.
|
|
|
|
|
2015-01-22 22:40:15 -06:00
|
|
|
import re
|
2016-02-23 19:42:50 -06:00
|
|
|
import os
|
2013-01-18 01:28:42 -06:00
|
|
|
|
2015-01-22 22:40:15 -06:00
|
|
|
license_re = re.compile(
|
|
|
|
u"""(#|//) Copyright .* The Rust Project Developers. See the COPYRIGHT
|
|
|
|
\\1 file at the top-level directory of this distribution and at
|
|
|
|
\\1 http://rust-lang.org/COPYRIGHT.
|
|
|
|
\\1
|
|
|
|
\\1 Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
\\1 http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
\\1 <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
\\1 option. This file may not be copied, modified, or distributed
|
|
|
|
\\1 except according to those terms.""")
|
2013-01-18 01:28:42 -06:00
|
|
|
|
|
|
|
exceptions = [
|
2014-12-23 13:53:35 -06:00
|
|
|
"libstd/sync/mpsc/mpsc_queue.rs", # BSD
|
|
|
|
"libstd/sync/mpsc/spsc_queue.rs", # BSD
|
2014-06-12 16:41:48 -05:00
|
|
|
"test/bench/shootout-binarytrees.rs", # BSD
|
2014-09-08 01:43:21 -05:00
|
|
|
"test/bench/shootout-chameneos-redux.rs", # BSD
|
2014-06-08 15:25:49 -05:00
|
|
|
"test/bench/shootout-fannkuch-redux.rs", # BSD
|
2014-09-17 01:44:44 -05:00
|
|
|
"test/bench/shootout-fasta.rs", # BSD
|
2014-09-24 17:31:47 -05:00
|
|
|
"test/bench/shootout-fasta-redux.rs", # BSD
|
2014-07-26 08:06:40 -05:00
|
|
|
"test/bench/shootout-k-nucleotide.rs", # BSD
|
2014-07-01 03:00:27 -05:00
|
|
|
"test/bench/shootout-mandelbrot.rs", # BSD
|
2014-06-05 02:55:49 -05:00
|
|
|
"test/bench/shootout-meteor.rs", # BSD
|
2014-09-07 12:16:55 -05:00
|
|
|
"test/bench/shootout-nbody.rs", # BSD
|
2014-06-07 12:34:29 -05:00
|
|
|
"test/bench/shootout-regex-dna.rs", # BSD
|
2014-09-07 11:09:01 -05:00
|
|
|
"test/bench/shootout-reverse-complement.rs", # BSD
|
2014-09-17 01:33:57 -05:00
|
|
|
"test/bench/shootout-spectralnorm.rs", # BSD
|
2014-07-04 14:39:15 -05:00
|
|
|
"test/bench/shootout-threadring.rs", # BSD
|
2013-01-18 01:28:42 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
def check_license(name, contents):
|
2016-02-23 19:42:50 -06:00
|
|
|
name = os.path.normpath(name)
|
2014-01-04 14:16:57 -06:00
|
|
|
# Whitelist check
|
2016-02-23 19:42:50 -06:00
|
|
|
if any(name.endswith(os.path.normpath(e)) for e in exceptions):
|
2015-01-22 19:54:49 -06:00
|
|
|
return True
|
2013-01-18 01:28:42 -06:00
|
|
|
|
2014-01-04 14:16:57 -06:00
|
|
|
# Xfail check
|
2013-01-18 01:28:42 -06:00
|
|
|
firstlineish = contents[:100]
|
2015-01-22 19:54:49 -06:00
|
|
|
if "ignore-license" in firstlineish:
|
2013-01-18 01:28:42 -06:00
|
|
|
return True
|
|
|
|
|
2014-01-04 14:16:57 -06:00
|
|
|
# License check
|
|
|
|
boilerplate = contents[:500]
|
2015-01-22 22:40:15 -06:00
|
|
|
return bool(license_re.search(boilerplate))
|