| OLD | NEW |
| 1 #!/usr/bin/python | 1 #!/usr/bin/python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """ | 6 """ |
| 7 Downloads trimmed-down Android Tools from Google Cloud Storage and extracts | 7 Downloads trimmed-down Android Tools from Google Cloud Storage and extracts |
| 8 them to INSTALL_DIR, updating INSTALL_DIR/VERSION_* stamp files with current | 8 them to INSTALL_DIR, updating INSTALL_DIR/VERSION_* stamp files with current |
| 9 version. Does nothing if INSTALL_DIR/VERSION_* are already up to date. | 9 version. Does nothing if INSTALL_DIR/VERSION_* are already up to date. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import multiprocessing |
| 12 import os | 13 import os |
| 13 import shutil | 14 import shutil |
| 14 import subprocess | 15 import subprocess |
| 15 import sys | 16 import sys |
| 16 import tarfile | 17 import tarfile |
| 17 | 18 |
| 18 # Path constants. (All of these should be absolute paths.) | 19 # Path constants. (All of these should be absolute paths.) |
| 19 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) | 20 THIS_DIR = os.path.abspath(os.path.dirname(__file__)) |
| 20 MOJO_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..')) | 21 MOJO_DIR = os.path.abspath(os.path.join(THIS_DIR, '..', '..')) |
| 21 # Should be the same as in upload.py. | 22 # Should be the same as in upload.py. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 78 |
| 78 # Download tools from GCS. | 79 # Download tools from GCS. |
| 79 archive_path = os.path.join(INSTALL_DIR, tools_name + '.tar.gz') | 80 archive_path = os.path.join(INSTALL_DIR, tools_name + '.tar.gz') |
| 80 download_cmd = ['python', GSUTIL_PATH, 'cp', | 81 download_cmd = ['python', GSUTIL_PATH, 'cp', |
| 81 'gs://mojo/android/tool/%s.tar.gz' % version, | 82 'gs://mojo/android/tool/%s.tar.gz' % version, |
| 82 archive_path] | 83 archive_path] |
| 83 if not RunCommand(download_cmd): | 84 if not RunCommand(download_cmd): |
| 84 print ('WARNING: Failed to download Android tools.') | 85 print ('WARNING: Failed to download Android tools.') |
| 85 return | 86 return |
| 86 | 87 |
| 87 print "Extracting Android tools (" + tools_name + ")" | 88 def Extract(): |
| 88 with tarfile.open(archive_path) as arch: | 89 print "Extracting Android tools (" + tools_name + ")..." |
| 89 arch.extractall(INSTALL_DIR) | 90 with tarfile.open(archive_path) as arch: |
| 90 os.remove(archive_path) | 91 arch.extractall(INSTALL_DIR) |
| 91 # Write version as the last step. | 92 os.remove(archive_path) |
| 92 with open(os.path.join(INSTALL_DIR, version_stamp), 'w+') as f: | 93 # Write version as the last step. |
| 93 f.write('%s\n' % version) | 94 with open(os.path.join(INSTALL_DIR, version_stamp), 'w+') as f: |
| 95 f.write('%s\n' % version) |
| 96 print "Finished extracting Android tools (" + tools_name + ")" |
| 97 multiprocessing.Process(target=Extract).start() |
| 94 | 98 |
| 95 def main(): | 99 def main(): |
| 100 UpdateTools('ndk') |
| 96 UpdateTools('sdk') | 101 UpdateTools('sdk') |
| 97 UpdateTools('ndk') | |
| 98 | 102 |
| 99 if __name__ == '__main__': | 103 if __name__ == '__main__': |
| 100 sys.exit(main()) | 104 sys.exit(main()) |
| OLD | NEW |