[Pkg-mozext-commits] [requestpolicy] 07/65: [ref] Makefile: get rid of duplicate code

David Prévot taffit at moszumanska.debian.org
Fri Mar 25 22:59:46 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository requestpolicy.

commit 1571220aab0cceeb461090fc980b60efeaf500e6
Author: Martin Kimmerle <dev at 256k.de>
Date:   Tue Jan 5 11:13:34 2016 +0100

    [ref] Makefile: get rid of duplicate code
    
    Resolves #698
---
 Makefile                      | 597 ++++++++++++++++++------------------------
 tests/xpcshell/head_loadrp.js |   2 +-
 2 files changed, 257 insertions(+), 342 deletions(-)

diff --git a/Makefile b/Makefile
index e120a29..d37e5be 100644
--- a/Makefile
+++ b/Makefile
@@ -2,322 +2,222 @@
 # Otherwise .RECIPEPREFIX would have to be set.
 
 
-# ==============================================================================
-# create variables
-# ==============================================================================
+#===============================================================================
+# general variables and targets
+#===============================================================================
 
-# _________________
-# general variables
-#
-
-SHELL := /bin/bash
+SHELL      := /bin/bash
+ZIP        := zip
+PREPROCESS := /usr/bin/preprocess --content-types-path build/preprocess-content-types.txt
 
-extension_name := requestpolicy
+#-------------------------------------------------------------------------------
+# extension metadata
+#-------------------------------------------------------------------------------
 
+extension_name        := requestpolicy
 amo__extension_id     := rpcontinued at requestpolicy.org
 off_amo__extension_id := rpcontinued at non-amo.requestpolicy.org
 
+#-------------------------------------------------------------------------------
+# directories
+#-------------------------------------------------------------------------------
 
-# ____________________________________
-# generating XPIs -- general variables
-#
-
-# The zip application to be used.
-ZIP := zip
-PREPROCESS := /usr/bin/preprocess --content-types-path build/preprocess-content-types.txt
-
-source_dirname := src
-build_dirname := build
-dist_dirname := dist
-
-source_path := $(source_dirname)/
-dist_path := $(dist_dirname)/
+source_dir     := src
+build_dir_root := build
+dist_dir       := dist
 
+# create the dist directory
+$(dist_dir):
+	@mkdir -p $(dist_dir)
 
-# _____________________________________________
-# RequestPolicy XPI -- collect the files' paths
-#
+#-------------------------------------------------------------------------------
+# other
+#-------------------------------------------------------------------------------
 
