Commit b1b678fa authored by Nicolas Dossou-gbete's avatar Nicolas Dossou-gbete Committed by Commit Bot

🔧 Allow providing README for license.py in 3p subdirectories

Additionally to scaning the first level of third_party for
README.chromium files, these directories can now contain an
additional_readme_paths.json file that lists subdirectories
that will contain the actual third_party dependencies to
take into account for credits generation.

Bug: 794210
Change-Id: If6eef9fcd615bd96b9a260f9ae4d0c0c4fd6405a
Reviewed-on: https://chromium-review.googlesource.com/822612
Commit-Queue: Nicolas Dossou-Gbété <dgn@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Reviewed-by: default avatarBernhard Bauer <bauerb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#533270}
parent 2f79d543
......@@ -17,6 +17,7 @@ Commands:
import argparse
import cgi
import json
import os
import shutil
import re
......@@ -104,6 +105,11 @@ PRUNE_DIRS = (VCS_METADATA_DIRS +
('out', 'Debug', 'Release', # build files
'layout_tests')) # lots of subdirs
# A third_party directory can define this file, containing a list of
# subdirectories to process instead of itself. Intended for directories that
# contain multiple others as transitive dependencies.
ADDITIONAL_PATHS_FILENAME = 'additional_readme_paths.json'
ADDITIONAL_PATHS = (
os.path.join('chrome', 'common', 'extensions', 'docs', 'examples'),
os.path.join('chrome', 'test', 'chromeos', 'autotest'),
......@@ -358,7 +364,7 @@ def ParseDir(path, root, require_license_file=True, optional_keys=None):
readme_path = os.path.join(root, path, 'README.chromium')
if not os.path.exists(readme_path):
raise LicenseError("missing README.chromium or licenses.py "
"SPECIAL_CASES entry in %s" % path)
"SPECIAL_CASES entry in %s\n" % path)
for line in open(readme_path):
line = line.strip()
......@@ -395,7 +401,7 @@ def ParseDir(path, root, require_license_file=True, optional_keys=None):
metadata["License File"] = license_path
if errors:
raise LicenseError(";\n".join(errors))
raise LicenseError("Errors in %s:\n %s\n" % (path, ";\n ".join(errors)))
return metadata
......@@ -438,7 +444,14 @@ def FindThirdPartyDirs(prune_paths, root):
# 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:
additional_paths_file = os.path.join(
dirpath, ADDITIONAL_PATHS_FILENAME)
if os.path.exists(additional_paths_file):
with open(additional_paths_file) as paths_file:
extra_paths = json.load(paths_file)
third_party_dirs.update([
os.path.join(dirpath, p) for p in extra_paths])
elif dirpath not in prune_paths:
third_party_dirs.add(dirpath)
# Don't recurse into any subdirs from here.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment