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

Side by Side Diff: tools/isolate_driver.py

Issue 1320793004: Fix sbox_validation_tests & Make isolate_driver.py include the executable itself (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Fix for official build Created 5 years, 3 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 | « tools/gn/gn_unittests.isolate ('k') | ui/accessibility/accessibility_unittests.isolate » ('j') | 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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 Ignores many rules that are assumed to not depend on a dynamic library. If 112 Ignores many rules that are assumed to not depend on a dynamic library. If
113 the assumption doesn't hold true anymore for a file format, remove it from 113 the assumption doesn't hold true anymore for a file format, remove it from
114 this list. This is simply an optimization. 114 this list. This is simply an optimization.
115 """ 115 """
116 # *.json is ignored below, *.isolated.gen.json is an exception, it is produced 116 # *.json is ignored below, *.isolated.gen.json is an exception, it is produced
117 # by isolate_driver.py in 'test_isolation_mode==prepare'. 117 # by isolate_driver.py in 'test_isolation_mode==prepare'.
118 if item.endswith('.isolated.gen.json'): 118 if item.endswith('.isolated.gen.json'):
119 return True 119 return True
120 IGNORED = ( 120 IGNORED = (
121 '.a', '.cc', '.css', '.def', '.frag', '.h', '.html', '.js', '.json', 121 '.a', '.cc', '.css', '.dat', '.def', '.frag', '.h', '.html', '.isolate',
122 '.manifest', '.o', '.obj', '.pak', '.png', '.pdb', '.strings', '.test', 122 '.js', '.json', '.manifest', '.o', '.obj', '.pak', '.png', '.pdb', '.py',
123 '.txt', '.vert', 123 '.strings', '.test', '.txt', '.vert',
124 ) 124 )
125 # ninja files use native path format. 125 # ninja files use native path format.
126 ext = os.path.splitext(item)[1] 126 ext = os.path.splitext(item)[1]
127 if ext in IGNORED: 127 if ext in IGNORED:
128 return False 128 return False
129 # Special case Windows, keep .dll.lib but discard .lib. 129 # Special case Windows, keep .dll.lib but discard .lib.
130 if item.endswith('.dll.lib'): 130 if item.endswith('.dll.lib'):
131 return True 131 return True
132 if ext == '.lib': 132 if ext == '.lib':
133 return False 133 return False
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 # Remove only the suffix .TOC, not the .so! 173 # Remove only the suffix .TOC, not the .so!
174 return i[:-4] 174 return i[:-4]
175 if i.endswith('.dylib.TOC'): 175 if i.endswith('.dylib.TOC'):
176 # Remove only the suffix .TOC, not the .dylib! 176 # Remove only the suffix .TOC, not the .dylib!
177 return i[:-4] 177 return i[:-4]
178 if i.endswith('.dll.lib'): 178 if i.endswith('.dll.lib'):
179 # Remove only the suffix .lib, not the .dll! 179 # Remove only the suffix .lib, not the .dll!
180 return i[:-4] 180 return i[:-4]
181 return i 181 return i
182 182
183 def f(i): 183 def is_exe(i):
184 # This script is only for adding new binaries that are created as part of 184 # This script is only for adding new binaries that are created as part of
185 # the component build. 185 # the component build.
186 ext = os.path.splitext(i)[1] 186 ext = os.path.splitext(i)[1]
187 if ext not in ['.dll', '.nexe', '.so', '.dylib']: 187 # On POSIX, executables have no extension.
188 if ext not in ('', '.dll', '.dylib', '.exe', '.nexe', '.so'):
189 return False
190 if os.path.isabs(i):
191 # In some rare case, there's dependency set explicitly on files outside
192 # the checkout.
188 return False 193 return False
189 194
190 # Check for execute access and strip directories. This gets rid of all the 195 # Check for execute access and strip directories. This gets rid of all the
191 # phony rules. 196 # phony rules.
192 p = os.path.join(build_dir, i) 197 p = os.path.join(build_dir, i)
193 return os.access(p, os.X_OK) and not os.path.isdir(p) 198 return os.access(p, os.X_OK) and not os.path.isdir(p)
194 199
195 return filter(f, map(filter_item, dependencies)) 200 return filter(is_exe, map(filter_item, dependencies))
196 201
197 202
198 def create_wrapper(args, isolate_index, isolated_index): 203 def create_wrapper(args, isolate_index, isolated_index):
199 """Creates a wrapper .isolate that add dynamic libs. 204 """Creates a wrapper .isolate that add dynamic libs.
200 205
201 The original .isolate is not modified. 206 The original .isolate is not modified.
202 """ 207 """
203 cwd = os.getcwd() 208 cwd = os.getcwd()
204 isolate = args[isolate_index] 209 isolate = args[isolate_index]
205 # The code assumes the .isolate file is always specified path-less in cwd. Fix 210 # The code assumes the .isolate file is always specified path-less in cwd. Fix
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 304
300 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') 305 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client')
301 sys.stdout.flush() 306 sys.stdout.flush()
302 result = subprocess.call( 307 result = subprocess.call(
303 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) 308 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args)
304 return result 309 return result
305 310
306 311
307 if __name__ == '__main__': 312 if __name__ == '__main__':
308 sys.exit(main()) 313 sys.exit(main())
OLDNEW
« no previous file with comments | « tools/gn/gn_unittests.isolate ('k') | ui/accessibility/accessibility_unittests.isolate » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698