summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2021-05-31 08:56:07 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2021-05-31 09:16:36 +0200
commit2da8fa77e9f223743d41ef8e7dc5fe86eb41ff44 (patch)
treef051ca1ac24a8bceea73c77deae56dad32133e11
parentabc09b3a78f0a87e57215de25ff99b7e13f12b13 (diff)
downloadptxdist-2da8fa77e9f223743d41ef8e7dc5fe86eb41ff44.tar.gz
ptxdist-2da8fa77e9f223743d41ef8e7dc5fe86eb41ff44.tar.xz
rules: rework some error handling
There are several places where 'make' is aborted with an '$(error ...)' immediately when starting ptxdist. It's useful to detect problems early on. However, this means, that it also interferes with 'ptxdist print' to it can make debugging issues a bit more tricky. So collect the errors instead and print them in a early make target instead. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--rules/code-signing.make2
-rw-r--r--rules/dtc.make7
-rw-r--r--rules/kernel-checks.make5
-rw-r--r--rules/openssl.make2
-rw-r--r--rules/other/Toplevel.make15
-rw-r--r--rules/ply.make2
-rw-r--r--rules/ppp.make7
-rw-r--r--rules/pre/000-error.make22
-rw-r--r--rules/pre/000-option-disabled.make2
-rw-r--r--rules/pre/bootloader.make7
-rw-r--r--rules/pre/kernel.make7
-rw-r--r--rules/qt5.make4
-rw-r--r--rules/sw-ek-lm3s3748.make6
-rw-r--r--rules/templates/template-src-stellaris-make6
-rw-r--r--rules/tf-a.make2
-rw-r--r--rules/valgrind.make7
-rw-r--r--scripts/lib/ptxd_make_errors.sh29
17 files changed, 92 insertions, 40 deletions
diff --git a/rules/code-signing.make b/rules/code-signing.make
index db1c5ab88..d79f893c1 100644
--- a/rules/code-signing.make
+++ b/rules/code-signing.make
@@ -8,6 +8,6 @@
ifdef PTXCONF_CODE_SIGNING
ifeq ($(call remove_quotes,$(PTXCONF_CODE_SIGNING_PROVIDER)),)
-$(error PTXCONF_CODE_SIGNING_PROVIDER must be set correctly)
+$(call ptx/error, PTXCONF_CODE_SIGNING_PROVIDER must be set correctly)
endif
endif
diff --git a/rules/dtc.make b/rules/dtc.make
index 8c0455af9..7c281e8f0 100644
--- a/rules/dtc.make
+++ b/rules/dtc.make
@@ -21,10 +21,9 @@ DTC_VERSION := 1.0.0
DTC_LICENSE := ignore
ifneq ($(subst PTXCONF_KERNEL_ARCH_STRING,,$(value PTXCONF_DTC_OFTREE_DTS_PATH)),$(value PTXCONF_DTC_OFTREE_DTS_PATH))
-$(warning *** invalid value for PTXCONF_DTC_OFTREE_DTS_PATH:)
-$(warning *** PTXCONF_KERNEL_ARCH_STRING is no longer defined.)
-$(warning *** Use GENERIC_KERNEL_ARCH instead)
-$(error )
+$(call ptx/error, invalid value for PTXCONF_DTC_OFTREE_DTS_PATH:)
+$(call ptx/error, PTXCONF_KERNEL_ARCH_STRING is no longer defined.)
+$(call ptx/error, Use GENERIC_KERNEL_ARCH instead)
endif
# ----------------------------------------------------------------------------
diff --git a/rules/kernel-checks.make b/rules/kernel-checks.make
index e0b03acb4..cfd9284ac 100644
--- a/rules/kernel-checks.make
+++ b/rules/kernel-checks.make
@@ -9,9 +9,8 @@
ifdef PTXCONF_KERNEL
ifeq ($(PTXCONF_KERNEL_VERSION),)
- $(warning *** PTXCONF_KERNEL_VERSION is empty)
- $(warning *** please run 'ptxdist platformconfig' and activate the kernel)
- $(error )
+$(call ptx/error, PTXCONF_KERNEL_VERSION is empty)
+$(call ptx/error, please run 'ptxdist platformconfig' and activate the kernel)
endif
endif # PTXCONF_KERNEL
diff --git a/rules/openssl.make b/rules/openssl.make
index 492bac3e1..f8fbf5725 100644
--- a/rules/openssl.make
+++ b/rules/openssl.make
@@ -55,7 +55,7 @@ endif
ifdef PTXCONF_OPENSSL
ifndef OPENSSL_ARCH-y
-$(error *** Sorry unsupported ARCH in openssl.make)
+$(call ptx/error, Sorry unsupported ARCH in openssl.make)
endif
endif
diff --git a/rules/other/Toplevel.make b/rules/other/Toplevel.make
index 9e095eba0..acbf72a2c 100644
--- a/rules/other/Toplevel.make
+++ b/rules/other/Toplevel.make
@@ -225,6 +225,21 @@ endif
print-%: /print-%
@:
+ifneq ($(call ptx/have-errors),)
+# skip error reporting for 'ptxdist print'
+ifeq ($(filter /print-% print-%,$(MAKECMDGOALS)),)
+ptxdist-error-report:
+ @$(call ptx/report-errors)
+
+ptxdist-error-target: ptxdist-error-report
+ @$(error failed)
+
+PHONY += ptxdist-error-target ptxdist-error-report
+# make sure this is executed befor any other target
+-include ptxdist-error-target
+endif
+endif
+
.PHONY: $(PHONY)
#
diff --git a/rules/ply.make b/rules/ply.make
index bb3c1998f..a6a9532b5 100644
--- a/rules/ply.make
+++ b/rules/ply.make
@@ -43,7 +43,7 @@ PLY_CONF_TOOL := autoconf
ifdef PTXCONF_PLY
ifdef PTXCONF_KERNEL
ifneq ($(call remove_quotes,$(PTXCONF_KERNEL_HEADER_VERSION)),$(call remove_quotes,$(PTXCONF_KERNEL_VERSION)))
-$(error ply only works if the kernel header version matches the kernel version)
+$(call ptx/error, ply only works if the kernel header version matches the kernel version)
endif
endif
endif
diff --git a/rules/ppp.make b/rules/ppp.make
index fc5f821a5..8bfb88b55 100644
--- a/rules/ppp.make
+++ b/rules/ppp.make
@@ -33,11 +33,8 @@ PPP_KERNEL_VERSION := $(if $(KERNEL_HEADER_VERSION),$(KERNEL_HEADER_VERSION),$(K
ifdef PTXCONF_PPP
ifeq ($(PPP_KERNEL_VERSION),)
- $(warning ######################### ERROR ###########################)
- $(warning # Linux kernel version required in order to make ppp work #)
- $(warning # Define a platform kernel or the kernel headers #)
- $(warning ###########################################################)
- $(error )
+$(call ptx/error, Linux kernel version required in order to make ppp work!)
+$(call ptx/error, Define a platform kernel or the kernel headers)
endif
endif
diff --git a/rules/pre/000-error.make b/rules/pre/000-error.make
new file mode 100644
index 000000000..51e20881d
--- /dev/null
+++ b/rules/pre/000-error.make
@@ -0,0 +1,22 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2021 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+
+define ptx/error
+$(shell ptxd_make_log_error $(PTXDIST_TEMPDIR)/make-errors '$(lastword $(MAKEFILE_LIST))' '$(strip $(1))')
+endef
+
+define ptx/have-errors
+$(wildcard $(PTXDIST_TEMPDIR)/make-errors)
+endef
+
+define ptx/report-errors
+$(shell ptxd_make_report_errors $(PTXDIST_TEMPDIR)/make-errors)
+endef
+
+# vim: syntax=make
diff --git a/rules/pre/000-option-disabled.make b/rules/pre/000-option-disabled.make
index 5bb63b01d..fa0e8a294 100644
--- a/rules/pre/000-option-disabled.make
+++ b/rules/pre/000-option-disabled.make
@@ -150,7 +150,7 @@ define ptx/config-foo
$(strip $(if $($(strip $(1))),
$(if $(call remove_quotes,$($(2))),
$(call remove_quotes,$($(2))),
- $(if $(filter update,$(3)),,$(error $(2) is undefined or empty))),
+ $(if $(filter update,$(3)),,$(call ptx/error, $(2) is undefined or empty))),
undefined))
endef
diff --git a/rules/pre/bootloader.make b/rules/pre/bootloader.make
index 17f76723e..889dda415 100644
--- a/rules/pre/bootloader.make
+++ b/rules/pre/bootloader.make
@@ -12,10 +12,9 @@
ifdef PTXCONF_BOOTLOADER
ifneq ($(PTXCONF_COMPILER_PREFIX),$(PTXCONF_COMPILER_PREFIX_BOOTLOADER))
ifeq ($(wildcard selected_toolchain_bootloader/$(PTXCONF_COMPILER_PREFIX_BOOTLOADER)gcc),)
- $(warning *** no 'selected_toolchain_bootloader' link found. Please create a link)
- $(warning *** 'selected_toolchain_bootloader' to the bin directory of your)
- $(warning *** '$(PTXCONF_COMPILER_PREFIX_BOOTLOADER)' toolchain)
- $(error )
+ $(call ptx/error, no 'selected_toolchain_bootloader' link found. Please create a link)
+ $(call ptx/error, 'selected_toolchain_bootloader' to the bin directory of your)
+ $(call ptx/error, '$(PTXCONF_COMPILER_PREFIX_BOOTLOADER)' toolchain)
endif
BOOTLOADER_TOOLCHAIN_LINK := $(PTXDIST_WORKSPACE)/selected_toolchain_bootloader/
endif
diff --git a/rules/pre/kernel.make b/rules/pre/kernel.make
index 242b48c0c..f4cb5283b 100644
--- a/rules/pre/kernel.make
+++ b/rules/pre/kernel.make
@@ -94,10 +94,9 @@ PTXDIST_LOWLEVEL_WRAPPER_BLACKLIST := \
ifdef PTXCONF_KERNEL
ifneq ($(PTXCONF_COMPILER_PREFIX),$(PTXCONF_COMPILER_PREFIX_KERNEL))
ifeq ($(wildcard selected_toolchain_kernel/$(PTXCONF_COMPILER_PREFIX_KERNEL)gcc),)
- $(warning *** no 'selected_toolchain_kernel' link found. Please create a link)
- $(warning *** 'selected_toolchain_kernel' to the bin directory of your)
- $(warning '$(PTXCONF_COMPILER_PREFIX_KERNEL)' toolchain)
- $(error )
+ $(call ptx/error, no 'selected_toolchain_kernel' link found. Please create a link)
+ $(call ptx/error, 'selected_toolchain_kernel' to the bin directory of your)
+ $(call ptx/error, '$(PTXCONF_COMPILER_PREFIX_KERNEL)' toolchain)
endif
KERNEL_TOOLCHAIN_LINK := $(PTXDIST_WORKSPACE)/selected_toolchain_kernel/
endif
diff --git a/rules/qt5.make b/rules/qt5.make
index ab7f34a8d..0aff502a9 100644
--- a/rules/qt5.make
+++ b/rules/qt5.make
@@ -35,7 +35,7 @@ QT5_MKSPECS = $(call ptx/get-alternative, config/qt5, linux-ptx-g++)
ifdef PTXCONF_QT5
ifeq ($(strip $(QT5_MKSPECS)),)
-$(error Qt5 mkspecs are missing)
+$(call ptx/error, Qt5 mkspecs are missing)
endif
endif
@@ -314,7 +314,7 @@ endif
ifdef PTXCONF_QT5_GUI
ifndef PTXCONF_QT5_PLATFORM_DEFAULT
-$(error Qt5: select at least one GUI platform!)
+$(call ptx/error, Qt5: select at least one GUI platform!)
endif
endif
diff --git a/rules/sw-ek-lm3s3748.make b/rules/sw-ek-lm3s3748.make
index 0b65b6588..0c8ecf8ae 100644
--- a/rules/sw-ek-lm3s3748.make
+++ b/rules/sw-ek-lm3s3748.make
@@ -8,12 +8,10 @@
ifdef PTXCONF_SW_EK_LM3S3748
ifneq ($(call ptx/force-sh, test -h $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris && echo ok),ok)
- $(warning *** selected_toolchain_stellaris must point to a valid stellaris toolchain)
- $(error )
+$(call ptx/error, selected_toolchain_stellaris must point to a valid stellaris toolchain)
endif
ifneq ($(call ptx/force-sh, test -x $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris/$(PTXCONF_STELLARIS_CC) && echo ok),ok)
- $(warning *** $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris/$(PTXCONF_STELLARIS_CC) not found)
- $(error )
+$(call ptx/error, $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris/$(PTXCONF_STELLARIS_CC) not found)
endif
endif
diff --git a/rules/templates/template-src-stellaris-make b/rules/templates/template-src-stellaris-make
index e5943f68e..750724376 100644
--- a/rules/templates/template-src-stellaris-make
+++ b/rules/templates/template-src-stellaris-make
@@ -13,12 +13,10 @@ PACKAGES-$(PTXCONF_@PACKAGE@) += @package@
ifdef PTXCONF_@PACKAGE@
ifneq ($(shell test -h $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris && echo ok),ok)
- $(warning *** selected_toolchain_stellaris must point to a valid stellaris toolchain)
- $(error )
+$(call ptx/error, selected_toolchain_stellaris must point to a valid stellaris toolchain)
endif
ifneq ($(shell test -x $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris/$(PTXCONF_STELLARIS_CC) && echo ok),ok)
- $(warning *** $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris/$(PTXCONF_STELLARIS_CC) not found)
- $(error )
+$(call ptx/error, $(PTXDIST_WORKSPACE)/selected_toolchain_stellaris/$(PTXCONF_STELLARIS_CC) not found)
endif
endif
diff --git a/rules/tf-a.make b/rules/tf-a.make
index 3f3908f07..dc8a34710 100644
--- a/rules/tf-a.make
+++ b/rules/tf-a.make
@@ -64,7 +64,7 @@ endif
ifdef PTXCONF_TF_A
ifeq ($(TF_A_ARTIFACTS),)
-$(error TF_A_ARTIFACTS is empty. Nothing to install.)
+$(call ptx/error, TF_A_ARTIFACTS is empty. Nothing to install.)
endif
endif
diff --git a/rules/valgrind.make b/rules/valgrind.make
index 9662b4b9b..6dacd4f9a 100644
--- a/rules/valgrind.make
+++ b/rules/valgrind.make
@@ -45,11 +45,8 @@ VALGRIND_ENV := \
ifdef PTXCONF_VALGRIND
ifeq ($(VALGRIND_KERNEL_VERSION),)
- $(warning ######################### ERROR ################################)
- $(warning # Linux kernel version required in order to make valgrind work #)
- $(warning # Define a platform kernel or the kernel headers #)
- $(warning ################################################################)
- $(error )
+$(call ptx/error, Linux kernel version required in order to make valgrind work!)
+$(call ptx/error, Define a platform kernel or the kernel headers.)
endif
endif
diff --git a/scripts/lib/ptxd_make_errors.sh b/scripts/lib/ptxd_make_errors.sh
new file mode 100644
index 000000000..0554f0d65
--- /dev/null
+++ b/scripts/lib/ptxd_make_errors.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+#
+# Copyright (C) 2021 by Michael Olbrich <m.olbrich@pengutronix.de>
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+ptxd_make_log_error() {
+ local file="${1}"
+ local src="$(ptxd_print_path "${2}")"
+
+ shift 2
+ echo "${src}: $*" >> "${file}"
+}
+export -f ptxd_make_log_error
+
+ptxd_make_report_errors() {
+ local line log file="${1}"
+ local -a msgs
+
+ exec {log}< "${file}"
+ while read line <&${log}; do
+ msgs+=( "${line}" )
+ done
+ ptxd_bailout "${msgs[@]}"
+}
+export -f ptxd_make_report_errors
+