Skip to content

Commit

Permalink
Move version definition to version.h
Browse files Browse the repository at this point in the history
  • Loading branch information
black-sliver committed Mar 6, 2023
1 parent 75826a4 commit 45a4238
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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)))
Expand Down
3 changes: 2 additions & 1 deletion src/poptracker.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _POPTRACKER_H
#define _POPTRACKER_H

#include "version.h"
#include "app.h"
#include "uilib/ui.h"
#include "ui/defaulttrackerwindow.h"
Expand Down Expand Up @@ -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:
Expand Down
16 changes: 16 additions & 0 deletions src/version.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 45a4238

Please sign in to comment.