From 3ee3ecfeeebf23af86c0eb0493c70cf1127cd2b9 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Thu, 1 Oct 2026 09:12:29 -0700 Subject: [PATCH] do not require git to build correctly; optionally mix in IDs in builds, do not reference git hash without checking in raddbg; do not build/run metaprogram by default in build.sh; also match build.bat behavior of single 'release' arg implying raddbg build --- build.bat | 11 +++++++---- build.sh | 18 ++++++++++-------- src/raddbg/raddbg_core.c | 2 ++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/build.bat b/build.bat index 684a30d3..9d384c56 100644 --- a/build.bat +++ b/build.bat @@ -69,6 +69,13 @@ if "%pgo%"=="1" ( ) ) +:: --- Mix Git Commit ID ------------------------------------------------------ +git rev-parse --is-inside-work-tree >nul 2>&1 && set in_git_tree=1 +if "%in_git_tree%"=="1" ( + for /f %%i in ('call git describe --always --dirty') do set auto_compile_flags=!auto_compile_flags! -DBUILD_GIT_HASH=\"%%i\" + for /f %%i in ('call git rev-parse HEAD') do set auto_compile_flags=!auto_compile_flags! -DBUILD_GIT_HASH_FULL=\"%%i\" +) + :: --- Compile/Link Line Definitions ------------------------------------------ set cl_common= /I..\src\ /I..\local\ /nologo /FC /Z7 /Zc:preprocessor set cl_debug= call cl /Od /Ob1 /DBUILD_DEBUG=1 %cl_common% %auto_compile_flags% @@ -127,10 +134,6 @@ pushd build %rc% /nologo /fo logo.res ..\data\logo.rc || exit /b 1 popd -:: --- Get Current Git Commit Id ---------------------------------------------- -for /f %%i in ('call git describe --always --dirty') do set compile=%compile% -DBUILD_GIT_HASH=\"%%i\" -for /f %%i in ('call git rev-parse HEAD') do set compile=%compile% -DBUILD_GIT_HASH_FULL=\"%%i\" - :: --- Build & Run Metaprogram ------------------------------------------------ pushd build if "%meta%"=="1" ( diff --git a/build.sh b/build.sh index da58b7da..dfa98c5a 100755 --- a/build.sh +++ b/build.sh @@ -3,22 +3,24 @@ set -eu cd "$(dirname "$0")" # --- Unpack Arguments -------------------------------------------------------- +auto_compile_flags="" for arg in "$@"; do declare $arg='1'; done if [[ "$#" == "0" ]]; then raddbg='1'; fi -cc_sanitize="" +if [[ "$#" == "1" && "${release:-0}" == "1" ]]; then raddbg='1'; fi if [[ "${asan:-0}" == "1" ]]; then echo "[asan enabled]" - cc_sanitize="-fsanitize=address" + auto_compile_flags="-fsanitize=address" fi -# --- Get Current Git Commit Id ----------------------------------------------- -git_hash=$(git describe --always --dirty) -git_hash_full=$(git rev-parse HEAD) +# --- Mix Git Commit ID ------------------------------------------------------- +if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then + auto_compile_flags="-DBUILD_GIT_HASH=\"$(git describe --always --dirty)\" -DBUILD_GIT_HASH_FULL=$(git rev-parse HEAD)" +fi # --- Compile/Link Line Definitions ------------------------------------------- cc_cflags_gcc="" -cc_cflags_clang=${cc_sanitize}" -fdiagnostics-absolute-paths -Wno-for-loop-analysis -Wno-incompatible-pointer-types-discards-qualifiers -Wno-initializer-overrides -Wno-compare-distinct-pointer-types -Wno-single-bit-bitfield-constant-conversion -Wno-deprecated-declarations -Wno-writable-strings -Wno-unknown-warning-option -Wno-deprecated-register -Wno-unused-local-typedef -msse2" -cc_common="-mcx16 -I../src/ -I../local/ -D_GNU_SOURCE -g -DBUILD_GIT_HASH=\"$git_hash\" -DBUILD_GIT_HASH_FULL=\"$git_hash_full\" -Wall -Wno-missing-braces -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-value -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf" +cc_cflags_clang=" -fdiagnostics-absolute-paths -Wno-for-loop-analysis -Wno-incompatible-pointer-types-discards-qualifiers -Wno-initializer-overrides -Wno-compare-distinct-pointer-types -Wno-single-bit-bitfield-constant-conversion -Wno-deprecated-declarations -Wno-writable-strings -Wno-unknown-warning-option -Wno-deprecated-register -Wno-unused-local-typedef -msse2" +cc_common=${auto_compile_flags}"-mcx16 -I../src/ -I../local/ -D_GNU_SOURCE -g -Wall -Wno-missing-braces -Wno-unused-function -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-value -D_USE_MATH_DEFINES -Dstrdup=_strdup -Dgnu_printf=printf" cc_debug="-g -O0 -DBUILD_DEBUG=1 ${cc_common}" cc_release="-g -O2 -DBUILD_DEBUG=0 ${cc_common}" cc_link="-lpthread -lm -lrt -ldl" @@ -58,7 +60,7 @@ compile() { mkdir -p build local # --- Build & Run Metaprogram ------------------------------------------------- -if [[ "${no_meta:-0}" == "0" ]] +if [[ "${meta:-0}" == "1" ]] then echo "[building metagen]" cd build diff --git a/src/raddbg/raddbg_core.c b/src/raddbg/raddbg_core.c index 70a0dfb5..05e46e50 100644 --- a/src/raddbg/raddbg_core.c +++ b/src/raddbg/raddbg_core.c @@ -1830,7 +1830,9 @@ rd_view_ui(Rng2F32 rect) UI_TagF("weak") { ui_label(s(BUILD_VERSION_STRING_LITERAL " " BUILD_RELEASE_PHASE_STRING_LITERAL)); +#if defined(BUILD_GIT_HASH) ui_label(s(BUILD_GIT_HASH)); +#endif } }