Bug 1454771 - Add mozconfig variables to the environment when running tup.
MozReview-Commit-ID: BneMu8DfKLY
--- a/python/mozbuild/mozbuild/backend/tup.py
+++ b/python/mozbuild/mozbuild/backend/tup.py
@@ -4,19 +4,21 @@
from __future__ import absolute_import, unicode_literals
import os
import json
import sys
import mozpack.path as mozpath
+from mozbuild import shellutil
from mozbuild.base import MozbuildObject
from mozbuild.backend.base import PartialBackend, HybridBackend
from mozbuild.backend.recursivemake import RecursiveMakeBackend
+from mozbuild.mozconfig import MozconfigLoader
from mozbuild.shellutil import quote as shell_quote
from mozbuild.util import OrderedDefaultDict
from collections import defaultdict
import multiprocessing
from mozpack.files import (
FileFinder,
)
@@ -220,31 +222,45 @@ class TupBackend(CommonBackend):
# The preprocessor including source-repo.h and buildid.h creates
# dependencies that aren't specified by moz.build and cause errors
# in Tup. Express these as a group dependency.
self._early_generated_files = '$(MOZ_OBJ_ROOT)/<early-generated-files>'
self._built_in_addons = set()
self._built_in_addons_file = 'dist/bin/browser/chrome/browser/content/browser/built_in_addons.json'
+ def _get_mozconfig_env(self, config):
+ env = {}
+ loader = MozconfigLoader(config.topsrcdir)
+ mozconfig = loader.read_mozconfig(config.substs['MOZCONFIG'])
+ make_extra = mozconfig['make_extra'] or []
+ env = {}
+ for line in make_extra:
+ if line.startswith('export '):
+ line = line[len('export '):]
+ key, value = line.split('=')
+ env[key] = value
+ return env
+
def build(self, config, output, jobs, verbose, what=None):
if not what:
what = [self.environment.topobjdir]
args = [self.environment.substs['TUP'], 'upd'] + what
if self.environment.substs.get('MOZ_AUTOMATION'):
args += ['--quiet']
if verbose:
args += ['--verbose']
if jobs > 0:
args += ['-j%d' % jobs]
else:
args += ['-j%d' % multiprocessing.cpu_count()]
return config.run_process(args=args,
line_handler=output.on_line,
- ensure_exit_code=False)
+ ensure_exit_code=False,
+ append_env=self._get_mozconfig_env(config))
def _get_backend_file(self, relobjdir):
objdir = mozpath.normpath(mozpath.join(self.environment.topobjdir, relobjdir))
if objdir not in self._backend_files:
self._backend_files[objdir] = \
BackendTupfile(objdir, self.environment,
self.environment.topsrcdir, self.environment.topobjdir)
return self._backend_files[objdir]