blob: 5cc8de25b3137e50b529a3f0afd0b9986f9021ac [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))
23DEPOT_TOOLS_DIR = os.path.join(SRC_DIR, 'third_party', 'depot_tools')
24sys.path.insert(0, DEPOT_TOOLS_DIR)
25
26
27import gclient_utils
28import subprocess2
oprypin3b2fb202017-03-06 02:23:34 -080029
30
31def main(directories):
32 if not directories:
33 directories = [SCRIPT_DIR]
34
35 for path in directories:
36 cmd = [
Henrik Kjellandera2543042017-10-15 19:51:55 +020037 sys.executable,
38 os.path.join(DEPOT_TOOLS_DIR, 'download_from_google_storage.py'),
oprypin3b2fb202017-03-06 02:23:34 -080039 '--directory',
40 '--num_threads=10',
41 '--bucket', 'chrome-webrtc-resources',
42 '--auto_platform',
43 '--recursive',
44 path,
45 ]
46 print 'Downloading precompiled tools...'
Henrik Kjellandera2543042017-10-15 19:51:55 +020047
48 # Perform download similar to how gclient hooks execute.
49 try:
50 gclient_utils.CheckCallAndFilterAndHeader(cmd, cwd=SRC_DIR, always=True)
51 except (gclient_utils.Error, subprocess2.CalledProcessError) as e:
52 print 'Error: %s' % str(e)
53 return 2
54 return 0
oprypin3b2fb202017-03-06 02:23:34 -080055
56
57if __name__ == '__main__':
58 sys.exit(main(sys.argv[1:]))