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."""
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
))
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'
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())
39 gyp_defines
= os
.environ
.get('GYP_DEFINES', '')
40 if not 'use_prebuilt_instrumented_libraries=1' in gyp_defines
:
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',
54 '--bucket', 'chromium-instrumented-libraries',
55 '-s', sha1file
], cwd
=target_directory
)
60 if __name__
== '__main__':
61 sys
.exit(main(sys
.argv
[1:]))