Skip to content

Commit 5e70fed

Browse files
committed
general: add git hash to build version
Signed-off-by: Kieran Levin <ktl@frame.work>
1 parent e52ac56 commit 5e70fed

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ COSMOCC=../cosmopolitan
55
gpu_cfg_generator.exe: gpu_cfg_generator
66
cp gpu_cfg_gen gpu_cfg_gen.exe
77

8+
GIT_HASH := $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
9+
810
gpu_cfg_generator: gpu_cfg_generator.c gpu_cfg_generator.h
9-
$(COSMOCC)/bin/cosmocc -o gpu_cfg_gen *.c -I ./
11+
$(COSMOCC)/bin/cosmocc -o gpu_cfg_gen *.c -I ./ -DGIT_HASH=\"$(GIT_HASH)\"
1012

1113
native: gpu_cfg_generator.c gpu_cfg_generator.h
12-
$(CC) -o gpu_cfg_gen *.c -Wall -I ./
14+
$(CC) -o gpu_cfg_gen *.c -Wall -I ./ -DGIT_HASH=\"$(GIT_HASH)\"
1315

1416

1517
clean :

gpu_cfg_generator.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#include <gpu_cfg_generator.h>
22
#include "crc.h"
33

4+
#ifndef GIT_HASH
5+
#define GIT_HASH "unknown"
6+
#endif
7+
48

59
static bool verbose = false;
610

@@ -539,7 +543,7 @@ int main(int argc, char *argv[]) {
539543
default:
540544
abort ();
541545
}
542-
printf("Build: %s %s\n", __DATE__, __TIME__);
546+
printf("Build: %s %s (%s)\n", __DATE__, __TIME__, GIT_HASH);
543547

544548
if (infilename) {
545549
read_eeprom(infilename);

0 commit comments

Comments
 (0)