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