OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 """Downloads and unpacks a toolchain for building on Windows. The contents are | 6 """Downloads and unpacks a toolchain for building on Windows. The contents are |
7 matched by sha1 which will be updated when the toolchain is updated. | 7 matched by sha1 which will be updated when the toolchain is updated. |
8 | 8 |
9 Having a toolchain script in depot_tools means that it's not versioned | 9 Having a toolchain script in depot_tools means that it's not versioned |
10 directly with the source code. That is, if the toolchain is upgraded, but | 10 directly with the source code. That is, if the toolchain is upgraded, but |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 temp_dir, local_zip = DownloadUsingGsutil(tree_sha1 + '.zip') | 206 temp_dir, local_zip = DownloadUsingGsutil(tree_sha1 + '.zip') |
207 sys.stdout.write('Extracting %s...\n' % local_zip) | 207 sys.stdout.write('Extracting %s...\n' % local_zip) |
208 sys.stdout.flush() | 208 sys.stdout.flush() |
209 with zipfile.ZipFile(local_zip, 'r', zipfile.ZIP_DEFLATED, True) as zf: | 209 with zipfile.ZipFile(local_zip, 'r', zipfile.ZIP_DEFLATED, True) as zf: |
210 zf.extractall(target_dir) | 210 zf.extractall(target_dir) |
211 if temp_dir: | 211 if temp_dir: |
212 RmDir(temp_dir) | 212 RmDir(temp_dir) |
213 | 213 |
214 | 214 |
215 def main(): | 215 def main(): |
216 if not sys.platform.startswith(('cygwin', 'win32')): | |
217 return 0 | |
218 | |
219 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) | 216 parser = optparse.OptionParser(description=sys.modules[__name__].__doc__) |
220 parser.add_option('--output-json', metavar='FILE', | 217 parser.add_option('--output-json', metavar='FILE', |
221 help='write information about toolchain to FILE') | 218 help='write information about toolchain to FILE') |
| 219 parser.add_option('--force', action='store_true', |
| 220 help='force script to run on non-Windows hosts') |
222 options, args = parser.parse_args() | 221 options, args = parser.parse_args() |
223 | 222 |
| 223 if not (sys.platform.startswith(('cygwin', 'win32')) or options.force): |
| 224 return 0 |
| 225 |
224 if sys.platform == 'cygwin': | 226 if sys.platform == 'cygwin': |
225 # This script requires Windows Python, so invoke with depot_tools' Python. | 227 # This script requires Windows Python, so invoke with depot_tools' Python. |
226 def winpath(path): | 228 def winpath(path): |
227 return subprocess.check_output(['cygpath', '-w', path]).strip() | 229 return subprocess.check_output(['cygpath', '-w', path]).strip() |
228 python = os.path.join(DEPOT_TOOLS_PATH, 'python.bat') | 230 python = os.path.join(DEPOT_TOOLS_PATH, 'python.bat') |
229 cmd = [python, winpath(__file__)] | 231 cmd = [python, winpath(__file__)] |
230 if options.output_json: | 232 if options.output_json: |
231 cmd.extend(['--output-json', winpath(options.output_json)]) | 233 cmd.extend(['--output-json', winpath(options.output_json)]) |
232 cmd.extend(args) | 234 cmd.extend(args) |
233 sys.exit(subprocess.call(cmd)) | 235 sys.exit(subprocess.call(cmd)) |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 324 |
323 if options.output_json: | 325 if options.output_json: |
324 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), | 326 shutil.copyfile(os.path.join(target_dir, '..', 'data.json'), |
325 options.output_json) | 327 options.output_json) |
326 | 328 |
327 return 0 | 329 return 0 |
328 | 330 |
329 | 331 |
330 if __name__ == '__main__': | 332 if __name__ == '__main__': |
331 sys.exit(main()) | 333 sys.exit(main()) |
OLD | NEW |