Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: tools/isolate_driver.py

Issue 1130523003: Add support for escaped target names in isolate driver (3rd try) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add inclusion of chrome.isolate Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/sync_integration_tests.isolate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Adaptor script called through build/isolate.gypi. 6 """Adaptor script called through build/isolate.gypi.
7 7
8 Creates a wrapping .isolate which 'includes' the original one, that can be 8 Creates a wrapping .isolate which 'includes' the original one, that can be
9 consumed by tools/swarming_client/isolate.py. Path variables are determined 9 consumed by tools/swarming_client/isolate.py. Path variables are determined
10 based on the current working directory. The relative_cwd in the .isolated file 10 based on the current working directory. The relative_cwd in the .isolated file
11 is determined based on the .isolate file that declare the 'command' variable to 11 is determined based on the .isolate file that declare the 'command' variable to
12 be used so the wrapping .isolate doesn't affect this value. 12 be used so the wrapping .isolate doesn't affect this value.
13 13
14 This script loads build.ninja and processes it to determine all the executables 14 This script loads build.ninja and processes it to determine all the executables
15 referenced by the isolated target. It adds them in the wrapping .isolate file. 15 referenced by the isolated target. It adds them in the wrapping .isolate file.
16 16
17 WARNING: The target to use for build.ninja analysis is the base name of the 17 WARNING: The target to use for build.ninja analysis is the base name of the
18 .isolate file plus '_run'. For example, 'foo_test.isolate' would have the target 18 .isolate file plus '_run'. For example, 'foo_test.isolate' would have the target
19 'foo_test_run' analysed. 19 'foo_test_run' analysed.
20 """ 20 """
21 21
22 import glob 22 import glob
23 import json 23 import json
24 import logging 24 import logging
25 import os 25 import os
26 import posixpath 26 import posixpath
27 import re
27 import StringIO 28 import StringIO
28 import subprocess 29 import subprocess
29 import sys 30 import sys
30 import time 31 import time
31 32
32 TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) 33 TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
33 SWARMING_CLIENT_DIR = os.path.join(TOOLS_DIR, 'swarming_client') 34 SWARMING_CLIENT_DIR = os.path.join(TOOLS_DIR, 'swarming_client')
34 SRC_DIR = os.path.dirname(TOOLS_DIR) 35 SRC_DIR = os.path.dirname(TOOLS_DIR)
35 36
36 sys.path.insert(0, SWARMING_CLIENT_DIR) 37 sys.path.insert(0, SWARMING_CLIENT_DIR)
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return item not in ('', '|', '||') 135 return item not in ('', '|', '||')
135 136
136 137
137 def raw_build_to_deps(item): 138 def raw_build_to_deps(item):
138 """Converts a raw ninja build statement into the list of interesting 139 """Converts a raw ninja build statement into the list of interesting
139 dependencies. 140 dependencies.
140 """ 141 """
141 # TODO(maruel): Use a whitelist instead? .stamp, .so.TOC, .dylib.TOC, 142 # TODO(maruel): Use a whitelist instead? .stamp, .so.TOC, .dylib.TOC,
142 # .dll.lib, .exe and empty. 143 # .dll.lib, .exe and empty.
143 # The first item is the build rule, e.g. 'link', 'cxx', 'phony', etc. 144 # The first item is the build rule, e.g. 'link', 'cxx', 'phony', etc.
144 return filter(using_blacklist, item.split(' ')[1:]) 145 # In ninja build files, spaces in targets are escaped with a $-prefix.
146 # Use a negative lookbehind to not split on '$ '.
147 return filter(using_blacklist, re.split('(?<!\$) ', item)[1:])
145 148
146 149
147 def collect_deps(target, build_steps, dependencies_added, rules_seen): 150 def collect_deps(target, build_steps, dependencies_added, rules_seen):
148 """Recursively adds all the interesting dependencies for |target| 151 """Recursively adds all the interesting dependencies for |target|
149 into |dependencies_added|. 152 into |dependencies_added|.
150 """ 153 """
151 if rules_seen is None: 154 if rules_seen is None:
152 rules_seen = set() 155 rules_seen = set()
153 if target in rules_seen: 156 if target in rules_seen:
154 # TODO(maruel): Figure out how it happens. 157 # TODO(maruel): Figure out how it happens.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 306
304 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') 307 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client')
305 sys.stdout.flush() 308 sys.stdout.flush()
306 result = subprocess.call( 309 result = subprocess.call(
307 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) 310 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args)
308 return result 311 return result
309 312
310 313
311 if __name__ == '__main__': 314 if __name__ == '__main__':
312 sys.exit(main()) 315 sys.exit(main())
OLDNEW
« no previous file with comments | « chrome/sync_integration_tests.isolate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698