OLD | NEW |
---|---|
1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 # Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Module containing the various individual commands a builder can run.""" | 5 """Module containing the various individual commands a builder can run.""" |
6 | 6 |
7 import os | 7 import os |
8 import re | 8 import re |
9 import shutil | 9 import shutil |
10 import sys | 10 import sys |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 | 173 |
174 | 174 |
175 def SetupBoard(buildroot, board='x86-generic'): | 175 def SetupBoard(buildroot, board='x86-generic'): |
176 """Wrapper around setup_board.""" | 176 """Wrapper around setup_board.""" |
177 cwd = os.path.join(buildroot, 'src', 'scripts') | 177 cwd = os.path.join(buildroot, 'src', 'scripts') |
178 cros_lib.OldRunCommand( | 178 cros_lib.OldRunCommand( |
179 ['./setup_board', '--fast', '--default', '--board=%s' % board], cwd=cwd, | 179 ['./setup_board', '--fast', '--default', '--board=%s' % board], cwd=cwd, |
180 enter_chroot=True) | 180 enter_chroot=True) |
181 | 181 |
182 | 182 |
183 def Build(buildroot, emptytree, build_autotest=True, usepkg=True): | 183 def Build(buildroot, emptytree, build_autotest=True, usepkg=True, |
184 extra_env=None): | |
184 """Wrapper around build_packages.""" | 185 """Wrapper around build_packages.""" |
185 cwd = os.path.join(buildroot, 'src', 'scripts') | 186 cwd = os.path.join(buildroot, 'src', 'scripts') |
186 cmd = ['./build_packages'] | 187 cmd = ['./build_packages'] |
188 env = {} | |
187 if not build_autotest: cmd.append('--nowithautotest') | 189 if not build_autotest: cmd.append('--nowithautotest') |
188 if not usepkg: cmd.append('--nousepkg') | 190 if not usepkg: cmd.append('--nousepkg') |
189 if emptytree: | 191 if emptytree: |
190 cmd = ['sh', '-c', 'EXTRA_BOARD_FLAGS=--emptytree %s' % ' '.join(cmd)] | 192 env['EXTRA_BOARD_FLAGS'] = '--emptytree' |
193 if extra_env: | |
194 env.update(extra_env) | |
dgarrett
2011/04/18 21:17:38
Shouldn't --emptytree be appended to the env value
Peter Mayo
2011/04/19 03:59:39
Seems like overkill, but sure. Similarly, I don't
| |
191 | 195 |
192 cros_lib.OldRunCommand(cmd, cwd=cwd, enter_chroot=True) | 196 cros_lib.RunCommand(cmd, cwd=cwd, enter_chroot=True, extra_env=env) |
193 | 197 |
194 | 198 |
195 def BuildImage(buildroot): | 199 def BuildImage(buildroot, extra_env=None): |
196 _WipeOldOutput(buildroot) | 200 _WipeOldOutput(buildroot) |
197 | 201 |
198 cwd = os.path.join(buildroot, 'src', 'scripts') | 202 cwd = os.path.join(buildroot, 'src', 'scripts') |
199 cros_lib.OldRunCommand(['./build_image', '--replace'], cwd=cwd, | 203 cros_lib.RunCommand(['./build_image', '--replace'], cwd=cwd, |
200 enter_chroot=True) | 204 enter_chroot=True, extra_env=extra_env) |
201 | 205 |
202 | 206 |
203 def BuildVMImageForTesting(buildroot): | 207 def BuildVMImageForTesting(buildroot, extra_env=None): |
204 (vdisk_size, statefulfs_size) = _GetVMConstants(buildroot) | 208 (vdisk_size, statefulfs_size) = _GetVMConstants(buildroot) |
205 cwd = os.path.join(buildroot, 'src', 'scripts') | 209 cwd = os.path.join(buildroot, 'src', 'scripts') |
206 cros_lib.OldRunCommand(['./image_to_vm.sh', | 210 cros_lib.RunCommand(['./image_to_vm.sh', |
207 '--test_image', | 211 '--test_image', |
208 '--full', | 212 '--full', |
209 '--vdisk_size=%s' % vdisk_size, | 213 '--vdisk_size=%s' % vdisk_size, |
210 '--statefulfs_size=%s' % statefulfs_size, | 214 '--statefulfs_size=%s' % statefulfs_size, |
211 ], cwd=cwd, enter_chroot=True) | 215 ], cwd=cwd, enter_chroot=True, extra_env=extra_env) |
212 | 216 |
213 | 217 |
214 def RunUnitTests(buildroot, full): | 218 def RunUnitTests(buildroot, full): |
215 cwd = os.path.join(buildroot, 'src', 'scripts') | 219 cwd = os.path.join(buildroot, 'src', 'scripts') |
216 | 220 |
217 cmd = ['cros_run_unit_tests'] | 221 cmd = ['cros_run_unit_tests'] |
218 | 222 |
219 # If we aren't running ALL tests, then restrict to just the packages | 223 # If we aren't running ALL tests, then restrict to just the packages |
220 # uprev noticed were changed. | 224 # uprev noticed were changed. |
221 if not full: | 225 if not full: |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 | 474 |
471 archive_url = None | 475 archive_url = None |
472 key_re = re.compile('^%s=(.*)$' % _CROS_ARCHIVE_URL) | 476 key_re = re.compile('^%s=(.*)$' % _CROS_ARCHIVE_URL) |
473 for line in result.output.splitlines(): | 477 for line in result.output.splitlines(): |
474 line_match = key_re.match(line) | 478 line_match = key_re.match(line) |
475 if line_match: | 479 if line_match: |
476 archive_url = line_match.group(1) | 480 archive_url = line_match.group(1) |
477 | 481 |
478 assert archive_url, 'Archive Build Failed to Provide Archive URL' | 482 assert archive_url, 'Archive Build Failed to Provide Archive URL' |
479 return archive_url | 483 return archive_url |
OLD | NEW |