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

Side by Side Diff: tools/isolate_driver.py

Issue 970203003: Add support for escaped target names in isolate driver. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use list-comprehension Created 5 years, 9 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 | « no previous file | 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
(...skipping 10 matching lines...) Expand all
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 StringIO 27 import StringIO
28 import subprocess 28 import subprocess
29 import sys 29 import sys
30 import time 30 import time
31 import uuid
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)
37 38
38 import isolate_format 39 import isolate_format
39 40
40 41
(...skipping 93 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
146 # In ninja build files, spaces in targets are escaped with a $-prefix.
147 # Create a random UUID to use as a replacement for '$ ' and use it while
148 # splitting the item variable on ' '. When the split has been done, iterate
149 # over all items, and replace the random variable back to the original.
150 rand = str(uuid.uuid4())
Avi (use Gerrit) 2015/03/03 20:20:30 Rather than uuids, can you pick something simple t
nyquist 2015/03/04 02:06:22 Done.
151 items_no_space = item.replace('$ ', rand).split(' ')[1:]
152 items = [it.replace(rand, '$ ') for it in items_no_space]
153
154 return filter(using_blacklist, items)
145 155
146 156
147 def collect_deps(target, build_steps, dependencies_added, rules_seen): 157 def collect_deps(target, build_steps, dependencies_added, rules_seen):
148 """Recursively adds all the interesting dependencies for |target| 158 """Recursively adds all the interesting dependencies for |target|
149 into |dependencies_added|. 159 into |dependencies_added|.
150 """ 160 """
151 if rules_seen is None: 161 if rules_seen is None:
152 rules_seen = set() 162 rules_seen = set()
153 if target in rules_seen: 163 if target in rules_seen:
154 # TODO(maruel): Figure out how it happens. 164 # TODO(maruel): Figure out how it happens.
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 313
304 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') 314 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client')
305 sys.stdout.flush() 315 sys.stdout.flush()
306 result = subprocess.call( 316 result = subprocess.call(
307 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) 317 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args)
308 return result 318 return result
309 319
310 320
311 if __name__ == '__main__': 321 if __name__ == '__main__':
312 sys.exit(main()) 322 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698