|
OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/python | |
2 # Copyright 2013 The Chromium Authors. All rights reserved. | |
kjellander_chromium
2014/12/08 13:58:08
year 2014
phoglund_chromium
2014/12/08 14:26:16
Done.
| |
3 # Use of this source code is governed by a BSD-style license that can be | |
4 # found in the LICENSE file. | |
5 | |
6 """Downloads the golang SDK from WebRTC storage and unpacks it. | |
7 | |
8 Requires that depot_tools is installed and in the PATH. This script expects | |
9 to run with Chrome's base dir as the working directory, e.g. where the .gclient | |
10 file is. This is what should happen if this script is invoked as a hook action. | |
11 """ | |
12 | |
13 import os | |
14 import subprocess | |
15 import sys | |
16 import tarfile | |
17 import zipfile | |
18 | |
19 import utils | |
20 | |
kjellander_chromium
2014/12/08 13:58:08
+ 1 blank line
phoglund_chromium
2014/12/08 14:26:16
Done.
| |
21 def _DownloadFilesFromGoogleStorage(webrtc_deps_path): | |
22 print 'Downloading files in %s...' % webrtc_deps_path | |
23 | |
24 extension = 'bat' if 'win32' in sys.platform else 'py' | |
25 cmd = ['download_from_google_storage.%s' % extension, | |
26 '--bucket=chromium-webrtc-resources', | |
27 '--auto_platform', | |
28 '--recursive', | |
29 '--directory', webrtc_deps_path] | |
30 subprocess.check_call(cmd) | |
31 | |
32 | |
33 def _GetGoArchivePathForPlatform(): | |
34 archive_extension = 'zip' if utils.GetPlatform() == 'win' else 'tar.gz' | |
35 return os.path.join(utils.GetPlatform(), 'go.%s' % archive_extension) | |
36 | |
37 | |
38 def main(argv): | |
39 if len(argv) == 1: | |
40 return 'Usage: %s <path to webrtc.DEPS>' % argv[0] | |
41 if not os.path.exists('.gclient'): | |
42 return 'Invoked from wrong dir; invoke from dir with .gclient' | |
43 | |
44 webrtc_deps_path = argv[1] | |
45 golang_path = os.path.join(webrtc_deps_path, 'golang') | |
46 archive_path = os.path.join(golang_path, _GetGoArchivePathForPlatform()) | |
47 old_archive_sha1 = utils.ComputeSHA1(archive_path) | |
48 | |
49 _DownloadFilesFromGoogleStorage(golang_path) | |
50 | |
51 if old_archive_sha1 != utils.ComputeSHA1(archive_path): | |
52 utils.DeleteDirNextToGclient('go') | |
53 utils.UnpackToWorkingDir(archive_path) | |
54 | |
55 | |
56 if __name__ == '__main__': | |
57 sys.exit(main(sys.argv)) | |
OLD | NEW |