OLD | NEW |
---|---|
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'), | |
ricow1
2015/06/11 15:51:50
indentation
keertip
2015/06/11 18:10:10
Done.
| |
37 'dart-sdk') | |
ricow1
2015/06/11 15:51:50
indentatione
keertip
2015/06/11 18:10:09
Done.
| |
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' , 'dartdo c.dart') | |
ricow1
2015/06/11 15:51:50
long line
keertip
2015/06/11 18:10:09
Done.
| |
41 packages_dir = os.path.join(bot_utils.DART_DIR, | |
42 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), | |
43 'packages') | |
44 with bot.BuildStep('Build API docs by dartdoc'): | |
45 subprocess.call([dart_exe, '--package-root=' + packages_dir, dartdoc_dart, ' --sdk-docs', | |
ricow1
2015/06/11 15:51:50
long line
ricow1
2015/06/11 15:51:50
'--package-root=%s' % packages_dir
is the python w
keertip
2015/06/11 18:10:09
Done.
keertip
2015/06/11 18:10:10
Done.
| |
46 '--output', dirname, '--dart-sdk', dart_sdk, '--package-ro ot', packages_dir], | |
ricow1
2015/06/11 15:51:50
long line
keertip
2015/06/11 18:10:10
Done.
| |
47 stdout=open(os.devnull, 'wb')) | |
48 | |
33 def CreateUploadVersionFile(): | 49 def CreateUploadVersionFile(): |
34 file_path = os.path.join(bot_utils.DART_DIR, | 50 file_path = os.path.join(bot_utils.DART_DIR, |
35 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), | 51 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), |
36 'VERSION') | 52 'VERSION') |
37 with open(file_path, 'w') as fd: | 53 with open(file_path, 'w') as fd: |
38 fd.write(utils.GetVersionFileContent()) | 54 fd.write(utils.GetVersionFileContent()) |
39 DartArchiveUploadVersionFile(file_path) | 55 DartArchiveUploadVersionFile(file_path) |
40 | 56 |
41 def DartArchiveUploadVersionFile(version_file): | 57 def DartArchiveUploadVersionFile(version_file): |
42 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW) | 58 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 BuildSDK() | 95 BuildSDK() |
80 CreateUploadSDKZips() | 96 CreateUploadSDKZips() |
81 | 97 |
82 def CreateUploadAPIDocs(): | 98 def CreateUploadAPIDocs(): |
83 api_path = os.path.join(bot_utils.DART_DIR, | 99 api_path = os.path.join(bot_utils.DART_DIR, |
84 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), | 100 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), |
85 'api_docs') | 101 'api_docs') |
86 api_zip = os.path.join(bot_utils.DART_DIR, | 102 api_zip = os.path.join(bot_utils.DART_DIR, |
87 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), | 103 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), |
88 'dart-api-docs.zip') | 104 'dart-api-docs.zip') |
105 dartdoc_dir = os.path.join(bot_utils.DART_DIR, | |
106 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), | |
107 'gen-dartdocs') | |
108 dartdoc_zip = os.path.join(bot_utils.DART_DIR, | |
109 utils.GetBuildRoot(BUILD_OS, 'release', 'ia32'), | |
110 'dartdocs-api.zip') | |
89 shutil.rmtree(api_path, ignore_errors=True) | 111 shutil.rmtree(api_path, ignore_errors=True) |
90 FileDelete(api_zip) | 112 FileDelete(api_zip) |
91 BuildAPIDocs() | 113 BuildAPIDocs() |
92 UploadApiDocs(api_path) | 114 UploadApiDocs(api_path) |
115 UploadApiLatestFile() | |
93 CreateZip(api_path, api_zip) | 116 CreateZip(api_path, api_zip) |
94 DartArchiveUploadAPIDocs(api_zip) | 117 DartArchiveUploadAPIDocs(api_zip) |
118 BuildDartdocAPIDocs(dartdoc_dir) | |
119 UploadDartdocApiDocs(dartdoc_dir) | |
120 CreateZip(dartdoc_dir, dartdoc_zip) | |
121 DartArchiveUploadDartdocAPIDocs(dartdoc_zip) | |
95 | 122 |
96 def DartArchiveUploadAPIDocs(api_zip): | 123 def DartArchiveUploadAPIDocs(api_zip): |
97 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW) | 124 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW) |
98 revision = utils.GetArchiveVersion() | 125 revision = utils.GetArchiveVersion() |
99 for revision in [revision, 'latest']: | 126 for revision in [revision, 'latest']: |
100 destination = (namer.apidocs_directory(revision) + '/' + | 127 destination = (namer.apidocs_directory(revision) + '/' + |
101 namer.apidocs_zipfilename()) | 128 namer.apidocs_zipfilename()) |
102 DartArchiveFile(api_zip, destination, checksum_files=False) | 129 DartArchiveFile(api_zip, destination, checksum_files=False) |
103 | 130 |
104 def UploadApiDocs(dir_name): | 131 def UploadApiDocs(dir_name): |
105 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL) | 132 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL) |
106 revision = utils.GetArchiveVersion() | 133 revision = utils.GetArchiveVersion() |
107 apidocs_destination_gcsdir = apidocs_namer.docs_dirpath(revision) | 134 apidocs_destination_gcsdir = apidocs_namer.docs_dirpath(revision) |
108 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(revision) | 135 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(revision) |
109 | 136 |
110 # Return early if the documents have already been uploaded. | 137 # 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 | 138 # (This can happen if a build was forced, or a commit had no changes in the |
112 # dart repository (e.g. DEPS file update).) | 139 # dart repository (e.g. DEPS file update).) |
113 if GsutilExists(apidocs_destination_gcsdir): | 140 if GsutilExists(apidocs_destination_gcsdir): |
114 print ("Not uploading api docs, since %s is already present." | 141 print ("Not uploading api docs, since %s is already present." |
115 % apidocs_destination_gcsdir) | 142 % apidocs_destination_gcsdir) |
116 return | 143 return |
117 | 144 |
118 # Upload everything inside the built apidocs directory. | 145 # Upload everything inside the built apidocs directory. |
119 gsutil = bot_utils.GSUtil() | 146 gsutil = bot_utils.GSUtil() |
120 gsutil.upload(dir_name, apidocs_destination_gcsdir, recursive=True, | 147 gsutil.upload(dir_name, apidocs_destination_gcsdir, recursive=True, |
121 public=True) | 148 public=True) |
122 | 149 |
150 def DartArchiveUploadDartdocAPIDocs(api_zip): | |
151 namer = bot_utils.GCSNamer(CHANNEL, bot_utils.ReleaseType.RAW) | |
152 revision = utils.GetArchiveVersion() | |
153 for revision in [revision, 'latest']: | |
154 destination = (namer.apidocs_directory(revision) + '/' + | |
ricow1
2015/06/11 15:51:50
I don't like the + between strings, but I am fine
keertip
2015/06/11 18:10:09
Acknowledged.
| |
155 namer.dartdocs_zipfilename()) | |
156 DartArchiveFile(api_zip, destination, checksum_files=False) | |
157 | |
158 def UploadDartdocApiDocs(dir_name): | |
159 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL) | |
160 revision = utils.GetArchiveVersion() | |
161 dartdocs_destination_gcsdir = apidocs_namer.dartdocs_dirpath(revision) | |
162 | |
163 # Return early if the documents have already been uploaded. | |
164 # (This can happen if a build was forced, or a commit had no changes in the | |
ricow1
2015/06/11 15:51:50
lose the ()
keertip
2015/06/11 18:10:09
Done.
| |
165 # dart repository (e.g. DEPS file update).) | |
166 if GsutilExists(dartdocs_destination_gcsdir): | |
167 print ("Not uploading api docs, since %s is already present." | |
168 % dartdocs_destination_gcsdir) | |
169 return | |
170 | |
171 # Upload everything inside the built apidocs directory. | |
172 gsutil = bot_utils.GSUtil() | |
173 gsutil.upload(dir_name, dartdocs_destination_gcsdir, recursive=True, | |
174 public=True, multithread=True) | |
175 | |
176 def UploadApiLatestFile(): | |
177 apidocs_namer = bot_utils.GCSNamerApiDocs(CHANNEL) | |
178 revision = utils.GetArchiveVersion() | |
179 apidocs_destination_latestfile = apidocs_namer.docs_latestpath(revision) | |
123 # Update latest.txt to contain the newest revision. | 180 # Update latest.txt to contain the newest revision. |
124 with utils.TempDir('latest_file') as temp_dir: | 181 with utils.TempDir('latest_file') as temp_dir: |
125 latest_file = os.path.join(temp_dir, 'latest.txt') | 182 latest_file = os.path.join(temp_dir, 'latest.txt') |
126 with open(latest_file, 'w') as f: | 183 with open(latest_file, 'w') as f: |
127 f.write('%s' % revision) | 184 f.write('%s' % revision) |
128 DartArchiveFile(latest_file, apidocs_destination_latestfile) | 185 DartArchiveFile(latest_file, apidocs_destination_latestfile) |
129 | 186 |
130 def GsutilExists(gsu_path): | 187 def GsutilExists(gsu_path): |
131 # This is a little hackish, but it is basically a one off doing very | 188 # This is a little hackish, but it is basically a one off doing very |
132 # specialized check that we don't use elsewhere. | 189 # specialized check that we don't use elsewhere. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
180 gsutil.upload(local_md5sum, remote_path + '.md5sum', public=True) | 237 gsutil.upload(local_md5sum, remote_path + '.md5sum', public=True) |
181 local_sha256 = bot_utils.CreateSha256ChecksumFile(local_path, | 238 local_sha256 = bot_utils.CreateSha256ChecksumFile(local_path, |
182 mangled_filename) | 239 mangled_filename) |
183 gsutil.upload(local_sha256, remote_path + '.sha256sum', public=True) | 240 gsutil.upload(local_sha256, remote_path + '.sha256sum', public=True) |
184 | 241 |
185 def Run(command): | 242 def Run(command): |
186 print "Running %s" % ' '.join(command) | 243 print "Running %s" % ' '.join(command) |
187 return bot.RunProcess(command) | 244 return bot.RunProcess(command) |
188 | 245 |
189 if __name__ == '__main__': | 246 if __name__ == '__main__': |
247 | |
ricow1
2015/06/11 15:51:50
stray edit?
keertip
2015/06/11 18:10:09
Done.
| |
190 # We always clobber the bot, to make sure releases are build from scratch | 248 # We always clobber the bot, to make sure releases are build from scratch |
191 force = CHANNEL != bot_utils.Channel.BLEEDING_EDGE | 249 force = CHANNEL != bot_utils.Channel.BLEEDING_EDGE |
192 bot.Clobber(force=force) | 250 bot.Clobber(force=force) |
193 | 251 |
194 CreateUploadSDK() | 252 CreateUploadSDK() |
195 if BUILD_OS == 'linux': | 253 if BUILD_OS == 'linux': |
196 CreateUploadVersionFile() | 254 CreateUploadVersionFile() |
197 CreateUploadAPIDocs() | 255 CreateUploadAPIDocs() |
OLD | NEW |