OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 6 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
7 # Use of this source code is governed by a BSD-style license that can be | 7 # Use of this source code is governed by a BSD-style license that can be |
8 # found in the LICENSE file. | 8 # found in the LICENSE file. |
9 | 9 |
10 """Dart client buildbot steps | 10 """Dart client buildbot steps |
11 | 11 |
12 Compiles dart client apps with dartc, and run the client tests both in headless | 12 Compiles dart client apps with dartc, and run the client tests both in headless |
13 chromium and headless dartium. | 13 chromium and headless dartium. |
14 """ | 14 """ |
15 | 15 |
| 16 import imp |
16 import os | 17 import os |
17 import re | 18 import re |
18 import socket | 19 import socket |
19 import subprocess | 20 import subprocess |
20 import sys | 21 import sys |
21 import shutil | |
22 import glob | |
23 | 22 |
24 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' | 23 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' |
25 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' | 24 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' |
26 REVISION = 'BUILDBOT_REVISION' | 25 REVISION = 'BUILDBOT_REVISION' |
27 | 26 |
28 # latest dartium location | 27 # latest dartium location |
29 DARTIUM_VERSION_FILE = 'client/tests/drt/LAST_VERSION' | 28 DARTIUM_VERSION_FILE = 'client/tests/drt/LAST_VERSION' |
30 DARTIUM_V_MATCHER = ( | 29 DARTIUM_V_MATCHER = ( |
31 'gs://dartium-archive/[^/]*/dartium-\w*-inc-([0-9]*).([0-9]*).zip') | 30 'gs://dartium-archive/[^/]*/dartium-\w*-inc-([0-9]*).([0-9]*).zip') |
32 | 31 |
| 32 def GetUtils(): |
| 33 '''Dynamically load the tools/utils.py python module.''' |
| 34 dart_dir = os.path.abspath(os.path.join(__file__, '..', '..', '..')) |
| 35 return imp.load_source('utils', os.path.join(dart_dir, 'tools', 'utils.py')) |
| 36 |
| 37 utils = GetUtils() |
| 38 |
33 def GetBuildInfo(): | 39 def GetBuildInfo(): |
34 """Returns a tuple (name, version, mode) where: | 40 """Returns a tuple (name, version, mode) where: |
35 - name: A name for the build - the buildbot host if a buildbot. | 41 - name: A name for the build - the buildbot host if a buildbot. |
36 - version: A version string corresponding to this build. | 42 - version: A version string corresponding to this build. |
37 """ | 43 """ |
38 name = None | 44 name = None |
39 version = None | 45 version = None |
40 | 46 |
41 # Populate via builder environment variables. | 47 # Populate via builder environment variables. |
42 name = os.environ.get(BUILDER_NAME) | 48 name = os.environ.get(BUILDER_NAME) |
43 version = os.environ.get(REVISION) | 49 version = os.environ.get(REVISION) |
44 | 50 |
45 # Fall back if not on builder. | 51 # Fall back if not on builder. |
46 if not name: | 52 if not name: |
47 name = socket.gethostname().split('.')[0] | 53 name = socket.gethostname().split('.')[0] |
48 if not version: | 54 if not version: |
49 # In Windows we need to run in the shell, so that we have all the | 55 # In Windows we need to run in the shell, so that we have all the |
50 # environment variables available. | 56 # environment variables available. |
51 pipe = subprocess.Popen( | 57 pipe = subprocess.Popen( |
52 ['svnversion', '-n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, | 58 ['svnversion', '-n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, |
53 shell=True) | 59 shell=True) |
54 output = pipe.communicate() | 60 output = pipe.communicate() |
55 if pipe.returncode == 0: | 61 if pipe.returncode == 0: |
56 version = output[0] | 62 version = output[0] |
57 else: | 63 else: |
58 version = 'unknown' | 64 version = 'unknown' |
59 return (name, version) | 65 return (name, version) |
60 | 66 |
61 | 67 def GetOutDir(mode): |
62 def GetUtils(): | |
63 ''' | |
64 dynamically get the utils module | |
65 We use a dynamic import for tools/util.py because we derive its location | |
66 dynamically using sys.argv[0]. This allows us to run this script from | |
67 different directories. | |
68 | |
69 args: | |
70 ''' | |
71 sys.path.append(os.path.abspath(os.path.join('.', 'tools'))) | |
72 utils = __import__('utils') | |
73 return utils | |
74 | |
75 def GetOutDir(utils, mode): | |
76 ''' | 68 ''' |
77 get the location to place the output | 69 get the location to place the output |
78 | 70 |
79 args: | 71 args: |
80 utils - the tools/utils.py module | 72 utils - the tools/utils.py module |
81 mode - the mode release or debug | 73 mode - the mode release or debug |
82 ''' | 74 ''' |
83 return utils.GetBuildRoot(utils.GuessOS(), mode, utils.ARCH_GUESS) | 75 return utils.GetBuildRoot(utils.GuessOS(), mode, utils.ARCH_GUESS) |
84 | 76 |
85 def ProcessTools(mode, name, version): | 77 def ProcessTools(mode, name, version): |
86 ''' | 78 ''' |
87 build and test the tools | 79 build and test the tools |
88 | 80 |
89 args: | 81 args: |
90 srcpath - the location of the source code to build | 82 srcpath - the location of the source code to build |
91 mode - the mode release or debug | 83 mode - the mode release or debug |
92 version - the svn version of the currently checked out code | 84 version - the svn version of the currently checked out code |
93 ''' | 85 ''' |
94 print 'ProcessTools' | 86 print 'ProcessTools' |
95 | 87 |
96 toolsBuildScript = os.path.join('.', 'editor', 'build', 'build.py') | 88 toolsBuildScript = os.path.join('.', 'editor', 'build', 'build.py') |
97 | 89 |
98 # TODO(devoncarew): should we move this into GetBuildInfo()? | 90 # TODO(devoncarew): should we move this into GetBuildInfo()? |
99 # get the latest changed revision from the current repository sub-tree | 91 # get the latest changed revision from the current repository sub-tree |
100 version = GetLatestChangedRevision() | 92 version = GetLatestChangedRevision() |
101 | 93 |
102 utils = GetUtils() | 94 outdir = GetOutDir(mode) |
103 outdir = GetOutDir(utils, mode) | |
104 cmds = [sys.executable, toolsBuildScript, | 95 cmds = [sys.executable, toolsBuildScript, |
105 '--mode=' + mode, '--revision=' + version, | 96 '--mode=' + mode, '--revision=' + version, |
106 '--name=' + name, '--out=' + outdir] | 97 '--name=' + name, '--out=' + outdir] |
107 local_env = EnvironmentWithoutBotoConfig() | 98 local_env = EnvironmentWithoutBotoConfig() |
108 #if 'linux' in name: | 99 #if 'linux' in name: |
109 # javahome = os.path.join(os.path.expanduser('~'), 'jdk1.6.0_25') | 100 # javahome = os.path.join(os.path.expanduser('~'), 'jdk1.6.0_25') |
110 # local_env['JAVA_HOME'] = javahome | 101 # local_env['JAVA_HOME'] = javahome |
111 # local_env['PATH'] = (os.path.join(javahome, 'bin') + | 102 # local_env['PATH'] = (os.path.join(javahome, 'bin') + |
112 # os.pathsep + local_env['PATH']) | 103 # os.pathsep + local_env['PATH']) |
113 | 104 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 """ Clobber the builder before we do the build. | 146 """ Clobber the builder before we do the build. |
156 """ | 147 """ |
157 cmd = [sys.executable, | 148 cmd = [sys.executable, |
158 './tools/clean_output_directory.py'] | 149 './tools/clean_output_directory.py'] |
159 print 'Clobbering %s' % (' '.join(cmd)) | 150 print 'Clobbering %s' % (' '.join(cmd)) |
160 return subprocess.call(cmd) | 151 return subprocess.call(cmd) |
161 | 152 |
162 def GetShouldClobber(): | 153 def GetShouldClobber(): |
163 return os.environ.get(BUILDER_CLOBBER) == "1" | 154 return os.environ.get(BUILDER_CLOBBER) == "1" |
164 | 155 |
165 def RunDart(scriptPath): | |
166 if sys.platform == 'darwin': | |
167 pipe = subprocess.Popen( | |
168 ['./tools/testing/bin/macos/dart', scriptPath], | |
169 stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
170 elif os.name == 'posix': | |
171 pipe = subprocess.Popen( | |
172 ['./tools/testing/bin/linux/dart', scriptPath], | |
173 stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
174 else: | |
175 pipe = subprocess.Popen( | |
176 ['tools\\testing\\bin\\windows\\dart.exe', scriptPath], | |
177 stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) | |
178 | |
179 output = pipe.communicate() | |
180 return output[0] | |
181 | |
182 def GetLatestChangedRevision(): | 156 def GetLatestChangedRevision(): |
183 # 0.1.2.0_r13661 | 157 revision = utils.GetSVNRevision() |
184 # 0.1.2.0_r13661_username | 158 if not revision: |
185 fullVersion = RunDart("tools/version.dart") | 159 raise Exception("Couldn't determine last changed revision.") |
186 | 160 return revision |
187 m = re.search('._r(\d+)', fullVersion) | |
188 svnRev = m.group(1) | |
189 | |
190 return svnRev | |
191 | 161 |
192 def main(): | 162 def main(): |
193 if len(sys.argv) == 0: | 163 if len(sys.argv) == 0: |
194 print 'Script pathname not known, giving up.' | 164 print 'Script pathname not known, giving up.' |
195 return 1 | 165 return 1 |
196 | 166 |
197 scriptdir = os.path.dirname(sys.argv[0]) | 167 scriptdir = os.path.dirname(sys.argv[0]) |
198 # Get at the top-level directory. This script is in client/tools | 168 # Get at the top-level directory. This script is in client/tools |
199 os.chdir(os.path.abspath(os.path.join(scriptdir, os.pardir, os.pardir))) | 169 os.chdir(os.path.abspath(os.path.join(scriptdir, os.pardir, os.pardir))) |
200 | 170 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 status = ProcessBot(name, 'compiler') | 204 status = ProcessBot(name, 'compiler') |
235 | 205 |
236 if status: | 206 if status: |
237 print '@@@STEP_FAILURE@@@' | 207 print '@@@STEP_FAILURE@@@' |
238 | 208 |
239 return status | 209 return status |
240 | 210 |
241 | 211 |
242 if __name__ == '__main__': | 212 if __name__ == '__main__': |
243 sys.exit(main()) | 213 sys.exit(main()) |
OLD | NEW |