From ae6920cdf9fed20780ed671c86150b00283c67b6 Mon Sep 17 00:00:00 2001 From: Tristan Krause Date: Fri, 28 Jun 2019 13:31:15 +0200 Subject: [PATCH] makefile --- firmware/Makefile | 8 +++++++- firmware/commit_hash.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 firmware/commit_hash.h diff --git a/firmware/Makefile b/firmware/Makefile index 76308ba..4ec9c02 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -28,7 +28,9 @@ OBJECTS = main.o spi.o mcp23s17.o tlc5615.o adu.o selftest.o global_vars.o us COMPILE = $(COMPILER_PATH) $(CFLAGS) FUSES = (E:$(EFUSE), H:$(HFUSE), L:$(LFUSE)) -b15f: $(OBJECTS) +.PHONY: commit_hash + +b15f: commit_hash $(OBJECTS) @echo "Linking binary..." $(COMPILE) $(OBJECTS) -o $(OUTPUT) $(LDFLAGS) @@ -51,5 +53,9 @@ upload: b15f checkfuses @echo "Uploading hex file..." avrdude -v -Pusb -p $(MCU) -c $(PROGRAMMER) -U flash:w:$(HEX) +commit_hash: + @echo "Updating commit hash..." + @echo -e "#ifndef COMMIT_HASH_H\n#define COMMIT_HASH_H\nconstexpr char* COMMIT_HASH = \"`git log --pretty=format:'%H' -n 1`\";\n#endif // COMMIT_HASH_H" > commit_hash.h + .cpp.o: $(COMPILE) -c $< -o $@ diff --git a/firmware/commit_hash.h b/firmware/commit_hash.h new file mode 100644 index 0000000..6671807 --- /dev/null +++ b/firmware/commit_hash.h @@ -0,0 +1,4 @@ +#ifndef COMMIT_HASH_H +#define COMMIT_HASH_H +constexpr char* COMMIT_HASH = "2e29c6fcb5debd952e967adc773d396b7f645450"; +#endif // COMMIT_HASH_H