Chromium Code Reviews| Index: tools/isolate_driver.py |
| diff --git a/tools/isolate_driver.py b/tools/isolate_driver.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..afdfb0646728705bab3c10dadcd393c92feb1570 |
| --- /dev/null |
| +++ b/tools/isolate_driver.py |
| @@ -0,0 +1,67 @@ |
| +#!/usr/bin/env python |
| +# Copyright 2015 the V8 project authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| +"""Adaptor script called through build/isolate.gypi. |
| + |
| +Slimmed down version of chromium's isolate driver that doesn't process dynamic |
| +dependencies. |
| +""" |
| + |
| +import json |
| +import logging |
| +import os |
| +import subprocess |
| +import sys |
| + |
| +TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) |
| +SWARMING_CLIENT_DIR = os.path.join(TOOLS_DIR, 'swarming_client') |
|
M-A Ruel
2015/10/01 12:17:06
Remove lines 19-22
Michael Achenbach
2015/10/01 12:28:29
Done.
|
| +SRC_DIR = os.path.dirname(TOOLS_DIR) |
| + |
| +sys.path.insert(0, SWARMING_CLIENT_DIR) |
| + |
| + |
| +def prepare_isolate_call(args, output): |
| + """Gathers all information required to run isolate.py later. |
| + |
| + Dumps it as JSON to |output| file. |
| + """ |
| + with open(output, 'wb') as f: |
| + json.dump({ |
| + 'args': args, |
| + 'dir': os.getcwd(), |
| + 'version': 1, |
| + }, f, indent=2, sort_keys=True) |
| + |
| + |
| +def main(): |
| + logging.basicConfig(level=logging.ERROR, format='%(levelname)7s %(message)s') |
| + args = sys.argv[1:] |
|
M-A Ruel
2015/10/01 12:17:06
replace lines 40-41 with:
if len(sys.argv) < 2:
Michael Achenbach
2015/10/01 12:28:29
Done.
|
| + mode = args[0] if args else None |
| + isolate = None |
| + isolated = None |
| + for i, arg in enumerate(args): |
| + if arg == '--isolate': |
| + isolate = i + 1 |
| + if arg == '--isolated': |
| + isolated = i + 1 |
| + if isolate is None or isolated is None or not mode: |
|
M-A Ruel
2015/10/01 12:17:06
if not isolate or not isolated:
Michael Achenbach
2015/10/01 12:28:29
Done.
|
| + print >> sys.stderr, 'Internal failure' |
| + return 1 |
| + |
| + # In 'prepare' mode just collect all required information for postponed |
| + # isolated.py invocation later, store it in *.isolated.gen.json file. |
| + if mode == 'prepare': |
| + prepare_isolate_call(args[1:], args[isolated] + '.gen.json') |
| + return 0 |
| + |
| + swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') |
|
M-A Ruel
2015/10/01 12:17:06
os.path.join(TOOLS_DIR, 'swarming_client')
Michael Achenbach
2015/10/01 12:28:29
Done.
|
| + sys.stdout.flush() |
| + result = subprocess.call( |
|
M-A Ruel
2015/10/01 12:17:06
return subprocess.call(
Michael Achenbach
2015/10/01 12:28:29
Done.
|
| + [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) |
| + return result |
| + |
| + |
| +if __name__ == '__main__': |
| + sys.exit(main()) |