1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/Makefile.buildtests
René Kijewski f49bd3e660 make: add Makefile.features telling the BOARDs' features
Please see #1715.
Closes #1715.

This PR implements the new Makefile variables "FEATURES_PROVIDED" and
"FEATURES_REQUIRED". A board *can* have a new file `Makefile.features`
which looks like:

```make
FEATURES_PROVIDED = transceiver
```

An application can have a corresponding line

```make
FEATURES_REQUIRED = transceiver
```

If the selected BOARD does not fulfil the requirements of the
application, then a *warning* is issued at compile time.

This change only includes the feature "transceiver", further features
are expected to be listed in further PRs. The requirement "transceiver"
is automatically added if the application uses the module
"defaulttransceiver".

`make buildtest` understands the new feature listing, so the user won't
need to add boards to `BOARD_BLACKLIST` manually.

Part of the change are the added Make targets
* `info-features-missing`, which prints the required features
  `\setminus` the provided features. The output is empty if there are no
  features missing.
* `info-boards-features-missing`, the same as `info-features-missing`
  but as a table for all boards, but heeded `BOARD_WHITELIST` and
  `BOARD_BLACKLIST`.

Applications don't have to use this new feature. This change does not
break existing Makefile.
2014-10-06 17:42:11 +02:00

246 lines
7.5 KiB
Makefile

