oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | # |
| 4 | # Use of this source code is governed by a BSD-style license |
| 5 | # that can be found in the LICENSE file in the root of the source |
| 6 | # tree. An additional intellectual property rights grant can be found |
| 7 | # in the file PATENTS. All contributing project authors may |
| 8 | # be found in the AUTHORS file in the root of the source tree. |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 9 | """Downloads precompiled tools. |
| 10 | |
| 11 | These are checked into the repository as SHA-1 hashes (see *.sha1 files in |
| 12 | subdirectories). Note that chrome-webrtc-resources is a Google-internal bucket, |
| 13 | so please download and compile these tools manually if this script fails. |
| 14 | """ |
| 15 | |
| 16 | import os |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 17 | import sys |
| 18 | |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 19 | SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 20 | SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir)) |
Henrik Kjellander | ec57e05 | 2017-10-17 21:36:01 +0200 | [diff] [blame] | 21 | sys.path.append(os.path.join(SRC_DIR, 'build')) |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 22 | |
Henrik Kjellander | ec57e05 | 2017-10-17 21:36:01 +0200 | [diff] [blame] | 23 | import find_depot_tools |
| 24 | find_depot_tools.add_depot_tools_to_path() |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 25 | import gclient_utils |
| 26 | import subprocess2 |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 27 | |
| 28 | |
| 29 | def main(directories): |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame^] | 30 | if not directories: |
| 31 | directories = [SCRIPT_DIR] |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 32 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame^] | 33 | for path in directories: |
| 34 | cmd = [ |
| 35 | sys.executable, |
| 36 | os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, |
| 37 | 'download_from_google_storage.py'), |
| 38 | '--directory', |
| 39 | '--num_threads=10', |
| 40 | '--bucket', |
| 41 | 'chrome-webrtc-resources', |
| 42 | '--auto_platform', |
| 43 | '--recursive', |
| 44 | path, |
| 45 | ] |
| 46 | print 'Downloading precompiled tools...' |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 47 | |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame^] | 48 | # Perform download similar to how gclient hooks execute. |
| 49 | try: |
| 50 | gclient_utils.CheckCallAndFilter(cmd, |
| 51 | cwd=SRC_DIR, |
| 52 | always_show_header=True) |
| 53 | except (gclient_utils.Error, subprocess2.CalledProcessError) as e: |
| 54 | print 'Error: %s' % str(e) |
| 55 | return 2 |
| 56 | return 0 |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 57 | |
| 58 | |
| 59 | if __name__ == '__main__': |
Mirko Bonadei | 8cc6695 | 2020-10-30 10:13:45 +0100 | [diff] [blame^] | 60 | sys.exit(main(sys.argv[1:])) |