From 7083bc0a06fde61ffd606ec3c742735318ccac7d Mon Sep 17 00:00:00 2001 From: Dan Langford <721364+danlangford@users.noreply.github.com> Date: Fri, 19 May 2023 13:07:30 -0600 Subject: [PATCH 1/6] print version info from git tag and hash --- CMakeLists.txt | 9 +++++++++ src/bmai.cpp | 2 +- src/bmai.h | 5 +++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9a0c6ee..311b576 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,15 @@ set(CMAKE_CXX_EXTENSIONS OFF) project(bmai) +# Get the latest git tag and short commit hash +execute_process( + COMMAND git describe --abbrev=4 --dirty --always --tags + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_VARIABLE GIT_TAG_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE +) +add_definitions("-DGIT_TAG_HASH=\"${GIT_TAG_HASH}\"") + # to collect only needed source files set(SOURCE ./src/bmai.cpp ./src/bmai_ai.cpp ./src/player.cpp ./src/stats.cpp) diff --git a/src/bmai.cpp b/src/bmai.cpp index 90fcc45..bede583 100644 --- a/src/bmai.cpp +++ b/src/bmai.cpp @@ -4114,7 +4114,7 @@ int main(int argc, char *argv[]) //g_ai.SetQAI(&g_ai_mode0); // banner - printf("BMAI: the Button Men AI\nCopyright (c) 2001-2023, Denis Papp.\nFor information, contact Denis Papp, denis@accessdenied.net\n"); + printf("BMAI: the Button Men AI\nCopyright (c) 2001-2023, Denis Papp.\nFor information, contact Denis Papp, denis@accessdenied.net\nVersion: %s\n", GIT_TAG_HASH); //g_parser.SetupTestGame(); if (argc>1) diff --git a/src/bmai.h b/src/bmai.h index 1d2fa1a..680bccf 100644 --- a/src/bmai.h +++ b/src/bmai.h @@ -48,6 +48,11 @@ typedef float F32; // special types typedef std::vector BMC_FloatVector; +// version number +#ifndef GIT_TAG_HASH +#define GIT_TAG_HASH "n/a" +#endif + // assert #define BM_ASSERT assert #define BM_ERROR(check) { if (!(check)) { BMF_Error(#check); } } From 2f72bc9dba6228a9f526f353b7aa75e1bb4a49c1 Mon Sep 17 00:00:00 2001 From: Dan Langford <721364+danlangford@users.noreply.github.com> Date: Fri, 19 May 2023 13:16:23 -0600 Subject: [PATCH 2/6] checkout action needs to pull in more tag data --- .github/workflows/cmake.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 0c6316a..d4fbb66 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -37,6 +37,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + fetch-depth: 0 - uses: lukka/get-cmake@latest - name: CMake Configure From 606c3cf67d1799bb2683a7575c3467cfb8e765d2 Mon Sep 17 00:00:00 2001 From: Dan Langford <721364+danlangford@users.noreply.github.com> Date: Fri, 19 May 2023 13:35:51 -0600 Subject: [PATCH 3/6] dont appreviate git hash --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 311b576..dfa0076 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ project(bmai) # Get the latest git tag and short commit hash execute_process( - COMMAND git describe --abbrev=4 --dirty --always --tags + COMMAND git describe --dirty --always --tags WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} OUTPUT_VARIABLE GIT_TAG_HASH OUTPUT_STRIP_TRAILING_WHITESPACE From 45650c9578a88c932a4c41db8db1793ca2c13a3f Mon Sep 17 00:00:00 2001 From: Dan Langford <721364+danlangford@users.noreply.github.com> Date: Fri, 19 May 2023 13:39:21 -0600 Subject: [PATCH 4/6] changelog comment --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfa0076..466e424 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,5 @@ # drp022521 - reduced from 3.14 to 3.8 for VS2017 support +# dbl051923 - capture git describe for banner cmake_minimum_required (VERSION 3.8) set(CMAKE_CXX_STANDARD 14) From 527a060c90c6d4be296b5d5446fcbcac0807452b Mon Sep 17 00:00:00 2001 From: Dan Langford <721364+danlangford@users.noreply.github.com> Date: Fri, 19 May 2023 13:40:10 -0600 Subject: [PATCH 5/6] formatting --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 466e424..057b590 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ # drp022521 - reduced from 3.14 to 3.8 for VS2017 support # dbl051923 - capture git describe for banner + cmake_minimum_required (VERSION 3.8) set(CMAKE_CXX_STANDARD 14) From 970328213e7fde72d8be40c15c40b62d2d0af45c Mon Sep 17 00:00:00 2001 From: Dan Langford <721364+danlangford@users.noreply.github.com> Date: Fri, 19 May 2023 13:41:54 -0600 Subject: [PATCH 6/6] var naming --- CMakeLists.txt | 4 ++-- src/bmai.cpp | 2 +- src/bmai.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 057b590..1fba524 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,10 +13,10 @@ project(bmai) execute_process( COMMAND git describe --dirty --always --tags WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - OUTPUT_VARIABLE GIT_TAG_HASH + OUTPUT_VARIABLE GIT_DESCRIBE OUTPUT_STRIP_TRAILING_WHITESPACE ) -add_definitions("-DGIT_TAG_HASH=\"${GIT_TAG_HASH}\"") +add_definitions("-DGIT_DESCRIBE=\"${GIT_DESCRIBE}\"") # to collect only needed source files set(SOURCE ./src/bmai.cpp ./src/bmai_ai.cpp ./src/player.cpp ./src/stats.cpp) diff --git a/src/bmai.cpp b/src/bmai.cpp index bede583..69a0146 100644 --- a/src/bmai.cpp +++ b/src/bmai.cpp @@ -4114,7 +4114,7 @@ int main(int argc, char *argv[]) //g_ai.SetQAI(&g_ai_mode0); // banner - printf("BMAI: the Button Men AI\nCopyright (c) 2001-2023, Denis Papp.\nFor information, contact Denis Papp, denis@accessdenied.net\nVersion: %s\n", GIT_TAG_HASH); + printf("BMAI: the Button Men AI\nCopyright (c) 2001-2023, Denis Papp.\nFor information, contact Denis Papp, denis@accessdenied.net\nVersion: %s\n", GIT_DESCRIBE); //g_parser.SetupTestGame(); if (argc>1) diff --git a/src/bmai.h b/src/bmai.h index 680bccf..5b68625 100644 --- a/src/bmai.h +++ b/src/bmai.h @@ -49,8 +49,8 @@ typedef float F32; typedef std::vector BMC_FloatVector; // version number -#ifndef GIT_TAG_HASH -#define GIT_TAG_HASH "n/a" +#ifndef GIT_DESCRIBE +#define GIT_DESCRIBE "n/a" #endif // assert