OLD | NEW |
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 Loading... |
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', '.dat', '.def', '.frag', '.h', '.html', '.isolate', | 121 '.a', '.cc', '.css', '.def', '.frag', '.h', '.html', '.js', '.json', |
122 '.js', '.json', '.manifest', '.o', '.obj', '.pak', '.png', '.pdb', '.py', | 122 '.manifest', '.o', '.obj', '.pak', '.png', '.pdb', '.strings', '.test', |
123 '.strings', '.test', '.txt', '.vert', | 123 '.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 Loading... |
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 is_exe(i): | 183 def f(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 # On POSIX, executables have no extension. | 187 if ext not in ['.dll', '.nexe', '.so', '.dylib']: |
188 if ext not in ('', '.dll', '.dylib', '.exe', '.nexe', '.so'): | |
189 return False | 188 return False |
190 | 189 |
191 # Check for execute access and strip directories. This gets rid of all the | 190 # Check for execute access and strip directories. This gets rid of all the |
192 # phony rules. | 191 # phony rules. |
193 p = os.path.join(build_dir, i) | 192 p = os.path.join(build_dir, i) |
194 return os.access(p, os.X_OK) and not os.path.isdir(p) | 193 return os.access(p, os.X_OK) and not os.path.isdir(p) |
195 | 194 |
196 return filter(is_exe, map(filter_item, dependencies)) | 195 return filter(f, map(filter_item, dependencies)) |
197 | 196 |
198 | 197 |
199 def create_wrapper(args, isolate_index, isolated_index): | 198 def create_wrapper(args, isolate_index, isolated_index): |
200 """Creates a wrapper .isolate that add dynamic libs. | 199 """Creates a wrapper .isolate that add dynamic libs. |
201 | 200 |
202 The original .isolate is not modified. | 201 The original .isolate is not modified. |
203 """ | 202 """ |
204 cwd = os.getcwd() | 203 cwd = os.getcwd() |
205 isolate = args[isolate_index] | 204 isolate = args[isolate_index] |
206 # The code assumes the .isolate file is always specified path-less in cwd. Fix | 205 # 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 Loading... |
300 | 299 |
301 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') | 300 swarming_client = os.path.join(SRC_DIR, 'tools', 'swarming_client') |
302 sys.stdout.flush() | 301 sys.stdout.flush() |
303 result = subprocess.call( | 302 result = subprocess.call( |
304 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) | 303 [sys.executable, os.path.join(swarming_client, 'isolate.py')] + args) |
305 return result | 304 return result |
306 | 305 |
307 | 306 |
308 if __name__ == '__main__': | 307 if __name__ == '__main__': |
309 sys.exit(main()) | 308 sys.exit(main()) |
OLD | NEW |