diff options
| author | Brian Anderson <banderson@mozilla.com> | 2013-01-17 23:28:42 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2013-01-17 23:28:42 -0800 |
| commit | 6b6acde972bfd646e5b8a3eeaabd613c44d1028c (patch) | |
| tree | 1057dd2b7728eb3a37a7d0ed222c847329501578 /src/etc/licenseck.py | |
| parent | 1244c0b6fd8325e1eab274e6d9b989e1ee1e2c57 (diff) | |
| download | rust-6b6acde972bfd646e5b8a3eeaabd613c44d1028c.tar.gz rust-6b6acde972bfd646e5b8a3eeaabd613c44d1028c.zip | |
Add a license check to tidy. #4018
Diffstat (limited to 'src/etc/licenseck.py')
| -rw-r--r-- | src/etc/licenseck.py | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/etc/licenseck.py b/src/etc/licenseck.py new file mode 100644 index 00000000000..14d00e8c2cb --- /dev/null +++ b/src/etc/licenseck.py @@ -0,0 +1,72 @@ +# 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. + +license1 = """// Copyright 2012 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. +""" + +license2 = """// 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. +""" + +license3 = """# 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. +""" + +licenses = [license1, license2, license3] + +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 +] + +def check_license(name, contents): + valid_license = False + for a_valid_license in licenses: + if contents.startswith(a_valid_license): + valid_license = True + break + if valid_license: + return True + + for exception in exceptions: + if name.endswith(exception): + return True + + firstlineish = contents[:100] + if firstlineish.find("xfail-license") != -1: + return True + + return False + |
