Bug 1216817 - Part 5: Run |mach artifact install| automatically when asked. r=glandium

It turns out to be much easier to hook |mach artifact install| into
config.status and |mach build| than to hook into client.mk.

The additional virtualenv package avoids an import error when running
|mach artifact install|.
This commit is contained in:
Nick Alexander 2015-12-23 14:25:37 -08:00
parent 238daaa69f
commit fe2907f66f
4 changed files with 37 additions and 1 deletions

View File

@ -33,3 +33,4 @@ requests.pth:python/requests
rsa.pth:python/rsa
futures.pth:python/futures
ecc.pth:python/PyECC
xpcshell.pth:testing/xpcshell

View File

@ -257,7 +257,7 @@ class MozbuildObject(ProcessExecutionMixin):
config_status = os.path.join(self.topobjdir, 'config.status')
if not os.path.exists(config_status):
raise Exception('config.status not available. Run configure.')
raise BuildEnvironmentNotFoundException('config.status not available. Run configure.')
self._config_environment = \
ConfigEnvironment.from_config_status(config_status)

View File

@ -10,6 +10,7 @@ from __future__ import absolute_import, print_function
import logging
import os
import subprocess
import sys
import time
@ -209,3 +210,8 @@ def config_status(topobjdir='.', topsrcdir='.',
if MachCommandConditions.is_android(env):
if 'AndroidEclipse' not in options.backend:
print(ANDROID_IDE_ADVERTISEMENT)
if env.substs['MOZ_ARTIFACT_BUILDS']:
# Execute |mach artifact install| from the top source directory.
os.chdir(topsrcdir)
return subprocess.check_call([sys.executable, os.path.join(topsrcdir, 'mach'), 'artifact', 'install'])

View File

@ -25,6 +25,7 @@ from mach.decorators import (
from mach.mixin.logging import LoggingMixin
from mozbuild.base import (
BuildEnvironmentNotFoundException,
MachCommandBase,
MachCommandConditions as conditions,
MozbuildObject,
@ -381,6 +382,9 @@ class Build(MachCommandBase):
line_handler=output.on_line, log=False,
print_directory=False)
if self.substs['MOZ_ARTIFACT_BUILDS']:
self._run_mach_artifact_install()
# Build target pairs.
for make_dir, make_target in target_pairs:
# We don't display build status messages during partial
@ -395,6 +399,19 @@ class Build(MachCommandBase):
if status != 0:
break
else:
try:
if self.substs['MOZ_ARTIFACT_BUILDS']:
self._run_mach_artifact_install()
except BuildEnvironmentNotFoundException:
# Can't read self.substs from config.status? That means we
# need to run configure. The client.mk invocation below
# will configure, which will run config.status, which will
# invoke |mach artifact install| itself before continuing
# the build. Therefore, we needn't install artifacts
# ourselves.
self.log(logging.DEBUG, 'artifact',
{}, "Not running |mach artifact install| -- it will be run by client.mk.")
monitor.start_resource_recording()
status = self._run_make(srcdir=True, filename='client.mk',
line_handler=output.on_line, log=False, print_directory=False,
@ -602,6 +619,18 @@ class Build(MachCommandBase):
return self._run_command_in_objdir(args=args, pass_thru=True,
ensure_exit_code=False)
def _run_mach_artifact_install(self):
# We'd like to launch artifact using
# self._mach_context.commands.dispatch. However, artifact activates
# the virtualenv, which plays badly with the rest of this code.
# Therefore, we run |mach artifact install| in a new process (and
# throw an exception if it fails).
self.log(logging.INFO, 'artifact',
{}, "Running |mach artifact install|.")
args = [os.path.join(self.topsrcdir, 'mach'), 'artifact', 'install']
self._run_command_in_srcdir(args=args,
pass_thru=True, ensure_exit_code=True)
@CommandProvider
class Doctor(MachCommandBase):
"""Provide commands for diagnosing common build environment problems"""