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. |
| 9 | |
| 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 02:23:34 -0800 | [diff] [blame] | 18 | import sys |
| 19 | |
| 20 | |
| 21 | SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__)) |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 22 | SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir)) |
Henrik Kjellander | ec57e05 | 2017-10-17 21:36:01 +0200 | [diff] [blame] | 23 | sys.path.append(os.path.join(SRC_DIR, 'build')) |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 24 | |
| 25 | |
Henrik Kjellander | ec57e05 | 2017-10-17 21:36:01 +0200 | [diff] [blame] | 26 | import find_depot_tools |
| 27 | find_depot_tools.add_depot_tools_to_path() |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 28 | import gclient_utils |
| 29 | import subprocess2 |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 30 | |
| 31 | |
| 32 | def main(directories): |
| 33 | if not directories: |
| 34 | directories = [SCRIPT_DIR] |
| 35 | |
| 36 | for path in directories: |
| 37 | cmd = [ |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 38 | sys.executable, |
Henrik Kjellander | ec57e05 | 2017-10-17 21:36:01 +0200 | [diff] [blame] | 39 | os.path.join(find_depot_tools.DEPOT_TOOLS_PATH, |
| 40 | 'download_from_google_storage.py'), |
oprypin | 3b2fb20 | 2017-03-06 02:23:34 -0800 | [diff] [blame] | 41 | '--directory', |
| 42 | '--num_threads=10', |
| 43 | '--bucket', 'chrome-webrtc-resources', |
| 44 | '--auto_platform', |
| 45 | '--recursive', |
| 46 | path, |
| 47 | ] |
| 48 | print 'Downloading precompiled tools...' |
Henrik Kjellander | a254304 | 2017-10-15 19:51:55 +0200 | [diff] [blame] | 49 | |
| 50 | # Perform download similar to how gclient hooks execute. |
| 51 | try: |
| 52 | gclient_utils.CheckCallAndFilterAndHeader(cmd, cwd=SRC_DIR, always=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__': |
| 60 | sys.exit(main(sys.argv[1:])) |