mudgangster

Tiny, scriptable MUD client
Log | Files | Refs | README

commit 1a383ebc6b4a14a1b3325278e2064f35bd27f6c3
parent 6c242d72a5352d5501d9c5ca1554b90e6f3268dd
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sun,  3 May 2020 02:09:48 +0300

Print git hash at startup

Diffstat:
M.gitignore | 1+
MMakefile | 1+
Aggbuild/git_version.lua | 25+++++++++++++++++++++++++
Mmake.lua | 1+
Msrc/ui.cc | 4++++
5 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -1,6 +1,7 @@ /build /release /build.ninja +/src/gitversion.h /mudgangster /mudgangster-* diff --git a/Makefile b/Makefile @@ -33,6 +33,7 @@ clean: @$(NINJA) -t clean || true @$(LUA) make.lua bench > build.ninja || true @$(NINJA) -t clean || true + @rm -f src/gitversion.h @rm -rf build release @rm -f *.exp *.ilk *.ilp *.lib *.pdb @rm -f build.ninja diff --git a/ggbuild/git_version.lua b/ggbuild/git_version.lua @@ -0,0 +1,25 @@ +local function exec( cmd ) + local pipe = assert( io.popen( cmd ) ) + local res = pipe:read( "*line" ) + pipe:close() + return res or "" +end + +local version = exec( "git tag --points-at HEAD" ) +if version == "" then + version = exec( "git rev-parse --short HEAD" ) +end + +local gitversion = "#define APP_VERSION \"" .. version .. "\"\n" + +local r = io.open( "src/gitversion.h", "r" ) +local current = r and r:read( "*all" ) +if r then + r:close() +end + +if current ~= gitversion then + local w = assert( io.open( "src/gitversion.h", "w" ) ) + w:write( gitversion ) + assert( w:close() ) +end diff --git a/make.lua b/make.lua @@ -1,4 +1,5 @@ require( "ggbuild.gen_ninja" ) +require( "ggbuild.git_version" ) require( "libs.tracy" ) require( "libs.whereami" ) diff --git a/src/ui.cc b/src/ui.cc @@ -1,6 +1,7 @@ #include "platform_ui.h" #include "input.h" #include "textbox.h" +#include "gitversion.h" static TextBox main_text; static TextBox chat_text; @@ -28,6 +29,9 @@ void ui_init() { statusContents = ( StatusChar * ) malloc( statusCapacity * sizeof( StatusChar ) ); if( statusContents == NULL ) FATAL( "malloc" ); + + ui_main_print( "> Mud Gangster ", 0, SYSTEM, BLACK, false ); + ui_main_print( APP_VERSION, 0, SYSTEM, BLACK, true ); } void ui_term() {