OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
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 | |
4 # found in the LICENSE file. | |
5 | |
6 """Downloads pre-built sanitizer-instrumented third-party libraries from GCS.""" | |
7 | |
8 import os | |
9 import subprocess | |
10 import sys | |
11 | |
12 def get_ubuntu_release(): | |
13 supported_releases = ['precise', 'trusty'] | |
14 release = subprocess.check_output(['lsb_release', '-cs']).strip() | |
15 if release not in supported_releases: | |
16 raise Exception("Supported Ubuntu versions: %s", str(supported_releases)) | |
17 return release | |
18 | |
19 | |
20 def get_configuration(gyp_defines): | |
21 if 'msan=1' in gyp_defines: | |
Alexander Potapenko
2015/03/23 17:18:44
This may break if there's another GYP flag ending
earthdok
2015/03/23 17:31:47
fixed
| |
22 if 'msan_track_origins=2' in gyp_defines: | |
23 return 'msan-chained-origins' | |
24 if 'msan_track_origins' not in gyp_defines: | |
25 # NB: must be the same as the default value in common.gypi | |
26 return 'msan-chained-origins' | |
27 raise Exception( | |
28 "Prebuilt instrumented libraries not available for your configuration.") | |
29 | |
30 | |
31 def get_archive_name(gyp_defines): | |
32 return "%s-%s.tgz" % (get_configuration(gyp_defines), get_ubuntu_release()) | |
33 | |
34 | |
35 def main(args): | |
36 gyp_defines = os.environ.get('GYP_DEFINES', '') | |
37 if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines: | |
38 return 0 | |
39 | |
40 if not sys.platform.startswith('linux'): | |
41 raise Exception("'use_prebuilt_instrumented_libraries=1' requires Linux.") | |
42 | |
43 archive_name = get_archive_name(gyp_defines) | |
44 sha1file = '%s.sha1' % archive_name | |
45 target_directory = 'src/third_party/instrumented_libraries/binaries/' | |
46 | |
47 subprocess.check_call([ | |
48 'download_from_google_storage', | |
49 '--no_resume', | |
50 '--no_auth', | |
51 '--bucket', 'chromium-instrumented-libraries', | |
52 '-s', sha1file], cwd=target_directory) | |
53 | |
54 return 0 | |
55 | |
56 | |
57 if __name__ == '__main__': | |
58 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |