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

Side by Side Diff: tools/isolate/isolate.py

Issue 10091011: Added function to get native path case on Windows and OSX. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase against 10080013 Created 8 years, 8 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 | « tools/isolate/data/trace_inputs/child2.py ('k') | tools/isolate/isolate_smoke_test.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/env python 1 #!/usr/bin/env 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 """Does one of the following depending on the --mode argument: 6 """Does one of the following depending on the --mode argument:
7 check Verifies all the inputs exist, touches the file specified with 7 check Verifies all the inputs exist, touches the file specified with
8 --result and exits. 8 --result and exits.
9 hashtable Puts a manifest file and hard links each of the inputs into the 9 hashtable Puts a manifest file and hard links each of the inputs into the
10 output directory. 10 output directory.
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 384
385 It constructs the equivalent of dictfiles. It is hardcoded to base the 385 It constructs the equivalent of dictfiles. It is hardcoded to base the
386 checkout at src/. 386 checkout at src/.
387 """ 387 """
388 logging.info( 388 logging.info(
389 'Running %s, cwd=%s' % ( 389 'Running %s, cwd=%s' % (
390 data['command'], os.path.join(indir, data['relative_cwd']))) 390 data['command'], os.path.join(indir, data['relative_cwd'])))
391 product_dir = None 391 product_dir = None
392 if data['resultdir'] and indir: 392 if data['resultdir'] and indir:
393 # Defaults to none if both are the same directory. 393 # Defaults to none if both are the same directory.
394 product_dir = os.path.relpath(data['resultdir'], indir) or None 394 try:
395 product_dir = os.path.relpath(data['resultdir'], indir) or None
396 except ValueError:
397 # This happens on Windows if data['resultdir'] is one drive, let's say
398 # 'C:\' and indir on another one like 'D:\'.
399 product_dir = None
395 if not data['command']: 400 if not data['command']:
396 print 'No command to run' 401 print 'No command to run'
397 return 1 402 return 1
398 return trace_inputs.trace_inputs( 403 return trace_inputs.trace_inputs(
399 data['resultfile'], 404 data['resultfile'],
400 data['command'], 405 data['command'],
401 indir, 406 indir,
402 data['relative_cwd'], 407 data['relative_cwd'],
403 product_dir, 408 product_dir,
404 False) 409 False)
(...skipping 27 matching lines...) Expand all
432 variable = os.path.abspath(variable) 437 variable = os.path.abspath(variable)
433 # All variables are relative to the input file. 438 # All variables are relative to the input file.
434 variables[i] = os.path.relpath(variable, isolate_dir) 439 variables[i] = os.path.relpath(variable, isolate_dir)
435 440
436 command, infiles, read_only = load_isolate( 441 command, infiles, read_only = load_isolate(
437 open(input_file, 'r').read(), variables, error) 442 open(input_file, 'r').read(), variables, error)
438 443
439 # The trick used to determine the root directory is to look at "how far" back 444 # The trick used to determine the root directory is to look at "how far" back
440 # up it is looking up. 445 # up it is looking up.
441 # TODO(maruel): Stop the msbuild generator from generating a mix of / and \\. 446 # TODO(maruel): Stop the msbuild generator from generating a mix of / and \\.
442 root_dir = isolate_dir.replace(os.path.sep, '/') 447 isolate_dir_replaced = isolate_dir.replace(os.path.sep, '/')
448 root_dir = isolate_dir_replaced
449 logging.debug('root_dir before searching: %s' % root_dir)
443 for i in infiles: 450 for i in infiles:
444 i = i.replace(os.path.sep, '/') 451 i = i.replace(os.path.sep, '/')
445 x = isolate_dir.replace(os.path.sep, '/') 452 x = isolate_dir.replace(os.path.sep, '/')
446 while i.startswith('../'): 453 while i.startswith('../'):
447 i = i[3:] 454 i = i[3:]
448 assert not i.startswith('/') 455 assert not i.startswith('/')
449 x = posixpath.dirname(x) 456 x = posixpath.dirname(x)
450 if root_dir.startswith(x): 457 if root_dir.startswith(x):
451 root_dir = x 458 root_dir = x
452 root_dir = root_dir.replace('/', os.path.sep) 459 root_dir = root_dir.replace('/', os.path.sep)
460 logging.debug('root_dir after searching: %s' % root_dir)
461
453 # The relative directory is automatically determined by the relative path 462 # The relative directory is automatically determined by the relative path
454 # between root_dir and the directory containing the .isolate file. 463 # between root_dir and the directory containing the .isolate file.
455 relative_dir = os.path.relpath(isolate_dir, root_dir) 464 relative_dir = os.path.relpath(isolate_dir, root_dir).replace(
465 os.path.sep, '/')
456 logging.debug('relative_dir: %s' % relative_dir) 466 logging.debug('relative_dir: %s' % relative_dir)
457 467
458 logging.debug( 468 logging.debug(
459 'variables: %s' % ', '.join( 469 'variables: %s' % ', '.join(
460 '%s=%s' % (k, v) for k, v in variables.iteritems())) 470 '%s=%s' % (k, v) for k, v in variables.iteritems()))
461 471
462 data = load_results(resultfile) 472 data = load_results(resultfile)
463 473
464 command, infiles, read_only = load_isolate( 474 command, infiles, read_only = load_isolate(
465 open(input_file, 'r').read(), variables, error) 475 open(input_file, 'r').read(), variables, error)
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 data) 555 data)
546 except run_test_from_archive.MappingError, e: 556 except run_test_from_archive.MappingError, e:
547 print >> sys.stderr, str(e) 557 print >> sys.stderr, str(e)
548 return 1 558 return 1
549 save_results(options.result, data) 559 save_results(options.result, data)
550 return resultcode 560 return resultcode
551 561
552 562
553 if __name__ == '__main__': 563 if __name__ == '__main__':
554 sys.exit(main()) 564 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/isolate/data/trace_inputs/child2.py ('k') | tools/isolate/isolate_smoke_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698