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 re |
| 10 import subprocess |
| 11 import sys |
| 12 |
| 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 |
| 19 |
| 20 |
| 21 def get_configuration(gyp_defines): |
| 22 if re.search(r'\b(msan)=1', gyp_defines): |
| 23 if 'msan_track_origins=2' in gyp_defines: |
| 24 return 'msan-chained-origins' |
| 25 if 'msan_track_origins=' not in gyp_defines: |
| 26 # NB: must be the same as the default value in common.gypi |
| 27 return 'msan-chained-origins' |
| 28 raise Exception( |
| 29 "Prebuilt instrumented libraries not available for your configuration.") |
| 30 |
| 31 |
| 32 def get_archive_name(gyp_defines): |
| 33 return "%s-%s.tgz" % (get_configuration(gyp_defines), get_ubuntu_release()) |
| 34 |
| 35 |
| 36 def main(args): |
| 37 gyp_defines = os.environ.get('GYP_DEFINES', '') |
| 38 if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines: |
| 39 return 0 |
| 40 |
| 41 if not sys.platform.startswith('linux'): |
| 42 raise Exception("'use_prebuilt_instrumented_libraries=1' requires Linux.") |
| 43 |
| 44 archive_name = get_archive_name(gyp_defines) |
| 45 sha1file = '%s.sha1' % archive_name |
| 46 target_directory = 'src/third_party/instrumented_libraries/binaries/' |
| 47 |
| 48 subprocess.check_call([ |
| 49 'download_from_google_storage', |
| 50 '--no_resume', |
| 51 '--no_auth', |
| 52 '--bucket', 'chromium-instrumented-libraries', |
| 53 '-s', sha1file], cwd=target_directory) |
| 54 |
| 55 return 0 |
| 56 |
| 57 |
| 58 if __name__ == '__main__': |
| 59 sys.exit(main(sys.argv[1:])) |
OLD | NEW |