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

Side by Side Diff: infra/bots/recipe_modules/skia/resources/generate_and_upload_doxygen.py

Issue 2175373002: Move Skia recipes from build repo (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Address more comments Created 4 years, 4 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
OLDNEW
(Empty)
1 #!/usr/bin/env 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
7 """Generate Doxygen documentation."""
8
9
10 import datetime
11 import os
12 import shutil
13 import subprocess
14 import sys
15
16 from common.skia import global_constants
17
18
19 DOXYFILE_BASENAME = 'Doxyfile' # must match name of Doxyfile in skia root
20 DOXYGEN_BINARY = 'doxygen'
21 WORKDIR = os.path.join(os.pardir, 'doxygen_workdir')
22 DOXYGEN_CONFIG_DIR = os.path.join(WORKDIR, 'doxygen-config')
23 DOXYGEN_WORKING_DIR = os.path.join(WORKDIR, 'doxygen')
24 DOXYGEN_GS_PATH = '/'.join(['gs:/', global_constants.GS_GM_BUCKET, 'doxygen'])
25
26 IFRAME_FOOTER_TEMPLATE = """
27 <html><body><address style="text-align: right;"><small>
28 Generated at %s for skia
29 by <a href="http://www.doxygen.org/index.html">doxygen</a>
30 %s </small></address></body></html>
31 """
32
33
34 def recreate_dir(path):
35 """Delete and recreate the directory."""
36 try:
37 shutil.rmtree(path)
38 except OSError:
39 if os.path.exists(path):
40 raise Exception('Could not remove %s' % path)
41 os.makedirs(path)
42
43
44 def generate_and_upload_doxygen(gsutil_path):
45 """Generate Doxygen."""
46 # Create empty dir and add static_footer.txt
47 recreate_dir(DOXYGEN_WORKING_DIR)
48 static_footer_path = os.path.join(DOXYGEN_WORKING_DIR, 'static_footer.txt')
49 shutil.copyfile(os.path.join('tools', 'doxygen_footer.txt'),
50 static_footer_path)
51
52 # Make copy of doxygen config file, overriding any necessary configs,
53 # and run doxygen.
54 recreate_dir(DOXYGEN_CONFIG_DIR)
55 modified_doxyfile = os.path.join(DOXYGEN_CONFIG_DIR, DOXYFILE_BASENAME)
56 with open(DOXYFILE_BASENAME, 'r') as reader:
57 with open(modified_doxyfile, 'w') as writer:
58 shutil.copyfileobj(reader, writer)
59 writer.write('OUTPUT_DIRECTORY = %s\n' % DOXYGEN_WORKING_DIR)
60 writer.write('HTML_FOOTER = %s\n' % static_footer_path)
61 subprocess.check_call([DOXYGEN_BINARY, modified_doxyfile])
62
63 # Create iframe_footer.html
64 with open(os.path.join(DOXYGEN_WORKING_DIR, 'iframe_footer.html'), 'w') as f:
65 f.write(IFRAME_FOOTER_TEMPLATE % (
66 datetime.datetime.now().isoformat(' '),
67 subprocess.check_output([DOXYGEN_BINARY, '--version']).rstrip()))
68
69 # Upload.
70 cmd = [gsutil_path, 'cp', '-a', 'public-read', '-R',
71 DOXYGEN_WORKING_DIR, DOXYGEN_GS_PATH]
72 subprocess.check_call(cmd)
73
74
75 if '__main__' == __name__:
76 generate_and_upload_doxygen(*sys.argv[1:])
77
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698