mirror of
https://github.com/dhewm/dhewm3.git
synced 2025-03-21 02:01:03 +00:00
Support reproducible builds, fixes #172
If REPRODUCIBLE_BUILD is enabled in CMake, the code will not use __DATE__ or __TIME__ macros, but instead hardcoded values. Wherever __DATE__ or __TIME__ were previously used, we now use ID__DATE__ and ID__TIME__, which are either set to hardcoded values or to __DATE__ and __TIME__ in neo/framework/Licensee.h.
This commit is contained in:
parent
504b572ae4
commit
5e7019ebfe
7 changed files with 30 additions and 8 deletions
|
@ -50,11 +50,12 @@ option(CORE "Build the core" ON)
|
|||
option(BASE "Build the base game code" ON)
|
||||
option(D3XP "Build the d3xp game code" ON)
|
||||
if(MSVC)
|
||||
option(TOOLS "Build the tools game code (Windows+Visual Studio+SDL2 only)" OFF)
|
||||
option(TOOLS "Build the tools game code (32bit Windows+Visual Studio+SDL2 only)" OFF)
|
||||
endif()
|
||||
option(DEDICATED "Build the dedicated server" OFF)
|
||||
option(ONATIVE "Optimize for the host CPU" OFF)
|
||||
option(SDL2 "Use SDL2 instead of SDL1.2" ON)
|
||||
option(REPRODUCIBLE_BUILD "Replace __DATE__ and __TIME__ by hardcoded values for reproducible builds" OFF)
|
||||
|
||||
if(NOT CMAKE_SYSTEM_PROCESSOR)
|
||||
message(FATAL_ERROR "No target CPU architecture set")
|
||||
|
@ -153,6 +154,12 @@ else()
|
|||
set(SDLx_LIBRARY ${SDL_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(REPRODUCIBLE_BUILD)
|
||||
# don't use __DATE__ and __TIME__ macros so builds are reproducible
|
||||
add_definitions(-DID_REPRODUCIBLE_BUILD)
|
||||
endif()
|
||||
|
||||
|
||||
find_package(CURL QUIET)
|
||||
if(CURL_FOUND)
|
||||
set(ID_ENABLE_CURL ON)
|
||||
|
|
|
@ -47,6 +47,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "Misc.h"
|
||||
#include "Trigger.h"
|
||||
|
||||
#include "framework/Licensee.h" // DG: for ID__DATE__
|
||||
|
||||
#include "Game_local.h"
|
||||
|
||||
const int NUM_RENDER_PORTAL_BITS = idMath::BitsForInteger( PS_BLOCK_ALL );
|
||||
|
@ -328,7 +330,7 @@ void idGameLocal::Init( void ) {
|
|||
|
||||
Printf( "----- Initializing Game -----\n" );
|
||||
Printf( "gamename: %s\n", GAME_VERSION );
|
||||
Printf( "gamedate: %s\n", __DATE__ );
|
||||
Printf( "gamedate: %s\n", ID__DATE__ );
|
||||
|
||||
// register game specific decl types
|
||||
declManager->RegisterDeclType( "model", DECL_MODELDEF, idDeclAllocator<idDeclModelDef> );
|
||||
|
|
|
@ -65,7 +65,7 @@ const char *ui_skinArgs[] = { "skins/characters/player/marine_mp", "skins/char
|
|||
const char *ui_teamArgs[] = { "Red", "Blue", NULL };
|
||||
|
||||
struct gameVersion_s {
|
||||
gameVersion_s( void ) { sprintf( string, "%s.%d%s %s-%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_OS, BUILD_CPU, __DATE__, __TIME__ ); }
|
||||
gameVersion_s( void ) { sprintf( string, "%s.%d%s %s-%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_OS, BUILD_CPU, ID__DATE__, ID__TIME__ ); }
|
||||
char string[256];
|
||||
} gameVersion;
|
||||
|
||||
|
@ -73,7 +73,7 @@ idCVar g_version( "g_version", gameVersion.string, CVAR_GAME | CVAR_ROM,
|
|||
|
||||
// noset vars
|
||||
idCVar gamename( "gamename", GAME_VERSION, CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "" );
|
||||
idCVar gamedate( "gamedate", __DATE__, CVAR_GAME | CVAR_ROM, "" );
|
||||
idCVar gamedate( "gamedate", ID__DATE__, CVAR_GAME | CVAR_ROM, "" );
|
||||
|
||||
// server info
|
||||
idCVar si_name( "si_name", "dhewm server", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "name of the server" );
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef enum {
|
|||
#endif
|
||||
|
||||
struct version_s {
|
||||
version_s( void ) { sprintf( string, "%s.%d%s %s-%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_OS, BUILD_CPU, __DATE__, __TIME__ ); }
|
||||
version_s( void ) { sprintf( string, "%s.%d%s %s-%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_OS, BUILD_CPU, ID__DATE__, ID__TIME__ ); }
|
||||
char string[256];
|
||||
} version;
|
||||
|
||||
|
|
|
@ -43,6 +43,17 @@ If you have questions concerning this license or the applicable additional terms
|
|||
|
||||
#define ENGINE_VERSION "dhewm3 1.5.1pre" // printed in console
|
||||
|
||||
#ifdef ID_REPRODUCIBLE_BUILD
|
||||
// for reproducible builds we hardcode values that would otherwise come from __DATE__ and __TIME__
|
||||
// NOTE: remember to update esp. the date for (pre-) releases and RCs and the like
|
||||
#define ID__DATE__ "Jul 12 2020"
|
||||
#define ID__TIME__ "13:37:42"
|
||||
|
||||
#else // not reproducible build, use __DATE__ and __TIME__ macros
|
||||
#define ID__DATE__ __DATE__
|
||||
#define ID__TIME__ __TIME__
|
||||
#endif
|
||||
|
||||
// paths
|
||||
#define BASE_GAMEDIR "base"
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ If you have questions concerning this license or the applicable additional terms
|
|||
#include "Misc.h"
|
||||
#include "Trigger.h"
|
||||
|
||||
#include "framework/Licensee.h" // DG: for ID__DATE__
|
||||
|
||||
#include "Game_local.h"
|
||||
|
||||
const int NUM_RENDER_PORTAL_BITS = idMath::BitsForInteger( PS_BLOCK_ALL );
|
||||
|
@ -298,7 +300,7 @@ void idGameLocal::Init( void ) {
|
|||
|
||||
Printf( "----- Initializing Game -----\n" );
|
||||
Printf( "gamename: %s\n", GAME_VERSION );
|
||||
Printf( "gamedate: %s\n", __DATE__ );
|
||||
Printf( "gamedate: %s\n", ID__DATE__ );
|
||||
|
||||
// register game specific decl types
|
||||
declManager->RegisterDeclType( "model", DECL_MODELDEF, idDeclAllocator<idDeclModelDef> );
|
||||
|
|
|
@ -55,7 +55,7 @@ const char *ui_skinArgs[] = { "skins/characters/player/marine_mp", "skins/char
|
|||
const char *ui_teamArgs[] = { "Red", "Blue", NULL };
|
||||
|
||||
struct gameVersion_s {
|
||||
gameVersion_s( void ) { sprintf( string, "%s.%d%s %s-%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_OS, BUILD_CPU, __DATE__, __TIME__ ); }
|
||||
gameVersion_s( void ) { sprintf( string, "%s.%d%s %s-%s %s %s", ENGINE_VERSION, BUILD_NUMBER, BUILD_DEBUG, BUILD_OS, BUILD_CPU, ID__DATE__, ID__TIME__ ); }
|
||||
char string[256];
|
||||
} gameVersion;
|
||||
|
||||
|
@ -63,7 +63,7 @@ idCVar g_version( "g_version", gameVersion.string, CVAR_GAME | CVAR_ROM,
|
|||
|
||||
// noset vars
|
||||
idCVar gamename( "gamename", GAME_VERSION, CVAR_GAME | CVAR_SERVERINFO | CVAR_ROM, "" );
|
||||
idCVar gamedate( "gamedate", __DATE__, CVAR_GAME | CVAR_ROM, "" );
|
||||
idCVar gamedate( "gamedate", ID__DATE__, CVAR_GAME | CVAR_ROM, "" );
|
||||
|
||||
// server info
|
||||
idCVar si_name( "si_name", "dhewm server", CVAR_GAME | CVAR_SERVERINFO | CVAR_ARCHIVE, "name of the server" );
|
||||
|
|
Loading…
Reference in a new issue