gbuild: tweak var2file so it handles some shell metacharacters

Always quote the passed string; this cannot handle arbitrary strings
like $(file) can, but everything that is needed currently.

Also, try to ensure that output does not start with a space.

Note: there needs to be a newline at the end, otherwise helpex
ignores the last item on the line.

Change-Id: I51a4058591cc4f12dd878c2d113bd5cfc8c22d61
This commit is contained in:
Michael Stahl
2014-06-04 22:13:13 +02:00
parent 0d2542d67a
commit 50b10febf3

View File

@@ -29,13 +29,14 @@ else
define var2file define var2file
$(strip $(1) $(strip $(1)
$(eval gb_var2file_helpervar := $$(shell printf "%s" "" > $(1) ))\ $(eval gb_var2file_helpervar := $$(shell printf "%s" "" > $(1) ))\
$(foreach item,$(3),$(eval gb_var2file_curblock += $(item) $(eval gb_var2file_curblock := $(firstword $(3)))\
$(foreach item,$(wordlist 2,99999,$(3)),$(eval gb_var2file_curblock += $(item)
ifeq ($$(words $$(gb_var2file_curblock)),$(2)) ifeq ($$(words $$(gb_var2file_curblock)),$(2))
gb_var2file_helpervar := $$(shell printf "%s" "$$(gb_var2file_curblock)" >> $(1) ) gb_var2file_helpervar := $$(shell printf "%s" "$$(gb_var2file_curblock)" >> $(1) )
gb_var2file_curblock := gb_var2file_curblock :=
endif endif
))\ ))\
$(eval gb_var2file_helpervar := $(shell echo " "$(gb_var2file_curblock) >> $(1) ) $(eval gb_var2file_helpervar := $(shell printf "%s\n" "$(gb_var2file_curblock)" >> $(1) )
gb_var2file_curblock := gb_var2file_curblock :=
)) ))
endef endef