From ebe789aa52afa359894f0d11d2958b1439a3acca Mon Sep 17 00:00:00 2001 From: Rickey Fehr Date: Tue, 23 Sep 2025 16:15:50 -0700 Subject: [PATCH] Add git hash baked into ROM for bug reports --- Makefile | 6 ++++++ include/version.h | 7 +++++++ source/game.c | 1 + 3 files changed, 14 insertions(+) create mode 100644 include/version.h diff --git a/Makefile b/Makefile index 9bee64f..d76c021 100644 --- a/Makefile +++ b/Makefile @@ -38,11 +38,17 @@ GRAPHICS := graphics #--------------------------------------------------------------------------------- ARCH := -mthumb -mthumb-interwork +GIT_DIRTY := $(shell git diff-index --quiet HEAD -- || echo "-dirty") +GIT_HASH := $(shell git rev-parse --short HEAD) +GIT_C_FLAGS := -DGIT_HASH=\"$(GIT_HASH)\" -DGIT_DIRTY=\"$(GIT_DIRTY)\" + CFLAGS := -g -O3 -Wall -Werror\ -mcpu=arm7tdmi -mtune=arm7tdmi \ -ffast-math -fomit-frame-pointer -funroll-loops \ $(ARCH) +CFLAGS += $(GIT_C_FLAGS) + CFLAGS += $(INCLUDE) CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions diff --git a/include/version.h b/include/version.h new file mode 100644 index 0000000..8e1345b --- /dev/null +++ b/include/version.h @@ -0,0 +1,7 @@ +#ifndef VERSION_H +#define VERSION_H + +__attribute__((used)) +const char gba_version[] = "GBA_VERSION:" GIT_HASH GIT_DIRTY; + +#endif // VERSION_H diff --git a/source/game.c b/source/game.c index 625ecc6..018ebb6 100644 --- a/source/game.c +++ b/source/game.c @@ -28,6 +28,7 @@ #include "soundbank.h" #include "list.h" +#include "version.h" static uint rng_seed = 0;