From 0c67281bd87eb011a37036c5ae1737bed1740b0e Mon Sep 17 00:00:00 2001 From: GalaxyShard Date: Sat, 21 Sep 2024 18:46:49 -0400 Subject: [PATCH 1/2] build: Replace PACKAGE_VERSION & __DATE__ with git tag --- Makefile | 12 +++++++++++- source/compile_date.c | 3 --- source/ndstool.cpp | 2 +- source/ndstool.h | 2 -- 4 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 source/compile_date.c diff --git a/Makefile b/Makefile index 2e7f00b..67b99e2 100644 --- a/Makefile +++ b/Makefile @@ -8,10 +8,20 @@ SOURCEDIRS := source INCLUDEDIRS := source +# Try to find the SDK version if it wasn't already provided e.g. by the parent Makefile +SDK_VERSION ?= $(shell git describe --tags --exact-match --dirty 2>/dev/null) + +# Fallback to commit hash +ifeq ($(SDK_VERSION),) + VERSION_ID := "commit $(shell git describe --always --dirty 2>/dev/null)" +else + VERSION_ID := "BlocksDS $(SDK_VERSION)" +endif + # Defines passed to all files # --------------------------- -DEFINES := -DPACKAGE_VERSION=\"2.3.0\" +DEFINES := -DVERSION_ID=\"$(VERSION_ID)\" # Libraries # --------- diff --git a/source/compile_date.c b/source/compile_date.c deleted file mode 100644 index cb2dbf7..0000000 --- a/source/compile_date.c +++ /dev/null @@ -1,3 +0,0 @@ -// SPDX-FileNotice: Modified from the original version by the BlocksDS project, starting from 2023. - -const char CompileDate[] = __DATE__; diff --git a/source/ndstool.cpp b/source/ndstool.cpp index 4d5099b..b2f6bdb 100644 --- a/source/ndstool.cpp +++ b/source/ndstool.cpp @@ -60,7 +60,7 @@ unsigned int appFlags = 0x01; void Title() { - printf("Nintendo DS rom tool " PACKAGE_VERSION " - %s\nby Rafael Vuijk, Dave Murphy, Alexei Karpenko\n",CompileDate); + printf("Nintendo DS rom tool (" VERSION_ID ")\nby Rafael Vuijk, Dave Murphy, Alexei Karpenko\n"); } // Argument information diff --git a/source/ndstool.h b/source/ndstool.h index bdcca37..37fc830 100644 --- a/source/ndstool.h +++ b/source/ndstool.h @@ -74,5 +74,3 @@ extern char *gamecode; extern int latency1; extern int latency2; extern unsigned int romversion; - -extern const char CompileDate[]; From 24bedf002bff26d167fe0539e60d2ffe7db99a2d Mon Sep 17 00:00:00 2001 From: GalaxyShard Date: Sun, 6 Oct 2024 02:06:34 -0400 Subject: [PATCH 2/2] build: exclude older git tags from prefixing version hash --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 67b99e2..2e94415 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,8 @@ SDK_VERSION ?= $(shell git describe --tags --exact-match --dirty 2>/dev/null) # Fallback to commit hash ifeq ($(SDK_VERSION),) - VERSION_ID := "commit $(shell git describe --always --dirty 2>/dev/null)" + # --exclude to prevent any older tags from being displayed + VERSION_ID := "commit $(shell git describe --always --dirty --exclude '*' 2>/dev/null)" else VERSION_ID := "BlocksDS $(SDK_VERSION)" endif