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

Side by Side Diff: deps2git.py

Issue 619133002: deps2git: Add support for overriding DEPS vars (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/deps2git/
Patch Set: Changed to var_overrides Created 6 years, 2 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | deps_utils.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Convert SVN based DEPS into .DEPS.git for use with NewGit.""" 6 """Convert SVN based DEPS into .DEPS.git for use with NewGit."""
7 7
8 import collections 8 import collections
9 from cStringIO import StringIO 9 from cStringIO import StringIO
10 import json 10 import json
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 message_th.start() 273 message_th.start()
274 274
275 for th in threads: 275 for th in threads:
276 th.join() 276 th.join()
277 message_q.put(Queue.Empty) 277 message_q.put(Queue.Empty)
278 message_th.join() 278 message_th.join()
279 279
280 return results 280 return results
281 281
282 282
283 def convert_json(option, _, value, parser):
284 """Provide an OptionParser callback to unmarshal a JSON string."""
285 setattr(parser.values, option.dest, json.loads(value))
286
287
283 def main(): 288 def main():
284 parser = optparse.OptionParser() 289 parser = optparse.OptionParser()
285 parser.add_option('-d', '--deps', default='DEPS', 290 parser.add_option('-d', '--deps', default='DEPS',
286 help='path to the DEPS file to convert') 291 help='path to the DEPS file to convert')
287 parser.add_option('-o', '--out', 292 parser.add_option('-o', '--out',
288 help='path to the converted DEPS file (default: stdout)') 293 help='path to the converted DEPS file (default: stdout)')
289 parser.add_option('-j', '--num-threads', type='int', default=4, 294 parser.add_option('-j', '--num-threads', type='int', default=4,
290 help='Maximum number of threads') 295 help='Maximum number of threads')
291 parser.add_option('-t', '--type', 296 parser.add_option('-t', '--type',
292 help='[DEPRECATED] type of DEPS file (public, etc)') 297 help='[DEPRECATED] type of DEPS file (public, etc)')
293 parser.add_option('-x', '--extra-rules', 298 parser.add_option('-x', '--extra-rules',
294 help='Path to file with additional conversion rules.') 299 help='Path to file with additional conversion rules.')
295 parser.add_option('-r', '--repos', 300 parser.add_option('-r', '--repos',
296 help='path to the directory holding all the Git repos') 301 help='path to the directory holding all the Git repos')
297 parser.add_option('-w', '--workspace', metavar='PATH', 302 parser.add_option('-w', '--workspace', metavar='PATH',
298 help='top level of a git-based gclient checkout') 303 help='top level of a git-based gclient checkout')
299 parser.add_option('-c', '--cache_dir', 304 parser.add_option('-c', '--cache_dir',
300 help='top level of a gclient git cache diretory.') 305 help='top level of a gclient git cache diretory.')
301 parser.add_option('-s', '--shallow', action='store_true', 306 parser.add_option('-s', '--shallow', action='store_true',
302 help='Use shallow checkouts when populating cache dirs.') 307 help='Use shallow checkouts when populating cache dirs.')
308 parser.add_option('--var_overrides', action='callback', callback=convert_json,
309 type='string', default=None,
310 help='A dict in JSON format containing key-value pairs '
311 'that will override variables used in the DEPS file.')
303 parser.add_option('--no_fail_fast', action='store_true', 312 parser.add_option('--no_fail_fast', action='store_true',
304 help='Try to process the whole DEPS, rather than failing ' 313 help='Try to process the whole DEPS, rather than failing '
305 'on the first bad entry.') 314 'on the first bad entry.')
306 parser.add_option('--verify', action='store_true', 315 parser.add_option('--verify', action='store_true',
307 help='ping each Git repo to make sure it exists') 316 help='ping each Git repo to make sure it exists')
308 parser.add_option('--json', 317 parser.add_option('--json',
309 help='path to a JSON file for machine-readable output') 318 help='path to a JSON file for machine-readable output')
310 options = parser.parse_args()[0] 319 options = parser.parse_args()[0]
311 320
312 # Get the content of the DEPS file. 321 # Get the content of the DEPS file.
313 deps, deps_os, include_rules, skip_child_includes, hooks, deps_vars = ( 322 deps, deps_os, include_rules, skip_child_includes, hooks, deps_vars = (
314 deps_utils.GetDepsContent(options.deps)) 323 deps_utils.GetDepsContent(options.deps, options.var_overrides))
315 324
316 if options.extra_rules and options.type: 325 if options.extra_rules and options.type:
317 parser.error('Can\'t specify type and extra-rules at the same time.') 326 parser.error('Can\'t specify type and extra-rules at the same time.')
318 elif options.type: 327 elif options.type:
319 options.extra_rules = os.path.join( 328 options.extra_rules = os.path.join(
320 os.path.abspath(os.path.dirname(__file__)), 329 os.path.abspath(os.path.dirname(__file__)),
321 'svn_to_git_%s.py' % options.type) 330 'svn_to_git_%s.py' % options.type)
322 if options.cache_dir and options.repos: 331 if options.cache_dir and options.repos:
323 parser.error('Can\'t specify both cache_dir and repos at the same time.') 332 parser.error('Can\'t specify both cache_dir and repos at the same time.')
324 if options.shallow and not options.cache_dir: 333 if options.shallow and not options.cache_dir:
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 return 0 435 return 0
427 436
428 # Write the DEPS file to disk. 437 # Write the DEPS file to disk.
429 deps_utils.WriteDeps(options.out, deps_vars, results.new_deps, deps_os, 438 deps_utils.WriteDeps(options.out, deps_vars, results.new_deps, deps_os,
430 include_rules, skip_child_includes, hooks) 439 include_rules, skip_child_includes, hooks)
431 return 0 440 return 0
432 441
433 442
434 if '__main__' == __name__: 443 if '__main__' == __name__:
435 sys.exit(main()) 444 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | deps_utils.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698