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): | |
davidjames
2011/04/19 06:38:59
extra_env={}
Peter Mayo
2011/04/19 17:43:17
I'm a little surprised that's stylisticly OK. But
| |
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 = {} | |
davidjames
2011/04/19 06:38:59
env = extra_env.copy()
then you don't need the nex
Peter Mayo
2011/04/19 17:43:17
Done.
| |
189 if extra_env: | |
190 env.update(extra_env) | |
187 if not build_autotest: cmd.append('--nowithautotest') | 191 if not build_autotest: cmd.append('--nowithautotest') |
188 if not usepkg: cmd.append('--nousepkg') | 192 if not usepkg: cmd.append('--nousepkg') |
189 if emptytree: | 193 if emptytree: |
190 cmd = ['sh', '-c', 'EXTRA_BOARD_FLAGS=--emptytree %s' % ' '.join(cmd)] | 194 key = 'EXTRA_BOARD_FLAGS' |
191 | 195 prev = env.get(key) |
192 cros_lib.OldRunCommand(cmd, cwd=cwd, enter_chroot=True) | 196 env[key] = (prev and prev + ' ' or '') + '--emptytree' |
197 cros_lib.RunCommand(cmd, cwd=cwd, enter_chroot=True, extra_env=env) | |
193 | 198 |
194 | 199 |
195 def BuildImage(buildroot): | 200 def BuildImage(buildroot, extra_env=None): |
196 _WipeOldOutput(buildroot) | 201 _WipeOldOutput(buildroot) |
197 | 202 |
198 cwd = os.path.join(buildroot, 'src', 'scripts') | 203 cwd = os.path.join(buildroot, 'src', 'scripts') |
199 cros_lib.OldRunCommand(['./build_image', '--replace'], cwd=cwd, | 204 cros_lib.RunCommand(['./build_image', '--replace'], cwd=cwd, |
200 enter_chroot=True) | 205 enter_chroot=True, extra_env=extra_env) |
201 | 206 |
202 | 207 |
203 def BuildVMImageForTesting(buildroot): | 208 def BuildVMImageForTesting(buildroot, extra_env=None): |
204 (vdisk_size, statefulfs_size) = _GetVMConstants(buildroot) | 209 (vdisk_size, statefulfs_size) = _GetVMConstants(buildroot) |
205 cwd = os.path.join(buildroot, 'src', 'scripts') | 210 cwd = os.path.join(buildroot, 'src', 'scripts') |
206 cros_lib.OldRunCommand(['./image_to_vm.sh', | 211 cros_lib.RunCommand(['./image_to_vm.sh', |
207 '--test_image', | 212 '--test_image', |
208 '--full', | 213 '--full', |
209 '--vdisk_size=%s' % vdisk_size, | 214 '--vdisk_size=%s' % vdisk_size, |
210 '--statefulfs_size=%s' % statefulfs_size, | 215 '--statefulfs_size=%s' % statefulfs_size, |
211 ], cwd=cwd, enter_chroot=True) | 216 ], cwd=cwd, enter_chroot=True, extra_env=extra_env) |
212 | 217 |
213 | 218 |
214 def RunUnitTests(buildroot, full): | 219 def RunUnitTests(buildroot, full): |
215 cwd = os.path.join(buildroot, 'src', 'scripts') | 220 cwd = os.path.join(buildroot, 'src', 'scripts') |
216 | 221 |
217 cmd = ['cros_run_unit_tests'] | 222 cmd = ['cros_run_unit_tests'] |
218 | 223 |
219 # If we aren't running ALL tests, then restrict to just the packages | 224 # If we aren't running ALL tests, then restrict to just the packages |
220 # uprev noticed were changed. | 225 # uprev noticed were changed. |
221 if not full: | 226 if not full: |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
470 | 475 |
471 archive_url = None | 476 archive_url = None |
472 key_re = re.compile('^%s=(.*)$' % _CROS_ARCHIVE_URL) | 477 key_re = re.compile('^%s=(.*)$' % _CROS_ARCHIVE_URL) |
473 for line in result.output.splitlines(): | 478 for line in result.output.splitlines(): |
474 line_match = key_re.match(line) | 479 line_match = key_re.match(line) |
475 if line_match: | 480 if line_match: |
476 archive_url = line_match.group(1) | 481 archive_url = line_match.group(1) |
477 | 482 |
478 assert archive_url, 'Archive Build Failed to Provide Archive URL' | 483 assert archive_url, 'Archive Build Failed to Provide Archive URL' |
479 return archive_url | 484 return archive_url |
OLD | NEW |