OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 3 # Copyright (c) 2012, 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 glob | 7 import glob |
| 8 import gsutil |
| 9 import hashlib |
| 10 import imp |
8 import optparse | 11 import optparse |
9 import os | 12 import os |
10 import re | 13 import re |
11 import shutil | 14 import shutil |
12 import subprocess | 15 import subprocess |
13 import sys | 16 import sys |
14 import tempfile | 17 import tempfile |
15 import gsutil | |
16 import ziputils | 18 import ziputils |
17 import hashlib | |
18 | 19 |
19 from os.path import join | 20 from os.path import join |
20 | 21 |
21 BUILD_OS = None | 22 BUILD_OS = None |
22 DART_PATH = None | 23 DART_PATH = None |
23 TOOLS_PATH = None | 24 TOOLS_PATH = None |
24 | 25 |
25 GSU_PATH_REV = None | 26 GSU_PATH_REV = None |
26 GSU_PATH_LATEST = None | 27 GSU_PATH_LATEST = None |
27 GSU_API_DOCS_PATH = None | 28 GSU_API_DOCS_PATH = None |
28 GSU_API_DOCS_BUCKET = 'gs://dartlang-api-docs' | 29 GSU_API_DOCS_BUCKET = 'gs://dartlang-api-docs' |
29 | 30 |
30 REVISION = None | 31 REVISION = None |
31 TRUNK_BUILD = None | 32 TRUNK_BUILD = None |
32 MILESTONE_BUILD = None | 33 MILESTONE_BUILD = None |
33 PLUGINS_BUILD = None | 34 PLUGINS_BUILD = None |
34 | 35 |
35 NO_UPLOAD = None | 36 NO_UPLOAD = None |
36 | 37 |
37 utils = None | 38 def GetUtils(): |
| 39 '''Dynamically load the tools/utils.py python module.''' |
| 40 dart_dir = os.path.abspath(os.path.join(__file__, '..', '..', '..')) |
| 41 return imp.load_source('utils', os.path.join(dart_dir, 'tools', 'utils.py')) |
| 42 |
| 43 utils = GetUtils() |
38 | 44 |
39 class AntWrapper(object): | 45 class AntWrapper(object): |
40 """A wrapper for ant build invocations""" | 46 """A wrapper for ant build invocations""" |
41 | 47 |
42 _antpath = None | 48 _antpath = None |
43 _bzippath = None | 49 _bzippath = None |
44 _propertyfile = None | 50 _propertyfile = None |
45 | 51 |
46 def __init__(self, propertyfile, antpath='/usr/bin', bzippath=None): | 52 def __init__(self, propertyfile, antpath='/usr/bin', bzippath=None): |
47 """Initialize the ant path. | 53 """Initialize the ant path. |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 help='builder name.', | 170 help='builder name.', |
165 action='store') | 171 action='store') |
166 result.add_option('-o', '--out', | 172 result.add_option('-o', '--out', |
167 help='Output Directory.', | 173 help='Output Directory.', |
168 action='store') | 174 action='store') |
169 result.add_option('--dest', | 175 result.add_option('--dest', |
170 help='Output Directory.', | 176 help='Output Directory.', |
171 action='store') | 177 action='store') |
172 return result | 178 return result |
173 | 179 |
174 | |
175 def GetUtils(toolspath): | |
176 """Dynamically get the utils module. | |
177 | |
178 We use a dynamic import for tools/util.py because we derive its location | |
179 dynamically using sys.argv[0]. This allows us to run this script from | |
180 different directories. | |
181 | |
182 Args: | |
183 toolspath: the path to the tools directory | |
184 | |
185 Returns: | |
186 the utils module | |
187 """ | |
188 global utils | |
189 sys.path.append(os.path.abspath(toolspath)) | |
190 utils = __import__('utils') | |
191 return utils | |
192 | |
193 | |
194 def main(): | 180 def main(): |
195 """Main entry point for the build program.""" | 181 """Main entry point for the build program.""" |
196 global BUILD_OS | 182 global BUILD_OS |
197 global DART_PATH | 183 global DART_PATH |
198 global TOOLS_PATH | 184 global TOOLS_PATH |
199 global GSU_PATH_REV | 185 global GSU_PATH_REV |
200 global GSU_API_DOCS_PATH | 186 global GSU_API_DOCS_PATH |
201 global GSU_PATH_LATEST | 187 global GSU_PATH_LATEST |
202 global REVISION | 188 global REVISION |
203 global TRUNK_BUILD | 189 global TRUNK_BUILD |
204 global MILESTONE_BUILD | 190 global MILESTONE_BUILD |
205 global PLUGINS_BUILD | 191 global PLUGINS_BUILD |
206 global NO_UPLOAD | 192 global NO_UPLOAD |
207 global utils | |
208 | 193 |
209 if not sys.argv: | 194 if not sys.argv: |
210 print 'Script pathname not known, giving up.' | 195 print 'Script pathname not known, giving up.' |
211 return 1 | 196 return 1 |
212 | 197 |
213 scriptdir = os.path.abspath(os.path.dirname(sys.argv[0])) | 198 scriptdir = os.path.abspath(os.path.dirname(sys.argv[0])) |
214 editorpath = os.path.abspath(os.path.join(scriptdir, '..')) | 199 editorpath = os.path.abspath(os.path.join(scriptdir, '..')) |
215 thirdpartypath = os.path.abspath(os.path.join(scriptdir, '..', '..', | 200 thirdpartypath = os.path.abspath(os.path.join(scriptdir, '..', '..', |
216 'third_party')) | 201 'third_party')) |
217 toolspath = os.path.abspath(os.path.join(scriptdir, '..', '..', | 202 toolspath = os.path.abspath(os.path.join(scriptdir, '..', '..', |
218 'tools')) | 203 'tools')) |
219 dartpath = os.path.abspath(os.path.join(scriptdir, '..', '..')) | 204 dartpath = os.path.abspath(os.path.join(scriptdir, '..', '..')) |
220 antpath = os.path.join(thirdpartypath, 'apache_ant', '1.8.4') | 205 antpath = os.path.join(thirdpartypath, 'apache_ant', '1.8.4') |
221 bzip2libpath = os.path.join(thirdpartypath, 'bzip2') | 206 bzip2libpath = os.path.join(thirdpartypath, 'bzip2') |
222 buildpath = os.path.join(editorpath, 'tools', 'features', | 207 buildpath = os.path.join(editorpath, 'tools', 'features', |
223 'com.google.dart.tools.deploy.feature_releng') | 208 'com.google.dart.tools.deploy.feature_releng') |
224 utils = GetUtils(toolspath) | |
225 buildos = utils.GuessOS() | 209 buildos = utils.GuessOS() |
226 | 210 |
227 BUILD_OS = utils.GuessOS() | 211 BUILD_OS = utils.GuessOS() |
228 DART_PATH = dartpath | 212 DART_PATH = dartpath |
229 TOOLS_PATH = toolspath | 213 TOOLS_PATH = toolspath |
230 | 214 |
231 if (os.environ.get('DART_NO_UPLOAD') is not None): | 215 if (os.environ.get('DART_NO_UPLOAD') is not None): |
232 NO_UPLOAD = True | 216 NO_UPLOAD = True |
233 | 217 |
234 # TODO(devoncarew): remove this hardcoded e:\ path | 218 # TODO(devoncarew): remove this hardcoded e:\ path |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 """delete the given file - do not re-throw any exceptions that occur""" | 1071 """delete the given file - do not re-throw any exceptions that occur""" |
1088 if os.path.exists(f): | 1072 if os.path.exists(f): |
1089 try: | 1073 try: |
1090 os.remove(f) | 1074 os.remove(f) |
1091 except OSError: | 1075 except OSError: |
1092 print 'error deleting %s' % f | 1076 print 'error deleting %s' % f |
1093 | 1077 |
1094 | 1078 |
1095 if __name__ == '__main__': | 1079 if __name__ == '__main__': |
1096 sys.exit(main()) | 1080 sys.exit(main()) |
OLD | NEW |