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

Side by Side Diff: tools/bots/dart_sdk.py

Issue 1164423008: add dartdoc to third_party/pkg, run dartdoc to generate docs for sdk and upload to GCS (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: fix long line Created 5 years, 6 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 | « tools/bots/bot_utils.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 6
7 import os.path 7 import os.path
8 import shutil 8 import shutil
9 import sys 9 import sys
10 import subprocess
10 11
11 import bot 12 import bot
12 import bot_utils 13 import bot_utils
13 14
14 utils = bot_utils.GetUtils() 15 utils = bot_utils.GetUtils()
15 16
16 BUILD_OS = utils.GuessOS() 17 BUILD_OS = utils.GuessOS()
17 18
18 (bot_name, _) = bot.GetBotName() 19 (bot_name, _) = bot.GetBotName()
19 CHANNEL = bot_utils.GetChannelFromName(bot_name) 20 CHANNEL = bot_utils.GetChannelFromName(bot_name)
20 21
21 def BuildSDK(): 22 def BuildSDK():
22 with bot.BuildStep('Build SDK'): 23 with bot.BuildStep('Build SDK'):
23 Run([sys.executable, './tools/build.py', '--mode=release', 24 Run([sys.executable, './tools/build.py', '--mode=release',
24 '--arch=ia32,x64', 'create_sdk']) 25 '--arch=ia32,x64', 'create_sdk'])
25 26
26 def BuildAPIDocs(): 27 def BuildAPIDocs():
27 with bot.BuildStep('Build API docs'): 28 with bot.BuildStep('Build API docs'):
28 Run([sys.executable, './tools/build.py', '--mode=release', 29 Run([sys.executable, './tools/build.py', '--mode=release',
29 '--arch=ia32', 'api_docs']) 30 '--arch=ia32', 'api_docs'])
30 Run([sys.executable, './tools/build.py', '--mode=release', 31 Run([sys.executable, './tools/build.py', '--mode=release',
31 '--arch=ia32', 'dartdocgen']) 32 '--arch=ia32', 'dartdocgen'])
32 33
34 def BuildDartdocAPIDocs(dirname):
35 dart_sdk = os.path.join(bot_utils.DART_DIR,
36 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
37 'dart-sdk')
38 dart_exe = os.path.join(dart_sdk, 'bin', 'dart')
39 dartdoc_dart = os.path.join(bot_utils.DART_DIR,
40 'third_party', 'pkg' , 'dartdoc' , 'bin' ,
41 'dartdoc.dart')
42 packages_dir = os.path.join(bot_utils.DART_DIR,
43 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
44 'packages')
45 with bot.BuildStep('Build API docs by dartdoc'):
46 subprocess.call([dart_exe, '--package-root=' + packages_dir, dartdoc_dart,
47 '--sdk-docs','--output', dirname, '--dart-sdk', dart_sdk,
48 '--package-root=%s' % packages_dir],
49 stdout=open(os.devnull, 'wb'))
50
33 def CreateUploadVersionFile(): 51 def CreateUploadVersionFile():
34 file_path = os.path.join(bot_utils.DART_DIR, 52 file_path = os.path.join(bot_utils.DART_DIR,
35 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), 53 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
36 'VERSION') 54 'VERSION')
37 with open(file_path, 'w') as fd: 55 with open(file_path, 'w') as fd:
38 fd.write(utils.GetVersionFileContent()) 56 fd.write(utils.GetVersionFileContent())
39 DartArchiveUploadVersionFile(file_path) 57 DartArchiveUploadVersionFile(file_path)
40 58
41 def DartArchiveUploadVersionFile(version_file): 59 def DartArchiveUploadVersionFile(version_file):
42 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW) 60 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW)
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 BuildSDK() 97 BuildSDK()
80 CreateUploadSDKZips() 98 CreateUploadSDKZips()
81 99
82 def CreateUploadAPIDocs(): 100 def CreateUploadAPIDocs():
83 api_path = os.path.join(bot_utils.DART_DIR, 101 api_path = os.path.join(bot_utils.DART_DIR,
84 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), 102 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
85 'api_docs') 103 'api_docs')
86 api_zip = os.path.join(bot_utils.DART_DIR, 104 api_zip = os.path.join(bot_utils.DART_DIR,
87 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), 105 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
88 'dart-api-docs.zip') 106 'dart-api-docs.zip')
107 dartdoc_dir = os.path.join(bot_utils.DART_DIR,
108 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
109 'gen-dartdocs')
110 dartdoc_zip = os.path.join(bot_utils.DART_DIR,
111 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'),
112 'dartdocs-api.zip')
89 shutil.rmtree(api_path, ignore_errors=True) 113 shutil.rmtree(api_path, ignore_errors=True)
90 FileDelete(api_zip) 114 FileDelete(api_zip)
91 BuildAPIDocs() 115 BuildAPIDocs()
92 UploadApiDocs(api_path) 116 UploadApiDocs(api_path)
117 UploadApiLatestFile()
93 CreateZip(api_path, api_zip) 118 CreateZip(api_path, api_zip)
94 DartArchiveUploadAPIDocs(api_zip) 119 DartArchiveUploadAPIDocs(api_zip)
120 BuildDartdocAPIDocs(dartdoc_dir)
121 UploadDartdocApiDocs(dartdoc_dir)
122 CreateZip(dartdoc_dir, dartdoc_zip)
123 DartArchiveUploadDartdocAPIDocs(dartdoc_zip)
95 124
96 def DartArchiveUploadAPIDocs(api_zip): 125 def DartArchiveUploadAPIDocs(api_zip):
97 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW) 126 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW)
98 revision = utils.GetArchiveVersion() 127 revision = utils.GetArchiveVersion()
99 for revision in [revision, 'latest']: 128 for revision in [revision, 'latest']:
100 destination = (namer.apidocs_directory(revision) + '/' + 129 destination = (namer.apidocs_directory(revision) + '/' +
101 namer.apidocs_zipfilename()) 130 namer.apidocs_zipfilename())
102 DartArchiveFile(api_zip, destination, checksum_files=False) 131 DartArchiveFile(api_zip, destination, checksum_files=False)
103 132
104 def UploadApiDocs(dir_name): 133 def UploadApiDocs(dir_name):
105 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL) 134 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL)
106 revision = utils.GetArchiveVersion() 135 revision = utils.GetArchiveVersion()
107 apidocs_destination_gcsdir = apidocs_namer.docs_dirpath(revision) 136 apidocs_destination_gcsdir = apidocs_namer.docs_dirpath(revision)
108 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(revision) 137 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(revision)
109 138
110 # Return early if the documents have already been uploaded. 139 # Return early if the documents have already been uploaded.
111 # (This can happen if a build was forced, or a commit had no changes in the 140 # (This can happen if a build was forced, or a commit had no changes in the
112 # dart repository (e.g. DEPS file update).) 141 # dart repository (e.g. DEPS file update).)
113 if GsutilExists(apidocs_destination_gcsdir): 142 if GsutilExists(apidocs_destination_gcsdir):
114 print ("Not uploading api docs, since %s is already present." 143 print ("Not uploading api docs, since %s is already present."
115 % apidocs_destination_gcsdir) 144 % apidocs_destination_gcsdir)
116 return 145 return
117 146
118 # Upload everything inside the built apidocs directory. 147 # Upload everything inside the built apidocs directory.
119 gsutil = bot_utils.GSUtil() 148 gsutil = bot_utils.GSUtil()
120 gsutil.upload(dir_name, apidocs_destination_gcsdir, recursive=True, 149 gsutil.upload(dir_name, apidocs_destination_gcsdir, recursive=True,
121 public=True) 150 public=True)
122 151
152 def DartArchiveUploadDartdocAPIDocs(api_zip):
153 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW)
154 revision = utils.GetArchiveVersion()
155 for revision in [revision, 'latest']:
156 destination = (namer.apidocs_directory(revision) + '/' +
157 namer.dartdocs_zipfilename())
158 DartArchiveFile(api_zip, destination, checksum_files=False)
159
160 def UploadDartdocApiDocs(dir_name):
161 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL)
162 revision = utils.GetArchiveVersion()
163 dartdocs_destination_gcsdir = apidocs_namer.dartdocs_dirpath(revision)
164
165 # Return early if the documents have already been uploaded.
166 # This can happen if a build was forced, or a commit had no changes in the
167 # dart repository (e.g. DEPS file update).
168 if GsutilExists(dartdocs_destination_gcsdir):
169 print ("Not uploading api docs, since %s is already present."
170 % dartdocs_destination_gcsdir)
171 return
172
173 # Upload everything inside the built apidocs directory.
174 gsutil = bot_utils.GSUtil()
175 gsutil.upload(dir_name, dartdocs_destination_gcsdir, recursive=True,
176 public=True, multithread=True)
177
178 def UploadApiLatestFile():
179 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL)
180 revision = utils.GetArchiveVersion()
181 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(revision)
123 # Update latest.txt to contain the newest revision. 182 # Update latest.txt to contain the newest revision.
124 with utils.TempDir('latest_file') as temp_dir: 183 with utils.TempDir('latest_file') as temp_dir:
125 latest_file = os.path.join(temp_dir, 'latest.txt') 184 latest_file = os.path.join(temp_dir, 'latest.txt')
126 with open(latest_file, 'w') as f: 185 with open(latest_file, 'w') as f:
127 f.write('%s' % revision) 186 f.write('%s' % revision)
128 DartArchiveFile(latest_file, apidocs_destination_latestfile) 187 DartArchiveFile(latest_file, apidocs_destination_latestfile)
129 188
130 def GsutilExists(gsu_path): 189 def GsutilExists(gsu_path):
131 # This is a little hackish, but it is basically a one off doing very 190 # This is a little hackish, but it is basically a one off doing very
132 # specialized check that we don't use elsewhere. 191 # specialized check that we don't use elsewhere.
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 247
189 if __name__ == '__main__': 248 if __name__ == '__main__':
190 # We always clobber the bot, to make sure releases are build from scratch 249 # We always clobber the bot, to make sure releases are build from scratch
191 force = CHANNEL != bot_utils.Channel.BLEEDING_EDGE 250 force = CHANNEL != bot_utils.Channel.BLEEDING_EDGE
192 bot.Clobber(force=force) 251 bot.Clobber(force=force)
193 252
194 CreateUploadSDK() 253 CreateUploadSDK()
195 if BUILD_OS == 'linux': 254 if BUILD_OS == 'linux':
196 CreateUploadVersionFile() 255 CreateUploadVersionFile()
197 CreateUploadAPIDocs() 256 CreateUploadAPIDocs()
OLDNEW
« no previous file with comments | « tools/bots/bot_utils.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698