Skip to content

Commit

Permalink
build system: add fallback for RIOT_VERSION_CODE
Browse files Browse the repository at this point in the history
If the repository was checked out without tags, parsing RIOT_VERSION
will fail.

Fall back to creating a fake release version code based on the current
year and month.
  • Loading branch information
benpicco committed Sep 27, 2021
1 parent 5e81bd5 commit 74a0f8d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ PKGDIRBASE ?= $(RIOTBASE)/build/pkg
DLCACHE ?= $(RIOTTOOLS)/dlcache/dlcache.sh
DLCACHE_DIR ?= $(RIOTBASE)/.dlcache
WARNING_EXTERNAL_MODULE_DIRS ?= 1
RIOT_VERSION_DUMMY_CODE ?= RIOT_VERSION_NUM\(2042,5,23,0\)

# include CI info such as BOARD_INSUFFICIENT_MEMORY, if existing
-include Makefile.ci
Expand Down Expand Up @@ -487,7 +488,7 @@ endif
ifeq ($(RIOT_CI_BUILD),1)
RIOT_VERSION ?= buildtest
# set a dummy version number
RIOT_VERSION_CODE ?= RIOT_VERSION_NUM\(2042,5,23,0\)
RIOT_VERSION_CODE ?= $(RIOT_VERSION_DUMMY_CODE)
ifneq ($(filter $(BOARD_INSUFFICIENT_MEMORY), $(BOARD)),)
$(info CI-build: skipping link step)
RIOTNOLINK:=1
Expand Down Expand Up @@ -529,8 +530,9 @@ ifneq (,$(RIOT_VERSION_OVERRIDE))
endif

# Generate machine readable RIOT VERSION macro
RIOT_VERSION_CODE ?= $(shell echo ${RIOT_VERSION} | \
sed -E 's/([0-9]+).([0-9]+).?([0-9]+)?.*/RIOT_VERSION_NUM\\\(\1,\2,0\3,${RIOT_EXTRAVERSION}\\\)/')
RIOT_VERSION_CODE ?= $(shell echo $(RIOT_VERSION) | \
sed -E 's/([0-9]+)\.([0-9]+)\.?([0-9]+)?.*/RIOT_VERSION_NUM\\\(\1,\2,0\3,$(RIOT_EXTRAVERSION)\\\)/' | \
grep RIOT_VERSION_NUM || echo "$(RIOT_VERSION_DUMMY_CODE)")

# Set module by prepending APPLICATION name with 'application_'.
# It prevents conflict with application and modules with the same name.
Expand Down

0 comments on commit 74a0f8d

Please sign in to comment.