| OLD | NEW |
| 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 | 7 |
| 8 import os | 8 import os |
| 9 import re | 9 import re |
| 10 import subprocess | 10 import subprocess |
| 11 import sys | 11 import sys |
| 12 | 12 |
| 13 |
| 14 SCRIPT_PATH = os.path.abspath(__file__) |
| 15 BASE_PATH = os.path.normpath(os.path.join(SCRIPT_PATH, *(4 * ['..']))) |
| 16 |
| 17 # This defaults to the consuming project's base directory, e.g. 'src' in |
| 18 # chromium. |
| 19 BASE_DIR = os.path.basename(BASE_PATH) |
| 20 |
| 21 |
| 13 def get_ubuntu_release(): | 22 def get_ubuntu_release(): |
| 14 supported_releases = ['precise', 'trusty'] | 23 supported_releases = ['precise', 'trusty'] |
| 15 release = subprocess.check_output(['lsb_release', '-cs']).strip() | 24 release = subprocess.check_output(['lsb_release', '-cs']).strip() |
| 16 if release not in supported_releases: | 25 if release not in supported_releases: |
| 17 raise Exception("Supported Ubuntu versions: %s", str(supported_releases)) | 26 raise Exception("Supported Ubuntu versions: %s", str(supported_releases)) |
| 18 return release | 27 return release |
| 19 | 28 |
| 20 | 29 |
| 21 def get_configuration(gyp_defines): | 30 def get_configuration(gyp_defines): |
| 22 if re.search(r'\b(msan)=1', gyp_defines): | 31 if re.search(r'\b(msan)=1', gyp_defines): |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 def main(args): | 47 def main(args): |
| 39 gyp_defines = os.environ.get('GYP_DEFINES', '') | 48 gyp_defines = os.environ.get('GYP_DEFINES', '') |
| 40 if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines: | 49 if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines: |
| 41 return 0 | 50 return 0 |
| 42 | 51 |
| 43 if not sys.platform.startswith('linux'): | 52 if not sys.platform.startswith('linux'): |
| 44 raise Exception("'use_prebuilt_instrumented_libraries=1' requires Linux.") | 53 raise Exception("'use_prebuilt_instrumented_libraries=1' requires Linux.") |
| 45 | 54 |
| 46 archive_name = get_archive_name(gyp_defines) | 55 archive_name = get_archive_name(gyp_defines) |
| 47 sha1file = '%s.sha1' % archive_name | 56 sha1file = '%s.sha1' % archive_name |
| 48 target_directory = 'src/third_party/instrumented_libraries/binaries/' | 57 target_directory = os.path.join( |
| 58 BASE_DIR, 'third_party', 'instrumented_libraries', 'binaries') |
| 49 | 59 |
| 50 subprocess.check_call([ | 60 subprocess.check_call([ |
| 51 'download_from_google_storage', | 61 'download_from_google_storage', |
| 52 '--no_resume', | 62 '--no_resume', |
| 53 '--no_auth', | 63 '--no_auth', |
| 54 '--bucket', 'chromium-instrumented-libraries', | 64 '--bucket', 'chromium-instrumented-libraries', |
| 55 '-s', sha1file], cwd=target_directory) | 65 '-s', sha1file], cwd=target_directory) |
| 56 | 66 |
| 57 return 0 | 67 return 0 |
| 58 | 68 |
| 59 | 69 |
| 60 if __name__ == '__main__': | 70 if __name__ == '__main__': |
| 61 sys.exit(main(sys.argv[1:])) | 71 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |