blob: a77955a3f69e9a1908c7a7fa154fe115166bad84 [file] [log] [blame]
oprypin1d7392a2017-05-16 05:36:15 -07001#!/usr/bin/env python
2# Copyright (c) 2017 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.
oprypin1d7392a2017-05-16 05:36:15 -07009"""Downloads prebuilt AppRTC and Go from WebRTC storage and unpacks it.
10
11Requires that depot_tools is installed and in the PATH.
12
13It downloads compressed files in the directory where the script lives.
14This is because the precondition is that the script lives in the same
15directory of the .sha1 files.
16"""
17
18import os
19import sys
20
21import utils
22
oprypin1d7392a2017-05-16 05:36:15 -070023SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
24
25
26def _GetGoArchivePathForPlatform():
Mirko Bonadei8cc66952020-10-30 10:13:45 +010027 archive_extension = 'zip' if utils.GetPlatform() == 'win' else 'tar.gz'
28 return os.path.join(utils.GetPlatform(), 'go.%s' % archive_extension)
oprypin1d7392a2017-05-16 05:36:15 -070029
30
31def main(argv):
Mirko Bonadei8cc66952020-10-30 10:13:45 +010032 if len(argv) > 2:
33 return 'Usage: %s [output_dir]' % argv[0]
oprypin1d7392a2017-05-16 05:36:15 -070034
Mirko Bonadei8cc66952020-10-30 10:13:45 +010035 output_dir = os.path.abspath(argv[1]) if len(argv) > 1 else None
oprypin1d7392a2017-05-16 05:36:15 -070036
Mirko Bonadei8cc66952020-10-30 10:13:45 +010037 apprtc_zip_path = os.path.join(SCRIPT_DIR, 'prebuilt_apprtc.zip')
38 if os.path.isfile(apprtc_zip_path + '.sha1'):
39 utils.DownloadFilesFromGoogleStorage(SCRIPT_DIR, auto_platform=False)
oprypin1d7392a2017-05-16 05:36:15 -070040
Mirko Bonadei8cc66952020-10-30 10:13:45 +010041 if output_dir is not None:
42 utils.RemoveDirectory(os.path.join(output_dir, 'apprtc'))
43 utils.UnpackArchiveTo(apprtc_zip_path, output_dir)
oprypin1d7392a2017-05-16 05:36:15 -070044
Mirko Bonadei8cc66952020-10-30 10:13:45 +010045 golang_path = os.path.join(SCRIPT_DIR, 'golang')
46 golang_zip_path = os.path.join(golang_path, _GetGoArchivePathForPlatform())
47 if os.path.isfile(golang_zip_path + '.sha1'):
48 utils.DownloadFilesFromGoogleStorage(golang_path)
oprypin1d7392a2017-05-16 05:36:15 -070049
Mirko Bonadei8cc66952020-10-30 10:13:45 +010050 if output_dir is not None:
51 utils.RemoveDirectory(os.path.join(output_dir, 'go'))
52 utils.UnpackArchiveTo(golang_zip_path, output_dir)
oprypin1d7392a2017-05-16 05:36:15 -070053
54
55if __name__ == '__main__':
Mirko Bonadei8cc66952020-10-30 10:13:45 +010056 sys.exit(main(sys.argv))