diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 21:20:38 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-17 21:20:38 +0000 |
commit | e9396f6a151a5273f47f2e77be98f6d6f874fd6b (patch) | |
tree | 950479ca593fc151bbf840d4d6fb1589cb845798 /tools/isolate | |
parent | fbb1f7af8e01c71a92c2d912b762375a159c9335 (diff) | |
download | chromium_src-e9396f6a151a5273f47f2e77be98f6d6f874fd6b.zip chromium_src-e9396f6a151a5273f47f2e77be98f6d6f874fd6b.tar.gz chromium_src-e9396f6a151a5273f47f2e77be98f6d6f874fd6b.tar.bz2 |
Revert 132608 - 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
TBR=maruel@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10117005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/isolate')
-rwxr-xr-x | tools/isolate/isolate.py | 60 | ||||
-rwxr-xr-x | tools/isolate/isolate_smoke_test.py | 6 |
2 files changed, 37 insertions, 29 deletions
diff --git a/tools/isolate/isolate.py b/tools/isolate/isolate.py index 0db25cd..7e39bf4 100755 --- a/tools/isolate/isolate.py +++ b/tools/isolate/isolate.py @@ -24,7 +24,6 @@ import json import logging import optparse import os -import posixpath import re import stat import subprocess @@ -463,47 +462,50 @@ 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 set it as relative to - # isolate_dir. - for i in ('PRODUCT_DIR',): + # 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: if i not in variables: continue - 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) + 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]) - # 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 root_dir and the directory containing the .isolate file. - relative_dir = os.path.relpath(isolate_dir, root_dir) + # 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']) 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) @@ -513,7 +515,7 @@ def main(): try: return isolate( options.outdir, - root_dir, + abs_variables['DEPTH'], infiles, options.mode, read_only, diff --git a/tools/isolate/isolate_smoke_test.py b/tools/isolate/isolate_smoke_test.py index 1da347c..2fd64d6 100755 --- a/tools/isolate/isolate_smoke_test.py +++ b/tools/isolate/isolate_smoke_test.py @@ -148,10 +148,16 @@ 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(), ] |