OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 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 |
| 21 |
| 22 def _DownloadFilesFromGoogleStorage(webrtc_deps_path): |
| 23 print 'Downloading files in %s...' % webrtc_deps_path |
| 24 |
| 25 extension = 'bat' if 'win32' in sys.platform else 'py' |
| 26 cmd = ['download_from_google_storage.%s' % extension, |
| 27 '--bucket=chromium-webrtc-resources', |
| 28 '--auto_platform', |
| 29 '--recursive', |
| 30 '--directory', webrtc_deps_path] |
| 31 subprocess.check_call(cmd) |
| 32 |
| 33 |
| 34 def _GetGoArchivePathForPlatform(): |
| 35 archive_extension = 'zip' if utils.GetPlatform() == 'win' else 'tar.gz' |
| 36 return os.path.join(utils.GetPlatform(), 'go.%s' % archive_extension) |
| 37 |
| 38 |
| 39 def main(argv): |
| 40 if len(argv) == 1: |
| 41 return 'Usage: %s <path to webrtc.DEPS>' % argv[0] |
| 42 if not os.path.exists('.gclient'): |
| 43 return 'Invoked from wrong dir; invoke from dir with .gclient' |
| 44 |
| 45 webrtc_deps_path = argv[1] |
| 46 golang_path = os.path.join(webrtc_deps_path, 'golang') |
| 47 archive_path = os.path.join(golang_path, _GetGoArchivePathForPlatform()) |
| 48 old_archive_sha1 = utils.ComputeSHA1(archive_path) |
| 49 |
| 50 _DownloadFilesFromGoogleStorage(golang_path) |
| 51 |
| 52 if old_archive_sha1 != utils.ComputeSHA1(archive_path): |
| 53 utils.DeleteDirNextToGclient('go') |
| 54 utils.UnpackToWorkingDir(archive_path) |
| 55 |
| 56 |
| 57 if __name__ == '__main__': |
| 58 sys.exit(main(sys.argv)) |
OLD | NEW |