Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: build/android/download_doclava.py

Issue 1557233003: Download doclava when building for Android and use to build cronet Javadocs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: separate download and extract steps Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « DEPS ('k') | components/cronet/android/api/build.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 shutil
11 import subprocess
12 import sys
13
14
15 # Its existence signifies an Android checkout.
16 ANDROID_ONLY_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)),
17 os.pardir, os.pardir,
18 'third_party', 'android_tools')
19
20
21 def ReadFile(filename):
22 with file(filename, 'r') as f:
23 return f.read().strip()
24
25
26 def WriteFile(filename, content):
27 assert not os.path.exists(filename)
28 with file(filename, 'w') as f:
29 f.write(content)
30 f.write('\n')
31
32
33 def main():
34 # Some Windows bots inadvertently have third_party/android_tools installed,
35 # but are unable to run download_from_google_storage because depot_tools
36 # is not in their path, so avoid failure and bail.
37 if sys.platform == 'win32':
38 return 0
39 if not os.path.exists(ANDROID_ONLY_DIR):
40 return 0
41
42 outdir = os.path.join('src', 'buildtools', 'android', 'doclava')
43 tarball = outdir + '.tar.gz'
44 sha1file = tarball + '.sha1'
45 stampfile = tarball + '.stamp'
46
47 checksum = ReadFile(sha1file)
48
49 if os.path.exists(stampfile):
50 if (os.path.exists(tarball) and
51 os.path.exists(outdir) and
52 checksum == ReadFile(stampfile)):
53 return 0
54 else:
55 os.unlink(stampfile)
56
57 subprocess.check_call([
58 'download_from_google_storage',
59 '--no_resume',
60 '--no_auth',
61 '--bucket', 'chromium-doclava',
62 '-s', sha1file])
agrieve 2016/04/11 17:12:56 You should add a comment saying why --extract does
63 assert os.path.exists(tarball)
64
65 if os.path.exists(outdir):
66 shutil.rmtree(outdir)
67 assert not os.path.exists(outdir)
68 os.makedirs(outdir)
69 assert os.path.exists(outdir)
70
71 print "Extracting", tarball
72 subprocess.check_call(['tar', 'axf', os.path.abspath(tarball)], cwd=outdir)
agrieve 2016/04/11 17:12:57 Probably better to use Python's tarfile module for
73
74 WriteFile(stampfile, checksum)
75 return 0
76
77 if __name__ == '__main__':
78 sys.exit(main())
OLDNEW
« no previous file with comments | « DEPS ('k') | components/cronet/android/api/build.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698