diff options
author | luqui <luqui@chromium.org> | 2015-03-13 11:23:24 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-13 18:24:41 +0000 |
commit | 6bf6ab9a092f8d920aa4235383303f6fe0cb791c (patch) | |
tree | 01390a50812affa761892059d63c510f90fdf384 /tools/resources | |
parent | b6adc8e056abcabf8f35f56a743b00bb058b05cd (diff) | |
download | chromium_src-6bf6ab9a092f8d920aa4235383303f6fe0cb791c.zip chromium_src-6bf6ab9a092f8d920aa4235383303f6fe0cb791c.tar.gz chromium_src-6bf6ab9a092f8d920aa4235383303f6fe0cb791c.tar.bz2 |
Changed find_used_resources to take input and output file arguments.
BUG=
Review URL: https://codereview.chromium.org/998083002
Cr-Commit-Position: refs/heads/master@{#320534}
Diffstat (limited to 'tools/resources')
-rwxr-xr-x | tools/resources/find_used_resources.py | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/tools/resources/find_used_resources.py b/tools/resources/find_used_resources.py index 63bcaa0..9fc99ae 100755 --- a/tools/resources/find_used_resources.py +++ b/tools/resources/find_used_resources.py @@ -3,14 +3,14 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. - +import argparse import re import sys -usage = """find_used_resources.py +USAGE = """find_used_resources.py [-h] [-i INPUT] [-o OUTPUT] -Prints out (to stdout) the sorted list of resource ids that are part of unknown -pragma warning in the given build log (via stdin). +Outputs the sorted list of resource ids that are part of unknown pragma warning +in the given build log. This script is used to find the resources that are actually compiled in Chrome in order to only include the needed strings/images in Chrome PAK files. The @@ -41,13 +41,19 @@ def GetResourceIdsInPragmaWarnings(input): return sorted(used_resources) def Main(): - if len(sys.argv) != 1: - sys.stderr.write(usage) - sys.exit(1) - else: - used_resources = GetResourceIdsInPragmaWarnings(sys.stdin) - for resource_id in used_resources: - sys.stdout.write('%d\n' % resource_id) + parser = argparse.ArgumentParser(usage=USAGE) + parser.add_argument( + '-i', '--input', type=argparse.FileType('r'), default=sys.stdin, + help='The build log to read (default stdin)') + parser.add_argument( + '-o', '--output', type=argparse.FileType('w'), default=sys.stdout, + help='The resource list path to write (default stdout)') + args = parser.parse_args() + + + used_resources = GetResourceIdsInPragmaWarnings(args.input) + for resource_id in used_resources: + args.output.write('%d\n' % resource_id) if __name__ == '__main__': Main() |