]> git.lizzy.rs Git - dragonblocks_alpha.git/commitdiff
Fix version detection
authorElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 26 Aug 2021 10:34:34 +0000 (12:34 +0200)
committerElias Fleckenstein <eliasfleckenstein@web.de>
Thu, 26 Aug 2021 10:34:34 +0000 (12:34 +0200)
.gitignore
src/CMakeLists.txt
src/client/debug_menu.c
src/debug.sh
src/version.cmake [new file with mode: 0644]
src/version.h.in [new file with mode: 0644]

index 51071ea510e6eb3ed36d11bf064897312fc1477a..21e15f08714ecf05234661d8a014252ba702f875 100644 (file)
@@ -13,3 +13,4 @@ DragonblocksServer
 Dragonblocks
 world.sqlite
 DragonblocksAlpha-*.zip
+src/version.h
index bcf2e34f9b0a3bc896eb23a4c9d68e56cb50f121..534244378e28ce9312390e63e83acd9b7a31e6c0 100644 (file)
@@ -90,19 +90,12 @@ target_link_libraries(DragonblocksServer
        sqlite3
 )
 
-execute_process(COMMAND git tag --points-at HEAD
-       OUTPUT_VARIABLE GIT_VERSION
-       OUTPUT_STRIP_TRAILING_WHITESPACE
+add_custom_target(version
+       COMMAND ${CMAKE_COMMAND} -P ${CMAKE_SOURCE_DIR}/version.cmake
 )
 
-if ("${GIT_VERSION}" STREQUAL "")
-       execute_process(COMMAND git rev-parse --short HEAD
-               OUTPUT_VARIABLE GIT_VERSION
-               OUTPUT_STRIP_TRAILING_WHITESPACE
-       )
-endif()
-
-add_compile_definitions(DRAGONBLOCKS_VERSION="${GIT_VERSION}")
+add_dependencies(Dragonblocks version)
+add_dependencies(DragonblocksServer version)
 
 if (CMAKE_BUILD_TYPE STREQUAL "Release")
        add_compile_definitions(RELEASE)
index d9ecd14a77c734ebe0fcda2e93cc8bbd020c72ba..d7ced2aaf722325545029c40a046251cc9a913ef 100644 (file)
@@ -6,6 +6,7 @@
 #include "client/debug_menu.h"
 #include "client/hud.h"
 #include "client/window.h"
+#include "version.h"
 
 typedef enum
 {
@@ -59,7 +60,9 @@ void debug_menu_toggle()
 
 void debug_menu_update_version()
 {
-       hud_change_text(huds[DME_VERSION], "Dragonblocks Alpha " DRAGONBLOCKS_VERSION);
+       char text[BUFSIZ];
+       sprintf(text, "Dragonblocks Alpha %s", VERSION);
+       hud_change_text(huds[DME_VERSION], text);
 }
 
 void debug_menu_update_fps(int fps)
index 0f82ee743730248303554e77534b12390a2ed581..88dc3fa76aaccdd846aed4bd254f46e9fdc515cc 100755 (executable)
@@ -12,6 +12,7 @@ COMMON="set confirm off
 handle SIGTERM nostop print pass
 handle SIGPIPE nostop noprint pass
 set height 0
+set \$_exitcode 1
 define hook-stop
     if \$_exitcode == 0
         quit
diff --git a/src/version.cmake b/src/version.cmake
new file mode 100644 (file)
index 0000000..8845a56
--- /dev/null
@@ -0,0 +1,18 @@
+execute_process(COMMAND git tag --points-at HEAD
+       OUTPUT_VARIABLE GIT_VERSION
+       OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+if ("${GIT_VERSION}" STREQUAL "")
+       execute_process(COMMAND git rev-parse --short HEAD
+               OUTPUT_VARIABLE GIT_VERSION
+               OUTPUT_STRIP_TRAILING_WHITESPACE
+       )
+endif()
+
+set(VERSION_DEF "const char *version = \"${GIT_VERSION}\";")
+
+configure_file(
+       ${CMAKE_SOURCE_DIR}/version.h.in
+       ${CMAKE_SOURCE_DIR}/version.h
+)
diff --git a/src/version.h.in b/src/version.h.in
new file mode 100644 (file)
index 0000000..6db616e
--- /dev/null
@@ -0,0 +1 @@
+#define VERSION "@GIT_VERSION@"