blob: 62602dea59ebd32da061c3fa64a26ce23f520aae [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.
oprypin3b2fb202017-03-06 02:23:34 -08009"""Downloads precompiled tools.
10
11These are checked into the repository as SHA-1 hashes (see *.sha1 files in
12subdirectories). Note that chrome-webrtc-resources is a Google-internal bucket,
13so please download and compile these tools manually if this script fails.
14"""
15
16import os
oprypin3b2fb202017-03-06 02:23:34 -080017import sys
18
oprypin3b2fb202017-03-06 02:23:34 -080019SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
Henrik Kjellandera2543042017-10-15 19:51:55 +020020SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
Henrik Kjellanderec57e052017-10-17 21:36:01 +020021sys.path.append(os.path.join(SRC_DIR, 'build'))
Henrik Kjellandera2543042017-10-15 19:51:55 +020022
Henrik Kjellanderec57e052017-10-17 21:36:01 +020023import find_depot_tools
24find_depot_tools.add_depot_tools_to_path()
Henrik Kjellandera2543042017-10-15 19:51:55 +020025import gclient_utils
26import subprocess2
oprypin3b2fb202017-03-06 02:23:34 -080027
28
29def main(directories):
Mirko Bonadei8cc66952020-10-30 10:13:45 +010030 if not directories:
31 directories = [SCRIPT_DIR]
oprypin3b2fb202017-03-06 02:23:34 -080032
Mirko Bonadei8cc66952020-10-30 10:13:45 +010033 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 Kjellandera2543042017-10-15 19:51:55 +020047
Mirko Bonadei8cc66952020-10-30 10:13:45 +010048 # 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
oprypin3b2fb202017-03-06 02:23:34 -080057
58
59if __name__ == '__main__':
Mirko Bonadei8cc66952020-10-30 10:13:45 +010060 sys.exit(main(sys.argv[1:]))