diff --git a/config/baseconfig.mk b/config/baseconfig.mk index dd4af0d901e..3d4c8b171c2 100644 --- a/config/baseconfig.mk +++ b/config/baseconfig.mk @@ -53,83 +53,6 @@ include_deps = $(eval $(if $(2),,-)include $(1)) ifndef INCLUDED_AUTOCONF_MK default:: else - -# Integrate with mozbuild-generated make files. We first verify that no -# variables provided by the automatically generated .mk files are -# present. If they are, this is a violation of the separation of -# responsibility between Makefile.in and mozbuild files. -_MOZBUILD_EXTERNAL_VARIABLES := \ - ANDROID_GENERATED_RESFILES \ - ANDROID_RES_DIRS \ - CMSRCS \ - CMMSRCS \ - CPP_UNIT_TESTS \ - DIRS \ - EXTRA_DSO_LDOPTS \ - EXTRA_JS_MODULES \ - EXTRA_PP_COMPONENTS \ - EXTRA_PP_JS_MODULES \ - FORCE_SHARED_LIB \ - FORCE_STATIC_LIB \ - FINAL_LIBRARY \ - HOST_CSRCS \ - HOST_CMMSRCS \ - HOST_EXTRA_LIBS \ - HOST_LIBRARY_NAME \ - HOST_PROGRAM \ - HOST_SIMPLE_PROGRAMS \ - IS_COMPONENT \ - JAR_MANIFEST \ - JAVA_JAR_TARGETS \ - LD_VERSION_SCRIPT \ - LIBRARY_NAME \ - LIBS \ - MAKE_FRAMEWORK \ - MODULE \ - MSVC_ENABLE_PGO \ - NO_DIST_INSTALL \ - OS_LIBS \ - PARALLEL_DIRS \ - PREF_JS_EXPORTS \ - PROGRAM \ - PYTHON_UNIT_TESTS \ - RESOURCE_FILES \ - SDK_HEADERS \ - SDK_LIBRARY \ - SHARED_LIBRARY_LIBS \ - SHARED_LIBRARY_NAME \ - SIMPLE_PROGRAMS \ - SONAME \ - STATIC_LIBRARY_NAME \ - TEST_DIRS \ - TOOL_DIRS \ - XPCSHELL_TESTS \ - XPIDL_MODULE \ - $(NULL) - -_DEPRECATED_VARIABLES := \ - ANDROID_RESFILES \ - EXPORT_LIBRARY \ - EXTRA_LIBS \ - HOST_LIBS \ - LIBXUL_LIBRARY \ - MOCHITEST_A11Y_FILES \ - MOCHITEST_BROWSER_FILES \ - MOCHITEST_BROWSER_FILES_PARTS \ - MOCHITEST_CHROME_FILES \ - MOCHITEST_FILES \ - MOCHITEST_FILES_PARTS \ - MOCHITEST_METRO_FILES \ - MOCHITEST_ROBOCOP_FILES \ - SHORT_LIBNAME \ - TESTING_JS_MODULES \ - TESTING_JS_MODULE_DIR \ - $(NULL) - -# Freeze the values specified by moz.build to catch them if they fail. - -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES) $(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) - TIERS := export $(if $(COMPILE_ENVIRONMENT),compile )misc libs tools endif diff --git a/config/config.mk b/config/config.mk index 7d8d8d9b82e..4d1dff3d0c7 100644 --- a/config/config.mk +++ b/config/config.mk @@ -34,18 +34,6 @@ ifndef EXTERNALLY_MANAGED_MAKE_FILE # scenarios. _current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST)) -CHECK_MOZBUILD_VARIABLES = $(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES), \ - $(if $(subst $($(var)_FROZEN),,'$($(var))'), \ - $(error Variable $(var) is defined in $(_current_makefile). It should only be defined in moz.build files),\ - )) $(foreach var,$(_DEPRECATED_VARIABLES), \ - $(if $(subst $($(var)_FROZEN),,'$($(var))'), \ - $(error Variable $(var) is defined in $(_current_makefile). This variable has been deprecated. It does nothing. It must be removed in order to build),\ - )) - -# Check variables set after autoconf.mk (included at the top of Makefiles) is -# included and before config.mk is included. -_eval_for_side_effects := $(CHECK_MOZBUILD_VARIABLES) - # Import the automatically generated backend file. If this file doesn't exist, # the backend hasn't been properly configured. We want this to be a fatal # error, hence not using "-include". @@ -54,8 +42,6 @@ GLOBAL_DEPS += backend.mk include backend.mk endif -# Freeze the values specified by moz.build to catch them if they fail. -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES) $(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) endif space = $(NULL) $(NULL) @@ -697,6 +683,3 @@ export CL_INCLUDES_PREFIX export NONASCII DEFINES += -DNO_NSPR_10_SUPPORT - -# Freeze the values specified by moz.build to catch them if they fail. -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES) $(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) diff --git a/config/recurse.mk b/config/recurse.mk index 21831a6d8e6..46e13082410 100644 --- a/config/recurse.mk +++ b/config/recurse.mk @@ -6,10 +6,6 @@ ifndef INCLUDED_RULES_MK include $(topsrcdir)/config/rules.mk endif -# Make sure that anything that needs to be defined in moz.build wasn't -# overwritten after including rules.mk. -_eval_for_side_effects := $(CHECK_MOZBUILD_VARIABLES) - # The traditional model of directory traversal with make is as follows: # make -C foo # Entering foo diff --git a/config/rules.mk b/config/rules.mk index b14f9fcd4bb..70a6e15044d 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -16,10 +16,6 @@ $(error Do not include rules.mk twice!) endif INCLUDED_RULES_MK = 1 -# Make sure that anything that needs to be defined in moz.build wasn't -# overwritten after including config.mk. -_eval_for_side_effects := $(CHECK_MOZBUILD_VARIABLES) - ifndef INCLUDED_CONFIG_MK include $(topsrcdir)/config/config.mk endif @@ -1635,10 +1631,3 @@ endif export:: $(GENERATED_FILES) GARBAGE += $(GENERATED_FILES) - -# We may have modified "frozen" variables in rules.mk (we do that), but we don't -# want Makefile.in doing that, so collect the possibly modified variables here, -# and check them again in recurse.mk, which is always included after Makefile.in -# contents. -$(foreach var,$(_MOZBUILD_EXTERNAL_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) -$(foreach var,$(_DEPRECATED_VARIABLES),$(eval $(var)_FROZEN := '$($(var))')) diff --git a/python/mozbuild/mozbuild/backend/recursivemake.py b/python/mozbuild/mozbuild/backend/recursivemake.py index d19056ea79a..901a9b9c5a3 100644 --- a/python/mozbuild/mozbuild/backend/recursivemake.py +++ b/python/mozbuild/mozbuild/backend/recursivemake.py @@ -68,6 +68,74 @@ from ..util import ( ) from ..makeutil import Makefile +MOZBUILD_VARIABLES = [ + 'ANDROID_GENERATED_RESFILES', + 'ANDROID_RES_DIRS', + 'CMSRCS', + 'CMMSRCS', + 'CPP_UNIT_TESTS', + 'DIRS', + 'EXTRA_DSO_LDOPTS', + 'EXTRA_JS_MODULES', + 'EXTRA_PP_COMPONENTS', + 'EXTRA_PP_JS_MODULES', + 'FORCE_SHARED_LIB', + 'FORCE_STATIC_LIB', + 'FINAL_LIBRARY', + 'HOST_CSRCS', + 'HOST_CMMSRCS', + 'HOST_EXTRA_LIBS', + 'HOST_LIBRARY_NAME', + 'HOST_PROGRAM', + 'HOST_SIMPLE_PROGRAMS', + 'IS_COMPONENT', + 'JAR_MANIFEST', + 'JAVA_JAR_TARGETS', + 'LD_VERSION_SCRIPT', + 'LIBRARY_NAME', + 'LIBS', + 'MAKE_FRAMEWORK', + 'MODULE', + 'MSVC_ENABLE_PGO', + 'NO_DIST_INSTALL', + 'OS_LIBS', + 'PARALLEL_DIRS', + 'PREF_JS_EXPORTS', + 'PROGRAM', + 'PYTHON_UNIT_TESTS', + 'RESOURCE_FILES', + 'SDK_HEADERS', + 'SDK_LIBRARY', + 'SHARED_LIBRARY_LIBS', + 'SHARED_LIBRARY_NAME', + 'SIMPLE_PROGRAMS', + 'SONAME', + 'STATIC_LIBRARY_NAME', + 'TEST_DIRS', + 'TOOL_DIRS', + 'XPCSHELL_TESTS', + 'XPIDL_MODULE', +] + +DEPRECATED_VARIABLES = [ + 'ANDROID_RESFILES', + 'EXPORT_LIBRARY', + 'EXTRA_LIBS', + 'HOST_LIBS', + 'LIBXUL_LIBRARY', + 'MOCHITEST_A11Y_FILES', + 'MOCHITEST_BROWSER_FILES', + 'MOCHITEST_BROWSER_FILES_PARTS', + 'MOCHITEST_CHROME_FILES', + 'MOCHITEST_FILES', + 'MOCHITEST_FILES_PARTS', + 'MOCHITEST_METRO_FILES', + 'MOCHITEST_ROBOCOP_FILES', + 'SHORT_LIBNAME', + 'TESTING_JS_MODULES', + 'TESTING_JS_MODULE_DIR', +] + class BackendMakeFile(object): """Represents a generated backend.mk file. @@ -623,6 +691,18 @@ class RecursiveMakeBackend(CommonBackend): rule = makefile.create_rule(['$(all_absolute_unified_files)']) rule.add_dependencies(['$(CURDIR)/%: %']) + def _check_blacklisted_variables(self, makefile_in, makefile_content): + for x in MOZBUILD_VARIABLES: + if re.search(r'[^#]\b%s\s*[:?+]?=' % x, makefile_content, re.M): + raise Exception('Variable %s is defined in %s. It should ' + 'only be defined in moz.build files.' % (x, makefile_in)) + + for x in DEPRECATED_VARIABLES: + if re.search(r'[^#]\b%s\s*[:?+]?=' % x, makefile_content, re.M): + raise Exception('Variable %s is defined in %s. This variable ' + 'has been deprecated. It does nothing. It must be removed ' + 'in order to build.' % (x, makefile_in)) + def consume_finished(self): CommonBackend.consume_finished(self) @@ -670,6 +750,10 @@ class RecursiveMakeBackend(CommonBackend): self._no_skip['tools'].add(mozpath.relpath(objdir, self.environment.topobjdir)) + # Detect any Makefile.ins that contain variables on the + # moz.build-only list + self._check_blacklisted_variables(makefile_in, content) + self._fill_root_mk() # Write out a dependency file used to determine whether a config.status