Skip to content
This repository was archived by the owner on Jun 27, 2019. It is now read-only.

Commit c6dcfe5

Browse files
author
Leandro Dorileo
committed
build: add warning message support
This patch introduces a mechanism to inform the user about missing features or possible misbehaving features based on target system's configuration. The first feature's user is the string flow module, this module implements an ascii fallback case the target system doesn't provide ICU. We support the following formats: warning-msg := "an arbitrary message" warning-msg-$(CONFIG_OPTION) := "another arbitrary message" Where warning-msg-$(CONFIG_OPTION) may expand either to warning-msg-y or warning-msg-m. See: #463 Signed-off-by: Leandro Dorileo <[email protected]>
1 parent 2a301d9 commit c6dcfe5

File tree

4 files changed

+32
-10
lines changed

4 files changed

+32
-10
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ include $(top_srcdir)tools/build/Makefile.rules
5252

5353
include $(top_srcdir)tools/build/Makefile.targets
5454

55-
all: $(PRE_GEN) $(SOL_LIB_SO) $(SOL_LIB_AR) $(bins-out) $(modules-out)
55+
default_target: $(PRE_GEN) $(SOL_LIB_SO) $(SOL_LIB_AR) $(bins-out) $(modules-out)
56+
all: default_target
5657
endif # HAVE_KCONFIG_CONFIG
5758
endif # NOT_FOUND
5859

5960
$(KCONFIG_CONFIG): $(KCONFIG_GEN)
6061

6162
.DEFAULT_GOAL = all
62-
.PHONY = $(PHONY) all
63+
.PHONY = $(PHONY) default_target

src/modules/flow/string/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
obj-$(FLOW_NODE_TYPE_STRING) += string.mod
22
obj-string-$(FLOW_NODE_TYPE_STRING) := string.json
33

4-
ifdef USE_ICU
4+
ifeq (y,$(HAVE_ICU))
55
obj-string-$(FLOW_NODE_TYPE_STRING) += string-icu.o string-replace-icu.o
66
else
77
obj-string-$(FLOW_NODE_TYPE_STRING) += string-ascii.o string-replace-ascii.o
8+
warning-msg := "You're building the string nodes module without i18n support -- some nodes will only act properly on pure ASCII input, not the intended utf-8 for Soletta. Please re-configure after you have ICU development packages installed to get the intended string nodes behavior."
89
endif
910

1011
obj-string-$(FLOW_NODE_TYPE_STRING)-extra-cflags += $(LOCALE_CFLAGS) $(ICU_CFLAGS)

src/modules/flow/string/string-ascii.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,6 @@
3030
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3131
*/
3232

33-
//FIXME: change to build system warning, not compile time
34-
35-
#ifdef LINUX
36-
#warning "You're building the string nodes module without i18n support -- some nodes will only act properly on pure ASCII input, not the intended utf-8 for Soletta. Please re-configure after you have ICU development packages installed to get the intended string nodes behavior."
37-
#endif
38-
3933
#include <ctype.h>
4034
#include <errno.h>
4135

tools/build/Makefile.rules

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,23 @@ parse-sample = \
167167
$(eval $(1)-deps := $(subst .mod,,$(sample-$(1)-y-deps))) \
168168
$(eval samples-out += $(sample-$(1)-out)) \
169169

170+
parse-warnings = \
171+
$(if $(2), \
172+
$(eval all-warnings += $(1)bs-warnings) \
173+
$(eval $(1)bs-warnings-msg += $(2)) \
174+
) \
175+
170176
clean-control = $(eval headers-y:=) $(eval obj-y:=) $(eval obj-m:=) $(eval bin-y:=) \
171-
$(eval test-y:=) $(eval test-internal-y:=) $(eval sample-y:=) $(eval headers-m:=)
177+
$(eval test-y:=) $(eval test-internal-y:=) $(eval sample-y:=) $(eval headers-m:=) \
178+
$(eval warning-msg:=) $(eval warning-msg-y:=) $(eval warning-msg-m:=)
172179

173180
inc-subdirs = \
174181
$(foreach subdir,$(SUBDIRS), $(clean-control) \
175182
$(eval -include $(subdir)Makefile) \
183+
$(eval warnings := $(warning-msg) $(warning-msg-y) $(warning-msg-m)) \
176184
$(call extra-headers,$(addprefix $(subdir),$(headers-y))) \
177185
$(call extra-headers,$(addprefix $(subdir),$(headers-m))) \
186+
$(call parse-warnings,$(subdir),$(warnings)) \
178187
$(eval curr-builtins := $(subst .mod,,$(filter %.mod,$(obj-y)))) \
179188
$(eval builtins += $(curr-builtins)) \
180189
$(foreach buin,$(curr-builtins), \
@@ -220,6 +229,23 @@ $(eval $(call extra-bins))
220229

221230
PRE_GEN += $(all-gen-hdrs) $(all-dest-hdr) $(all-dest-bin)
222231

232+
define make-warning
233+
$(1):
234+
$(Q)echo -e " [!] "$($(1)-msg)
235+
236+
all: $(1)
237+
PHONY += $(1)
238+
endef
239+
$(foreach wrn,$(all-warnings),$(eval $(call make-warning,$(wrn))))
240+
241+
define make-warning-header
242+
$(all-warnings): warning-header
243+
warning-header: default_target
244+
$(Q)echo -e "*** ATTENTION:"
245+
PHONY += warning-header
246+
endef
247+
$(if $(all-warnings),$(eval $(call make-warning-header,$(wrn))))
248+
223249
define make-extra-header
224250
$($(1)-dest): $(1)
225251
$(Q)echo " "INST" "$$@

0 commit comments

Comments
 (0)