Bug 1461836 - Write out complete configure dependencies from configure for consumption by make and non-make backends. draft
authorChris Manchester <cmanchester@mozilla.com>
Thu, 17 May 2018 12:09:57 -0700
changeset 796525 d3f9db3fae551be81107781bc5387801ccd92760
parent 796524 379b4d0eac096817cc5bfb64d6f17cc3dc3c0d20
child 796526 b69434ccd0f3c88b6478d5c2ea30212d1c151e58
push id110269
push userbmo:cmanchester@mozilla.com
push dateThu, 17 May 2018 19:27:47 +0000
bugs1461836
milestone62.0a1
Bug 1461836 - Write out complete configure dependencies from configure for consumption by make and non-make backends. MozReview-Commit-ID: 792seCZ2rs1
Makefile.in
client.mk
configure.py
moz.configure
--- a/Makefile.in
+++ b/Makefile.in
@@ -65,25 +65,16 @@ ifdef JS_STANDALONE
 CLOBBER:
 else
 CLOBBER: $(topsrcdir)/CLOBBER
 	@echo 'STOP!  The CLOBBER file has changed.'
 	@echo 'Please run the build through "mach build".'
 	@exit 1
 endif
 
-$(topsrcdir)/configure: $(topsrcdir)/configure.in $(topsrcdir)/old-configure.in
-$(topsrcdir)/js/src/configure: $(topsrcdir)/js/src/configure.in $(topsrcdir)/js/src/old-configure.in
-$(topsrcdir)/configure $(topsrcdir)/js/src/configure:
-	@echo 'STOP!  $? has changed, and your configure is out of date.'
-	@echo 'Please rerun autoconf and re-configure your build directory.'
-	@echo 'To ignore this message, touch "$@",'
-	@echo 'but your build might not succeed.'
-	@exit 1
-
 config.status: $(configure_dir)/configure $(configure_dir)/old-configure
 js/src/config.status: $(topsrcdir)/js/src/configure $(topsrcdir)/js/src/old-configure
 config.status js/src/config.status:
 	@echo 'STOP!  $? has changed and needs to be run again.'
 	@echo 'Please rerun it.'
 	@echo 'To ignore this message, touch "$(CURDIR)/$@",'
 	@echo 'but your build might not succeed.'
 	@exit 1
--- a/client.mk
+++ b/client.mk
@@ -86,46 +86,24 @@ build::
 endif
 
 ####################################
 # Configure
 
 MAKEFILE      = $(wildcard $(OBJDIR)/Makefile)
 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
 
-EXTRA_CONFIG_DEPS := \
-  $(TOPSRCDIR)/aclocal.m4 \
-  $(TOPSRCDIR)/old-configure.in \
-  $(wildcard $(TOPSRCDIR)/build/autoconf/*.m4) \
-  $(TOPSRCDIR)/js/src/aclocal.m4 \
-  $(TOPSRCDIR)/js/src/old-configure.in \
-  $(NULL)
+# Include deps for configure written by configure itself.
+CONFIG_STATUS_DEPS := $(if $(wildcard $(OBJDIR)/config_status_deps.in),$(shell cat $(OBJDIR)/config_status_deps.in),)
 
-$(CONFIGURES): %: %.in $(EXTRA_CONFIG_DEPS)
+$(CONFIGURES): %: %.in
 	@echo Generating $@
 	cp -f $< $@
 	chmod +x $@
 
-CONFIG_STATUS_DEPS := \
-  $(wildcard $(TOPSRCDIR)/*/confvars.sh) \
-  $(CONFIGURES) \
-  $(TOPSRCDIR)/nsprpub/configure \
-  $(TOPSRCDIR)/config/milestone.txt \
-  $(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))
@@ -164,17 +142,16 @@ else
 $(OBJDIR)/Makefile: $(CONFIG_STATUS_DEPS)
 endif
 	@$(MAKE) -f $(TOPSRCDIR)/client.mk configure
 
 ####################################
 # Build it
 
 build::  $(OBJDIR)/Makefile $(OBJDIR)/config.status
