blob: 9554c8cd7acab8a2641144b66149619962d36db4 [file] [log] [blame]
oprypin3b2fb202017-03-06 02:23:34 -08001#!/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
12These are checked into the repository as SHA-1 hashes (see *.sha1 files in
13subdirectories). Note that chrome-webrtc-resources is a Google-internal bucket,
14so please download and compile these tools manually if this script fails.
15"""
16
17import os
oprypin3b2fb202017-03-06 02:23:34 -080018import sys
19
20
21SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
Henrik Kjellandera2543042017-10-15 19:51:55 +020022SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
Henrik Kjellanderec57e052017-10-17 21:36:01 +020023sys.path.append(os.path.join(SRC_DIR, 'build'))
Henrik Kjellandera2543042017-10-15 19:51:55 +020024
25
Henrik Kjellanderec57e052017-10-17 21:36:01 +020026import find_depot_tools
27find_depot_tools.add_depot_tools_to_path()
Henrik Kjellandera2543042017-10-15 19:51:55 +020028import gclient_utils
29import subprocess2
oprypin3b2fb202017-03-06 02:23:34 -080030
31
32def main(directories):
33 if not directories:
34 directories = [SCRIPT_DIR]
35
36 for path in directories:
37 cmd = [
Henrik Kjellandera2543042017-10-15 19:51:55 +020038 sys.executable,
Henrik Kjellanderec57e052017-10-17 21:36:01 +020039 os.path.join(find_depot_tools.DEPOT_TOOLS_PATH,
40 'download_from_google_storage.py'),
oprypin3b2fb202017-03-06 02:23:34 -080041 '--directory',
42 '--num_threads=10',
43 '--bucket', 'chrome-webrtc-resources',
44 '--auto_platform',
45 '--recursive',
46 path,
47 ]
48 print 'Downloading precompiled tools...'
Henrik Kjellandera2543042017-10-15 19:51:55 +020049
50 # Perform download similar to how gclient hooks execute.
51 try:
Sergey Silkin916fda52019-08-02 09:24:48 +020052 gclient_utils.CheckCallAndFilter(
53 cmd, cwd=SRC_DIR, always_show_header=True)
Henrik Kjellandera2543042017-10-15 19:51:55 +020054 except (gclient_utils.Error, subprocess2.CalledProcessError) as e:
55 print 'Error: %s' % str(e)
56 return 2
57 return 0
oprypin3b2fb202017-03-06 02:23:34 -080058
59
60if __name__ == '__main__':
61 sys.exit(main(sys.argv[1:]))