Bug 852814 - Move mozbuild variable blacklist logic into the backend. r=gps

This commit is contained in:
Brian O'Keefe 2015-03-27 15:39:34 -04:00
parent 3ae80812fb
commit 6f8d3debc1
5 changed files with 84 additions and 109 deletions

View File

@ -53,83 +53,6 @@ include_deps = $(eval $(if $(2),,-)include $(1))
ifndef INCLUDED_AUTOCONF_MK ifndef INCLUDED_AUTOCONF_MK
default:: default::
else 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 TIERS := export $(if $(COMPILE_ENVIRONMENT),compile )misc libs tools
endif endif

View File

@ -34,18 +34,6 @@ ifndef EXTERNALLY_MANAGED_MAKE_FILE
# scenarios. # scenarios.
_current_makefile = $(CURDIR)/$(firstword $(MAKEFILE_LIST)) _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, # 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 # the backend hasn't been properly configured. We want this to be a fatal
# error, hence not using "-include". # error, hence not using "-include".
@ -54,8 +42,6 @@ GLOBAL_DEPS += backend.mk
include backend.mk include backend.mk
endif 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 endif
space = $(NULL) $(NULL) space = $(NULL) $(NULL)
@ -697,6 +683,3 @@ export CL_INCLUDES_PREFIX
export NONASCII export NONASCII
DEFINES += -DNO_NSPR_10_SUPPORT 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))'))

View File

@ -6,10 +6,6 @@ ifndef INCLUDED_RULES_MK
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
endif 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: # The traditional model of directory traversal with make is as follows:
# make -C foo # make -C foo
# Entering foo # Entering foo

View File

@ -16,10 +16,6 @@ $(error Do not include rules.mk twice!)
endif endif
INCLUDED_RULES_MK = 1 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 ifndef INCLUDED_CONFIG_MK
include $(topsrcdir)/config/config.mk include $(topsrcdir)/config/config.mk
endif endif
@ -1635,10 +1631,3 @@ endif
export:: $(GENERATED_FILES) export:: $(GENERATED_FILES)
GARBAGE += $(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))'))

View File

@ -68,6 +68,74 @@ from ..util import (
) )
from ..makeutil import Makefile 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): class BackendMakeFile(object):
"""Represents a generated backend.mk file. """Represents a generated backend.mk file.
@ -623,6 +691,18 @@ class RecursiveMakeBackend(CommonBackend):
rule = makefile.create_rule(['$(all_absolute_unified_files)']) rule = makefile.create_rule(['$(all_absolute_unified_files)'])
rule.add_dependencies(['$(CURDIR)/%: %']) 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): def consume_finished(self):
CommonBackend.consume_finished(self) CommonBackend.consume_finished(self)
@ -670,6 +750,10 @@ class RecursiveMakeBackend(CommonBackend):
self._no_skip['tools'].add(mozpath.relpath(objdir, self._no_skip['tools'].add(mozpath.relpath(objdir,
self.environment.topobjdir)) 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() self._fill_root_mk()
# Write out a dependency file used to determine whether a config.status # Write out a dependency file used to determine whether a config.status