Bug 1461836 - Write out complete configure dependencies from configure for consumption by make and non-make backends. draft
authorChris Manchester <cmanchester@mozilla.com>
Mon, 21 May 2018 14:01:50 -0700
changeset 797856 deca7995870bcb5fbe5436413d3ddcd864b4ac23
parent 797745 77c06979d9e88979ec96263eccdbd750cb9221a4
child 797857 91299bd8a60d8fc14b4443a14e65d0f32cdb7b9b
push id110605
push userbmo:cmanchester@mozilla.com
push dateMon, 21 May 2018 21:02:30 +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))
--- 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
-    # 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)
+    # Write out a file so the build backend knows to re-run configure when
+    # relevant Python changes.
+    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,38 @@ 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, 'configure.in'),
+        os.path.join(topsrcdir, 'js', 'src', 'configure.in'),
+        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.