Bug 770426 - Replace double colon rules with dependency chains for preprocessing rules. r=khuey

This commit is contained in:
Mike Hommey 2012-07-23 07:42:22 +02:00
parent 47fbe17a63
commit fd7fe8283e
4 changed files with 87 additions and 105 deletions

View File

@ -1232,17 +1232,9 @@ PREF_PPFLAGS = --line-endings=crlf
endif
ifndef NO_DIST_INSTALL
$(FINAL_TARGET)/$(PREF_DIR):
$(NSINSTALL) -D $@
libs:: $(FINAL_TARGET)/$(PREF_DIR)
libs:: $(PREF_JS_EXPORTS)
$(EXIT_ON_ERROR) \
for i in $^; do \
dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \
$(RM) -f $$dest; \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR)
PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS)
PP_TARGETS += PREF_JS_EXPORTS
endif
endif
@ -1322,6 +1314,7 @@ libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
ifndef NO_DIST_INSTALL
$(call install_cmd,$(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components)
ifndef NO_INTERFACES_MANIFEST
libs:: $(call mkdir_deps,$(FINAL_TARGET)/components)
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
endif
@ -1372,22 +1365,15 @@ endif
endif
ifdef EXTRA_PP_COMPONENTS
libs:: $(EXTRA_PP_COMPONENTS)
ifndef NO_DIST_INSTALL
$(EXIT_ON_ERROR) \
$(NSINSTALL) -D $(FINAL_TARGET)/components; \
for i in $^; do \
fname=`basename $$i`; \
dest=$(FINAL_TARGET)/components/$${fname}; \
$(RM) -f $$dest; \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components
PP_TARGETS += EXTRA_PP_COMPONENTS
endif
endif
EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
ifneq (,$(EXTRA_MANIFESTS))
libs::
libs:: $(call mkdir_deps,$(FINAL_TARGET))
$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
endif
@ -1405,17 +1391,10 @@ endif
endif
ifdef EXTRA_PP_JS_MODULES
libs:: $(EXTRA_PP_JS_MODULES)
ifndef NO_DIST_INSTALL
$(EXIT_ON_ERROR) \
$(NSINSTALL) -D $(JS_MODULES_PATH); \
for i in $^; do \
dest=$(JS_MODULES_PATH)/`basename $$i`; \
$(RM) -f $$dest; \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
EXTRA_PP_JS_MODULES_PATH := $(JS_MODULES_PATH)
PP_TARGETS += EXTRA_PP_JS_MODULES
endif
endif
################################################################################
@ -1486,31 +1465,15 @@ endif
endif
ifneq ($(DIST_FILES),)
$(DIST)/bin:
$(NSINSTALL) -D $@
libs:: $(DIST)/bin
libs:: $(DIST_FILES)
@$(EXIT_ON_ERROR) \
for f in $^; do \
dest=$(FINAL_TARGET)/`basename $$f`; \
$(RM) -f $$dest; \
$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
$(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$$f > $$dest; \
done
DIST_FILES_PATH := $(FINAL_TARGET)
DIST_FILES_FLAGS := $(XULAPP_DEFINES)
PP_TARGETS += DIST_FILES
endif
ifneq ($(DIST_CHROME_FILES),)
libs:: $(DIST_CHROME_FILES)
@$(EXIT_ON_ERROR) \
for f in $^; do \
dest=$(FINAL_TARGET)/chrome/`basename $$f`; \
$(RM) -f $$dest; \
$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
$(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$$f > $$dest; \
done
DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome
DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES)
PP_TARGETS += DIST_CHROME_FILES
endif
ifneq ($(XPI_PKGNAME),)
@ -1668,6 +1631,32 @@ TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
endif
endif
################################################################################
# Preprocessing rules
#
# The PP_TARGETS variable contains a list of all preprocessing target
# categories. Each category defines a target path, and optional extra flags
# like the following:
#
# FOO_PATH := target_path
# FOO_FLAGS := -Dsome_flag
# PP_TARGETS += FOO
# preprocess_file_template defines preprocessing rules.
# $(call preprocess_file_template, source_file, target_path, extra_flags)
define preprocess_file_template
$(2)/$(notdir $(1)): $(1) $$(call mkdir_deps,$(2)) $$(GLOBAL_DEPS)
$$(RM) $$@
$$(PYTHON) $$(topsrcdir)/config/Preprocessor.py $(3) $$(DEFINES) $$(ACDEFINES) $$(XULPPFLAGS) $$< > $$@
libs:: $(2)/$(notdir $(1))
endef
$(foreach category,$(PP_TARGETS),\
$(foreach file,$($(category)),\
$(eval $(call preprocess_file_template,$(file),$($(category)_PATH),$($(category)_FLAGS)))\
)\
)
################################################################################
# Special gmake rules.
################################################################################

View File

@ -1232,17 +1232,9 @@ PREF_PPFLAGS = --line-endings=crlf
endif
ifndef NO_DIST_INSTALL
$(FINAL_TARGET)/$(PREF_DIR):
$(NSINSTALL) -D $@
libs:: $(FINAL_TARGET)/$(PREF_DIR)
libs:: $(PREF_JS_EXPORTS)
$(EXIT_ON_ERROR) \
for i in $^; do \
dest=$(FINAL_TARGET)/$(PREF_DIR)/`basename $$i`; \
$(RM) -f $$dest; \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(PREF_PPFLAGS) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
PREF_JS_EXPORTS_PATH := $(FINAL_TARGET)/$(PREF_DIR)
PREF_JS_EXPORTS_FLAGS := $(PREF_PPFLAGS)
PP_TARGETS += PREF_JS_EXPORTS
endif
endif
@ -1322,6 +1314,7 @@ libs:: $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt
ifndef NO_DIST_INSTALL
$(call install_cmd,$(IFLAGS1) $(XPIDL_GEN_DIR)/$(XPIDL_MODULE).xpt $(FINAL_TARGET)/components)
ifndef NO_INTERFACES_MANIFEST
libs:: $(call mkdir_deps,$(FINAL_TARGET)/components)
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/components/interfaces.manifest "interfaces $(XPIDL_MODULE).xpt"
@$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "manifest components/interfaces.manifest"
endif
@ -1372,22 +1365,15 @@ endif
endif
ifdef EXTRA_PP_COMPONENTS
libs:: $(EXTRA_PP_COMPONENTS)
ifndef NO_DIST_INSTALL
$(EXIT_ON_ERROR) \
$(NSINSTALL) -D $(FINAL_TARGET)/components; \
for i in $^; do \
fname=`basename $$i`; \
dest=$(FINAL_TARGET)/components/$${fname}; \
$(RM) -f $$dest; \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
EXTRA_PP_COMPONENTS_PATH := $(FINAL_TARGET)/components
PP_TARGETS += EXTRA_PP_COMPONENTS
endif
endif
EXTRA_MANIFESTS = $(filter %.manifest,$(EXTRA_COMPONENTS) $(EXTRA_PP_COMPONENTS))
ifneq (,$(EXTRA_MANIFESTS))
libs::
libs:: $(call mkdir_deps,$(FINAL_TARGET))
$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest $(patsubst %,"manifest components/%",$(notdir $(EXTRA_MANIFESTS)))
endif
@ -1405,17 +1391,10 @@ endif
endif
ifdef EXTRA_PP_JS_MODULES
libs:: $(EXTRA_PP_JS_MODULES)
ifndef NO_DIST_INSTALL
$(EXIT_ON_ERROR) \
$(NSINSTALL) -D $(JS_MODULES_PATH); \
for i in $^; do \
dest=$(JS_MODULES_PATH)/`basename $$i`; \
$(RM) -f $$dest; \
$(PYTHON) $(topsrcdir)/config/Preprocessor.py $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) $$i > $$dest; \
done
EXTRA_PP_JS_MODULES_PATH := $(JS_MODULES_PATH)
PP_TARGETS += EXTRA_PP_JS_MODULES
endif
endif
################################################################################
@ -1486,31 +1465,15 @@ endif
endif
ifneq ($(DIST_FILES),)
$(DIST)/bin:
$(NSINSTALL) -D $@
libs:: $(DIST)/bin
libs:: $(DIST_FILES)
@$(EXIT_ON_ERROR) \
for f in $^; do \
dest=$(FINAL_TARGET)/`basename $$f`; \
$(RM) -f $$dest; \
$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
$(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$$f > $$dest; \
done
DIST_FILES_PATH := $(FINAL_TARGET)
DIST_FILES_FLAGS := $(XULAPP_DEFINES)
PP_TARGETS += DIST_FILES
endif
ifneq ($(DIST_CHROME_FILES),)
libs:: $(DIST_CHROME_FILES)
@$(EXIT_ON_ERROR) \
for f in $^; do \
dest=$(FINAL_TARGET)/chrome/`basename $$f`; \
$(RM) -f $$dest; \
$(PYTHON) $(MOZILLA_DIR)/config/Preprocessor.py \
$(XULAPP_DEFINES) $(DEFINES) $(ACDEFINES) $(XULPPFLAGS) \
$$f > $$dest; \
done
DIST_CHROME_FILES_PATH := $(FINAL_TARGET)/chrome
DIST_CHROME_FILES_FLAGS := $(XULAPP_DEFINES)
PP_TARGETS += DIST_CHROME_FILES
endif
ifneq ($(XPI_PKGNAME),)
@ -1668,6 +1631,32 @@ TAGS:: $(CSRCS) $(CPPSRCS) $(HEADERS)
endif
endif
################################################################################
# Preprocessing rules
#
# The PP_TARGETS variable contains a list of all preprocessing target
# categories. Each category defines a target path, and optional extra flags
# like the following:
#
# FOO_PATH := target_path
# FOO_FLAGS := -Dsome_flag
# PP_TARGETS += FOO
# preprocess_file_template defines preprocessing rules.
# $(call preprocess_file_template, source_file, target_path, extra_flags)
define preprocess_file_template
$(2)/$(notdir $(1)): $(1) $$(call mkdir_deps,$(2)) $$(GLOBAL_DEPS)
$$(RM) $$@
$$(PYTHON) $$(topsrcdir)/config/Preprocessor.py $(3) $$(DEFINES) $$(ACDEFINES) $$(XULPPFLAGS) $$< > $$@
libs:: $(2)/$(notdir $(1))
endef
$(foreach category,$(PP_TARGETS),\
$(foreach file,$($(category)),\
$(eval $(call preprocess_file_template,$(file),$($(category)_PATH),$($(category)_FLAGS)))\
)\
)
################################################################################
# Special gmake rules.
################################################################################

View File

@ -29,6 +29,10 @@ TEST_EXTENSIONS_DIR = $(DEPTH)/_tests/testing/mochitest/extensions
include $(topsrcdir)/config/rules.mk
# JarMaker creates a chrome.manifest already, so the one from the source
# directory is not copied if it's not forced to be.
$(FINAL_TARGET)/chrome.manifest: FORCE
libs-preqs = \
$(call mkdir_deps,$(TEST_EXTENSIONS_DIR)) \
$(NULL)

View File

@ -60,7 +60,7 @@ ifdef MOZILLA_OFFICIAL
DEFINES += -DMOZILLA_OFFICIAL
endif
libs::
libs:: $(call mkdir_deps,$(FINAL_TARGET))
$(PYTHON) $(MOZILLA_DIR)/config/buildlist.py $(FINAL_TARGET)/chrome.manifest "resource webapprt ./"
GRE_MILESTONE := $(shell tail -n 1 $(topsrcdir)/config/milestone.txt 2>/dev/null || tail -1 $(topsrcdir)/config/milestone.txt)