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 | |
| parent | 1244c0b6fd8325e1eab274e6d9b989e1ee1e2c57 (diff) | |
| download | rust-6b6acde972bfd646e5b8a3eeaabd613c44d1028c.tar.gz rust-6b6acde972bfd646e5b8a3eeaabd613c44d1028c.zip | |
Add a license check to tidy. #4018
Diffstat (limited to 'src/etc')
| -rwxr-xr-x | src/etc/check-summary.py | 1 | ||||
| -rwxr-xr-x | src/etc/combine-tests.py | 1 | ||||
| -rw-r--r-- | src/etc/extract-tests.py | 2 | ||||
| -rwxr-xr-x | src/etc/extract_grammar.py | 1 | ||||
| -rwxr-xr-x | src/etc/get-snapshot.py | 1 | ||||
| -rwxr-xr-x | src/etc/latest-unix-snaps.py | 1 | ||||
| -rw-r--r-- | src/etc/licenseck.py | 72 | ||||
| -rwxr-xr-x | src/etc/make-snapshot.py | 1 | ||||
| -rw-r--r-- | src/etc/mirror-all-snapshots.py | 1 | ||||
| -rw-r--r-- | src/etc/snapshot.py | 2 | ||||
| -rwxr-xr-x | src/etc/sugarise-doc-comments.py | 1 | ||||
| -rw-r--r-- | src/etc/tidy.py | 30 | ||||
| -rwxr-xr-x | src/etc/unicode.py | 1 |
13 files changed, 113 insertions, 2 deletions
diff --git a/src/etc/check-summary.py b/src/etc/check-summary.py index 7faacbfbb26..272bbc6fbbd 100755 --- a/src/etc/check-summary.py +++ b/src/etc/check-summary.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license import sys diff --git a/src/etc/combine-tests.py b/src/etc/combine-tests.py index 1e3c0bcfbfc..d6efcbc4642 100755 --- a/src/etc/combine-tests.py +++ b/src/etc/combine-tests.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license # this combines all the working run-pass tests into a single large crate so we # can run it "fast": spawning zillions of windows processes is our major build diff --git a/src/etc/extract-tests.py b/src/etc/extract-tests.py index 891e8674f88..9d9b7817f4b 100644 --- a/src/etc/extract-tests.py +++ b/src/etc/extract-tests.py @@ -1,3 +1,5 @@ +# xfail-license + # Script for extracting compilable fragments from markdown # documentation. See prep.js for a description of the format # recognized by this tool. Expects a directory fragements/ to exist diff --git a/src/etc/extract_grammar.py b/src/etc/extract_grammar.py index 63e89563464..58d1975c042 100755 --- a/src/etc/extract_grammar.py +++ b/src/etc/extract_grammar.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license # This script is for extracting the grammar from the rust docs. diff --git a/src/etc/get-snapshot.py b/src/etc/get-snapshot.py index 7d390c8c9aa..130ace64ce4 100755 --- a/src/etc/get-snapshot.py +++ b/src/etc/get-snapshot.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license import os, tarfile, re, shutil, sys from snapshot import * diff --git a/src/etc/latest-unix-snaps.py b/src/etc/latest-unix-snaps.py index 01d9edddf78..7a2ddba3a16 100755 --- a/src/etc/latest-unix-snaps.py +++ b/src/etc/latest-unix-snaps.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license import os, tarfile, hashlib, re, shutil, sys from snapshot import * 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 + diff --git a/src/etc/make-snapshot.py b/src/etc/make-snapshot.py index 4c2950af1cc..27d17c2ff16 100755 --- a/src/etc/make-snapshot.py +++ b/src/etc/make-snapshot.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license import snapshot, sys diff --git a/src/etc/mirror-all-snapshots.py b/src/etc/mirror-all-snapshots.py index f4bb8c042ea..f1fce7a94b5 100644 --- a/src/etc/mirror-all-snapshots.py +++ b/src/etc/mirror-all-snapshots.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license import os, tarfile, hashlib, re, shutil from snapshot import * diff --git a/src/etc/snapshot.py b/src/etc/snapshot.py index b19a44e968d..123987d4b1e 100644 --- a/src/etc/snapshot.py +++ b/src/etc/snapshot.py @@ -1,3 +1,5 @@ +# xfail-license + import re, os, sys, glob, tarfile, shutil, subprocess, tempfile try: diff --git a/src/etc/sugarise-doc-comments.py b/src/etc/sugarise-doc-comments.py index bd21447ffcc..6399cff6b88 100755 --- a/src/etc/sugarise-doc-comments.py +++ b/src/etc/sugarise-doc-comments.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license # # this script attempts to turn doc comment attributes (#[doc = "..."]) diff --git a/src/etc/tidy.py b/src/etc/tidy.py index 2c498b9283f..e866d80062d 100644 --- a/src/etc/tidy.py +++ b/src/etc/tidy.py @@ -1,6 +1,8 @@ #!/usr/bin/env python +# xfail-license import sys, fileinput, subprocess, re +from licenseck import * err=0 cols=78 @@ -13,14 +15,25 @@ result=config_proc.communicate()[0] true="true".encode('utf8') autocrlf=result.strip() == true if result is not None else False -def report_err(s): +def report_error_name_no(name, no, s): global err - print("%s:%d: %s" % (fileinput.filename(), fileinput.filelineno(), s)) + print("%s:%d: %s" % (name, no, s)) err=1 +def report_err(s): + report_error_name_no(fileinput.filename(), fileinput.filelineno(), s) + +def do_license_check(name, contents): + if not check_license(name, contents): + report_error_name_no(name, 1, "incorrect license") + + file_names = [s for s in sys.argv[1:] if (not s.endswith("_gen.rs")) and (not ".#" in s)] +current_name = "" +current_contents = "" + try: for line in fileinput.input(file_names, openhook=fileinput.hook_encoded("utf-8")): @@ -42,6 +55,19 @@ try: if line_len > cols: report_err("line longer than %d chars" % cols) + + if fileinput.isfirstline() and current_name != "": + do_license_check(current_name, current_contents) + + if fileinput.isfirstline(): + current_name = fileinput.filename() + current_contents = "" + + current_contents += line + + if current_name != "": + do_license_check(current_name, current_contents) + except UnicodeDecodeError, e: report_err("UTF-8 decoding error " + str(e)) diff --git a/src/etc/unicode.py b/src/etc/unicode.py index ff9f75e996e..5dabf34953b 100755 --- a/src/etc/unicode.py +++ b/src/etc/unicode.py @@ -1,4 +1,5 @@ #!/usr/bin/env python +# xfail-license # This digests UnicodeData.txt and DerivedCoreProperties.txt and emits rust # code covering the core properties. Since this is a pretty rare event we |
