diff --git a/Makefile b/Makefile index f63209b3f..fac5309ef 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,7 @@ default: all # Preprocessor definitions DEFINES := +C_DEFINES := #==============================================================================# # Build Options # @@ -333,13 +334,13 @@ OPT_FLAGS += $(BITS) TARGET := sm64.$(VERSION) -# Stuff for showing the git hash in the intro on nightly builds -# From https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source -#ifeq ($(shell git rev-parse --abbrev-ref HEAD),nightly) -# GIT_HASH=`git rev-parse --short HEAD` -# COMPILE_TIME=`date -u +'%Y-%m-%d %H:%M:%S UTC'` -# DEFINES += -DNIGHTLY -DGIT_HASH="\"$(GIT_HASH)\"" -DCOMPILE_TIME="\"$(COMPILE_TIME)\"" -#endif +# Stuff for showing the git hash and build time in dev builds +# Originally from https://stackoverflow.com/questions/44038428/include-git-commit-hash-and-or-branch-name-in-c-c-source +ifneq ($(shell git rev-parse --abbrev-ref HEAD),main) + GIT_HASH=$(shell git rev-parse --short HEAD) + COMPILE_TIME=$(shell date -u +'%Y-%m-%d %H:%M:%S UTC') + C_DEFINES += -DGIT_HASH="\"$(GIT_HASH)\"" -DCOMPILE_TIME="\"$(COMPILE_TIME)\"" +endif # GRUCODE - selects which RSP microcode to use. @@ -841,7 +842,7 @@ ifneq ($(SDL1_USED)$(SDL2_USED),00) endif endif -C_DEFINES := $(foreach d,$(DEFINES),-D$(d)) +C_DEFINES += $(foreach d,$(DEFINES),-D$(d)) DEF_INC_CFLAGS := $(foreach i,$(INCLUDE_DIRS),-I$(i)) $(C_DEFINES) # Check code syntax with host compiler diff --git a/src/pc/djui/djui_panel_main.c b/src/pc/djui/djui_panel_main.c index a32f3d415..08b730d95 100644 --- a/src/pc/djui/djui_panel_main.c +++ b/src/pc/djui/djui_panel_main.c @@ -61,7 +61,11 @@ void djui_panel_main_create(struct DjuiBase* caller) { djui_base_set_color(&message->base, 255, 255, 160, 255); djui_text_set_alignment(message, DJUI_HALIGN_CENTER, DJUI_VALIGN_BOTTOM); } else { + #ifdef COMPILE_TIME + struct DjuiText* version = djui_text_create(&panel->base, get_version_with_build_date()); + #else struct DjuiText* version = djui_text_create(&panel->base, get_version()); + #endif djui_base_set_size_type(&version->base, DJUI_SVT_RELATIVE, DJUI_SVT_ABSOLUTE); djui_base_set_size(&version->base, 1.0f, 1.0f); djui_base_set_color(&version->base, 50, 50, 50, 255); diff --git a/src/pc/network/version.c b/src/pc/network/version.c index 085d3fe0f..a061882ae 100644 --- a/src/pc/network/version.c +++ b/src/pc/network/version.c @@ -10,6 +10,17 @@ const char* get_version(void) { snprintf(sVersionString, MAX_VERSION_LENGTH, "%s", SM64COOPDX_VERSION); #else snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %s", SM64COOPDX_VERSION, VERSION_REGION); -#endif +#endif // VERSION_US return sVersionString; -} \ No newline at end of file +} + +#ifdef COMPILE_TIME +const char* get_version_with_build_date(void) { +#if defined(VERSION_US) + snprintf(sVersionString, MAX_VERSION_LENGTH, "%s, %s", SM64COOPDX_VERSION, COMPILE_TIME); +#else + snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %s, %s", SM64COOPDX_VERSION, VERSION_REGION, COMPILE_TIME); +#endif // VERSION_US + return sVersionString; +} +#endif \ No newline at end of file diff --git a/src/pc/network/version.h b/src/pc/network/version.h index 476c44ffe..7d37bb292 100644 --- a/src/pc/network/version.h +++ b/src/pc/network/version.h @@ -29,8 +29,11 @@ #define WINDOW_NAME "Super Mario 64 Coop Deluxe" #endif -#define MAX_VERSION_LENGTH 32 +#define MAX_VERSION_LENGTH 128 const char* get_version(void); +#ifdef COMPILE_TIME +const char* get_version_with_build_date(void); +#endif #endif