mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #11881 from cladmi/pr/git_version
makefiles: Introduce GIT_VERSION and use it for RIOT_VERSION
This commit is contained in:
commit
2d1eda550a
@ -350,20 +350,8 @@ include $(RIOTMAKE)/cflags.inc.mk
|
||||
# Include VERSION for releases
|
||||
-include $(RIOTBASE)/VERSION
|
||||
|
||||
# make the RIOT version available to the program
|
||||
ifeq ($(origin RIOT_VERSION), undefined)
|
||||
GIT_STRING := $(shell git --git-dir="$(RIOTBASE)/.git" describe --always --abbrev=4 2> /dev/null)
|
||||
ifneq (,$(GIT_STRING))
|
||||
GIT_BRANCH := $(shell git --git-dir="$(RIOTBASE)/.git" rev-parse --abbrev-ref HEAD)
|
||||
ifeq ($(strip $(GIT_BRANCH)),master)
|
||||
RIOT_VERSION := $(GIT_STRING)
|
||||
else
|
||||
RIOT_VERSION := $(GIT_STRING)-$(GIT_BRANCH)
|
||||
endif
|
||||
else
|
||||
RIOT_VERSION := 'UNKNOWN (builddir: $(RIOTBASE))'
|
||||
endif
|
||||
endif
|
||||
include $(RIOTMAKE)/git_version.inc.mk
|
||||
RIOT_VERSION ?= $(or $(GIT_VERSION),'UNKNOWN (builddir: $(RIOTBASE))')
|
||||
|
||||
# Set module by prepending APPLICATION name with 'application_'.
|
||||
# It prevents conflict with application and modules with the same name.
|
||||
@ -733,12 +721,14 @@ $(RIOTBUILD_CONFIG_HEADER_C): FORCE
|
||||
$(Q)'$(RIOTTOOLS)/genconfigheader/genconfigheader.sh' $(CFLAGS_WITH_MACROS) \
|
||||
| '$(LAZYSPONGE)' $(LAZYSPONGE_FLAGS) '$@'
|
||||
|
||||
CFLAGS_WITH_MACROS := $(CFLAGS)
|
||||
# Immediate evaluation but keep CLAGS_WITH_MACROS deferred
|
||||
_CFLAGS := $(CFLAGS)
|
||||
CFLAGS_WITH_MACROS = $(_CFLAGS)
|
||||
|
||||
ifneq (,$(RIOT_VERSION_OVERRIDE))
|
||||
export CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION_OVERRIDE)\"
|
||||
CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION_OVERRIDE)\"
|
||||
else
|
||||
export CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION)\"
|
||||
CFLAGS_WITH_MACROS += -DRIOT_VERSION=\"$(RIOT_VERSION)\"
|
||||
endif
|
||||
|
||||
CFLAGS := $(patsubst -D%,,$(CFLAGS))
|
||||
|
11
makefiles/git_version.inc.mk
Normal file
11
makefiles/git_version.inc.mk
Normal file
@ -0,0 +1,11 @@
|
||||
# GIT_VERSION is git description + branch name if it not master
|
||||
# Empty when not in a git repository
|
||||
#
|
||||
# 2019.10-devel-97-g3bcc72
|
||||
# 2019.10-devel-97-g3bcc72-pr/git_version
|
||||
|
||||
GIT_DESCRIBE = $(call memoized,GIT_DESCRIBE,$(shell git --git-dir="$(RIOTBASE)/.git" describe --always --abbrev=4 2> /dev/null))
|
||||
GIT_BRANCH = $(call memoized,GIT_BRANCH,$(shell git --git-dir="$(RIOTBASE)/.git" rev-parse --abbrev-ref HEAD))
|
||||
_GIT_VERSION = $(GIT_DESCRIBE)$(addprefix -,$(GIT_BRANCH:master=))
|
||||
|
||||
GIT_VERSION ?= $(if $(GIT_DESCRIBE),$(_GIT_VERSION))
|
Loading…
Reference in New Issue
Block a user