ifneq (, $(filter buildtest info-concurrency, $(MAKECMDGOALS)))
ifeq (, $(strip $(NPROC)))
# Linux (utility program)
NPROC := $(shell nproc 2>/dev/null)
ifeq (, $(strip $(NPROC)))
# Linux (generic)
NPROC := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
endif
ifeq (, $(strip $(NPROC)))
# BSD (at least FreeBSD and Mac OSX)
NPROC := $(shell sysctl -n hw.ncpu 2>/dev/null)
endif
ifeq (, $(strip $(NPROC)))
# Fallback
NPROC := 1
endif
NPROC := $(shell echo $$(($(NPROC) + 1)))
ifneq (, $(NPROC_MAX))
NPROC := $(shell if [ ${NPROC} -gt $(NPROC_MAX) ]; then echo $(NPROC_MAX); else echo ${NPROC}; fi)
endif
ifneq (, $(NPROC_MIN))
NPROC := $(shell if [ ${NPROC} -lt $(NPROC_MIN) ]; then echo $(NPROC_MIN); else echo ${NPROC}; fi)
endif
endif
endif
.PHONY: buildtest info-objsize info-buildsize info-buildsizes \
info-buildsizes-diff info-build info-boards-supported \
info-features-missing info-boards-features-missing
COLOR_GREEN :=
COLOR_RED :=
COLOR_PURPLE :=
COLOR_RESET :=
COLOR_ECHO := /bin/echo
ifeq (, ${JENKINS_URL})
ifeq (0, $(shell tput colors 2>&1 > /dev/null; echo $$?))
COLOR_GREEN := \033[1;32m
COLOR_RED := \033[1;31m
COLOR_PURPLE := \033[1;35m
COLOR_RESET := \033[0m
COLOR_ECHO := /bin/echo -e
endif
endif
buildtest:
@ \
BUILDTESTOK=true; \
rm -rf "$$BINDIRBASE"; \
for BOARD in $$($(MAKE) -s info-boards-supported); do \
RIOTNOLINK=$$(case ' $(BOARD_INSUFFICIENT_RAM) ' in *" $${BOARD} "*) echo 1; esac); \
${COLOR_ECHO} -n "Building for $${BOARD} "; \
[ -n "$${RIOTNOLINK}" ] && ${COLOR_ECHO} -n "(no linking) "; \
for NTH_TRY in 1 2; do \
${COLOR_ECHO} -n ".. "; \
LOG=$$(env -i \
HOME=$${HOME} \
PATH=$${PATH} \
BOARD=$${BOARD} \
RIOTBASE=$${RIOTBASE} \
RIOTBOARD=$${RIOTBOARD} \
RIOTCPU=$${RIOTCPU} \
BINDIRBASE=$${BINDIRBASE} \
RIOTNOLINK=$${RIOTNOLINK} \
RIOT_VERSION=$${RIOT_VERSION} \
$(MAKE) -j$(NPROC) 2>&1 >/dev/null) ; \
if [ "$${?}" = "0" ]; then \
${COLOR_ECHO} "${COLOR_GREEN}success${COLOR_RESET}"; \
elif [ -n "$${RIOT_DO_RETRY}" ] && $${BUILDTESTOK} && [ $${NTH_TRY} = 1 ]; then \
${COLOR_ECHO} -n "${COLOR_PURPLE}retrying${COLOR_RESET} "; \
continue; \
else \
${COLOR_ECHO} "${COLOR_RED}failed${COLOR_RESET}"; \
echo "$${LOG}" | grep -v -E '^make(\[[[:digit:]]])?:'; \
BUILDTESTOK=false; \
fi; \
break; \
done; \
done; \
$${BUILDTESTOK}
info-objsize:
@case "${SORTROW}" in \
text) SORTROW=1 ;; \
data) SORTROW=2 ;; \
bss) SORTROW=3 ;; \
dec) SORTROW=4 ;; \
"") SORTROW=4 ;; \
*) echo "Usage: $(MAKE) info-objsize SORTROW=[text|data|bss|dec]" ; return ;; \
esac; \
echo ' text\t data\t bss\t dec\t hex\tfilename'; \
$(SIZE) -dB $(BASELIBS) | \
tail -n+2 | \
sed -e 's#$(BINDIR)##' | \
sort -rnk$${SORTROW}
info-buildsize:
@$(SIZE) -dB $(BINDIR)$(APPLICATION).elf
info-buildsizes: SHELL=bash
info-buildsizes:
echo -e " text\t data\t bss\t dec\tboard"; \
for BOARD in $$($(MAKE) -s info-boards-supported); do \
echo "$$(env -i \
HOME=$${HOME} \
PATH=$${PATH} \
BOARD=$${BOARD} \
RIOTBASE=$${RIOTBASE} \
RIOTBOARD=$${RIOTBOARD} \
RIOTCPU=$${RIOTCPU} \
BINDIRBASE=$${BINDIRBASE} \
$(MAKE) info-buildsize 2>/dev/null | tail -n-1 | cut -f-4)" "$${BOARD}"; \
done;
info-buildsizes-diff: SHELL=bash
info-buildsizes-diff:
echo -e "text\tdata\tbss\tdec\tBOARD/BINDIRBASE\n"; \
for BOARD in $$($(MAKE) -s info-boards-supported); do \
for BINDIRBASE in $${OLDBIN} $${NEWBIN}; do \
env -i \
HOME=$${HOME} \
PATH=$${PATH} \
BOARD=$${BOARD} \
RIOTBASE=$${RIOTBASE} \
RIOTBOARD=$${RIOTBOARD} \
RIOTCPU=$${RIOTCPU} \
BINDIRBASE=$${BINDIRBASE} \
$(MAKE) info-buildsize 2>/dev/null | tail -n-1 | cut -f-4; \
done | \
while read -a OLD && read -a NEW; do \
for I in 0 1 2 3; do \
if [[ -n "$${NEW[I]}" && -n "$${OLD[I]}" ]]; then \
DIFF=$$(($${NEW[I]} - $${OLD[I]})); \
if [[ "$${DIFF}" -gt 0 ]]; then $(COLOR_ECHO) -n "${COLOR_RED}"; fi; \
if [[ "$${DIFF}" -lt 0 ]]; then $(COLOR_ECHO) -n "${COLOR_GREEN}"; fi; \
else \
DIFF="$${RED}ERR"; \
fi; \
echo -ne "$${DIFF}\t$${RESET}"; \
done; \
echo "$${BOARD}"; \
for I in 0 1 2 3; do echo -ne "$${OLD[I]-${COLOR_RED}ERR${COLOR_RESET}}\t"; done; echo -e "$${OLDBIN}"; \
for I in 0 1 2 3; do echo -ne "$${NEW[I]-${COLOR_RED}ERR${COLOR_RESET}}\t"; done; echo -e "$${NEWBIN}\n"; \
done; \
done;
info-build:
@echo 'APPLICATION: $(APPLICATION)'
@echo ''
@echo 'supported boards:'
@$(foreach board,$(BOARDS),echo ' * $(board)';)
@echo ''
@echo 'BOARD: $(BOARD)'
@echo 'CPU: $(CPU)'
@echo 'MCU: $(MCU)'
@echo ''
@echo 'RIOTBASE: $(RIOTBASE)'
@echo 'RIOTBOARD: $(RIOTBOARD)'
@echo 'RIOTCPU: $(RIOTCPU)'
@echo ''
@echo 'DEFAULT_MODULE: $(sort $(filter-out $(DISABLE_MODULE), $(DEFAULT_MODULE)))'
@echo 'DISABLE_MODULE: $(sort $(DISABLE_MODULE))'
@echo 'USEMODULE: $(sort $(filter-out $(DEFAULT_MODULE), $(USEMODULE)))'
@echo ''
@echo 'ELFFILE: $(ELFFILE)'
@echo 'HEXFILE: $(HEXFILE)'
@echo ''
@echo 'FEATURES_REQUIRED: $(sort $(FEATURES_REQUIRED))'
@echo 'FEATURES_PROVIDED: $(sort $(FEATURES_PROVIDED))'
@echo ''
@echo 'CC: $(CC)'
@echo -e 'CFLAGS:$(patsubst %, \n\t%, $(CFLAGS))'
@echo ''
@echo 'CXX: $(CXX)'
@echo -e 'CXXUWFLAGS:$(patsubst %, \n\t%, $(CXXUWFLAGS))'
@echo -e 'CXXEXFLAGS:$(patsubst %, \n\t%, $(CXXEXFLAGS))'
@echo ''
@echo 'LINK: $(LINK)'
@echo -e 'LINKFLAGS:$(patsubst %, \n\t%, $(LINKFLAGS))'
@echo ''
@echo 'OBJCOPY: $(OBJCOPY)'
@echo 'OFLAGS: $(OFLAGS)'
@echo ''
@echo 'FLASHER: $(FLASHER)'
@echo 'FFLAGS: $(FFLAGS)'
@echo ''
@echo 'TERMPROG: $(TERMPROG)'
@echo 'PORT: $(PORT)'
@echo ''
@echo 'DEBUGGER: $(DEBUGGER)'
@echo 'DEBUGGER_FLAGS: $(DEBUGGER_FLAGS)'
@echo
@echo 'DOWNLOAD_TO_FILE: $(DOWNLOAD_TO_FILE)'
@echo 'DOWNLOAD_TO_STDOUT: $(DOWNLOAD_TO_STDOUT)'
@echo 'UNZIP_HERE: $(UNZIP_HERE)'
@echo ''
@echo 'DEBUGSERVER: $(DEBUGSERVER)'
@echo 'DEBUGSERVER_FLAGS: $(DEBUGSERVER_FLAGS)'
@echo ''
@echo 'RESET: $(RESET)'
@echo 'RESET_FLAGS: $(RESET_FLAGS)'
@echo ''
@echo -e 'MAKEFILE_LIST:$(patsubst %, \n\t%, $(abspath $(MAKEFILE_LIST)))'
info-boards-supported:
@echo $(BOARDS)
info-features-missing:
@echo $(filter-out $(FEATURES_PROVIDED), $(FEATURES_REQUIRED))
info-boards-features-missing:
@for f in $(BOARDS_FEATURES_MISSING); do echo $${f}; done | column -t
ifneq (, $(filter info-boards-supported info-boards-features-missing info-build, $(MAKECMDGOALS)))
FEATURES_PROVIDED_BAK := $(FEATURES_PROVIDED)
define board_missing_features
FEATURES_PROVIDED :=
-include $${RIOTBOARD}/${1}/Makefile.features
FEATURES_MISSING := $$(filter-out $$(FEATURES_PROVIDED), $$(FEATURES_REQUIRED))
ifneq (, $${FEATURES_MISSING})
BOARDS_WITH_MISSING_FEATURES += ${1}
BOARDS_FEATURES_MISSING += "${1} $${FEATURES_MISSING}"
endif
endef
BOARDS ?= $(shell find $(RIOTBOARD)/* -maxdepth 0 -type d \! -name *-common -printf '%f ')
BOARDS := $(filter $(if $(BOARD_WHITELIST), $(BOARD_WHITELIST), %), $(BOARDS))
BOARDS := $(filter-out $(BOARD_BLACKLIST), $(BOARDS))
BOARDS_WITH_MISSING_FEATURES :=
BOARDS_FEATURES_MISSING :=
$(foreach BOARD, $(BOARDS), $(eval $(call board_missing_features,$(BOARD))))
BOARDS := $(filter-out $(BOARDS_WITH_MISSING_FEATURES), $(BOARDS))
FEATURES_PROVIDED := $(FEATURES_PROVIDED_BAK)
endif
info-concurrency:
@echo "$(NPROC)"