Index: tools/licenses.py |
diff --git a/tools/licenses.py b/tools/licenses.py |
index 1b935c93d227c58ae61e32c83cc99c5b68fe6ec4..a6c64ecb8f335d51ae13a9df5d8f6cfad9c286a4 100755 |
--- a/tools/licenses.py |
+++ b/tools/licenses.py |
@@ -10,6 +10,23 @@ directories. |
import os |
+# Paths from the root of the tree to directories to skip. |
+PRUNE_PATHS = set([ |
+ # This is just a tiny vsprops file, presumably written by the googleurl |
+ # authors. Not third-party code. |
+ "googleurl/third_party/icu", |
+ |
+ # We don't bundle o3d samples into our resulting binaries. |
+ "o3d/samples", |
+ |
+ # Written as part of Chromium. |
+ "tools/fuzzymatch", |
+ |
+ # Two directories that are the same as those in base/third_party. |
+ "v8/src/third_party/dtoa", |
+ "v8/src/third_party/valgrind", |
+]) |
+ |
class LicenseError(Exception): |
"""We raise this exception when a directory's licensing info isn't |
@@ -26,7 +43,7 @@ def ParseDir(path): |
raise LicenseError("missing README.chromium") |
# Parse metadata fields out of README.chromium. |
- # We provide a default value of "LICENSE" for the license file. |
+ # We examine "LICENSE" for the license file by default. |
metadata = { |
"License File": "LICENSE", # Relative path to license text. |
"Name": None, # Short name (for header on about:credits). |
@@ -46,12 +63,19 @@ def ParseDir(path): |
"in README.chromium") |
# Check that the license file exists. |
- license_file = metadata["License File"] |
- license_path = os.path.join(path, license_file) |
- if not os.path.exists(license_path): |
- raise LicenseError("License file '" + license_file + "' doesn't exist. " |
- "Either add a 'License File:' section to " |
- "README.chromium or add the missing file.") |
+ for filename in (metadata["License File"], "COPYING"): |
+ license_path = os.path.join(path, filename) |
+ if os.path.exists(license_path): |
+ metadata["License File"] = filename |
+ break |
+ license_path = None |
+ |
+ if not license_path: |
+ raise LicenseError("License file not found. " |
+ "Either add a file named LICENSE, " |
+ "import upstream's COPYING if available, " |
+ "or add a 'License File:' line to README.chromium " |
+ "with the appropriate path.") |
return metadata |
@@ -81,13 +105,22 @@ def FindThirdPartyDirs(): |
for path, dirs, files in os.walk('.'): |
path = path[len('./'):] # Pretty up the path. |
+ if path in PRUNE_PATHS: |
+ dirs[:] = [] |
+ continue |
+ |
# Prune out directories we want to skip. |
for skip in skip_dirs: |
if skip in dirs: |
dirs.remove(skip) |
if os.path.basename(path) == 'third_party': |
- third_party_dirs.extend([os.path.join(path, dir) for dir in dirs]) |
+ # Add all subdirectories that are not marked for skipping. |
+ for dir in dirs: |
+ dirpath = os.path.join(path, dir) |
+ if dirpath not in PRUNE_PATHS: |
+ third_party_dirs.append(dirpath) |
+ |
# Don't recurse into any subdirs from here. |
dirs[:] = [] |
continue |