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