2013-01-18 01:28:42 -06:00
|
|
|
# Copyright 2013 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
# 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.
|
|
|
|
|
2014-01-04 14:16:57 -06:00
|
|
|
license1 = """// Copyright """
|
|
|
|
license2 = """ 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.
|
|
|
|
"""
|
|
|
|
|
2014-01-04 14:16:57 -06:00
|
|
|
license3 = """# Copyright """
|
|
|
|
license4 = """ 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.
|
|
|
|
"""
|
|
|
|
|
|
|
|
exceptions = [
|
|
|
|
"rt/rust_android_dummy.cpp", # BSD, chromium
|
|
|
|
"rt/rust_android_dummy.h", # BSD, chromium
|
|
|
|
"rt/isaac/randport.cpp", # public domain
|
|
|
|
"rt/isaac/rand.h", # public domain
|
|
|
|
"rt/isaac/standard.h", # public domain
|
2013-12-13 23:14:08 -06:00
|
|
|
"libstd/sync/mpsc_queue.rs", # BSD
|
|
|
|
"libstd/sync/spsc_queue.rs", # BSD
|
|
|
|
"libstd/sync/mpmc_bounded_queue.rs", # BSD
|
2014-01-16 21:53:42 -06:00
|
|
|
"libextra/sync/mpsc_intrusive.rs", # BSD
|
2013-01-18 01:28:42 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
def check_license(name, contents):
|
2014-01-04 14:16:57 -06:00
|
|
|
# Whitelist check
|
2013-01-18 01:28:42 -06:00
|
|
|
for exception in exceptions:
|
|
|
|
if name.endswith(exception):
|
|
|
|
return True
|
|
|
|
|
2014-01-04 14:16:57 -06:00
|
|
|
# Xfail check
|
2013-01-18 01:28:42 -06:00
|
|
|
firstlineish = contents[:100]
|
|
|
|
if firstlineish.find("xfail-license") != -1:
|
|
|
|
return True
|
|
|
|
|
2014-01-04 14:16:57 -06:00
|
|
|
# License check
|
|
|
|
boilerplate = contents[:500]
|
|
|
|
if (boilerplate.find(license1) == -1 or boilerplate.find(license2) == -1) and \
|
|
|
|
(boilerplate.find(license3) == -1 or boilerplate.find(license4) == -1):
|
|
|
|
return False
|
|
|
|
return True
|