Fix missing GN dependencies.
[chromium-blink-merge.git] / third_party / instrumented_libraries / scripts / download_binaries.py
blob83ec7b6aa86ab9592c8661a88d03e046bef13f6a
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.
6 """Downloads pre-built sanitizer-instrumented third-party libraries from GCS."""
8 import os
9 import re
10 import subprocess
11 import sys
13 def get_ubuntu_release():
14 supported_releases = ['precise', 'trusty']
15 release = subprocess.check_output(['lsb_release', '-cs']).strip()
16 if release not in supported_releases:
17 raise Exception("Supported Ubuntu versions: %s", str(supported_releases))
18 return release
21 def get_configuration(gyp_defines):
22 if re.search(r'\b(msan)=1', gyp_defines):
23 if 'msan_track_origins=0' in gyp_defines:
24 return 'msan-no-origins'
25 if 'msan_track_origins=2' in gyp_defines:
26 return 'msan-chained-origins'
27 if 'msan_track_origins=' not in gyp_defines:
28 # NB: must be the same as the default value in common.gypi
29 return 'msan-chained-origins'
30 raise Exception(
31 "Prebuilt instrumented libraries not available for your configuration.")
34 def get_archive_name(gyp_defines):
35 return "%s-%s.tgz" % (get_configuration(gyp_defines), get_ubuntu_release())
38 def main(args):
39 gyp_defines = os.environ.get('GYP_DEFINES', '')
40 if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines:
41 return 0
43 if not sys.platform.startswith('linux'):
44 raise Exception("'use_prebuilt_instrumented_libraries=1' requires Linux.")
46 archive_name = get_archive_name(gyp_defines)
47 sha1file = '%s.sha1' % archive_name
48 target_directory = 'src/third_party/instrumented_libraries/binaries/'
50 subprocess.check_call([
51 'download_from_google_storage',
52 '--no_resume',
53 '--no_auth',
54 '--bucket', 'chromium-instrumented-libraries',
55 '-s', sha1file], cwd=target_directory)
57 return 0
60 if __name__ == '__main__':
61 sys.exit(main(sys.argv[1:]))