From 45a4238997b211c294de2ce1895f4256b379da70 Mon Sep 17 00:00:00 2001 From: black-sliver <59490463+black-sliver@users.noreply.github.com> Date: Mon, 6 Mar 2023 08:19:21 +0100 Subject: [PATCH] Move version definition to version.h --- Makefile | 12 ++++++++++-- src/poptracker.h | 3 ++- src/version.h | 16 ++++++++++++++++ 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 src/version.h diff --git a/Makefile b/Makefile index 028208f6..7a8b7f7d 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,14 @@ NIX_LIBS = -lSDL2_ttf -lSDL2_image $(SSL_LIBS) WIN32_LIBS = -lmingw32 -lSDL2main -lSDL2 -mwindows -lm -lSDL2_image -lz $(SSL_LIBS) -lwsock32 -lws2_32 -ldinput8 -ldxguid -ldxerr8 -luser32 -lusp10 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lversion -lhid -lsetupapi -lfreetype -lbz2 -lpng -lSDL2_ttf -luuid -lrpcrt4 -lcrypt32 -lssp -lcrypt32 -static-libgcc WIN64_LIBS = -lmingw32 -lSDL2main -lSDL2 -mwindows -Wl,--no-undefined -Wl,--dynamicbase -Wl,--nxcompat -lm -ldinput8 -ldxguid -ldxerr8 -luser32 -lusp10 -lgdi32 -lwinmm -limm32 -lole32 -loleaut32 -lshell32 -lsetupapi -lversion -lSDL2_ttf -lSDL2_image $(SSL_LIBS) -lwsock32 -lws2_32 -lfreetype -lpng -lz -lbz2 -lssp -luuid -lrpcrt4 -lcrypt32 -static-libgcc -Wl,--high-entropy-va +# extract version +VERSION_MAJOR := $(shell grep '#define APP_VERSION_MAJOR' $(SRC_DIR)/version.h | rev | cut -d' ' -f 1 | rev ) +VERSION_MINOR := $(shell grep '#define APP_VERSION_MINOR' $(SRC_DIR)/version.h | rev | cut -d' ' -f 1 | rev ) +VERSION_REVISION := $(shell grep '#define APP_VERSION_REVISION' $(SRC_DIR)/version.h | rev | cut -d' ' -f 1 | rev ) +VERSION := $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_REVISION) +VS := $(subst .,-,$(VERSION)) +$(info Version $(VERSION)) + # detect OS and compiler ifeq ($(OS),Windows_NT) IS_WIN = yes @@ -71,10 +79,9 @@ WIN32_EXE = $(WIN32_BUILD_DIR)/$(EXE_NAME).exe WIN64_EXE = $(WIN64_BUILD_DIR)/$(EXE_NAME).exe NIX_EXE = $(NIX_BUILD_DIR)/$(EXE_NAME) HTML = $(WASM_BUILD_DIR)/$(EXE_NAME).html + # dist/zip ifeq ($(CONF), DIST) -VERSION := $(shell grep VERSION_STRING $(SRC_DIR)/poptracker.h | cut -d'"' -f 2 ) -VS := $(subst .,-,$(VERSION)) ifdef IS_OSX OSX_APP := $(NIX_BUILD_DIR)/poptracker.app OSX_ZIP := $(DIST_DIR)/poptracker_$(VS)_macos.zip @@ -85,6 +92,7 @@ endif WIN32_ZIP := $(DIST_DIR)/poptracker_$(VS)_win32.zip WIN64_ZIP := $(DIST_DIR)/poptracker_$(VS)_win64.zip endif + # fragments NIX_OBJ := $(patsubst %.cpp, $(NIX_BUILD_DIR)/%.o, $(SRC)) NIX_OBJ_DIRS := $(sort $(dir $(NIX_OBJ))) diff --git a/src/poptracker.h b/src/poptracker.h index 0a1b4137..0f0ff11e 100644 --- a/src/poptracker.h +++ b/src/poptracker.h @@ -1,6 +1,7 @@ #ifndef _POPTRACKER_H #define _POPTRACKER_H +#include "version.h" #include "app.h" #include "uilib/ui.h" #include "ui/defaulttrackerwindow.h" @@ -79,7 +80,7 @@ class PopTracker final : public App { bool InstallPack(const std::string& uid, PackManager::confirmation_callback confirm = nullptr); static constexpr const char APPNAME[] = "PopTracker"; - static constexpr const char VERSION_STRING[] = "0.22.0"; + static constexpr const char VERSION_STRING[] = APP_VERSION_STRING; static constexpr int AUTOSAVE_INTERVAL = 60; // 1 minute protected: diff --git a/src/version.h b/src/version.h new file mode 100644 index 00000000..8f3251ed --- /dev/null +++ b/src/version.h @@ -0,0 +1,16 @@ +#ifndef _VERSION_H +#define _VERSION_H + +#define APP_VERSION_MAJOR 0 +#define APP_VERSION_MINOR 22 +#define APP_VERSION_REVISION 0 + +#ifndef XSTR +#define XSTR(s) STR(s) +#define STR(s) #s +#endif + +#define APP_VERSION_STRING XSTR(APP_VERSION_MAJOR.APP_VERSION_MINOR.APP_VERSION_REVISION) +#define APP_VERSION_TUPLE APP_VERSION_MAJOR,APP_VERSION_MINOR,APP_VERSION_REVISION,0 + +#endif // _VERSION_H