OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
Michael Achenbach
2015/10/01 09:52:17
1:1 c/p from https://code.google.com/p/chromium/co
| |
2 # Copyright 2015 the V8 project authors. All rights reserved. | |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Adaptor script called through build/isolate.gypi. | |
7 | |
8 Slimmed down version of chromium's isolate driver that doesn't process dynamic | |
9 dependencies. | |
10 """ | |
11 | |
12 import json | |
13 import logging | |
14 import os | |
15 import subprocess | |
16 import sys | |
17 | |
18 TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) | |
19 SWARMING_CLIENT_DIR = os.path.join(TOOLS_DIR, 'swarming_client') | |
20 SRC_DIR = os.path.dirname(TOOLS_DIR) | |
21 | |
22 sys.path.insert(0, SWARMING_CLIENT_DIR) | |
23 | |
24 | |
25 def prepare_isolate_call(args, output): | |
26 """Gathers all information required to run isolate.py later. | |
27 | |
28 Dumps it as JSON to |output| file. | |
29 """ | |
30 with open(output, 'wb') as f: | |
31 json.dump({ | |
32 'args': args, | |
33 'dir': os.getcwd(), | |
34 'version': 1, | |
35 }, f, indent=2, sort_keys=True) | |
36 | |
37 | |
38 def main(): | |
39 logging.basicConfig(level=logging.ERROR, format='%(levelname)7s %(message)s') | |
40 args = sys.argv[1:] | |
41 mode = args[0] if args else None | |
42 isolate = None | |
43 isolated = None | |
44 for i, arg in enumerate(args): | |
45 if arg == '--isolate': | |
46 isolate = i + 1 | |
47 if arg == '--isolated': | |
48 isolated = i + 1 | |
49 if isolate is None or isolated is None or not mode: | |
50 print >> sys.stderr, 'Internal failure' | |
51 return 1 | |
52 | |
53 # In 'prepare' mode just collect all required information for postponed | |
54 # isolated.py invocation later, store it in *.isolated.gen.json file. | |
55 if mode == 'prepare': | |
56 prepare_isolate_call(args[1:], args[isolated] + '.gen.json') | |
57 return 0 | |
58 | |
59 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') | |
60 sys.stdout.flush() | |
61 result = subprocess.call( | |
62 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) | |
63 return result | |
64 | |
65 | |
66 if __name__ == '__main__': | |
67 sys.exit(main()) | |
OLD | NEW |