Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: third_party/instrumented_libraries/scripts/download_binaries.py

Issue 2775913002: Instrumented libraries: Remove dependence on GYP_DEFINES (Closed)
Patch Set: fix python syntax Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2015 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 pre-built sanitizer-instrumented third-party libraries from GCS.""" 6 """Downloads pre-built sanitizer-instrumented third-party libraries from GCS.
7 This script should only be run from gn.
Michael Achenbach 2017/03/28 07:55:05 Maybe differentiate: It's not run from gn, it's ru
8 """
7 9
8 import os
9 import re
10 import subprocess 10 import subprocess
11 import sys 11 import sys
12 12
13 13
14 SCRIPT_PATH = os.path.abspath(__file__) 14 def main(args):
15 BASE_PATH = os.path.normpath(os.path.join(SCRIPT_PATH, *(4 * ['..']))) 15 if not sys.platform.startswith('linux'):
16 raise Exception("Prebuilt instrumented libraries require Linux.")
16 17
17 # This defaults to the consuming project's base directory, e.g. 'src' in 18 sha1file = args[0]
18 # chromium. 19 tarfile = args[1]
19 BASE_DIR = os.path.basename(BASE_PATH)
20
21
22 def get_ubuntu_release():
23 supported_releases = ['trusty']
24 release = subprocess.check_output(['lsb_release', '-cs']).strip()
25 if release not in supported_releases:
26 raise Exception("Supported Ubuntu versions: %s", str(supported_releases))
27 return release
28
29
30 def get_configuration(gyp_defines):
31 if re.search(r'\b(msan)=1', gyp_defines):
32 if 'msan_track_origins=0' in gyp_defines:
33 return 'msan-no-origins'
34 if 'msan_track_origins=2' in gyp_defines:
35 return 'msan-chained-origins'
36 if 'msan_track_origins=' not in gyp_defines:
37 # NB: must be the same as the default value in common.gypi
38 return 'msan-chained-origins'
39 raise Exception(
40 "Prebuilt instrumented libraries not available for your configuration.")
41
42
43 def get_archive_name(gyp_defines):
44 return "%s-%s.tgz" % (get_configuration(gyp_defines), get_ubuntu_release())
45
46
47 def main(args):
48 gyp_defines = os.environ.get('GYP_DEFINES', '')
49 if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines:
50 return 0
51
52 if not sys.platform.startswith('linux'):
53 raise Exception("'use_prebuilt_instrumented_libraries=1' requires Linux.")
54
55 archive_name = get_archive_name(gyp_defines)
56 sha1file = '%s.sha1' % archive_name
57 target_directory = os.path.join(
58 BASE_DIR, 'third_party', 'instrumented_libraries', 'binaries')
59 20
60 subprocess.check_call([ 21 subprocess.check_call([
61 'download_from_google_storage', 22 'download_from_google_storage',
62 '--no_resume', 23 '--no_resume',
63 '--no_auth', 24 '--no_auth',
64 '--bucket', 'chromium-instrumented-libraries', 25 '--bucket', 'chromium-instrumented-libraries',
65 '-s', sha1file], cwd=target_directory) 26 '-s', sha1file, '-o', tarfile])
66 27
67 return 0 28 return 0
68 29
69 30
70 if __name__ == '__main__': 31 if __name__ == '__main__':
32 # TODO(thomasanderson): Remove this once all third_party DEPS
33 # entires for this script are removed.
34 if (len(sys.argv) == 1):
35 sys.exit(0)
71 sys.exit(main(sys.argv[1:])) 36 sys.exit(main(sys.argv[1:]))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698