mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-06 21:08:08 +00:00
Merge pull request #374 from piotrmalek/master
Improve bootloader version parsing from GIT_VERSION
This commit is contained in:
+16
-7
@@ -316,13 +316,22 @@ endif()
|
||||
execute_process(COMMAND git describe --dirty --always --tags OUTPUT_VARIABLE GIT_VERSION)
|
||||
string(STRIP ${GIT_VERSION} GIT_VERSION)
|
||||
|
||||
string(REPLACE "-" ";" RELEASE_VERSION ${GIT_VERSION})
|
||||
list(GET RELEASE_VERSION 0 RELEASE_VERSION)
|
||||
string(REPLACE "." ";" RELEASE_VERSION ${RELEASE_VERSION})
|
||||
list(GET RELEASE_VERSION 0 RELEASE_VERSION_MAJOR)
|
||||
list(GET RELEASE_VERSION 1 RELEASE_VERSION_MINOR)
|
||||
list(GET RELEASE_VERSION 2 RELEASE_VERSION_PATCH)
|
||||
math(EXPR MK_BOOTLOADER_VERSION "(${RELEASE_VERSION_MAJOR} << 16) + (${RELEASE_VERSION_MINOR} << 8) + ${RELEASE_VERSION_PATCH}")
|
||||
# Extract semantic version numbers (MAJOR.MINOR.PATCH) from GIT_VERSION.
|
||||
# Supports tags like:
|
||||
# v1.2.3
|
||||
# 1.2.3
|
||||
# 1.2.3-147-gd71abcd
|
||||
# If the version string does not match MAJOR.MINOR.PATCH, defaults to 0.0.0.
|
||||
if(GIT_VERSION MATCHES "^v?([0-9]+)\\.([0-9]+)\\.([0-9]+)")
|
||||
set(RELEASE_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
set(RELEASE_VERSION_MINOR ${CMAKE_MATCH_2})
|
||||
set(RELEASE_VERSION_PATCH ${CMAKE_MATCH_3})
|
||||
else()
|
||||
set(RELEASE_VERSION_MAJOR 0)
|
||||
set(RELEASE_VERSION_MINOR 0)
|
||||
set(RELEASE_VERSION_PATCH 0)
|
||||
endif()
|
||||
math(EXPR MK_BOOTLOADER_VERSION "((${RELEASE_VERSION_MAJOR} << 16) | (${RELEASE_VERSION_MINOR} << 8) | ${RELEASE_VERSION_PATCH})")
|
||||
|
||||
cmake_print_variables(GIT_VERSION MK_BOOTLOADER_VERSION)
|
||||
|
||||
|
||||
@@ -262,7 +262,7 @@ IPATH += \
|
||||
src/cmsis/include \
|
||||
src/usb \
|
||||
$(TUSB_PATH)
|
||||
|
||||
|
||||
ifeq ($(SIGNED_FW), 1)
|
||||
IPATH += \
|
||||
$(TCRYPT_PATH)/include
|
||||
@@ -376,8 +376,25 @@ ifeq ($(DEFAULT_TO_OTA_DFU), 1)
|
||||
CFLAGS += -DDEFAULT_TO_OTA_DFU
|
||||
endif
|
||||
|
||||
_VER = $(subst ., ,$(word 1, $(subst -, ,$(GIT_VERSION))))
|
||||
CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)) << 8) + $(word 3,$(_VER))'
|
||||
# Extract semantic version numbers (MAJOR.MINOR.PATCH) from GIT_VERSION.
|
||||
# Supports tags like:
|
||||
# v1.2.3
|
||||
# 1.2.3
|
||||
# 1.2.3-147-gd71abcd
|
||||
# If the version string does not match MAJOR.MINOR.PATCH, defaults to 0.0.0.
|
||||
_VER3 := $(shell echo "$(GIT_VERSION)" | sed -E 's/^v?([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 \2 \3/; t; s/.*/0 0 0/')
|
||||
|
||||
# Split extracted version into individual numeric components
|
||||
_VER_MAJ := $(word 1,$(_VER3))
|
||||
_VER_MIN := $(word 2,$(_VER3))
|
||||
_VER_PAT := $(word 3,$(_VER3))
|
||||
|
||||
# Pack MAJOR.MINOR.PATCH into a single 32-bit integer:
|
||||
# [31:16] MAJOR
|
||||
# [15:8] MINOR
|
||||
# [7:0] PATCH
|
||||
# This value is stored in the bootloader version register and must be a valid C integer constant.
|
||||
CFLAGS += -DMK_BOOTLOADER_VERSION='((($(_VER_MAJ)<<16)|($(_VER_MIN)<<8)|($(_VER_PAT))))'
|
||||
|
||||
# Debug option use RTT for printf
|
||||
ifeq ($(DEBUG), 1)
|
||||
|
||||
Reference in New Issue
Block a user