Skip to content

Commit

Permalink
make: ensure PACKAGE_NAME has no spaces
Browse files Browse the repository at this point in the history
Adding even a trailing space causes the build to fail.
  • Loading branch information
bradjc committed Dec 10, 2024
1 parent 8205794 commit dfe9ab3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions AppMakefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ include $(TOCK_USERLAND_BASE_DIR)/libtock-sync/Makefile
# Include the makefile that has the programming functions for each board.
include $(TOCK_USERLAND_BASE_DIR)/Program.mk

# Remove any leading or trailing spaces from PACKAGE_NAME and then verify there
# are no spaces within the PACKAGE_NAME variable.
override PACKAGE_NAME := $(strip $(PACKAGE_NAME))
$(call check_no_spaces, PACKAGE_NAME)

# Rules to call library makefiles to build required libraries.
#
Expand Down
9 changes: 9 additions & 0 deletions Helpers.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ __check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))

# Check that the variable has no leading or trailing spaces, or spaces within
# the variable.
#
# Params:
# 1. Variable name to test.
check_no_spaces = \
$(if $(findstring $(strip $($(strip $1))),$($(strip $1))),,$(error Error: Space in variable $(strip $1))) \
$(if $(word 2,$($(strip $1))),$(error Error: Multiple entries in variable $(strip $1)),)

# Check for a ~/ at the beginning of a path variable (TOCK_USERLAND_BASE_DIR).
# Make will not properly expand this.
ifdef TOCK_USERLAND_BASE_DIR
Expand Down

0 comments on commit dfe9ab3

Please sign in to comment.