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