Commit e8d6580b authored by Justin DeWitt's avatar Justin DeWitt Committed by Commit Bot

Adds licenses.py support for internal third_party dependencies.

Refactor processing of additional_readme_paths.json into a newly
added ProcessAdditionalReadmePathsJson function

//clank is filtered by default, but projects inside //clank (such as //clank/third_party/elements) might need to
add a license file to about:credits if they depend on open source code.

Bug: 1099355
Change-Id: Id0e03664e1eb2e3b287ed33ee1771f21c13278eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2267919
Commit-Queue: Justin DeWitt <dewittj@chromium.org>
Reviewed-by: default avatarBruce Dawson <brucedawson@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782782}
parent a75cf61b
......@@ -113,10 +113,18 @@ PRUNE_DIRS = (VCS_METADATA_DIRS +
# that contain multiple others as transitive dependencies.
ADDITIONAL_PATHS_FILENAME = 'additional_readme_paths.json'
# A list of paths that contain license information but that would otherwise
# not be included. Possible reasons include:
# - Third party directories in //clank which are considered to be Google-owned
# - Directories that are directly checked out from upstream, and thus
# don't have a README.chromium
# - Directories that contain example code, or build tooling.
# - Nested third_party code inside other third_party libraries.
ADDITIONAL_PATHS = (
os.path.join('chrome', 'common', 'extensions', 'docs', 'examples'),
os.path.join('chrome', 'test', 'chromeos', 'autotest'),
os.path.join('chrome', 'test', 'data'),
os.path.join('clank', 'third_party', 'elements'),
os.path.join('native_client'),
os.path.join('testing', 'gmock'),
os.path.join('testing', 'gtest'),
......@@ -464,6 +472,16 @@ def FilterDirsWithFiles(dirs_list, root):
return [x for x in dirs_list if ContainsFiles(x, root)]
def ProcessAdditionalReadmePathsJson(dirname, third_party_dirs):
"""For a given directory, process the additional readme paths, and add to
third_party_dirs."""
additional_paths_file = os.path.join(dirname, 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(dirname, p) for p in extra_paths])
def FindThirdPartyDirs(prune_paths, root):
"""Find all third_party directories underneath the source root."""
third_party_dirs = set()
......@@ -485,15 +503,11 @@ def FindThirdPartyDirs(prune_paths, root):
# Add all subdirectories that are not marked for skipping.
for dir in dirs:
dirpath = os.path.join(path, dir)
additional_paths_file = os.path.join(root, dirpath,
ADDITIONAL_PATHS_FILENAME)
if dirpath not in prune_paths:
third_party_dirs.add(dirpath)
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])
additional_paths_dir = os.path.join(root, dirpath)
ProcessAdditionalReadmePathsJson(additional_paths_dir, third_party_dirs)
# Don't recurse into any subdirs from here.
dirs[:] = []
......@@ -507,6 +521,8 @@ def FindThirdPartyDirs(prune_paths, root):
for dir in ADDITIONAL_PATHS:
if dir not in prune_paths:
third_party_dirs.add(dir)
additional_paths_dir = os.path.join(root, dir)
ProcessAdditionalReadmePathsJson(additional_paths_dir, third_party_dirs)
return third_party_dirs
......
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