diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index dcc05d5e..fb2e4f79 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -9,6 +9,11 @@ // startup. Implementation of an idea by Prof Braino to inform user that any changes made to this // build by the user have been successfully uploaded into firmware. #define STRING_VERSION_CONFIG_H __DATE__ " " __TIME__ // build date and time + +#ifdef STRING_GIT_VERSION +#define STRING_CONFIG_H_AUTHOR STRING_GIT_VERSION +#endif + #ifndef STRING_CONFIG_H_AUTHOR #define STRING_CONFIG_H_AUTHOR "Version DEV" // Who made the changes. #endif diff --git a/Marlin/Makefile b/Marlin/Makefile index c746619d..28ed1114 100644 --- a/Marlin/Makefile +++ b/Marlin/Makefile @@ -54,6 +54,21 @@ UPLOAD_PORT ?= /dev/arduino #Directory used to build files in, contains all the build files, from object files to the final hex file. BUILD_DIR ?= applet +# Use git-revisions for builds +# Release version +GIT_VERSION=$(shell git describe --tags --exact-match --dirty 2> /dev/null) +ifeq ($(strip $(GIT_VERSION)), ) +# Dev version +GIT_VERSION=$(shell git describe --tags --dirty 2> /dev/null) +endif +# Fallback if the above for some reason fail +ifeq ($(strip $(GIT_VERSION)), ) +GIT_VERSION=$(shell git describe --always 2> /dev/null) +endif +ifneq ($(strip $(GIT_VERSION)), ) +GITVER='-D STRING_GIT_VERSION="$(GIT_VERSION)"' +endif + ############################################################################ # Below here nothing should be changed... @@ -284,8 +299,8 @@ CTUNING += -DMOTHERBOARD=${HARDWARE_MOTHERBOARD} endif #CEXTRA = -Wa,-adhlns=$(<:.c=.lst) -CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) -CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) +CFLAGS := $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CEXTRA) $(CTUNING) $(GITVER) +CXXFLAGS := $(CDEFS) $(CINCS) -O$(OPT) -Wall $(CEXTRA) $(CTUNING) $(GITVER) #ASFLAGS = -Wa,-adhlns=$(<:.S=.lst),-gstabs LDFLAGS = -lm diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 696a010d..b9dade89 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -449,6 +449,10 @@ void setup() SERIAL_ECHOLNPGM(STRING_CONFIG_H_AUTHOR); SERIAL_ECHOPGM("Compiled: "); SERIAL_ECHOLNPGM(__DATE__); + #ifdef STRING_GIT_VERSION + SERIAL_ECHOPGM("Git version: "); + SERIAL_ECHOLNPGM(STRING_GIT_VERSION); + #endif #endif #endif SERIAL_ECHO_START;