| OLD | NEW |
| (Empty) |
| 1 #!/usr/bin/env python | |
| 2 # Copyright 2017 The Dart project authors. All rights reserved. | |
| 3 # Use of this source code is governed by a BSD-style license that can be | |
| 4 # found in the LICENSE file. | |
| 5 | |
| 6 """Pulls down tools required to build Dart.""" | |
| 7 | |
| 8 import os | |
| 9 import subprocess | |
| 10 import shutil | |
| 11 import sys | |
| 12 | |
| 13 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | |
| 14 DART_ROOT = os.path.abspath(os.path.join(THIS_DIR, '..', '..')) | |
| 15 BUILDTOOLS = os.path.join(DART_ROOT, 'buildtools') | |
| 16 TOOLS_BUILDTOOLS = os.path.join(DART_ROOT, 'tools', 'buildtools') | |
| 17 | |
| 18 sys.path.insert(0, os.path.join(DART_ROOT, 'tools')) | |
| 19 import find_depot_tools | |
| 20 | |
| 21 DEPOT_PATH = find_depot_tools.add_depot_tools_to_path() | |
| 22 | |
| 23 | |
| 24 def Update(): | |
| 25 path = os.path.join(BUILDTOOLS, 'update.sh') | |
| 26 return subprocess.call(['/bin/bash', path, '--toolchain', '--gn'], cwd=DART_RO
OT) | |
| 27 | |
| 28 | |
| 29 def UpdateGNOnWindows(): | |
| 30 sha1_file = os.path.join(BUILDTOOLS, 'win', 'gn.exe.sha1') | |
| 31 downloader_script = os.path.join(DEPOT_PATH, 'download_from_google_storage.py'
) | |
| 32 download_cmd = [ | |
| 33 'python', | |
| 34 downloader_script, | |
| 35 '--no_auth', | |
| 36 '--no_resume', | |
| 37 '--quiet', | |
| 38 '--platform=win*', | |
| 39 '--bucket', | |
| 40 'chromium-gn', | |
| 41 '-s', | |
| 42 sha1_file | |
| 43 ] | |
| 44 return subprocess.call(download_cmd) | |
| 45 | |
| 46 | |
| 47 def UpdateClangFormatOnWindows(): | |
| 48 sha1_file = os.path.join(TOOLS_BUILDTOOLS, 'win', 'clang-format.exe.sha1') | |
| 49 output_dir = os.path.join(BUILDTOOLS, 'win', 'clang-format.exe') | |
| 50 downloader_script = os.path.join(DEPOT_PATH, 'download_from_google_storage.py'
) | |
| 51 download_cmd = [ | |
| 52 'python', | |
| 53 downloader_script, | |
| 54 '--no_auth', | |
| 55 '--no_resume', | |
| 56 '--quiet', | |
| 57 '--platform=win', | |
| 58 '--bucket', | |
| 59 'chromium-clang-format', | |
| 60 '-s', | |
| 61 sha1_file, | |
| 62 '-o', | |
| 63 output_dir | |
| 64 ] | |
| 65 return subprocess.call(download_cmd) | |
| 66 | |
| 67 | |
| 68 def CopyClangFormatScripts(): | |
| 69 linux_script = os.path.join(TOOLS_BUILDTOOLS, 'linux64', 'clang-format') | |
| 70 mac_script = os.path.join(TOOLS_BUILDTOOLS, 'mac', 'clang-format') | |
| 71 linux_dest = os.path.join(BUILDTOOLS, 'linux64', 'clang-format') | |
| 72 mac_dest = os.path.join(BUILDTOOLS, 'mac', 'clang-format') | |
| 73 shutil.copy2(linux_script, linux_dest) | |
| 74 shutil.copy2(mac_script, mac_dest) | |
| 75 | |
| 76 | |
| 77 def main(argv): | |
| 78 if sys.platform.startswith('win'): | |
| 79 result = UpdateGNOnWindows() | |
| 80 if result != 0: | |
| 81 return result | |
| 82 return UpdateClangFormatOnWindows() | |
| 83 CopyClangFormatScripts() | |
| 84 return Update() | |
| 85 | |
| 86 | |
| 87 if __name__ == '__main__': | |
| 88 sys.exit(main(sys.argv)) | |
| OLD | NEW |