Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make: ensure PACKAGE_NAME has no spaces #481

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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