]> git.lizzy.rs Git - rust.git/commitdiff
Add a license check to tidy. #4018
authorBrian Anderson <banderson@mozilla.com>
Fri, 18 Jan 2013 07:28:42 +0000 (23:28 -0800)
committerBrian Anderson <banderson@mozilla.com>
Fri, 18 Jan 2013 07:28:42 +0000 (23:28 -0800)
37 files changed:
src/etc/check-summary.py
src/etc/combine-tests.py
src/etc/extract-tests.py
src/etc/extract_grammar.py
src/etc/get-snapshot.py
src/etc/latest-unix-snaps.py
src/etc/licenseck.py [new file with mode: 0644]
src/etc/make-snapshot.py
src/etc/mirror-all-snapshots.py
src/etc/snapshot.py
src/etc/sugarise-doc-comments.py
src/etc/tidy.py
src/etc/unicode.py
src/libcargo/cargo.rc
src/libcore/bool.rs
src/libcore/os.rs
src/libcore/prelude.rs
src/libfuzzer/fuzzer.rc
src/librustc/driver/driver.rs
src/librustc/rustc.rc
src/libstd/bigint.rs
src/libstd/flatpipes.rs
src/libstd/priority_queue.rs
src/rt/arch/arm/context.cpp
src/rt/arch/arm/context.h
src/rt/arch/arm/gpr.cpp
src/rt/arch/arm/gpr.h
src/rt/arch/arm/regs.h
src/rt/arch/i386/context.h
src/rt/arch/x86_64/context.h
src/rt/rust_kernel.h
src/rt/rust_log.h
src/rt/sync/lock_and_signal.h
src/rt/sync/sync.h
src/rt/util/array_list.h
src/rt/util/hash_map.h
src/rt/util/indexed_list.h

index 7faacbfbb26bac44bb0e964a7c8ceb0b26dc4425..272bbc6fbbd6c05b964dcaefb7d804fb65202bdd 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# xfail-license
 
 import sys
 
index 1e3c0bcfbfc3ea98e5540a8ec6914e43be83462b..d6efcbc464298e51f1d31209c8b7ad193d9884b6 100755 (executable)
@@ -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
index 891e8674f887bebbcb1669c52e262b08270b2be6..9d9b7817f4b035493890ce2cc73fd17b58b75b72 100644 (file)
@@ -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
index 63e89563464f30d824671fd6c2e7da6f79d00512..58d1975c042b7bd3ebddf86d7aa83c02bb9caec9 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# xfail-license
 
 # This script is for extracting the grammar from the rust docs.
 
index 7d390c8c9aafb4bd3604f7e27fe3da460184f192..130ace64ce47a215c007b46fc4456d1a0f961623 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# xfail-license
 
 import os, tarfile, re, shutil, sys
 from snapshot import *
index 01d9edddf788f18af8672bd69c76f4c23028f7ca..7a2ddba3a16aac11f014b4bfd1d0eaf6fc98e150 100755 (executable)
@@ -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 (file)
index 0000000..14d00e8
--- /dev/null
@@ -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
+
index 4c2950af1cc3356fc001f47c61471db650cab1f6..27d17c2ff16f30c1cb91795ed4f5937d54a8dd2c 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# xfail-license
 
 import snapshot, sys
 
index f4bb8c042eadd3c2069a3073a4ed48bf9ef82f75..f1fce7a94b5b6b327675113e3cb8ffe1fc1fb6d7 100644 (file)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# xfail-license
 
 import os, tarfile, hashlib, re, shutil
 from snapshot import *
index b19a44e968df54f80f8e3c6150d3af6d179092d6..123987d4b1ead625122963eb51aac688324f24f9 100644 (file)
@@ -1,3 +1,5 @@
+# xfail-license
+
 import re, os, sys, glob, tarfile, shutil, subprocess, tempfile
 
 try:
index bd21447ffcc50217d91afc645f36932a39b647f8..6399cff6b880d14d985ce1b1e119d1e9429a45f0 100755 (executable)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python
+# xfail-license
 
 #
 # this script attempts to turn doc comment attributes (#[doc = "..."])
index 2c498b9283ff7bb18d1b464283a8ccfffe9314a6..e866d80062d5155d300655531b040510f7b60cf8 100644 (file)
@@ -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))
 
index ff9f75e996e22257438cb870f57f693a83a529a0..5dabf34953b01669dc3ebfac83c240ca6d4b330f 100755 (executable)
@@ -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
index ea67d0ea858d12f132ffe8216c603318b1348593..29a7af2bfdbd54c98ffd18d13f27d926212188ab 100644 (file)
@@ -1,4 +1,3 @@
-// -*- rust -*-
 // 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.
index 3e7b88b7b78f7b1d4c5edecbfb975fefb1c53c78..2f3a53ea504f4df97f0d334bc55c482dee5c7c93 100644 (file)
@@ -1,4 +1,3 @@
-// -*- rust -*-
 // 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.
index ff3253a8223ffd30ed7ba6cc48b7fb0caf6edc95..ffd41bc05b11ba71d507ddb836833563285e6c92 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers.src/libcore/os.rs
+// 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.
 //
