Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: tools/resources/generate_resource_whitelist.py

Issue 2278983002: Add resource whitelisting compatibility for offical builder scripts. (Closed)
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/BUILD.gn ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/resources/generate_resource_whitelist.py
diff --git a/tools/resources/generate_resource_whitelist.py b/tools/resources/generate_resource_whitelist.py
index 527ceb484158c9fcf32cb5d9dc34e7561d7471d9..c4431d687aed957532463d6d680488bc7128cc2e 100755
--- a/tools/resources/generate_resource_whitelist.py
+++ b/tools/resources/generate_resource_whitelist.py
@@ -55,6 +55,22 @@ def _FindResourceIds(header, resource_names):
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():
parser = argparse.ArgumentParser(usage=USAGE)
parser.add_argument(
@@ -66,11 +82,18 @@ def main():
parser.add_argument(
'--out-dir', required=True,
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()
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(
os.path.join(args.out_dir, COMPONENTS_STRINGS_HEADER),
ARCH_SPECIFIC_RESOURCES)
« no previous file with comments | « chrome/BUILD.gn ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698