Add the ability to pass use flags through cbuildbot to build_packages.
Change-Id: I0e069217dd57c0c5f916da7152f3674849ce8469
BUG=http://code.google.com/p/chromium/issues/detail?id=78345
TEST=manual: a -full ( nousepkg ), a -bin (no extra), a useflag single, and a useflag multiple.
Review URL: http://codereview.chromium.org/6773013
diff --git a/buildbot/cbuildbot_commands.py b/buildbot/cbuildbot_commands.py
index 3b49f11..cb61960 100644
--- a/buildbot/cbuildbot_commands.py
+++ b/buildbot/cbuildbot_commands.py
@@ -153,15 +153,20 @@
['./setup_board', '--fast', '--default', '--board=%s' % board], cwd=cwd,
enter_chroot=True)
-
-def Build(buildroot, emptytree, build_autotest=True, usepkg=True):
+def Build(buildroot, emptytree, build_autotest=True, usepkg=True,
+ extra_env=None):
"""Wrapper around build_packages."""
cwd = os.path.join(buildroot, 'src', 'scripts')
cmd = ['./build_packages']
+ env = []
if not build_autotest: cmd.append('--nowithautotest')
if not usepkg: cmd.append('--nousepkg')
if emptytree:
- cmd = ['sh', '-c', 'EXTRA_BOARD_FLAGS=--emptytree %s' % ' '.join(cmd)]
+ env.append('EXTRA_BOARD_FLAGS=--emptytree')
+ if extra_env:
+ env.extend(extra_env)
+ if env:
+ cmd = ['sh', '-c', '%s %s' % (' '.join(env), ' '.join(cmd))]
cros_lib.OldRunCommand(cmd, cwd=cwd, enter_chroot=True)
diff --git a/buildbot/cbuildbot_stages.py b/buildbot/cbuildbot_stages.py
index 197a50b..58fe388 100644
--- a/buildbot/cbuildbot_stages.py
+++ b/buildbot/cbuildbot_stages.py
@@ -319,10 +319,14 @@
BuilderStage.new_binhost = self._GetPortageEnvVar(_FULL_BINHOST)
emptytree = (BuilderStage.old_binhost and
BuilderStage.old_binhost != BuilderStage.new_binhost)
+ env=[]
+ if self._build_config['useflags']:
+ env.append('USE="%s"' % ' '.join(self._build_config['useflags']))
commands.Build(
self._build_root, emptytree, usepkg=self._build_config['usepkg'],
- build_autotest=(self._build_config['vm_tests'] and self._options.tests))
+ build_autotest=(self._build_config['vm_tests'] and self._options.tests),
+ extra_env=env)
# TODO(sosa): Do this optimization in a better way.
if self._build_type == 'full':