Skip to content

Commit

Permalink
Makefile.include: add way to prevent non listed subdirectories
Browse files Browse the repository at this point in the history
  • Loading branch information
aabadie committed Feb 12, 2021
1 parent 152b72c commit 61bf5a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ include $(RIOTMAKE)/boards.inc.mk
# Debug targets for build system migration
include $(RIOTMAKE)/dependencies_debug.inc.mk

# List all available applications
include $(RIOTMAKE)/app_dirs.inc.mk

ifeq (,$(filter $(APPDIR),$(APPLICATION_DIRS_ABSOLUTE)))
$(error Application parent directory is not listed in the list of examples \
or tests subdirectories. Please update 'makefiles/app_dirs.inc.mk')
endif

# Use TOOLCHAIN environment variable to select the toolchain to use.
# If native, TOOLCHAIN for OSX is llvm
ifeq ($(BOARD),native)
Expand Down
8 changes: 4 additions & 4 deletions makefiles/app_dirs.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ APPLICATION_DIRS := \
$(TEST_APPLICATIONS_SUBDIRS) \
#

APPLICATION_DIRS := $(addprefix $(RIOTBASE)/,$(APPLICATION_DIRS))
APPLICATION_DIRS := $(addsuffix /*/Makefile,$(APPLICATION_DIRS))

# 1. use wildcard to find Makefiles
# 2. use patsubst to drop trailing "/"
# 3. use patsubst to drop possible leading "./"
# 4. sort
APPLICATION_DIRS := $(sort $(patsubst ./%,%,$(patsubst %/,%,$(dir $(wildcard $(APPLICATION_DIRS))))))
APPLICATION_DIRS := $(addprefix $(RIOTBASE)/,$(APPLICATION_DIRS))
APPLICATION_DIRS_RELATIVE := $(dir $(wildcard $(addsuffix /*/Makefile,$(APPLICATION_DIRS))))
APPLICATION_DIRS_ABSOLUTE := $(abspath $(APPLICATION_DIRS_RELATIVE))
APPLICATION_DIRS := $(sort $(patsubst ./%,%,$(patsubst %/,%,$(APPLICATION_DIRS_RELATIVE))))

info-applications:
@for dir in $(APPLICATION_DIRS); do echo $$dir; done
Expand Down

0 comments on commit 61bf5a2

Please sign in to comment.