[gn] Fix isolate_driver for gn
This makes the isolate-driver script rebase all paths to be relative to the isolate-file location. This is an assumption of the go binaries and is needed for batcharchive to work. In gyp, actions were executed relative to the gyp file that specified them, while in gn it's relative to the product dir. BUG=chromium:474921 Review-Url: https://codereview.chromium.org/2039873002 Cr-Commit-Position: refs/heads/master@{#36746}
This commit is contained in:
parent
fb9ce9373b
commit
87affbc531
@ -101,6 +101,8 @@ template("v8_isolate_run") {
|
|||||||
use_snapshot = "0"
|
use_snapshot = "0"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Note, all paths will be rebased in isolate_driver.py to be relative to
|
||||||
|
# the isolate file.
|
||||||
args = [
|
args = [
|
||||||
v8_test_isolation_mode,
|
v8_test_isolation_mode,
|
||||||
"--isolated",
|
"--isolated",
|
||||||
|
@ -30,6 +30,16 @@ def prepare_isolate_call(args, output):
|
|||||||
'version': 1,
|
'version': 1,
|
||||||
}, f, indent=2, sort_keys=True)
|
}, f, indent=2, sort_keys=True)
|
||||||
|
|
||||||
|
def rebase_directories(args, abs_base):
|
||||||
|
"""Rebases all paths to be relative to abs_base."""
|
||||||
|
def replace(index):
|
||||||
|
args[index] = os.path.relpath(os.path.abspath(args[index]), abs_base)
|
||||||
|
for i, arg in enumerate(args):
|
||||||
|
if arg in ['--isolate', '--isolated']:
|
||||||
|
replace(i + 1)
|
||||||
|
if arg == '--path-variable':
|
||||||
|
# Path variables have a triple form: --path-variable NAME <path>.
|
||||||
|
replace(i + 2)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logging.basicConfig(level=logging.ERROR, format='%(levelname)7s %(message)s')
|
logging.basicConfig(level=logging.ERROR, format='%(levelname)7s %(message)s')
|
||||||
@ -49,6 +59,14 @@ def main():
|
|||||||
print >> sys.stderr, 'Internal failure'
|
print >> sys.stderr, 'Internal failure'
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# Make sure all paths are relative to the isolate file. This is an
|
||||||
|
# expectation of the go binaries. In gn, this script is not called
|
||||||
|
# relative to the isolate file, but relative to the product dir.
|
||||||
|
new_base = os.path.abspath(os.path.dirname(args[isolate]))
|
||||||
|
rebase_directories(args, new_base)
|
||||||
|
assert args[isolate] == os.path.basename(args[isolate])
|
||||||
|
os.chdir(new_base)
|
||||||
|
|
||||||
# In 'prepare' mode just collect all required information for postponed
|
# In 'prepare' mode just collect all required information for postponed
|
||||||
# isolated.py invocation later, store it in *.isolated.gen.json file.
|
# isolated.py invocation later, store it in *.isolated.gen.json file.
|
||||||
if mode == 'prepare':
|
if mode == 'prepare':
|
||||||
|
Loading…
Reference in New Issue
Block a user