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 This script will based on the name of the bot call the correct script in |
Bill Hesse
2015/05/12 10:45:42
Calls a script in tools/bots whose name is based o
ricow1
2015/05/12 10:47:15
Done.
| |
13 chromium and headless dartium. | 13 tools/bots/ |
14 | |
14 """ | 15 """ |
15 | 16 |
16 import imp | 17 import imp |
17 import os | 18 import os |
18 import re | 19 import re |
19 import socket | 20 import socket |
20 import subprocess | 21 import subprocess |
21 import sys | 22 import sys |
22 | 23 |
23 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' | 24 BUILDER_NAME = 'BUILDBOT_BUILDERNAME' |
24 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' | 25 BUILDER_CLOBBER = 'BUILDBOT_CLOBBER' |
25 REVISION = 'BUILDBOT_REVISION' | |
26 | 26 |
27 # latest dartium location | 27 def GetName(): |
28 DARTIUM_VERSION_FILE = 'client/tests/drt/LAST_VERSION' | 28 """Returns the name of the bot. |
29 DARTIUM_V_MATCHER = ( | |
30 'gs://dartium-archive/[^/]*/dartium-\w*-inc-([0-9]*).([0-9]*).zip') | |
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 | |
39 def GetBuildInfo(): | |
40 """Returns a tuple (name, version, mode) where: | |
41 - name: A name for the build - the buildbot host if a buildbot. | |
42 - version: A version string corresponding to this build. | |
43 """ | 29 """ |
44 name = None | 30 name = None |
45 version = None | |
46 | |
47 # Populate via builder environment variables. | 31 # Populate via builder environment variables. |
48 name = os.environ.get(BUILDER_NAME) | 32 name = os.environ.get(BUILDER_NAME) |
49 version = os.environ.get(REVISION) | |
50 | 33 |
51 # Fall back if not on builder. | 34 # Fall back if not on builder. |
52 if not name: | 35 if not name: |
53 name = socket.gethostname().split('.')[0] | 36 name = socket.gethostname().split('.')[0] |
54 if not version: | 37 return name |
55 # In Windows we need to run in the shell, so that we have all the | |
56 # environment variables available. | |
57 pipe = subprocess.Popen( | |
58 ['svnversion', '-n'], stdout=subprocess.PIPE, stderr=subprocess.PIPE, | |
59 shell=True) | |
60 output = pipe.communicate() | |
61 if pipe.returncode == 0: | |
62 version = output[0] | |
63 else: | |
64 version = 'unknown' | |
65 return (name, version) | |
66 | |
67 def GetOutDir(mode): | |
68 ''' | |
69 get the location to place the output | |
70 | |
71 args: | |
72 utils - the tools/utils.py module | |
73 mode - the mode release or debug | |
74 ''' | |
75 return utils.GetBuildRoot(utils.GuessOS(), mode, utils.ARCH_GUESS) | |
76 | |
77 def ProcessTools(mode, name, version): | |
78 ''' | |
79 build and test the tools | |
80 | |
81 args: | |
82 srcpath - the location of the source code to build | |
83 mode - the mode release or debug | |
84 version - the svn version of the currently checked out code | |
85 ''' | |
86 print 'ProcessTools' | |
87 | |
88 toolsBuildScript = os.path.join('.', 'editor', 'build', 'build.py') | |
89 | |
90 build_installer = name.startswith('dart-editor-installer') | |
91 | |
92 # TODO(devoncarew): should we move this into GetBuildInfo()? | |
93 # get the latest changed revision from the current repository sub-tree | |
94 version = GetLatestChangedRevision() | |
95 | |
96 outdir = GetOutDir(mode) | |
97 cmds = [sys.executable, toolsBuildScript, | |
98 '--mode=' + mode, '--revision=' + version, | |
99 '--name=' + name, '--out=' + outdir] | |
100 if build_installer: | |
101 cmds.append('--build-installer') | |
102 local_env = EnvironmentWithoutBotoConfig() | |
103 #if 'linux' in name: | |
104 # javahome = os.path.join(os.path.expanduser('~'), 'jdk1.6.0_25') | |
105 # local_env['JAVA_HOME'] = javahome | |
106 # local_env['PATH'] = (os.path.join(javahome, 'bin') + | |
107 # os.pathsep + local_env['PATH']) | |
108 | |
109 return subprocess.call(cmds, env=local_env) | |
110 | |
111 def EnvironmentWithoutBotoConfig(environment=None): | |
112 # The buildbot sets AWS_CREDENTIAL_FILE/BOTO_CONFIG to the chromium specific | |
113 # file, we use the one in home. | |
114 custom_env = dict(environment or os.environ) | |
115 if 'BOTO_CONFIG' in custom_env: | |
116 del custom_env['BOTO_CONFIG'] | |
117 if 'AWS_CREDENTIAL_FILE' in custom_env: | |
118 del custom_env['AWS_CREDENTIAL_FILE'] | |
119 return custom_env | |
120 | 38 |
121 def ProcessBot(name, target, custom_env=None): | 39 def ProcessBot(name, target, custom_env=None): |
122 ''' | 40 ''' |
123 Build and test the named bot target (compiler, android, pub). We look for | 41 Build and test the named bot target (compiler, android, pub). We look for |
124 the supporting script in tools/bots/ to run the tests and build. | 42 the supporting script in tools/bots/ to run the tests and build. |
125 ''' | 43 ''' |
126 print 'Process%s' % target.capitalize() | 44 print 'Process%s' % target.capitalize() |
127 has_shell = False | 45 has_shell = False |
128 environment = custom_env or os.environ | 46 environment = custom_env or os.environ |
129 if '-win' in name: | 47 if '-win' in name: |
130 # In Windows we need to run in the shell, so that we have all the | 48 # In Windows we need to run in the shell, so that we have all the |
131 # environment variables available. | 49 # environment variables available. |
132 has_shell = True | 50 has_shell = True |
133 return subprocess.call([sys.executable, | 51 return subprocess.call([sys.executable, |
134 os.path.join('tools', 'bots', target + '.py')], | 52 os.path.join('tools', 'bots', target + '.py')], |
135 env=environment, shell=has_shell) | 53 env=environment, shell=has_shell) |
136 | 54 |
137 def FixJavaHome(): | |
138 buildbot_javahome = os.getenv('BUILDBOT_JAVA_HOME') | |
139 if buildbot_javahome: | |
140 current_pwd = os.getenv('PWD') | |
141 java_home = os.path.join(current_pwd, buildbot_javahome) | |
142 java_bin = os.path.join(java_home, 'bin') | |
143 os.environ['JAVA_HOME'] = java_home | |
144 os.environ['PATH'] = '%s;%s' % (java_bin, os.environ['PATH']) | |
145 | |
146 print 'Setting java home to ', java_home | |
147 sys.stdout.flush() | |
148 | |
149 def ClobberBuilder(): | 55 def ClobberBuilder(): |
150 """ Clobber the builder before we do the build. | 56 """ Clobber the builder before we do the build. |
151 """ | 57 """ |
152 cmd = [sys.executable, | 58 cmd = [sys.executable, |
153 './tools/clean_output_directory.py'] | 59 './tools/clean_output_directory.py'] |
154 print 'Clobbering %s' % (' '.join(cmd)) | 60 print 'Clobbering %s' % (' '.join(cmd)) |
155 return subprocess.call(cmd) | 61 return subprocess.call(cmd) |
156 | 62 |
157 def GetShouldClobber(): | 63 def GetShouldClobber(): |
158 return os.environ.get(BUILDER_CLOBBER) == "1" | 64 return os.environ.get(BUILDER_CLOBBER) == "1" |
159 | 65 |
160 def GetLatestChangedRevision(): | |
161 revision = utils.GetSVNRevision() | |
162 if not revision: | |
163 raise Exception("Couldn't determine last changed revision.") | |
164 return revision | |
165 | |
166 def main(): | 66 def main(): |
167 if len(sys.argv) == 0: | 67 if len(sys.argv) == 0: |
168 print 'Script pathname not known, giving up.' | 68 print 'Script pathname not known, giving up.' |
169 return 1 | 69 return 1 |
170 | 70 |
171 scriptdir = os.path.dirname(sys.argv[0]) | 71 scriptdir = os.path.dirname(sys.argv[0]) |
172 # Get at the top-level directory. This script is in client/tools | 72 # Get at the top-level directory. This script is in client/tools |
173 os.chdir(os.path.abspath(os.path.join(scriptdir, os.pardir, os.pardir))) | 73 os.chdir(os.path.abspath(os.path.join(scriptdir, os.pardir, os.pardir))) |
174 | 74 |
175 if GetShouldClobber(): | 75 if GetShouldClobber(): |
176 print '@@@BUILD_STEP Clobber@@@' | 76 print '@@@BUILD_STEP Clobber@@@' |
177 status = ClobberBuilder() | 77 status = ClobberBuilder() |
178 if status != 0: | 78 if status != 0: |
179 print '@@@STEP_FAILURE@@@' | 79 print '@@@STEP_FAILURE@@@' |
180 return status | 80 return status |
181 | 81 |
182 | 82 name = GetName() |
183 #TODO(sigmund): remove this indirection once we update our bots | |
184 (name, version) = GetBuildInfo() | |
185 # The buildbot will set a BUILDBOT_JAVA_HOME relative to the dart | |
186 # root directory, set JAVA_HOME based on that. | |
187 FixJavaHome() | |
188 if name.startswith('pub-'): | 83 if name.startswith('pub-'): |
189 status = ProcessBot(name, 'pub') | 84 status = ProcessBot(name, 'pub') |
190 elif name.startswith('vm-android'): | 85 elif name.startswith('vm-android'): |
191 status = ProcessBot(name, 'android') | 86 status = ProcessBot(name, 'android') |
192 elif name.startswith('dart-sdk'): | 87 elif name.startswith('dart-sdk'): |
193 status = ProcessBot(name, 'dart_sdk') | 88 status = ProcessBot(name, 'dart_sdk') |
194 elif name.startswith('cross') or name.startswith('target'): | 89 elif name.startswith('cross') or name.startswith('target'): |
195 status = ProcessBot(name, 'cross-vm', | 90 status = ProcessBot(name, 'cross-vm') |
196 custom_env=EnvironmentWithoutBotoConfig()) | |
197 elif name.startswith('linux-distribution-support'): | 91 elif name.startswith('linux-distribution-support'): |
198 status = ProcessBot(name, 'linux_distribution_support') | 92 status = ProcessBot(name, 'linux_distribution_support') |
199 elif name.startswith('version-checker'): | 93 elif name.startswith('version-checker'): |
200 status = ProcessBot(name, 'version_checker') | 94 status = ProcessBot(name, 'version_checker') |
201 elif name.startswith('dart2js-dump-info'): | 95 elif name.startswith('dart2js-dump-info'): |
202 status = ProcessBot(name, 'dart2js_dump_info') | 96 status = ProcessBot(name, 'dart2js_dump_info') |
203 else: | 97 else: |
204 status = ProcessBot(name, 'compiler') | 98 status = ProcessBot(name, 'compiler') |
205 | 99 |
206 if status: | 100 if status: |
207 print '@@@STEP_FAILURE@@@' | 101 print '@@@STEP_FAILURE@@@' |
208 | 102 |
209 return status | 103 return status |
210 | 104 |
211 | 105 |
212 if __name__ == '__main__': | 106 if __name__ == '__main__': |
213 sys.exit(main()) | 107 sys.exit(main()) |
OLD | NEW |