diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 18:53:46 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 18:53:46 +0000 |
commit | 0ecd19b8772876f9a09e1f0e4b3c7ec90f2499b3 (patch) | |
tree | 77e68fc86b1c333c38854fc363284824b79df1ee /tools | |
parent | c46862ab8341be4203cf97e3de3e4d786abdbbbd (diff) | |
download | chromium_src-0ecd19b8772876f9a09e1f0e4b3c7ec90f2499b3.zip chromium_src-0ecd19b8772876f9a09e1f0e4b3c7ec90f2499b3.tar.gz chromium_src-0ecd19b8772876f9a09e1f0e4b3c7ec90f2499b3.tar.bz2 |
Removing DEPTH support.
It makes the code simpler by automatically deducing the root directory to use.
R=rogerta@chromium.org
TBR=mark@chromium.org
TBR=rsleevi@chromium.org
BUG=98834
TEST=
Review URL: http://codereview.chromium.org/10062001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132608 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/isolate/isolate.py | 60 | ||||
-rwxr-xr-x | tools/isolate/isolate_smoke_test.py | 6 |
2 files changed, 29 insertions, 37 deletions
diff --git a/tools/isolate/isolate.py b/tools/isolate/isolate.py index 7e39bf4..0db25cd 100755 --- a/tools/isolate/isolate.py +++ b/tools/isolate/isolate.py @@ -24,6 +24,7 @@ import json import logging import optparse import os +import posixpath import re import stat import subprocess @@ -462,50 +463,47 @@ def main(): parser.error('--mode is required') if len(args) != 1: parser.error('Use only one argument which should be a .isolate file') + input_file = os.path.abspath(args[0]) + isolate_dir = os.path.dirname(input_file) # Extract the variables. variables = dict(i.split('=', 1) for i in options.variables) - if not variables.get('DEPTH'): - parser.error('--variable DEPTH=<base dir> is required') - - PATH_VARIABLES = ('DEPTH', 'PRODUCT_DIR') # Process path variables as a special case. First normalize it, verifies it - # exists, convert it to an absolute path, then calculate relative_dir, and - # finally convert it back to a relative value from relative_dir. - abs_variables = {} - for i in PATH_VARIABLES: + # exists, convert it to an absolute path, then set it as relative to + # isolate_dir. + for i in ('PRODUCT_DIR',): if i not in variables: continue - abs_variables[i] = os.path.normpath(variables[i]) - if not os.path.isdir(abs_variables[i]): - parser.error('%s is not a directory' % abs_variables[i]) - abs_variables[i] = os.path.abspath(abs_variables[i]) + variable = os.path.normpath(variables[i]) + if not os.path.isdir(variable): + parser.error('%s=%s is not a directory' % (i, variable)) + variable = os.path.abspath(variable) + # All variables are relative to the input file. + variables[i] = os.path.relpath(variable, isolate_dir) + + command, infiles, read_only = load_isolate( + open(input_file, 'r').read(), variables, parser.error) + # The trick used to determine the root directory is to look at "how far" back + # up it is looking up. + root_dir = isolate_dir + for i in infiles: + x = isolate_dir + while i.startswith('../'): + i = i[3:] + assert not i.startswith('/') + x = posixpath.dirname(x) + if root_dir.startswith(x): + root_dir = x # The relative directory is automatically determined by the relative path - # between DEPTH and the directory containing the .isolate file. - isolate_dir = os.path.dirname(os.path.abspath(input_file)) - relative_dir = os.path.relpath(isolate_dir, abs_variables['DEPTH']) + # between root_dir and the directory containing the .isolate file. + relative_dir = os.path.relpath(isolate_dir, root_dir) logging.debug('relative_dir: %s' % relative_dir) - # Directories are _relative_ to relative_dir. - for i in PATH_VARIABLES: - if i not in variables: - continue - variables[i] = os.path.relpath(abs_variables[i], isolate_dir) - logging.debug( 'variables: %s' % ', '.join( '%s=%s' % (k, v) for k, v in variables.iteritems())) - - # TODO(maruel): Case insensitive file systems. - if not input_file.startswith(abs_variables['DEPTH']): - parser.error( - '%s must be under %s, as it is used as the relative start directory.' % - (args[0], abs_variables['DEPTH'])) - - command, infiles, read_only = load_isolate( - open(input_file, 'r').read(), variables, parser.error) logging.debug('command: %s' % command) logging.debug('infiles: %s' % infiles) logging.debug('read_only: %s' % read_only) @@ -515,7 +513,7 @@ def main(): try: return isolate( options.outdir, - abs_variables['DEPTH'], + root_dir, infiles, options.mode, read_only, diff --git a/tools/isolate/isolate_smoke_test.py b/tools/isolate/isolate_smoke_test.py index 2fd64d6..1da347c 100755 --- a/tools/isolate/isolate_smoke_test.py +++ b/tools/isolate/isolate_smoke_test.py @@ -148,16 +148,10 @@ class IsolateBase(unittest.TestCase): case, self.case() + '.isolate', 'Rename the test case to test_%s()' % case) - # TODO(maruel): This is going away, temporary until DEPTH support is - # removed. - depth = os.path.join('data', 'isolate') - if RELATIVE_CWD[self.case()] != '.': - depth = '.' cmd = [ sys.executable, os.path.join(ROOT_DIR, 'isolate.py'), '--result', self.result, '--outdir', self.outdir, - '-V', 'DEPTH=%s' % depth, self.filename(), '--mode', self.mode(), ] |