• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env vpython3
2
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.
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
18import sys
19
20SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
21SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
22sys.path.append(os.path.join(SRC_DIR, 'build'))
23
24import find_depot_tools
25find_depot_tools.add_depot_tools_to_path()
26import gclient_utils
27import subprocess2
28
29
30def main(directories):
31  if not directories:
32    directories = [SCRIPT_DIR]
33
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...')
48
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
58
59
60if __name__ == '__main__':
61  sys.exit(main(sys.argv[1:]))
62