From ae5415d4a1000022c568932e7a6efa96e684b016 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Wed, 10 May 2017 19:09:46 +0200 Subject: Make sure the build fails if a docs/rel/test/shell dep fails Before this change, the build would continue, even if a dependency failed to build. This could lead to obscure errors in the middle of a testsuite for instance. With this change, the build fails immediately, exactly like when a regular dependency fails to build. While here, replace most uses of `|| exit $$?` with `set -e`. This simplifies error handling if we need to add more commands to each blocks. Also, echo error messages to stderr. --- core/deps-tools.mk | 10 ++++------ core/deps.mk | 24 ++++++++++++------------ core/docs.mk | 2 +- core/rel.mk | 2 +- core/test.mk | 2 +- plugins/shell.mk | 2 +- 6 files changed, 20 insertions(+), 22 deletions(-) diff --git a/core/deps-tools.mk b/core/deps-tools.mk index d0b5203..de1cc2b 100644 --- a/core/deps-tools.mk +++ b/core/deps-tools.mk @@ -65,22 +65,20 @@ ifeq ($(IS_APP)$(IS_DEP),) $(verbose) rm -f $(ERLANG_MK_RECURSIVE_TMP_LIST) endif ifndef IS_APP - $(verbose) for dep in $(ALL_APPS_DIRS) ; do \ + $(verbose) set -e; for dep in $(ALL_APPS_DIRS) ; do \ $(MAKE) -C $$dep $@ \ IS_APP=1 \ - ERLANG_MK_RECURSIVE_TMP_LIST=$(ERLANG_MK_RECURSIVE_TMP_LIST) \ - || exit $$?; \ + ERLANG_MK_RECURSIVE_TMP_LIST=$(ERLANG_MK_RECURSIVE_TMP_LIST); \ done endif - $(verbose) for dep in $^ ; do \ + $(verbose) set -e; for dep in $^ ; do \ if ! grep -qs ^$$dep$$ $(ERLANG_MK_RECURSIVE_TMP_LIST); then \ echo $$dep >> $(ERLANG_MK_RECURSIVE_TMP_LIST); \ if grep -qs -E "^[[:blank:]]*include[[:blank:]]+(erlang\.mk|.*/erlang\.mk)$$" \ $$dep/GNUmakefile $$dep/makefile $$dep/Makefile; then \ $(MAKE) -C $$dep fetch-deps \ IS_DEP=1 \ - ERLANG_MK_RECURSIVE_TMP_LIST=$(ERLANG_MK_RECURSIVE_TMP_LIST) \ - || exit $$?; \ + ERLANG_MK_RECURSIVE_TMP_LIST=$(ERLANG_MK_RECURSIVE_TMP_LIST); \ fi \ fi \ done diff --git a/core/deps.mk b/core/deps.mk index d74a2ae..671ac45 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -58,19 +58,19 @@ endif # as proper OTP applications when using -include_lib. This is a temporary # fix, a proper fix would be to compile apps/* in the right order. ifndef IS_APP - $(verbose) for dep in $(ALL_APPS_DIRS) ; do \ - mkdir -p $$dep/ebin || exit $$?; \ + $(verbose) set -e; for dep in $(ALL_APPS_DIRS) ; do \ + mkdir -p $$dep/ebin; \ done endif # at the toplevel: if LOCAL_DEPS is defined with at least one local app, only # compile that list of apps. otherwise, compile everything. # within an app: compile all LOCAL_DEPS that are (uncompiled) local apps - $(verbose) for dep in $(if $(LOCAL_DEPS_DIRS)$(IS_APP),$(LOCAL_DEPS_DIRS),$(ALL_APPS_DIRS)) ; do \ + $(verbose) set -e; for dep in $(if $(LOCAL_DEPS_DIRS)$(IS_APP),$(LOCAL_DEPS_DIRS),$(ALL_APPS_DIRS)) ; do \ if grep -qs ^$$dep$$ $(ERLANG_MK_TMP)/apps.log; then \ :; \ else \ echo $$dep >> $(ERLANG_MK_TMP)/apps.log; \ - $(MAKE) -C $$dep IS_APP=1 || exit $$?; \ + $(MAKE) -C $$dep IS_APP=1; \ fi \ done @@ -84,15 +84,15 @@ deps:: else deps:: $(ALL_DEPS_DIRS) apps clean-tmp-deps.log $(verbose) mkdir -p $(ERLANG_MK_TMP) - $(verbose) for dep in $(ALL_DEPS_DIRS) ; do \ + $(verbose) set -e; for dep in $(ALL_DEPS_DIRS) ; do \ if grep -qs ^$$dep$$ $(ERLANG_MK_TMP)/deps.log; then \ :; \ else \ echo $$dep >> $(ERLANG_MK_TMP)/deps.log; \ if [ -f $$dep/GNUmakefile ] || [ -f $$dep/makefile ] || [ -f $$dep/Makefile ]; then \ - $(MAKE) -C $$dep IS_DEP=1 || exit $$?; \ + $(MAKE) -C $$dep IS_DEP=1; \ else \ - echo "Error: No Makefile to build dependency $$dep."; \ + echo "Error: No Makefile to build dependency $$dep." >&2; \ exit 2; \ fi \ fi \ @@ -525,7 +525,7 @@ $(DEPS_DIR)/$(call dep_name,$1): $(eval DEP_NAME := $(call dep_name,$1)) $(eval DEP_STR := $(if $(filter-out $1,$(DEP_NAME)),$1,"$1 ($(DEP_NAME))")) $(verbose) if test -d $(APPS_DIR)/$(DEP_NAME); then \ - echo "Error: Dependency" $(DEP_STR) "conflicts with application found in $(APPS_DIR)/$(DEP_NAME)."; \ + echo "Error: Dependency" $(DEP_STR) "conflicts with application found in $(APPS_DIR)/$(DEP_NAME)." >&2; \ exit 17; \ fi $(verbose) mkdir -p $(DEPS_DIR) @@ -567,15 +567,15 @@ ifndef IS_APP clean:: clean-apps clean-apps: - $(verbose) for dep in $(ALL_APPS_DIRS) ; do \ - $(MAKE) -C $$dep clean IS_APP=1 || exit $$?; \ + $(verbose) set -e; for dep in $(ALL_APPS_DIRS) ; do \ + $(MAKE) -C $$dep clean IS_APP=1; \ done distclean:: distclean-apps distclean-apps: - $(verbose) for dep in $(ALL_APPS_DIRS) ; do \ - $(MAKE) -C $$dep distclean IS_APP=1 || exit $$?; \ + $(verbose) set -e; for dep in $(ALL_APPS_DIRS) ; do \ + $(MAKE) -C $$dep distclean IS_APP=1; \ done endif diff --git a/core/docs.mk b/core/docs.mk index c702fbc..ea2529f 100644 --- a/core/docs.mk +++ b/core/docs.mk @@ -16,5 +16,5 @@ ifneq ($(SKIP_DEPS),) doc-deps: else doc-deps: $(ALL_DOC_DEPS_DIRS) - $(verbose) for dep in $(ALL_DOC_DEPS_DIRS) ; do $(MAKE) -C $$dep; done + $(verbose) set -e; for dep in $(ALL_DOC_DEPS_DIRS) ; do $(MAKE) -C $$dep; done endif diff --git a/core/rel.mk b/core/rel.mk index b149158..f64278c 100644 --- a/core/rel.mk +++ b/core/rel.mk @@ -15,5 +15,5 @@ ifneq ($(SKIP_DEPS),) rel-deps: else rel-deps: $(ALL_REL_DEPS_DIRS) - $(verbose) for dep in $(ALL_REL_DEPS_DIRS) ; do $(MAKE) -C $$dep; done + $(verbose) set -e; for dep in $(ALL_REL_DEPS_DIRS) ; do $(MAKE) -C $$dep; done endif diff --git a/core/test.mk b/core/test.mk index 46aa6b8..fa715e7 100644 --- a/core/test.mk +++ b/core/test.mk @@ -20,7 +20,7 @@ ifneq ($(SKIP_DEPS),) test-deps: else test-deps: $(ALL_TEST_DEPS_DIRS) - $(verbose) for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep IS_DEP=1; done + $(verbose) set -e; for dep in $(ALL_TEST_DEPS_DIRS) ; do $(MAKE) -C $$dep IS_DEP=1; done endif ifneq ($(wildcard $(TEST_DIR)),) diff --git a/plugins/shell.mk b/plugins/shell.mk index e771cbf..00d2c52 100644 --- a/plugins/shell.mk +++ b/plugins/shell.mk @@ -24,7 +24,7 @@ help:: $(foreach dep,$(SHELL_DEPS),$(eval $(call dep_target,$(dep)))) build-shell-deps: $(ALL_SHELL_DEPS_DIRS) - $(verbose) for dep in $(ALL_SHELL_DEPS_DIRS) ; do $(MAKE) -C $$dep ; done + $(verbose) set -e; for dep in $(ALL_SHELL_DEPS_DIRS) ; do $(MAKE) -C $$dep ; done shell: build-shell-deps $(gen_verbose) $(SHELL_ERL) -pa $(SHELL_PATHS) $(SHELL_OPTS) -- cgit v1.2.3