diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-05 18:13:43 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-05 18:13:43 +0000 |
commit | 677eb4f8b14d73214087c4ee9535ae8d636a97ba (patch) | |
tree | 3015436cb988f97d5642079252f5ca75945c2e39 /tools | |
parent | 06c8b08739df0a493445459d8ede0ae4eecc9a31 (diff) | |
download | chromium_src-677eb4f8b14d73214087c4ee9535ae8d636a97ba.zip chromium_src-677eb4f8b14d73214087c4ee9535ae8d636a97ba.tar.gz chromium_src-677eb4f8b14d73214087c4ee9535ae8d636a97ba.tar.bz2 |
Update grit_info.py to use optparse and add the ability to pass
in build defines (e.g., -D chromeos).
This will make it possible for us to handle build dependencies
in all configurations. I'll make a follow up change that adds
the -D flags to the gyp files.
BUG=68028
Review URL: http://codereview.chromium.org/6065012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70518 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/grit/grit_info.py | 56 |
1 files changed, 40 insertions, 16 deletions
diff --git a/tools/grit/grit_info.py b/tools/grit/grit_info.py index 70c82eb..042f457 100755 --- a/tools/grit/grit_info.py +++ b/tools/grit/grit_info.py @@ -6,6 +6,7 @@ '''Tool to determine inputs and outputs of a grit file. ''' +import optparse import os import posixpath import types @@ -14,8 +15,8 @@ from grit import grd_reader from grit import util -def Outputs(filename): - grd = grd_reader.Parse(filename) +def Outputs(filename, defines): + grd = grd_reader.Parse(filename, defines=defines) target = [] lang_folders = {} @@ -45,8 +46,8 @@ def Outputs(filename): return [t.replace('\\', '/') for t in target] -def Inputs(filename): - grd = grd_reader.Parse(filename, debug=False) +def Inputs(filename, defines): + grd = grd_reader.Parse(filename, debug=False, defines=defines) files = [] for node in grd: if (node.name == 'structure' or node.name == 'skeleton' or @@ -72,22 +73,45 @@ def Inputs(filename): return [f.replace('\\', '/') for f in files] +def PrintUsage(): + print 'USAGE: ./grit_info.py --inputs [-D foo] <grd-files>..' + print ' ./grit_info.py --outputs [-D foo] <out-prefix> <grd-files>..' + + def main(argv): - if len(argv) >= 3 and argv[1] == '--inputs': - for f in argv[2:]: - inputs = Inputs(f) + parser = optparse.OptionParser() + parser.add_option("--inputs", action="store_true", dest="inputs") + parser.add_option("--outputs", action="store_true", dest="outputs") + parser.add_option("-D", action="append", dest="defines", default=[]) + + options, args = parser.parse_args() + + if not len(args): + PrintUsage() + return 1 + + defines = {} + for define in options.defines: + defines[define] = 1 + + if options.inputs: + for filename in args: + inputs = Inputs(filename, defines) # Include grd file as second input (works around gyp expecting it). - inputs = [inputs[0], f] + inputs[1:] + inputs = [inputs[0], filename] + inputs[1:] print '\n'.join(inputs) - return 0 - if len(argv) >= 4 and argv[1] == '--outputs': - for f in argv[3:]: - outputs = [posixpath.join(argv[2], f) for f in Outputs(f)] + elif options.outputs: + if len(args) < 2: + PrintUsage() + return 1 + + for f in args[1:]: + outputs = [posixpath.join(args[0], f) for f in Outputs(f, defines)] print '\n'.join(outputs) - return 0 - print 'USAGE: ./grit_info.py --inputs <grd-files>..' - print ' ./grit_info.py --outputs <out-prefix> <grd-files>..' - return 1 + else: + PringUsage() + return 1 + return 0 if __name__ == '__main__': |