Chromium Code Reviews| Index: deps2git.py |
| =================================================================== |
| --- deps2git.py (revision 292133) |
| +++ deps2git.py (working copy) |
| @@ -280,6 +280,11 @@ |
| return results |
| +def convert_json(option, _, value, parser): |
| + """Provide an OptionParser callback to unmarshal a JSON string.""" |
| + setattr(parser.values, option.dest, json.loads(value)) |
| + |
| + |
| def main(): |
| parser = optparse.OptionParser() |
| parser.add_option('-d', '--deps', default='DEPS', |
| @@ -300,6 +305,9 @@ |
| help='top level of a gclient git cache diretory.') |
| parser.add_option('-s', '--shallow', action='store_true', |
| help='Use shallow checkouts when populating cache dirs.') |
| + parser.add_option('--custom_vars', action='callback', callback=convert_json, |
| + type='string', nargs=1, default={}, |
|
hinoka
2014/10/02 21:05:51
nargs is redundant.
szager1
2014/10/02 21:16:22
Prefer default=None
kjellander_chromium
2014/10/03 07:13:31
Done.
kjellander_chromium
2014/10/03 07:13:31
Done.
|
| + help='custom_vars dict in JSON format') |
| parser.add_option('--no_fail_fast', action='store_true', |
| help='Try to process the whole DEPS, rather than failing ' |
| 'on the first bad entry.') |
| @@ -311,7 +319,7 @@ |
| # Get the content of the DEPS file. |
| deps, deps_os, include_rules, skip_child_includes, hooks, deps_vars = ( |
| - deps_utils.GetDepsContent(options.deps)) |
| + deps_utils.GetDepsContent(options.deps, options.custom_vars)) |
| if options.extra_rules and options.type: |
| parser.error('Can\'t specify type and extra-rules at the same time.') |