Commit 76a9aecf authored by estevenson's avatar estevenson Committed by Commit bot

Add resource whitelisting compatibility for offical builder scripts.

https://codereview.chromium.org/2272713004/ breaks
official builders so this CL ensures the offical build scripts work as
they used to.

BUG=640877
TBR=dpranke@chromium.org, brettw@chromium.org

Review-Url: https://codereview.chromium.org/2278983002
Cr-Commit-Position: refs/heads/master@{#414463}
parent 0e41c539
...@@ -1702,6 +1702,7 @@ if (enable_resource_whitelist_generation) { ...@@ -1702,6 +1702,7 @@ if (enable_resource_whitelist_generation) {
"-o", "-o",
rebase_path(_outfile, root_build_dir), rebase_path(_outfile, root_build_dir),
"--out-dir=.", "--out-dir=.",
"--use-existing-resource-ids",
] ]
} }
} }
......
...@@ -55,6 +55,22 @@ def _FindResourceIds(header, resource_names): ...@@ -55,6 +55,22 @@ def _FindResourceIds(header, resource_names):
return set(res_ids) return set(res_ids)
# TODO(estevenson): Remove this after updating official build scripts.
def _GetResourceIdsInPragmaWarnings(input):
"""Returns set of resource ids that are inside unknown pragma warnings
for the given input.
"""
used_resources = set()
unknown_pragma_warning_pattern = re.compile(
'whitelisted_resource_(?P<resource_id>[0-9]+)')
for ln in input:
match = unknown_pragma_warning_pattern.search(ln)
if match:
resource_id = int(match.group('resource_id'))
used_resources.add(resource_id)
return used_resources
def main(): def main():
parser = argparse.ArgumentParser(usage=USAGE) parser = argparse.ArgumentParser(usage=USAGE)
parser.add_argument( parser.add_argument(
...@@ -66,11 +82,18 @@ def main(): ...@@ -66,11 +82,18 @@ def main():
parser.add_argument( parser.add_argument(
'--out-dir', required=True, '--out-dir', required=True,
help='The out target directory, for example out/Release') help='The out target directory, for example out/Release')
parser.add_argument(
'--use-existing-resource-ids', action='store_true', default=False,
help='Specifies that the input file already contains resource ids')
args = parser.parse_args() args = parser.parse_args()
used_resources = set() used_resources = set()
used_resources.update([int(resource_id) for resource_id in args.input]) if args.use_existing_resource_ids:
used_resources.update([int(resource_id) for resource_id in args.input])
else:
used_resources.update(_GetResourceIdsInPragmaWarnings(args.input))
used_resources |= _FindResourceIds( used_resources |= _FindResourceIds(
os.path.join(args.out_dir, COMPONENTS_STRINGS_HEADER), os.path.join(args.out_dir, COMPONENTS_STRINGS_HEADER),
ARCH_SPECIFIC_RESOURCES) ARCH_SPECIFIC_RESOURCES)
......
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