Bug 1317778 - Emit a depfile with python configure dependencies so Make will know when to re-run configure. r=glandium
MozReview-Commit-ID: AuTHadY7KqO
--- a/client.mk
+++ b/client.mk
@@ -324,16 +324,20 @@ CONFIG_STATUS_DEPS := \
$(TOPSRCDIR)/browser/config/version.txt \
$(TOPSRCDIR)/browser/config/version_display.txt \
$(TOPSRCDIR)/build/virtualenv_packages.txt \
$(TOPSRCDIR)/python/mozbuild/mozbuild/virtualenv.py \
$(TOPSRCDIR)/testing/mozbase/packages.txt \
$(OBJDIR)/.mozconfig.json \
$(NULL)
+# Include a dep file emitted by configure to track Python files that
+# may influence the result of configure.
+-include $(OBJDIR)/configure.d
+
CONFIGURE_ENV_ARGS += \
MAKE='$(MAKE)' \
$(NULL)
# configure uses the program name to determine @srcdir@. Calling it without
# $(TOPSRCDIR) will set @srcdir@ to "."; otherwise, it is set to the full
# path of $(TOPSRCDIR).
ifeq ($(TOPSRCDIR),$(OBJDIR))
--- a/configure.py
+++ b/configure.py
@@ -1,24 +1,27 @@
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
from __future__ import print_function, unicode_literals
import codecs
+import itertools
import os
import subprocess
import sys
import textwrap
base_dir = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.join(base_dir, 'python', 'mozbuild'))
from mozbuild.configure import ConfigureSandbox
+from mozbuild.makeutil import Makefile
+from mozbuild.pythonutil import iter_modules_in_path
from mozbuild.util import (
indented_repr,
encode,
)
def main(argv):
config = {}
@@ -41,17 +44,18 @@ def config_status(config):
return '1'
if v is False:
return ''
return v
sanitized_config = {}
sanitized_config['substs'] = {
k: sanitized_bools(v) for k, v in config.iteritems()
- if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR')
+ if k not in ('DEFINES', 'non_global_defines', 'TOPSRCDIR', 'TOPOBJDIR',
+ 'ALL_CONFIGURE_PATHS')
}
sanitized_config['defines'] = {
k: sanitized_bools(v) for k, v in config['DEFINES'].iteritems()
}
sanitized_config['non_global_defines'] = config['non_global_defines']
sanitized_config['topsrcdir'] = config['TOPSRCDIR']
sanitized_config['topobjdir'] = config['TOPOBJDIR']
sanitized_config['mozconfig'] = config.get('MOZCONFIG')
@@ -79,16 +83,27 @@ def config_status(config):
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
fh.write(textwrap.dedent('''
if __name__ == '__main__':
from mozbuild.config_status import config_status
args = dict([(name, globals()[name]) for name in __all__])
config_status(**args)
'''))
+ # Write out a depfile so Make knows to re-run configure when relevant Python
+ # changes.
+ mk = Makefile()
+ rule = mk.create_rule()
+ rule.add_targets(["$(OBJDIR)/config.status"])
+ rule.add_dependencies(itertools.chain(config['ALL_CONFIGURE_PATHS'],
+ iter_modules_in_path(config['TOPOBJDIR'],
+ config['TOPSRCDIR'])))
+ with open('configure.d', 'w') as fh:
+ mk.dump(fh)
+
# Other things than us are going to run this file, so we need to give it
# executable permissions.
os.chmod('config.status', 0o755)
if config.get('MOZ_BUILD_APP') != 'js' or config.get('JS_STANDALONE'):
os.environ[b'WRITE_MOZINFO'] = b'1'
from mozbuild.config_status import config_status
# Some values in sanitized_config also have more complex types, such as
--- a/moz.configure
+++ b/moz.configure
@@ -333,9 +333,15 @@ def nsis_binary_type(nsis):
if bin_type != 'win32':
raise FatalCheckError('%s is not a 32-bit Windows application' % nsis)
return 'yes'
# Fallthrough to autoconf-based configure
include('build/moz.configure/old.configure')
-# Please do not add anything after the include of old.configure.
+
+@imports('__sandbox__')
+def all_paths():
+ return __sandbox__._all_paths
+
+set_config('ALL_CONFIGURE_PATHS', all_paths())
+# Please do not add anything after setting ALL_CONFIGURE_PATHS.