-# files which are simply copied
-src__copy_files := \
-		$(source_dirname)/chrome.manifest \
-		$(source_dirname)/install.rdf \
-		$(source_dirname)/README \
-		$(source_dirname)/LICENSE \
-		$(wildcard $(source_dirname)/content/settings/*.css) \
-		$(wildcard $(source_dirname)/content/settings/*.html) \
-		$(wildcard $(source_dirname)/content/*.html) \
-		$(wildcard $(source_dirname)/content/ui/*.xul) \
-		$(wildcard $(source_dirname)/locale/*/*.dtd) \
-		$(wildcard $(source_dirname)/locale/*/*.properties) \
-		$(wildcard $(source_dirname)/skin/*.css) \
-		$(wildcard $(source_dirname)/skin/*.png) \
-		$(wildcard $(source_dirname)/skin/*.svg) \
-		$(shell find $(source_dirname) -type f -iname "jquery*.js")
-
-# JavaScript files which will be (pre)processed.
-# The `copy_files` will be filtered out.
-src__jspp_files := \
-		$(filter-out $(src__copy_files), \
-				$(shell find $(source_dirname) -type f -regex ".*\.jsm?") \
-		)
+.PHONY: preprocessor
+preprocessor: $(build_dir_root)/preprocess-content-types.txt
+$(build_dir_root)/preprocess-content-types.txt:
+	echo 'JavaScript .jsm' > $@
 
-# all source files
-src__all_files := $(src__copy_files) $(src__jspp_files)
 
+#===============================================================================
+# Building RequestPolicy
+#===============================================================================
 
-# Create generic variables without path prefixs.
-rp_all_files  := $(patsubst $(source_path)%,%,$(src__all_files))
-rp_jspp_files := $(patsubst $(source_path)%,%,$(src__jspp_files))
-rp_copy_files := $(patsubst $(source_path)%,%,$(src__copy_files))
+#-------------------------------------------------------------------------------
+# Meta-Targets
+#-------------------------------------------------------------------------------
 
-rp_deleted_files :=
-rp_empty_dirs :=
+define make_xpi
+	@$(MAKE) --no-print-directory _xpi BUILD=$(1)
+endef
 
-# _____________________________________
-# vars for generating the "off-AMO" XPI
-#
+define make_files
+	@$(MAKE) --no-print-directory _files BUILD=$(1)
+endef
 
-off_amo__build_path := $(build_dirname)/off-amo/
+.PHONY: all _xpi _files \
+	xpi unit-testing-xpi amo-xpi \
+	unit-testing-files
 
-off_amo__xpi_file := $(dist_path)$(extension_name).xpi
+.DEFAULT_GOAL := all
 
-off_amo__all_files  := $(addprefix $(off_amo__build_path),$(rp_all_files))
-off_amo__jspp_files := $(addprefix $(off_amo__build_path),$(rp_jspp_files))
-off_amo__copy_files := $(addprefix $(off_amo__build_path),$(rp_copy_files))
+all: xpi
+xpi:
+	$(call make_xpi,off_amo)
+unit-testing-xpi:
+	$(call make_xpi,unit_testing)
+amo-xpi:
+	$(call make_xpi,amo)
 
+unit-testing-files:
+	$(call make_files,unit_testing)
 
-# detect deleted files and empty directories
-off_amo__deleted_files :=
-off_amo__empty_dirs :=
-ifneq "$(wildcard $(off_amo__build_path))" ""
-# files that have been deleted but still exist in the build directory.
-off_amo__deleted_files := $(shell find $(off_amo__build_path) -type f | \
-		grep -v "META-INF" | \
-		grep -F -v $(addprefix -e ,$(off_amo__all_files)))
-# empty directories. -mindepth 1 to exclude the build directory itself.
-off_amo__empty_dirs := $(shell find $(off_amo__build_path) -mindepth 1 -type d -empty)
-endif
-rp_deleted_files += $(off_amo__deleted_files)
-rp_empty_dirs += $(off_amo__empty_dirs)
+#-------------------------------------------------------------------------------
+# [VARIABLES] configuration of different builds
+#-------------------------------------------------------------------------------
 
+alias__off_amo       := off-AMO
+alias__amo           := AMO
+alias__unit_testing  := unit-testing
 
-# _________________________________
-# vars for generating the "AMO" XPI
-#
+extension_id__off_amo      := $(off_amo__extension_id)
+extension_id__amo          := $(amo__extension_id)
+extension_id__unit_testing := $(off_amo__extension_id)
 
-amo__build_path := $(build_dirname)/amo/
+xpi_file__off_amo      := $(dist_dir)/$(extension_name).xpi
+xpi_file__amo          := $(dist_dir)/$(extension_name)-amo.xpi
+xpi_file__unit_testing := $(dist_dir)/$(extension_name)-unit-testing.xpi
 
-amo__xpi_file := $(dist_path)$(extension_name)-amo.xpi
+preprocess_args__off_amo      :=
+preprocess_args__amo          := -D AMO
+preprocess_args__unit_testing := --keep-lines -D UNIT_TESTING
 
-amo__all_files  := $(addprefix $(amo__build_path),$(rp_all_files))
-amo__jspp_files := $(addprefix $(amo__build_path),$(rp_jspp_files))
-amo__copy_files := $(addprefix $(amo__build_path),$(rp_copy_files))
+#-------------------------------------------------------------------------------
+# [VARIABLES] this configuration
+#-------------------------------------------------------------------------------
 
+current_build__alias           := $(alias__$(BUILD))
+current_build__extension_id    := $(extension_id__$(BUILD))
+current_build__xpi_file        := $(xpi_file__$(BUILD))
+current_build__preprocess_args := $(preprocess_args__$(BUILD))
 
-# detect deleted files and empty directories
-amo__deleted_files :=
-amo__empty_dirs :=
-ifneq "$(wildcard $(amo__build_path))" ""
-# files that have been deleted but still exist in the build directory.
-amo__deleted_files := \
-		$(shell find $(amo__build_path) -type f | \
-		grep -v "META-INF" | \
-		grep -F -v $(addprefix -e ,$(amo__all_files)))
-# empty directories. -mindepth 1 to exclude the build directory itself.
-amo__empty_dirs := $(shell find $(amo__build_path) -mindepth 1 -type d -empty)
-endif
-rp_deleted_files += $(amo__deleted_files)
-rp_empty_dirs += $(amo__empty_dirs)
+#-------------------------------------------------------------------------------
+# [VARIABLES] collect source files
+#-------------------------------------------------------------------------------
 
+# files which are simply copied
+src__copy_files := \
+		$(source_dir)/chrome.manifest \
+		$(source_dir)/install.rdf \
+		$(source_dir)/README \
+		$(source_dir)/LICENSE \
+		$(wildcard $(source_dir)/content/settings/*.css) \
+		$(wildcard $(source_dir)/content/settings/*.html) \
+		$(wildcard $(source_dir)/content/*.html) \
+		$(wildcard $(source_dir)/content/ui/*.xul) \
+		$(wildcard $(source_dir)/locale/*/*.dtd) \
+		$(wildcard $(source_dir)/locale/*/*.properties) \
+		$(wildcard $(source_dir)/skin/*.css) \
+		$(wildcard $(source_dir)/skin/*.png) \
+		$(wildcard $(source_dir)/skin/*.svg) \
+		$(shell find $(source_dir) -type f -iname "jquery*.js")
 
-# ________________________________________
-# vars for generating the unit-testing XPI
-#
+# JavaScript files which will be (pre)processed.
+# The `copy_files` will be filtered out.
+src__jspp_files := \
+		$(filter-out $(src__copy_files), \
+				$(shell find $(source_dir) -type f -regex ".*\.jsm?") \
+		)
 
-unit_testing__build_path := $(build_dirname)/unit-testing/
+# all source files
+src__all_files := $(src__copy_files) $(src__jspp_files)
 
-unit_testing__xpi_file := $(dist_path)$(extension_name)-unit-testing.xpi
+#-------------------------------------------------------------------------------
+# [VARIABLES] paths in the "build" directory
+#-------------------------------------------------------------------------------
 
-unit_testing__all_files  := $(addprefix $(unit_testing__build_path),$(rp_all_files))
-unit_testing__jspp_files := $(addprefix $(unit_testing__build_path),$(rp_jspp_files))
-unit_testing__copy_files := $(addprefix $(unit_testing__build_path),$(rp_copy_files))
+current_build_dir := $(build_dir_root)/$(BUILD)
 
+build__all_files  := $(patsubst $(source_dir)/%,$(current_build_dir)/%,$(src__all_files))
+build__jspp_files := $(patsubst $(source_dir)/%,$(current_build_dir)/%,$(src__jspp_files))
+build__copy_files := $(patsubst $(source_dir)/%,$(current_build_dir)/%,$(src__copy_files))
 
 # detect deleted files and empty directories
-unit_testing__deleted_files :=
-unit_testing__empty_dirs :=
-ifneq "$(wildcard $(unit_testing__build_path))" ""
-# files that have been deleted but still exist in the build directory.
-unit_testing__deleted_files := \
-		$(shell find $(unit_testing__build_path) -type f | \
-		grep -v "META-INF" | \
-		grep -F -v $(addprefix -e ,$(unit_testing__all_files)))
-# empty directories. -mindepth 1 to exclude the build directory itself.
-unit_testing__empty_dirs := $(shell find $(unit_testing__build_path) -mindepth 1 -type d -empty)
+ifdef BUILD
+ifneq "$(wildcard $(current_build_dir))" ""
+	# files that have been deleted but still exist in the build directory.
+	build__deleted_files := $(shell find $(current_build_dir) -type f | \
+		grep -F -v $(addprefix -e ,$(build__all_files)))
+	# empty directories. -mindepth 1 to exclude the build directory itself.
+	build__empty_dirs := $(shell find $(current_build_dir) -mindepth 1 -type d -empty)
 endif
-rp_deleted_files += $(unit_testing__deleted_files)
-rp_empty_dirs += $(unit_testing__empty_dirs)
-
-
-# ______________________________________
-# vars for generating the Dev Helper XPI
-#
-
-dev_helper__source_dirname := tests/helper-addons/dev-helper
-dev_helper__source_path := $(dev_helper__source_dirname)/
-
-dev_helper__src__all_files := $(shell find $(dev_helper__source_dirname) -type f -regex ".*\.jsm?") \
-		$(dev_helper__source_dirname)/chrome.manifest \
-		$(dev_helper__source_dirname)/install.rdf
-
-dev_helper__xpi_file := $(dist_path)rpc-dev-helper.xpi
-
-
-# _________________________________
-# vars for generating the Dummy XPI
-#
-
-dummy_ext__source_dirname := tests/helper-addons/dummy-ext
-dummy_ext__source_path := $(dummy_ext__source_dirname)/
-
-dummy_ext__src__all_files := $(shell find $(dummy_ext__source_dirname) -type f -regex ".*\.jsm?") \
-		$(dummy_ext__source_dirname)/install.rdf
-
-dummy_ext__xpi_file := $(dist_path)dummy-ext.xpi
-
-
-# __________________
-# vars for mozrunner
-#
-
-# the default XPI to use for mozrunner
-moz_xpi := $(unit_testing__xpi_file)
-
-# select the default app. Can be overridden e.g. via `make run app='seamonkey'`
-app := firefox
-# default app branch
-ifeq ($(app),firefox)
-app_branch := nightly
-else
-app_branch := release
 endif
-binary_filename := $(app)
-app_binary := .mozilla/software/$(app)/$(app_branch)/$(binary_filename)
-
-# __________________
-# vars for mozrunner
-#
-
-mozrunner_prefs_ini := tests/mozrunner-prefs.ini
-
-
-
-# ==============================================================================
-# define targets
-# ==============================================================================
 
-.PHONY: all build dist
+build_files_including_removals := $(build__all_files) $(build__deleted_files) $(build__empty_dirs)
 
-# set "all" to be the default target
-.DEFAULT_GOAL := all
+#-------------------------------------------------------------------------------
+# [TARGETS] intermediate targets
+#-------------------------------------------------------------------------------
 
-# building means to prepare all files in the build directory
-build: $(off_amo__build_path)
+_xpi: $(current_build__xpi_file)
+_files: $(build_files_including_removals)
 
-# build and create XPI file
-all: $(off_amo__xpi_file)
-	@echo "Build finished successfully."
-dist xpi: $(off_amo__xpi_file)
+#-------------------------------------------------------------------------------
+# [TARGETS] preprocess and/or copy files (src/ --> build/)
+#-------------------------------------------------------------------------------
 
-# create the dist directory
-$(dist_path):
-	@mkdir -p $(dist_path)
+$(build__jspp_files) : $(current_build_dir)/% : $(source_dir)/% | preprocessor
+	@mkdir -p $(@D)
+	$(PREPROCESS) $(current_build__preprocess_args) $< > $@
 
-.PHONY: preprocessor
-preprocessor: $(build_dirname)/preprocess-content-types.txt
-$(build_dirname)/preprocess-content-types.txt:
-	echo 'JavaScript .jsm' > $@
+$(build__copy_files) : $(current_build_dir)/% : $(source_dir)/%
+	@mkdir -p $(@D)
+	@# Use `--dereference` to copy the files instead of the symlinks.
+	cp --dereference $< $@
 
+	@if [[ "$(notdir $@)" == "install.rdf" ]]; then \
+		if [[ "$(current_build__extension_id)" == "$(amo__extension_id)" ]]; then \
+	  		echo 'install.rdf: changing the Extension ID !' ; \
+	  		sed -i s/$(off_amo__extension_id)/$(amo__extension_id)/ $@ ; \
+		fi ; \
+	fi
 
-# ________________________
-# create the "off-AMO" XPI
-#
-
-# Note: Here the build path is added as a prerequisite, *not* the
-#       phony "build" target. This avoids re-packaging in case
-#       nothing has changed.
-#       Also $(off_amo__all_files) is needed as prerequisite, so that the
-#       xpi gets updated.
-$(off_amo__xpi_file): $(off_amo__build_path) $(off_amo__all_files) | $(dist_path)
-	@rm -f $(off_amo__xpi_file)
-	@echo "Creating XPI file."
-	@cd $(off_amo__build_path) && \
-	$(ZIP) $(abspath $(off_amo__xpi_file)) $(rp_all_files)
-	@echo "Creating XPI file: Done!"
-
-# ____________________
-# create the "AMO" XPI
-#
-
-amo-xpi $(amo__xpi_file): $(amo__build_path) $(amo__all_files) | $(dist_path)
-	@rm -f $(amo__xpi_file)
-	@echo "Creating AMO XPI."
-	@cd $(amo__build_path) && \
-	$(ZIP) $(abspath $(amo__xpi_file)) $(rp_all_files)
-	@echo "Creating AMO XPI: Done!"
-
-# ___________________________
-# create the unit-testing XPI
-#
-
-unit-testing-xpi $(unit_testing__xpi_file): $(unit_testing__build_path) $(unit_testing__all_files) | $(dist_path)
-	@rm -f $(unit_testing__xpi_file)
-	@echo "Creating unit-testing XPI."
-	@cd $(unit_testing__build_path) && \
-	$(ZIP) $(abspath $(unit_testing__xpi_file)) $(rp_all_files)
-	@echo "Creating unit-testing XPI: Done!"
-
-
-# _________________________
-# create the Dev Helper XPI
-#
+#-------------------------------------------------------------------------------
+# [TARGETS] remove files/dirs no longer existant in the source
+#-------------------------------------------------------------------------------
 
-# For now use FORCE, i.e. create the XPI every time. If the
-# 'FORCE' should be removed, deleted files have to be detected,
-# just like for the other XPIs.
-dev-helper-xpi $(dev_helper__xpi_file): $(dev_helper__src__all_files) FORCE | $(dist_path)
-	@rm -f $(dev_helper__xpi_file)
-	@echo "Creating 'RPC Dev Helper' XPI."
-	@cd $(dev_helper__source_dirname) && \
-	$(ZIP) $(abspath $(dev_helper__xpi_file)) $(patsubst $(dev_helper__source_path)%,%,$(dev_helper__src__all_files))
-	@echo "Creating 'RPC Dev Helper' XPI: Done!"
+$(build__empty_dirs): FORCE
+	rmdir $@
 
+$(build__deleted_files): FORCE
+	@# delete:
+	rm $@
+	@# delete parent dirs if empty:
+	@rmdir --parents --ignore-fail-on-non-empty $(@D)
 
-# ____________________
-# create the Dummy XPI
-#
+#-------------------------------------------------------------------------------
+# [TARGETS] package the files to a XPI
+#-------------------------------------------------------------------------------
 
-# For now use FORCE, i.e. create the XPI every time. If the
-# 'FORCE' should be removed, deleted files have to be detected,
-# just like for the other XPIs.
-dummy-xpi $(dummy_ext__xpi_file): $(dummy_ext__src__all_files) FORCE | $(dist_path)
-	@rm -f $(dummy_ext__xpi_file)
-	@echo "Creating 'Dummy' XPI."
-	@cd $(dummy_ext__source_dirname) && \
-	$(ZIP) $(abspath $(dummy_ext__xpi_file)) $(patsubst $(dummy_ext__source_path)%,%,$(dummy_ext__src__all_files))
-	@echo "Creating 'Dummy' XPI: Done!"
+$(current_build__xpi_file): $(build_files_including_removals) | $(dist_dir)
+	@rm -f $(current_build__xpi_file)
+	@echo "Creating \"$(current_build__alias)\" XPI file."
+	@cd $(current_build_dir) && \
+	$(ZIP) $(abspath $(current_build__xpi_file)) \
+		$(patsubst $(source_dir)/%,%,$(src__all_files))
+	@echo "Creating \"$(current_build__alias)\" XPI file: Done!"
 
 
-# _________________________________________
-# create the XPI from any tag or any commit
-#
+#===============================================================================
+# Create a XPI from any git-tag or git-commit
+#===============================================================================
 
 # Default tree-ish.
 specific_xpi__treeish := v1.0.beta9.3__preprocess.py
 
-specific_xpi__file := $(dist_path)$(extension_name)-$(specific_xpi__treeish).xpi
-specific_xpi__build_path := $(build_dirname)/specific-xpi
+specific_xpi__file := $(dist_dir)/$(extension_name)-$(specific_xpi__treeish).xpi
+specific_xpi__build_dir := $(build_dir_root)/specific-xpi
 
 # create the XPI only if it doesn't exist yet
 .PHONY: specific-xpi
@@ -325,103 +225,111 @@ specific-xpi: $(specific_xpi__file)
 
 $(specific_xpi__file):
 	@# remove the build directory (if it exists) and recreate it
-	rm -rf $(specific_xpi__build_path)
-	mkdir -p $(specific_xpi__build_path)
+	rm -rf $(specific_xpi__build_dir)
+	mkdir -p $(specific_xpi__build_dir)
 
 	@# copy the content of the tree-ish to the build dir
 	@# see https://stackoverflow.com/questions/160608/do-a-git-export-like-svn-export/9416271#9416271
-	git archive $(specific_xpi__treeish) | (cd $(specific_xpi__build_path); tar x)
+	git archive $(specific_xpi__treeish) | (cd $(specific_xpi__build_dir); tar x)
 
 	@# run `make` in the build directory
-	(cd $(specific_xpi__build_path); make)
+	(cd $(specific_xpi__build_dir); make)
 
 	@# move the created XPI from the build directory to the actual
 	@# dist directory
-	mv $(specific_xpi__build_path)/dist/*.xpi $(specific_xpi__file)
+	mv $(specific_xpi__build_dir)/dist/*.xpi $(specific_xpi__file)
 
-# ______________________________________
-# create the files for the "off-AMO" XPI
-#
 
-# Process all source files and, if necessary, delete all
-# empty directories and deleted files from the build directory.
-$(off_amo__build_path): $(off_amo__all_files) $(off_amo__deleted_files) $(off_amo__empty_dirs)
+#===============================================================================
+# Other XPIs (simple XPIs)
+#===============================================================================
 
-$(off_amo__jspp_files) : $(off_amo__build_path)% : $(source_path)% | preprocessor
-	@mkdir -p $(@D)
-	$(PREPROCESS) $< > $@
+#-------------------------------------------------------------------------------
+# Meta-Targets
+#-------------------------------------------------------------------------------
 
-$(off_amo__copy_files) : $(off_amo__build_path)% : $(source_path)%
-	@mkdir -p $(@D)
-	@# Use `--dereference` to copy the files instead of the symlinks.
-	cp --dereference $< $@
+define make_other_xpi
+	@$(MAKE) --no-print-directory _other_xpi OTHER_BUILD=$(1)
+endef
 
-# __________________________________
-# create the files for the "AMO" XPI
-#
+.PHONY: _other_xpi \
+	dev-helper-xpi dummy-xpi
 
-$(amo__build_path): $(amo__all_files) $(amo__deleted_files) $(amo__empty_dirs)
+dev-helper-xpi:
+	$(call make_other_xpi,dev_helper)
+dummy-xpi:
+	$(call make_other_xpi,dummy)
 
-$(amo__jspp_files) : $(amo__build_path)% : $(source_path)% | preprocessor
-	@mkdir -p $(@D)
-	$(PREPROCESS) -D AMO $< > $@
+#-------------------------------------------------------------------------------
+# [VARIABLES] configuration of different builds
+#-------------------------------------------------------------------------------
 
-$(amo__copy_files) : $(amo__build_path)% : $(source_path)%
-	@mkdir -p $(@D)
-	cp --dereference $< $@
+alias__dev_helper  := RPC Dev Helper
+alias__dummy       := Dummy
 
-	@if [[ "$(notdir $@)" == "install.rdf" ]]; then \
-	  echo 'using `sed` on install.rdf !' ; \
-	  sed -i s/$(off_amo__extension_id)/$(amo__extension_id)/ $@ ; \
-	fi
+source_path__dev_helper := tests/helper-addons/dev-helper/
+source_path__dummy      := tests/helper-addons/dummy-ext/
 
-# _________________________________________
-# create the files for the unit-testing XPI
-#
+xpi_file__dev_helper  := $(dist_dir)/rpc-dev-helper.xpi
+xpi_file__dummy       := $(dist_dir)/dummy-ext.xpi
 
-$(unit_testing__build_path): $(unit_testing__all_files) $(unit_testing__deleted_files) $(unit_testing__empty_dirs)
+#-------------------------------------------------------------------------------
+# intermediate targets
+#-------------------------------------------------------------------------------
 
-$(unit_testing__jspp_files) : $(unit_testing__build_path)% : $(source_path)% | preprocessor
-	@mkdir -p $(@D)
-	$(PREPROCESS) --keep-lines -D UNIT_TESTING $< > $@
+other_build__alias       := $(alias__$(OTHER_BUILD))
+other_build__source_path := $(source_path__$(OTHER_BUILD))
+other_build__xpi_file    := $(xpi_file__$(OTHER_BUILD))
 
-$(unit_testing__copy_files) : $(unit_testing__build_path)% : $(source_path)%
-	@mkdir -p $(@D)
-	cp --dereference $< $@
+#-------------------------------------------------------------------------------
+# [VARIABLES] collect source files
+#-------------------------------------------------------------------------------
 
-.PHONY: unit-testing-files
-unit-testing-files: $(unit_testing__all_files)
+other_build__src__all_files := $(shell find $(other_build__source_path) -type f)
 
+#-------------------------------------------------------------------------------
+# TARGETS
+#-------------------------------------------------------------------------------
 
-# __________________
-# "cleaning" targets
-#
+_other_xpi: $(other_build__xpi_file)
 
-# This cleans all temporary files and directories created by 'make'.
-.PHONY: clean
-clean:
-	@rm -rf $(dist_dirname)/*.xpi $(build_dirname)/*
-	@echo "Cleanup is done."
+# For now use FORCE, i.e. create the XPI every time. If the
+# 'FORCE' should be removed, deleted files have to be detected,
+# just like for the RequestPolicy XPIs.
+$(other_build__xpi_file): $(other_build__src__all_files) FORCE | $(dist_dir)
+	@rm -f $(other_build__xpi_file)
+	@echo "Creating \"$(other_build__alias)\" XPI."
+	@cd $(other_build__source_path) && \
+	$(ZIP) $(abspath $(other_build__xpi_file)) $(patsubst $(other_build__source_path)%,%,$(other_build__src__all_files))
+	@echo "Creating \"$(other_build__alias)\" XPI: Done!"
 
-# remove empty directories
-$(rp_empty_dirs): FORCE
-	rmdir $@
 
-# delete deleted files that still exist in the build directory.
-# this target should be forced
-$(rp_deleted_files): FORCE
-	@# delete:
-	rm $@
-	@# delete parent dirs if empty:
-	@rmdir --parents --ignore-fail-on-non-empty $(@D)
+#===============================================================================
+# Running and Testing RequestPolicy
+#===============================================================================
+
+#-------------------------------------------------------------------------------
+# [VARIABLES] general variables
+#-------------------------------------------------------------------------------
+
+# select the default app. Can be overridden e.g. via `make run app='seamonkey'`
+app := firefox
+# default app branch
+ifeq ($(app),firefox)
+	app_branch := nightly
+else
+	app_branch := release
+endif
+binary_filename := $(app)
+app_binary := .mozilla/software/$(app)/$(app_branch)/$(binary_filename)
+
+mozrunner_prefs_ini := tests/mozrunner-prefs.ini
 
-# ____________________________
+#-------------------------------------------------------------------------------
 # virtual python environments
-# for running and unit-testing
-#
+#-------------------------------------------------------------------------------
 
 .PHONY: venv
-
 venv: .venv/bin/activate
 .venv/bin/activate: requirements.txt
 	test -d .venv || virtualenv --prompt='(RP)' .venv
@@ -434,27 +342,26 @@ venv: .venv/bin/activate
 	touch --no-create .venv/bin/activate ; \
 	)
 
-# ___________
+#-------------------------------------------------------------------------------
 # run firefox
-#
+#-------------------------------------------------------------------------------
 
 # arguments for mozrunner
-mozrunner_args := -a $(moz_xpi) -a $(dev_helper__xpi_file)
+mozrunner_args := -a $(xpi_file__unit_testing) -a $(xpi_file__dev_helper)
 mozrunner_args += -b $(app_binary)
 mozrunner_args += --preferences=$(mozrunner_prefs_ini):dev
 mozrunner_args += $(moz_args)
 
 .PHONY: run
-run: venv $(moz_xpi) $(dev_helper__xpi_file)
+run: venv unit-testing-xpi dev-helper-xpi
 	( \
 	source .venv/bin/activate ; \
 	mozrunner $(mozrunner_args) ; \
 	)
 
-
-# ____________
-# unit testing
-#
+#-------------------------------------------------------------------------------
+# unit testing: Marionette
+#-------------------------------------------------------------------------------
 
 # Note: currently you have to do some setup before this will work.
 # see https://github.com/RequestPolicyContinued/requestpolicy/wiki/Setting-up-a-development-environment#unit-tests-for-requestpolicy
@@ -479,14 +386,14 @@ marionette: venv \
 	( \
 	source .venv/bin/activate ; \
 	export PYTHONPATH=tests/marionette/ ; \
-	profile_dir=`mozprofile -a $(unit_testing__xpi_file) -a $(dev_helper__xpi_file) --preferences=$(mozrunner_prefs_ini):marionette` ; \
+	profile_dir=`mozprofile -a $(xpi_file__unit_testing) -a $(xpi_file__dev_helper) --preferences=$(mozrunner_prefs_ini):marionette` ; \
 	firefox-ui-functional --binary=$(app_binary) --profile=$$profile_dir $(marionette_prefs) $(marionette_tests) ; \
 	rm -rf $$profile_dir ; \
 	)
 
-# ____________________
+#-------------------------------------------------------------------------------
 # static code analysis
-#
+#-------------------------------------------------------------------------------
 
 .PHONY: static-analysis jshint
 static-analysis: jshint jscs
@@ -495,9 +402,17 @@ jshint:
 jscs:
 	jscs src/
 
-# ________________
-# "helper" targets
-#
 
+#===============================================================================
+# other targets
+#===============================================================================
+
+# Clean all temporary files and directories created by 'make'.
+.PHONY: clean
+clean:
+	@rm -rf $(dist_dir)/*.xpi $(build_dir_root)/*
+	@echo "Cleanup is done."
+
+# Can force a target to be executed every time.
 .PHONY: FORCE
 FORCE:
diff --git a/tests/xpcshell/head_loadrp.js b/tests/xpcshell/head_loadrp.js
index 7eda2b2..9653cf7 100644
--- a/tests/xpcshell/head_loadrp.js
+++ b/tests/xpcshell/head_loadrp.js
@@ -22,7 +22,7 @@ function getRPChromeManifest() {
   var cwd = Services.dirsvc.get("CurWorkD", Ci.nsIFile);
 
   var manifestFile = cwd.parent.parent.clone();
-  manifestFile.appendRelativePath("build/unit-testing/chrome.manifest");
+  manifestFile.appendRelativePath("build/unit_testing/chrome.manifest");
   return manifestFile;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/requestpolicy.git



More information about the Pkg-mozext-commits mailing list