Ben Murdoch | 097c5b2 | 2016-05-18 11:27:45 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2016 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 | """Minimal tool to download doclava from Google storage when building for |
| 7 | Android.""" |
| 8 | |
| 9 | import os |
| 10 | import subprocess |
| 11 | import sys |
| 12 | |
| 13 | |
| 14 | # Its existence signifies an Android checkout. |
| 15 | ANDROID_ONLY_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), |
| 16 | os.pardir, os.pardir, |
| 17 | 'third_party', 'android_tools') |
| 18 | |
| 19 | |
| 20 | def main(): |
| 21 | # Some Windows bots inadvertently have third_party/android_tools installed, |
| 22 | # but are unable to run download_from_google_storage because depot_tools |
| 23 | # is not in their path, so avoid failure and bail. |
| 24 | if sys.platform == 'win32': |
| 25 | return 0 |
| 26 | if not os.path.exists(ANDROID_ONLY_DIR): |
| 27 | return 0 |
| 28 | subprocess.check_call([ |
| 29 | 'download_from_google_storage', |
| 30 | '--no_resume', |
| 31 | '--no_auth', |
| 32 | '--bucket', 'chromium-doclava', |
| 33 | '--extract', |
| 34 | '-s', |
| 35 | os.path.join('src', 'buildtools', 'android', 'doclava.tar.gz.sha1')]) |
| 36 | return 0 |
| 37 | |
| 38 | if __name__ == '__main__': |
| 39 | sys.exit(main()) |