Commit d8113f43 authored by David Jean's avatar David Jean Committed by Commit Bot

[ios] Fix indenting from previous CL

Indenting was added by git cl format

Bug: 1065322
Change-Id: Id1d13cf3d81eb3391892917ca497da15bd09f538
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2124712
Auto-Submit: David Jean <djean@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Commit-Queue: David Jean <djean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#754833}
parent 372ac562
......@@ -369,7 +369,6 @@ class LicenseError(Exception):
fully filled out."""
pass
def AbsolutePath(path, filename, root):
"""Convert a path in README.chromium to be absolute based on the source
root."""
......@@ -383,7 +382,6 @@ def AbsolutePath(path, filename, root):
return absolute_path
return None
def ParseDir(path, root, require_license_file=True, optional_keys=None):
"""Examine a third_party/foo component and extract its metadata."""
# Parse metadata fields out of README.chromium.
......@@ -468,7 +466,7 @@ def FindThirdPartyDirs(prune_paths, root):
"""Find all third_party directories underneath the source root."""
third_party_dirs = set()
for path, dirs, files in os.walk(root):
path = path[len(root) + 1:] # Pretty up the path.
path = path[len(root)+1:] # Pretty up the path.
if path in prune_paths:
dirs[:] = []
......@@ -485,15 +483,15 @@ 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)
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])
third_party_dirs.update([
os.path.join(dirpath, p) for p in extra_paths])
# Don't recurse into any subdirs from here.
dirs[:] = []
......@@ -544,7 +542,8 @@ def GetThirdPartyDepsFromGNDepsOutput(gn_deps, target_os):
"""
third_party_deps = set()
for absolute_build_dep in gn_deps.split():
relative_build_dep = os.path.relpath(absolute_build_dep, _REPOSITORY_ROOT)
relative_build_dep = os.path.relpath(
absolute_build_dep, _REPOSITORY_ROOT)
m = re.search(
r'^((.+[/\\])?third_party[/\\][^/\\]+[/\\])(.+[/\\])?BUILD\.gn$',
relative_build_dep)
......@@ -553,8 +552,8 @@ def GetThirdPartyDepsFromGNDepsOutput(gn_deps, target_os):
third_party_path = m.group(1)
if any(third_party_path.startswith(p + os.sep) for p in PRUNE_PATHS):
continue
if (target_os == 'ios' and any(
third_party_path.startswith(p + os.sep)
if (target_os == 'ios' and
any(third_party_path.startswith(p + os.sep)
for p in KNOWN_NON_IOS_LIBRARIES)):
# Skip over files that are known not to be used on iOS.
continue
......@@ -572,13 +571,12 @@ def FindThirdPartyDeps(gn_out_dir, gn_target, target_os):
# effects.
tmp_dir = None
try:
tmp_dir = tempfile.mkdtemp(dir=gn_out_dir)
tmp_dir = tempfile.mkdtemp(dir = gn_out_dir)
shutil.copy(os.path.join(gn_out_dir, "args.gn"), tmp_dir)
subprocess.check_output([_GnBinary(), "gen", tmp_dir])
gn_deps = subprocess.check_output([
_GnBinary(), "desc", tmp_dir, gn_target, "deps", "--as=buildfile",
"--all"
])
_GnBinary(), "desc", tmp_dir, gn_target,
"deps", "--as=buildfile", "--all"])
if isinstance(gn_deps, bytes):
gn_deps = gn_deps.decode("utf-8")
finally:
......@@ -659,10 +657,9 @@ def GenerateCredits(
chromium_license_metadata = {
'Name': 'The Chromium Project',
'URL': 'http://www.chromium.org',
'License File': os.path.join(_REPOSITORY_ROOT, 'LICENSE')
}
entries.append(
MetadataToTemplateEntry(chromium_license_metadata, entry_template))
'License File': os.path.join(_REPOSITORY_ROOT, 'LICENSE') }
entries.append(MetadataToTemplateEntry(chromium_license_metadata,
entry_template))
for path in third_party_dirs:
try:
......@@ -689,8 +686,9 @@ def GenerateCredits(
entries_contents = '\n'.join([entry['content'] for entry in entries])
file_template = open(file_template_file).read()
template_contents = "<!-- Generated by licenses.py; do not edit. -->"
template_contents += EvaluateTemplate(
file_template, {'entries': entries_contents}, escape=False)
template_contents += EvaluateTemplate(file_template,
{'entries': entries_contents},
escape=False)
if output_file:
changed = True
......@@ -749,7 +747,8 @@ def GenerateLicenseFile(output_file, gn_out_dir, gn_target, target_os):
# Add necessary third_party.
for directory in sorted(third_party_dirs):
metadata = ParseDir(directory, _REPOSITORY_ROOT, require_license_file=True)
metadata = ParseDir(
directory, _REPOSITORY_ROOT, require_license_file=True)
content.append('-' * 20)
content.append(directory.split(os.sep)[-1])
content.append('-' * 20)
......@@ -769,16 +768,18 @@ def GenerateLicenseFile(output_file, gn_out_dir, gn_target, target_os):
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--file-template', help='Template HTML to use for the license page.')
parser.add_argument(
'--entry-template', help='Template HTML to use for each license.')
parser.add_argument('--target-os', help='OS that this build is targeting.')
parser.add_argument(
'--gn-out-dir', help='GN output directory for scanning dependencies.')
parser.add_argument('--gn-target', help='GN target to scan for dependencies.')
parser.add_argument(
'command', choices=['help', 'scan', 'credits', 'license_file'])
parser.add_argument('--file-template',
help='Template HTML to use for the license page.')
parser.add_argument('--entry-template',
help='Template HTML to use for each license.')
parser.add_argument('--target-os',
help='OS that this build is targeting.')
parser.add_argument('--gn-out-dir',
help='GN output directory for scanning dependencies.')
parser.add_argument('--gn-target',
help='GN target to scan for dependencies.')
parser.add_argument('command',
choices=['help', 'scan', 'credits', 'license_file'])
parser.add_argument('output_file', nargs='?')
build_utils.AddDepfileOption(parser)
args = parser.parse_args()
......@@ -788,12 +789,13 @@ def main():
return 1
elif args.command == 'credits':
if not GenerateCredits(args.file_template, args.entry_template,
args.output_file, args.target_os, args.gn_out_dir,
args.gn_target, args.depfile):
args.output_file, args.target_os,
args.gn_out_dir, args.gn_target, args.depfile):
return 1
elif args.command == 'license_file':
try:
GenerateLicenseFile(args.output_file, args.gn_out_dir, args.gn_target,
GenerateLicenseFile(
args.output_file, args.gn_out_dir, args.gn_target,
args.target_os)
except LicenseError as e:
print("Failed to parse README.chromium: {}".format(e))
......
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