index de23feceea5907478230cd038cfb9cb026faeebc..63b7628f119e58ad710d3851467e36d25b17c014 100644 (file)
@@ -1,3 +1,13 @@
+// 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.
+
 // This file is imported into every module by default.
 
 /* Reexported core operators */
index 3f37b6d17944e7c18b147ede469c4249dfa87ca5..b7ec10e1a4f3f171422a8329458447ae1b9de759 100644 (file)
@@ -1,4 +1,3 @@
-// -*- rust -*-
 // 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.
index 740cc526310985b083e3c385757502097c1bcbeb..70cad499e4cb79917ec360f32a04b20d269d7df8 100644 (file)
@@ -1,4 +1,3 @@
-// -*- rust -*-
 // 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.
index 56a228991939b60fdcb9599d4af038eb590350be..4e101eb5bb7089fca45349aa1802f7bf6d983f94 100644 (file)
@@ -1,4 +1,3 @@
-// -*- rust -*-
 // 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.
index 303129c2849e1cf1a96d7b67dd680b96ac25de59..678565ee325c27e21fb299181b9a87504a7a3503 100644 (file)
@@ -1,3 +1,13 @@
+// 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.
+
 /*!
 
 A Big integer (signed version: BigInt, unsigned version: BigUint).
index 0607055db5c03ce36e4c58f194e5c184f6decfbf..534f1b7d4791678309be3f7d35b4cf0530c0caac 100644 (file)
@@ -1,3 +1,13 @@
+// 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.
+
 /*!
 
 Generic communication channels for things that can be represented as,
index 4d341d737f60279e686111439c2476ba4e9680a1..b9c040de42a20e069d529217013ead5e906e25f2 100644 (file)
@@ -1,3 +1,12 @@
+// 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.
 
 //! A priority queue implemented with a binary heap
 
index dbf06a532a878c707d78a77b3a91a23d41761e18..2c735e410fa4aa6b7fa24733634960119001a9fc 100644 (file)
@@ -1,3 +1,4 @@
+// xfail-license
 
 #include "context.h"
 #include "../../rust_globals.h"
index 6c7db766d6a7e0bd40a934a983036b733dcf89bc..54f0df7de3144f615b50ce462ad19bc58dc705be 100644 (file)
@@ -1,4 +1,5 @@
 // -*- mode: c++ -*-
+// xfail-license
 
 #ifndef CONTEXT_H
 #define CONTEXT_H
index 32a68d0732ab342cca0eea25e6f52ae46467da77..6dd385fb3302588e8c9a0d9908a6758905f79775 100644 (file)
@@ -1,3 +1,5 @@
+// xfail-license
+
 #include "gpr.h"
 
 #define LOAD(rn) do { \
index 472c8a05e35e46a3390928217c0d9c7bbec142fa..49db1429903d973843995b1879763b198449d812 100644 (file)
@@ -1,3 +1,4 @@
+// xfail-license
 // General-purpose registers. This structure is used during stack crawling.
 
 #ifndef GPR_H
index a49fcab1184c5e270904e7c6cf05197d4b4c5d33..2b44bd3af357d1550056e5f0a8ea6eea375d8397 100644 (file)
@@ -1,3 +1,5 @@
+// xfail-license
+
 #define RUSTRT_RBX   0
 #define RUSTRT_RSP   1
 #define RUSTRT_RBP   2
index 99d633ebff27c20f1729c6fb75fa7de0d3c73ae1..33352b4a5562d8c64f7b184b7bddcf3b9c5ce5ec 100644 (file)
@@ -1,4 +1,3 @@
-// -*- mode: c++ -*-
 // 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.
index f78c92e365a2bee2aca0ca20f6359832097ab34d..b768a1fb7b089b12ddce0f4d111b5aa8c711ac77 100644 (file)
@@ -1,4 +1,3 @@
-// -*- mode: c++ -*-
 // 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.
index cd52bfae8d3f4e684a00278ceea597cae9ff2bab..48522b57d5c0dcacc6970cd4249a0db8c9d68443 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c++ -*-
 // 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.
index 8b32b1cc910770afcc61fb31e4cbc96c68104177..b98d8477dbc0879c86951dd52d18c550b871c603 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c++ -*-
 // 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.
index 1ed494a77ae56dc1967849119dccd32c344ddd4e..5a0eb83a3943c269bc6d81fdef7a06dfb3a6e5a5 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c++ -*-
 // 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.
index 13d11a550216fd155a3d3a9aa5d9b22248cd8dcc..6ac97d57933621caf64ececa1423995c1a0c9edf 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c++ -*-
 // 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.
index 4bef26750db3c3cf12d5c31de4387654244e5f30..0852cf9497e2bd79ea734641fc022c3e54deecd5 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c++ -*-
 // 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.
index 253a7a06fb7b7bdc87b0515bc724be880a5dd84d..e5bef45c1c3c57afdd6b3006daa3e66a303ec874 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c++ -*-
 // 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.
index 88f4f2776186bd51415546c5f360934c6f5d0a2c..4673e9e27e31b7baa06fe396750a8d4adcbf59ac 100644 (file)
@@ -1,4 +1,3 @@
-// -*- c++ -*-
 // 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.