Merge pull request #83 from phl0/GitID

Include Git ID in Modem description
This commit is contained in:
Jonathan Naylor 2017-04-12 12:43:01 +01:00 committed by GitHub
commit 42517d691e
3 changed files with 24 additions and 3 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
obj/ obj/
bin/ bin/
STM32F4XX_Lib/ STM32F4XX_Lib/
GitVersion.h

View File

@ -36,19 +36,19 @@ ifdef SYSTEMROOT
ASOURCES=$(shell dir /S /B *.s) ASOURCES=$(shell dir /S /B *.s)
CSOURCES=$(shell dir /S /B *.c) CSOURCES=$(shell dir /S /B *.c)
CXXSOURCES=$(shell dir /S /B *.cpp) CXXSOURCES=$(shell dir /S /B *.cpp)
CLEANCMD=del /S *.o *.hex *.bin *.elf CLEANCMD=del /S *.o *.hex *.bin *.elf GitVersion.h
MDBIN=md $@ MDBIN=md $@
else ifdef SystemRoot else ifdef SystemRoot
ASOURCES=$(shell dir /S /B *.s) ASOURCES=$(shell dir /S /B *.s)
CSOURCES=$(shell dir /S /B *.c) CSOURCES=$(shell dir /S /B *.c)
CXXSOURCES=$(shell dir /S /B *.cpp) CXXSOURCES=$(shell dir /S /B *.cpp)
CLEANCMD=del /S *.o *.hex *.bin *.elf CLEANCMD=del /S *.o *.hex *.bin *.elf GitVersion.h
MDBIN=md $@ MDBIN=md $@
else else
ASOURCES=$(shell find . -name '*.s') ASOURCES=$(shell find . -name '*.s')
CSOURCES=$(shell find . -name '*.c') CSOURCES=$(shell find . -name '*.c')
CXXSOURCES=$(shell find . -name '*.cpp') CXXSOURCES=$(shell find . -name '*.cpp')
CLEANCMD=rm -f $(OBJECTS) $(BINDIR)/$(BINELF) $(BINDIR)/$(BINHEX) $(BINDIR)/$(BINBIN) CLEANCMD=rm -f $(OBJECTS) $(BINDIR)/$(BINELF) $(BINDIR)/$(BINHEX) $(BINDIR)/$(BINBIN) GitVersion.h
MDBIN=mkdir $@ MDBIN=mkdir $@
endif endif
@ -109,6 +109,7 @@ pi: CXXFLAGS+=$(DEFS_PI) -Os -fno-exceptions -ffunction-sections -fdata-sections
pi: LDFLAGS+=-Os --specs=nano.specs pi: LDFLAGS+=-Os --specs=nano.specs
pi: release pi: release
nucleo: GitVersion.h
nucleo: CFLAGS+=$(DEFS_NUCLEO) -Os -ffunction-sections -fdata-sections -fno-builtin -Wno-implicit -DCUSTOM_NEW -DNO_EXCEPTIONS nucleo: CFLAGS+=$(DEFS_NUCLEO) -Os -ffunction-sections -fdata-sections -fno-builtin -Wno-implicit -DCUSTOM_NEW -DNO_EXCEPTIONS
nucleo: CXXFLAGS+=$(DEFS_NUCLEO) -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-builtin -fno-rtti -DCUSTOM_NEW -DNO_EXCEPTIONS nucleo: CXXFLAGS+=$(DEFS_NUCLEO) -Os -fno-exceptions -ffunction-sections -fdata-sections -fno-builtin -fno-rtti -DCUSTOM_NEW -DNO_EXCEPTIONS
nucleo: LDFLAGS+=-Os --specs=nano.specs nucleo: LDFLAGS+=-Os --specs=nano.specs
@ -171,3 +172,11 @@ endif
ifneq ($(wildcard /opt/openocd/bin/openocd),) ifneq ($(wildcard /opt/openocd/bin/openocd),)
/opt/openocd/bin/openocd -f /opt/openocd/share/openocd/scripts/board/stm32f4discovery.cfg -c "program bin/$(BINELF) verify reset exit" /opt/openocd/bin/openocd -f /opt/openocd/share/openocd/scripts/board/stm32f4discovery.cfg -c "program bin/$(BINELF) verify reset exit"
endif endif
# Export the current git version if the index file exists, else 000...
GitVersion.h:
ifneq ("$(wildcard .git/index)","")
echo "#define GITVERSION \"$(shell git rev-parse --short HEAD)\"" > $@
else
echo "#define GITVERSION \"0000000\"" > $@
endif

View File

@ -22,6 +22,11 @@
#include "Config.h" #include "Config.h"
#include "Globals.h" #include "Globals.h"
#if defined(STM32F4XX) || defined(STM32F4)
#include "GitVersion.h"
#endif
#include "SerialPort.h" #include "SerialPort.h"
const uint8_t MMDVM_FRAME_START = 0xE0U; const uint8_t MMDVM_FRAME_START = 0xE0U;
@ -74,8 +79,14 @@ const uint8_t MMDVM_DEBUG5 = 0xF5U;
#else #else
#define DESCRIPTION "MMDVM 20170406 (D-Star/DMR/System Fusion/P25/RSSI/CW Id)" #define DESCRIPTION "MMDVM 20170406 (D-Star/DMR/System Fusion/P25/RSSI/CW Id)"
#endif #endif
#if defined(GITVERSION)
#define concat(a, b) a " GitID #"b""
const char HARDWARE[] = concat(DESCRIPTION, GITVERSION);
#else
#define concat(a, b, c) a " (Build: " b " " c ")" #define concat(a, b, c) a " (Build: " b " " c ")"
const char HARDWARE[] = concat(DESCRIPTION, __TIME__, __DATE__); const char HARDWARE[] = concat(DESCRIPTION, __TIME__, __DATE__);
#endif
const uint8_t PROTOCOL_VERSION = 1U; const uint8_t PROTOCOL_VERSION = 1U;