Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ add_feature_info(OpenW3DHeadless W3D_FDS "Build OpenW3D headless server")
option(W3D_TOOLS "Build additional tools." ON)
add_feature_info(OpenW3DTools W3D_TOOLS "Build OpenW3D Mod Tools")

# Do we want to embed git information into the binary?
option(W3D_EMBED_GIT_INFO "Embed information from git." OFF)
add_feature_info(W3DEmbedGit W3D_EMBED_GIT_INFO "Embed information from git")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should make embedding git information optional.
When we ever do a source release, we should then make sure that it can build without git.


option(SYNTAX_CHECK_ONLY "Syntax check the files only?" OFF)
add_feature_info(SyntaxCheck SYNTAX_CHECK_ONLY "Syntax check files only")
if(SYNTAX_CHECK_ONLY)
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"cacheVariables": {
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
"CMAKE_MSVC_DEBUG_INFORMATION_FORMAT": "$<$<CONFIG:Release,Debug,RelWithDebInfo>:Embedded>",
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL",
"W3D_EMBED_GIT_INFO": "ON"
}
},
{
Expand Down
1 change: 1 addition & 0 deletions Code/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ else()
endif()

# Module static libraries
add_subdirectory(GitInfo)
add_subdirectory(BinkMovie)
add_subdirectory(Combat)
add_subdirectory(SControl)
Expand Down
2 changes: 2 additions & 0 deletions Code/Commando/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ if(W3D_CLIENT) # Full game client

target_link_libraries(renegade PRIVATE
commando
gitinfo
)

embed_resources(renegade
Expand All @@ -491,6 +492,7 @@ if(W3D_FDS) # Dedicated headless server

target_link_libraries(renegadeserver PRIVATE
commando
gitinfo
)

target_compile_definitions(renegadeserver PRIVATE FREEDEDICATEDSERVER)
Expand Down
2 changes: 1 addition & 1 deletion Code/Commando/ConsoleMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void ConsoleModeClass::Init(void)
#else //FREEDEDICATEDSERVER
Print("Renegade ");
#endif //FREEDEDICATEDSERVER
Print("v%d.%.3d %s-%s %s\n", (version_major >> 16), (version_major & 0xFFFF), BuildInfoClass::Get_Builder_Initials(), BuildInfoClass::Get_Build_Number_String(), BuildInfoClass::Get_Build_Date_String());
Print("v%s %s-%s %s\n", BuildInfoClass::Get_Build_Version_String(), BuildInfoClass::Get_Build_Commit_String(), BuildInfoClass::Get_Build_Number_String(), BuildInfoClass::Get_Build_Date_String());
Print("Console mode active\n");

LastKeypressTime = 0;
Expand Down
104 changes: 25 additions & 79 deletions Code/Commando/buildnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,11 @@
*---------------------------------------------------------------------------------------------*
* Functions: *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

#include "always.h"
#include "buildnum.h"
#include "wwdebug.h"
#include "gitinfo.h"
#include <stdio.h>
#include "win.h"

/*
**
** This is just a placeholder for the build number.
** A post build step will stamp the build number into here.
**
*/
char BuildInfoClass::BuildNumber [64] = {"Insert1Build2Number3Here4 xxxx "};
char BuildInfoClass::BuildDate [64] = {"Insert1Build2Date3Here4 xxxx "};
#include <string.h>

/***********************************************************************************************
* BuildInfoClass::Get_Build_Number -- Gets the 32 bit build number. *
Expand All @@ -65,12 +55,9 @@ char BuildInfoClass::BuildDate [64] = {"Insert1Build2Date3Here4 xxxx
*=============================================================================================*/
unsigned int BuildInfoClass::Get_Build_Number(void)
{
return (*(unsigned int*)(&BuildNumber[28]));
return (GitRevision);
}




/***********************************************************************************************
* BuildInfoClass::Get_Build_Number_String -- Gets the build number as a human readable string.*
* *
Expand All @@ -88,13 +75,10 @@ unsigned int BuildInfoClass::Get_Build_Number(void)
const char *BuildInfoClass::Get_Build_Number_String(void)
{
static char _buffer[16];
sprintf (_buffer, "%d", *(unsigned int*)(&BuildNumber[28]));
sprintf (_buffer, "%u", GitRevision);
return (_buffer);
}




/***********************************************************************************************
* BuildInfoClass::Get_Builder_Name -- Gets the name of the person who built this executable. *
* *
Expand All @@ -111,11 +95,9 @@ const char *BuildInfoClass::Get_Build_Number_String(void)
*=============================================================================================*/
const char *BuildInfoClass::Get_Builder_Name(void)
{
return(&BuildNumber[32]);
return BuildAuthorName;
}



/***********************************************************************************************
* BuildInfoClass::Get_Build_Date_String -- Gets the date this executable was built on. *
* *
Expand All @@ -132,47 +114,7 @@ const char *BuildInfoClass::Get_Builder_Name(void)
*=============================================================================================*/
const char *BuildInfoClass::Get_Build_Date_String(void)
{
static char _buffer[64];
SYSTEMTIME systime;

if (FileTimeToSystemTime ((LPFILETIME)(&BuildDate[28]), &systime) ) {
sprintf(_buffer, "%02d/%02d/%04d - %02d:%02d:%02d", systime.wMonth, systime.wDay, systime.wYear, systime.wHour, systime.wMinute, systime.wSecond);
} else {
_buffer[0] = 0;
}

return(_buffer);
}



/***********************************************************************************************
* BuildInfoClass::Get_Builder_Initials -- Gets the initials of the builder *
* *
* *
* *
* INPUT: Nothing *
* *
* OUTPUT: Ptr to string containing initials *
* *
* WARNINGS: None *
* *
* HISTORY: *
* 10/29/2001 5:12PM ST : Created *
*=============================================================================================*/
const char *BuildInfoClass::Get_Builder_Initials(void)
{
static char _buffer[4];

_buffer[0] = BuildNumber[32];
_buffer[1] = 0;
_buffer[2] = 0;

char *lastname = strchr(&BuildNumber[32], '_');
if (lastname) {
_buffer[1] = lastname[1];
}
return (_buffer);
return(GitCommitDate);
}

/***********************************************************************************************
Expand All @@ -192,12 +134,22 @@ const char *BuildInfoClass::Get_Builder_Initials(void)
const char *BuildInfoClass::Get_Build_Version_String(void)
{
static char _buffer[128];
sprintf(_buffer, "%s-%s", Get_Builder_Initials(), Get_Build_Number_String());
sprintf(_buffer, "%u.%u.%u.%u", GitMajor, GitMinor, GitPatch, GitRevision);
return(_buffer);
}

const char *BuildInfoClass::Get_Build_Commit_String(bool short_str)
{
if (short_str)
return(GitShortSHA1);
else
return(GitSHA1);
}


bool BuildInfoClass::Is_Build_Dirty(void)
{
return(GitUncommittedChanges);
}

/***********************************************************************************************
* BuildInfoClass::Get_Build_Type -- Get the type of build this is *
Expand Down Expand Up @@ -226,8 +178,6 @@ BuildInfoClass::BuildType BuildInfoClass::Get_Build_Type(void)
#endif //_DEBUG
}



/***********************************************************************************************
* BuildInfoClass::Get_Build_Type_String -- Get the build type as a string. *
* *
Expand Down Expand Up @@ -260,10 +210,6 @@ const char *BuildInfoClass::Get_Build_Type_String(void)
}
}





/***********************************************************************************************
* BuildInfoClass::Composite_Build_Info -- Get lots of build info *
* *
Expand All @@ -281,12 +227,16 @@ const char *BuildInfoClass::Get_Build_Type_String(void)
const char *BuildInfoClass::Composite_Build_Info(void)
{
static char _buffer[256];
sprintf(_buffer, "%s Build %d by %s - Build time %s", Get_Build_Type_String(), Get_Build_Number(), Get_Builder_Name(), Get_Build_Date_String());
[[maybe_unused]] int written = snprintf(_buffer, sizeof(_buffer), "%s %s Commit %s%s at %s",
BuildAuthorName,
Get_Build_Type_String(),
Is_Build_Dirty() ? "~" : "",
GitShortSHA1,
GitCommitDate);
WWASSERT(unsigned(written) < sizeof(_buffer));
return(_buffer);
}



/***********************************************************************************************
* BuildInfoClass::Log_Build_Info -- Dump build info to the logfile. *
* *
Expand All @@ -306,7 +256,3 @@ void BuildInfoClass::Log_Build_Info(void)
WWDEBUG_SAY((Composite_Build_Info()));
WWDEBUG_SAY(("\n"));
}




23 changes: 9 additions & 14 deletions Code/Commando/buildnum.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,19 @@ class BuildInfoClass
static const char *Get_Build_Date_String(void);

/*
** Gets the initials of the person who built this executable.
** Get a composite build number string with the works.
*/
static const char *Get_Builder_Initials(void);
static const char *Get_Build_Version_String(void);

/*
** Get a composite build number string with the works.
** Get a git hash string.
*/
static const char *Get_Build_Version_String(void);
static const char *Get_Build_Commit_String(bool short_str = true);

/*
** Is build tree modified since commit?
*/
static bool Is_Build_Dirty(void);

/*
** Get build type.
Expand All @@ -99,14 +104,4 @@ class BuildInfoClass
** Lots of build info together.
*/
static const char *Composite_Build_Info(void);




private:
static char BuildNumber [64];
static char BuildDate [64];
};



17 changes: 13 additions & 4 deletions Code/Commando/dlgmainmenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
#include "translatedb.h"
#include "string_ids.h"
#include "gamespyadmin.h"
#include "gitinfo.h"

////////////////////////////////////////////////////////////////
// Static member initialization
Expand Down Expand Up @@ -503,11 +504,19 @@ MainMenuDialogClass::Update_Version_Number (void)
// Put the version string into the dialog
//
WideStringClass version_string;
// Add build number temporarily. Will probably be removed for shipping.
WideStringClass build_number(BuildInfoClass::Get_Build_Number_String(), true);
WideStringClass build_initials(BuildInfoClass::Get_Builder_Initials(), true);
WideStringClass build_ver(BuildInfoClass::Get_Build_Version_String(), true);

WideStringClass build_hash(BuildInfoClass::Get_Build_Commit_String(), true);
if(BuildInfoClass::Is_Build_Dirty())
build_hash += L"~";

WideStringClass build_date(BuildInfoClass::Get_Build_Date_String(), true);
version_string.Format (U_CHAR("v%d.%.3d %s-%s %s"), (version_major >> 16), (version_major & 0xFFFF), build_initials, build_number, build_date);
WideStringClass build_author(BuildInfoClass::Get_Builder_Name(), true);
version_string.Format (U_CHAR("%s %s %s %s"),
static_cast<const unichar_t*>(build_ver),
static_cast<const unichar_t*>(build_hash),
static_cast<const unichar_t*>(build_author),
static_cast<const unichar_t*>(build_date));
Set_Dlg_Item_Text (IDC_VERSION_STATIC, version_string);
}

Expand Down
16 changes: 16 additions & 0 deletions Code/GitInfo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Embed some git version information in the binary.
set(PRE_CONFIGURE_FILE "gitinfo.cpp.in")
set(POST_CONFIGURE_FILE "${CMAKE_CURRENT_BINARY_DIR}/gitinfo.cpp")
if(NOT W3D_BUILD_AUTHOR)
set(W3D_BUILD_AUTHOR $ENV{W3D_BUILD_AUTHOR})
endif()
set(GIT_BUILD_AUTHOR ${W3D_BUILD_AUTHOR})

if(W3D_EMBED_GIT_INFO)
set(GIT_INFO_ENABLED TRUE)
endif()

include(GitWatcher.cmake)

add_library(gitinfo OBJECT ${CMAKE_CURRENT_BINARY_DIR}/gitinfo.cpp)
target_include_directories(gitinfo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
Loading
Loading