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 |
11 import shutil | 12 import shutil |
12 import subprocess | 13 import subprocess |
13 import sys | 14 import sys |
14 import zipfile | 15 import zipfile |
15 | 16 |
16 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) | 17 SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__)) |
17 CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir)) | 18 CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir)) |
18 sys.path.insert(0, os.path.join(CHROME_SRC, 'tools')) | 19 sys.path.insert(0, os.path.join(CHROME_SRC, 'tools')) |
19 | 20 |
20 import find_depot_tools | 21 import find_depot_tools |
21 | 22 |
22 DEPOT_PATH = find_depot_tools.add_depot_tools_to_path() | 23 DEPOT_PATH = find_depot_tools.add_depot_tools_to_path() |
23 GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py') | 24 GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py') |
24 | 25 |
25 LLVM_BUILD_PATH = os.path.join(CHROME_SRC, 'third_party', 'llvm-build', | 26 LLVM_BUILD_PATH = os.path.join(CHROME_SRC, 'third_party', 'llvm-build', |
26 'Release+Asserts') | 27 'Release+Asserts') |
27 CLANG_UPDATE_PY = os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts', | 28 CLANG_UPDATE_PY = os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts', |
28 'update.py') | 29 'update.py') |
29 CLANG_REVISION = os.popen(CLANG_UPDATE_PY + ' --print-revision').read().rstrip() | 30 CLANG_REVISION = os.popen(CLANG_UPDATE_PY + ' --print-revision').read().rstrip() |
30 | 31 |
31 CLANG_BUCKET = 'gs://chromium-browser-clang/Linux_x64' | 32 CLANG_BUCKET = 'gs://chromium-browser-clang/Linux_x64' |
32 | 33 |
| 34 GOLD_PLUGIN_PATH = os.path.join(LLVM_BUILD_PATH, 'lib', 'LLVMgold.so') |
| 35 |
| 36 sys.path.insert(0, os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts')) |
| 37 |
| 38 import update |
| 39 |
33 def main(): | 40 def main(): |
| 41 if not re.search(r'cfi_vptr=1', os.environ.get('GYP_DEFINES', '')): |
| 42 # Bailout if this is not a cfi build. |
| 43 print 'Skipping gold plugin download for non-cfi build.' |
| 44 return 0 |
| 45 if (os.path.exists(GOLD_PLUGIN_PATH) and |
| 46 update.ReadStampFile().strip() == update.PACKAGE_VERSION): |
| 47 # Bailout if clang is up-to-date. This requires the script to be run before |
| 48 # the clang update step! I.e. afterwards clang would always be up-to-date. |
| 49 print 'Skipping gold plugin download. File present and clang up to date.' |
| 50 return 0 |
| 51 |
34 targz_name = 'llvmgold-%s.tgz' % CLANG_REVISION | 52 targz_name = 'llvmgold-%s.tgz' % CLANG_REVISION |
35 remote_path = '%s/%s' % (CLANG_BUCKET, targz_name) | 53 remote_path = '%s/%s' % (CLANG_BUCKET, targz_name) |
36 | 54 |
37 os.chdir(LLVM_BUILD_PATH) | 55 os.chdir(LLVM_BUILD_PATH) |
38 | 56 |
39 # TODO(pcc): Fix gsutil.py cp url file < /dev/null 2>&0 | 57 # TODO(pcc): Fix gsutil.py cp url file < /dev/null 2>&0 |
40 # (currently aborts with exit code 1, | 58 # (currently aborts with exit code 1, |
41 # https://github.com/GoogleCloudPlatform/gsutil/issues/289) or change the | 59 # https://github.com/GoogleCloudPlatform/gsutil/issues/289) or change the |
42 # stdin->stderr redirect in update.py to do something else (crbug.com/494442). | 60 # stdin->stderr redirect in update.py to do something else (crbug.com/494442). |
43 subprocess.check_call(['python', GSUTIL_PATH, | 61 subprocess.check_call(['python', GSUTIL_PATH, |
44 'cp', remote_path, targz_name], | 62 'cp', remote_path, targz_name], |
45 stderr=open('/dev/null', 'w')) | 63 stderr=open('/dev/null', 'w')) |
46 subprocess.check_call(['tar', 'xzf', targz_name]) | 64 subprocess.check_call(['tar', 'xzf', targz_name]) |
47 os.remove(targz_name) | 65 os.remove(targz_name) |
48 return 0 | 66 return 0 |
49 | 67 |
50 if __name__ == '__main__': | 68 if __name__ == '__main__': |
51 sys.exit(main()) | 69 sys.exit(main()) |
OLD | NEW |