OLD | NEW |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 the V8 project authors. All rights reserved. | 2 # Copyright 2015 the V8 project authors. All rights reserved. |
3 # Copyright 2015 The Chromium Authors. All rights reserved. | 3 # Copyright 2015 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Script to download LLVM gold plugin from google storage.""" | 7 """Script to download LLVM gold plugin from google storage.""" |
8 | 8 |
9 import json | 9 import json |
10 import os | 10 import os |
11 import re | |
12 import platform | |
11 import shutil | 13 import shutil |
12 import subprocess | 14 import subprocess |
13 import sys | 15 import sys |
14 import zipfile | 16 import zipfile |
15 | 17 |
18 # Bail out on windows and cygwin. | |
Michael Achenbach
2015/09/03 13:22:04
This bailout is new compared to the original CL.
| |
19 if "win" in platform.system().lower(): | |
20 # Python 2.7.6 hangs at the second path.insert command on windows. Works | |
21 # with python 2.7.8. | |
22 print "Gold plugin download not supported on windows." | |
23 sys.exit(0) | |
24 | |
16 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | 25 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
17 CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir)) | 26 CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir)) |
18 sys.path.insert(0, os.path.join(CHROME_SRC, 'tools')) | 27 sys.path.insert(0, os.path.join(CHROME_SRC, 'tools')) |
19 | 28 |
20 import find_depot_tools | 29 import find_depot_tools |
21 | 30 |
22 DEPOT_PATH = find_depot_tools.add_depot_tools_to_path() | 31 DEPOT_PATH = find_depot_tools.add_depot_tools_to_path() |
23 GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py') | 32 GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py') |
24 | 33 |
25 LLVM_BUILD_PATH = os.path.join(CHROME_SRC, 'third_party', 'llvm-build', | 34 LLVM_BUILD_PATH = os.path.join(CHROME_SRC, 'third_party', 'llvm-build', |
26 'Release+Asserts') | 35 'Release+Asserts') |
27 CLANG_UPDATE_PY = os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts', | 36 CLANG_UPDATE_PY = os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts', |
28 'update.py') | 37 'update.py') |
29 CLANG_REVISION = os.popen(CLANG_UPDATE_PY + ' --print-revision').read().rstrip() | 38 CLANG_REVISION = os.popen(CLANG_UPDATE_PY + ' --print-revision').read().rstrip() |
30 | 39 |
31 CLANG_BUCKET = 'gs://chromium-browser-clang/Linux_x64' | 40 CLANG_BUCKET = 'gs://chromium-browser-clang/Linux_x64' |
32 | 41 |
42 GOLD_PLUGIN_PATH = os.path.join(LLVM_BUILD_PATH, 'lib', 'LLVMgold.so') | |
43 | |
44 sys.path.insert(0, os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts')) | |
45 | |
46 import update | |
47 | |
33 def main(): | 48 def main(): |
49 if not re.search(r'cfi_vptr=1', os.environ.get('GYP_DEFINES', '')): | |
50 # Bailout if this is not a cfi build. | |
51 print 'Skipping gold plugin download for non-cfi build.' | |
52 return 0 | |
53 if (os.path.exists(GOLD_PLUGIN_PATH) and | |
54 update.ReadStampFile().strip() == update.PACKAGE_VERSION): | |
55 # Bailout if clang is up-to-date. This requires the script to be run before | |
56 # the clang update step! I.e. afterwards clang would always be up-to-date. | |
57 print 'Skipping gold plugin download. File present and clang up to date.' | |
58 return 0 | |
59 | |
34 targz_name = 'llvmgold-%s.tgz' % CLANG_REVISION | 60 targz_name = 'llvmgold-%s.tgz' % CLANG_REVISION |
35 remote_path = '%s/%s' % (CLANG_BUCKET, targz_name) | 61 remote_path = '%s/%s' % (CLANG_BUCKET, targz_name) |
36 | 62 |
37 os.chdir(LLVM_BUILD_PATH) | 63 os.chdir(LLVM_BUILD_PATH) |
38 | 64 |
39 # TODO(pcc): Fix gsutil.py cp url file < /dev/null 2>&0 | 65 # TODO(pcc): Fix gsutil.py cp url file < /dev/null 2>&0 |
40 # (currently aborts with exit code 1, | 66 # (currently aborts with exit code 1, |
41 # https://github.com/GoogleCloudPlatform/gsutil/issues/289) or change the | 67 # https://github.com/GoogleCloudPlatform/gsutil/issues/289) or change the |
42 # stdin->stderr redirect in update.py to do something else (crbug.com/494442). | 68 # stdin->stderr redirect in update.py to do something else (crbug.com/494442). |
43 subprocess.check_call(['python', GSUTIL_PATH, | 69 subprocess.check_call(['python', GSUTIL_PATH, |
44 'cp', remote_path, targz_name], | 70 'cp', remote_path, targz_name], |
45 stderr=open('/dev/null', 'w')) | 71 stderr=open('/dev/null', 'w')) |
46 subprocess.check_call(['tar', 'xzf', targz_name]) | 72 subprocess.check_call(['tar', 'xzf', targz_name]) |
47 os.remove(targz_name) | 73 os.remove(targz_name) |
48 return 0 | 74 return 0 |
49 | 75 |
50 if __name__ == '__main__': | 76 if __name__ == '__main__': |
51 sys.exit(main()) | 77 sys.exit(main()) |
OLD | NEW |