-	@echo "Config status deps :: " $(sort $(CONFIG_STATUS_DEPS))
 	@echo "EXTRA config deps :: " $(sort $(EXTRA_CONFIG_DEPS))
 	+$(MOZ_MAKE)
 
 ifdef MOZ_AUTOMATION
 build::
 	+$(MOZ_MAKE) automation/build
 endif
 
--- a/configure.py
+++ b/configure.py
@@ -9,23 +9,23 @@ import itertools
 import os
 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.backend.configenvironment import PartialConfigEnvironment
 from mozbuild.util import (
     indented_repr,
     encode,
 )
+import mozpack.path as mozpath
 
 
 def main(argv):
     config = {}
     sandbox = ConfigureSandbox(config, os.environ, argv)
     sandbox.run(os.path.join(os.path.dirname(__file__), 'moz.configure'))
 
     if sandbox._help:
@@ -45,17 +45,17 @@ def config_status(config):
         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',
-                     'ALL_CONFIGURE_PATHS')
+                     'CONFIG_STATUS_DEPS')
     }
     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')
@@ -88,26 +88,23 @@ def config_status(config):
                     from mozbuild.config_status import config_status
                     args = dict([(name, globals()[name]) for name in __all__])
                     config_status(**args)
             '''))
 
     partial_config = PartialConfigEnvironment(config['TOPOBJDIR'])
     partial_config.write_vars(sanitized_config)
 
-    # Write out a depfile so Make knows to re-run configure when relevant Python
+    # Write out a file so Make knows to re-run configure when relevant Python
     # changes.
-    mk = Makefile()
-    rule = mk.create_rule()
-    rule.add_targets(["%s/config.status" % config['TOPOBJDIR']])
-    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)
+    with open('config_status_deps.in', 'w') as fh:
+        for f in itertools.chain(config['CONFIG_STATUS_DEPS'],
+                                 iter_modules_in_path(config['TOPOBJDIR'],
+                                                      config['TOPSRCDIR'])):
+            fh.write('%s\n' % mozpath.normpath(f))
 
     # 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'):
         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
@@ -560,14 +560,36 @@ def nsis_flags(host):
 
 set_config('MAKENSISU_FLAGS', nsis_flags)
 
 check_prog('7Z', ('7z', '7za'), allow_missing=True, when=target_is_windows)
 
 # Fallthrough to autoconf-based configure
 include('build/moz.configure/old.configure')
 
+@depends(check_build_environment, build_project)
 @imports('__sandbox__')
-def all_paths():
-    return __sandbox__._all_paths
+@imports('glob')
+def config_status_deps(build_env, build_project):
+
+    topsrcdir = build_env.topsrcdir
+    topobjdir = build_env.topobjdir
 
-set_config('ALL_CONFIGURE_PATHS', all_paths())
-# Please do not add anything after setting ALL_CONFIGURE_PATHS.
+    return list(__sandbox__._all_paths) + [
+        os.path.join(topsrcdir, build_project, 'confvars.sh'),
+        os.path.join(topsrcdir, 'configure'),
+        os.path.join(topsrcdir, 'js', 'src', 'configure'),
+        os.path.join(topsrcdir, 'nsprpub', 'configure'),
+        os.path.join(topsrcdir, 'config', 'milestone.txt'),
+        os.path.join(topsrcdir, 'browser', 'config', 'version.txt'),
+        os.path.join(topsrcdir, 'browser', 'config', 'version_display.txt'),
+        os.path.join(topsrcdir, 'build', 'virtualenv_packages.txt'),
+        os.path.join(topsrcdir, 'python', 'mozbuild', 'mozbuild', 'virtualenv.py'),
+        os.path.join(topsrcdir, 'testing', 'mozbase', 'packages.txt'),
+        os.path.join(topobjdir, '.mozconfig.json'),
+        os.path.join(topsrcdir, 'aclocal.m4'),
+        os.path.join(topsrcdir, 'old-configure.in'),
+        os.path.join(topsrcdir, 'js', 'src', 'aclocal.m4'),
+        os.path.join(topsrcdir, 'js', 'src', 'old-configure.in'),
+    ] + glob.glob(os.path.join(topsrcdir, 'build', 'autoconf', '*.m4'))
+
+set_config('CONFIG_STATUS_DEPS', config_status_deps)
+# Please do not add anything after setting config_dep_paths.