Extract version info into a static library to speed up builds (bug 5990, r=ds).
authorDavid Anderson <dvander@alliedmods.net>
Sat Nov 23 19:10:27 2013 -0800 (2013-11-23)
changeset 887e30d4a37f5e5
parent 886 94a2f05e21e3
child 888 70905719a92b
Extract version info into a static library to speed up builds (bug 5990, r=ds).
AMBuildScript
core-legacy/concommands.cpp
core-legacy/sourcemm.cpp
core-legacy/sourcemm.h
core-legacy/vsp_bridge.cpp
core/metamod.cpp
core/metamod.h
core/metamod_console.cpp
core/vsp_bridge.cpp
versionlib/AMBuildScript
versionlib/versionlib.cpp
versionlib/versionlib.h
     1.1 --- a/AMBuildScript	Mon Nov 18 12:57:33 2013 -0800
     1.2 +++ b/AMBuildScript	Sat Nov 23 19:10:27 2013 -0800
     1.3 @@ -63,6 +63,7 @@
     1.4      self.sdks = {}
     1.5      self.binaries = []
     1.6      self.generated_headers = None
     1.7 +    self.versionlib = None
     1.8  
     1.9    def detectProductVersion(self):
    1.10      builder.AddConfigureFile('product.version')
    1.11 @@ -214,6 +215,7 @@
    1.12      # Finish up.
    1.13      cfg.defines += ['MMS_GENERATED_BUILD']
    1.14      cfg.includes += [os.path.join(builder.buildPath, 'includes')]
    1.15 +    cfg.includes += [os.path.join(builder.sourcePath, 'versionlib')]
    1.16      cfg.cxxincludes += [os.path.join(builder.sourcePath, 'public')]
    1.17  
    1.18    def HL2Compiler(self, context, sdk):
    1.19 @@ -276,6 +278,7 @@
    1.20          '-compatibility_version', '1.0.0',
    1.21          '-current_version', self.productVersion
    1.22        ]
    1.23 +    binary.compiler.linkflags += [self.versionlib]
    1.24      binary.compiler.sourcedeps += MMS.generated_headers
    1.25      return binary
    1.26  
    1.27 @@ -354,6 +357,10 @@
    1.28    'support/buildbot/Versioning',
    1.29    { 'MMS': MMS }
    1.30  )
    1.31 +MMS.versionlib = builder.RunScript(
    1.32 +  'versionlib/AMBuildScript',
    1.33 +  { 'MMS': MMS }
    1.34 +)
    1.35  
    1.36  builder.RunBuildScripts(
    1.37    [
     2.1 --- a/core-legacy/concommands.cpp	Mon Nov 18 12:57:33 2013 -0800
     2.2 +++ b/core-legacy/concommands.cpp	Sat Nov 23 19:10:27 2013 -0800
     2.3 @@ -16,6 +16,7 @@
     2.4  #include "sh_string.h"
     2.5  #include "sh_list.h"
     2.6  #include "util.h"
     2.7 +#include <versionlib.h>
     2.8  
     2.9  /**
    2.10   * @brief Console Command Implementations
    2.11 @@ -105,7 +106,7 @@
    2.12  	}
    2.13  }
    2.14  
    2.15 -ConVar metamod_version("metamod_version", MMS_FULL_VERSION, FCVAR_SPONLY | FCVAR_NOTIFY, "Metamod:Source Version");
    2.16 +ConVar metamod_version("metamod_version", METAMOD_VERSION, FCVAR_SPONLY | FCVAR_NOTIFY, "Metamod:Source Version");
    2.17  #ifdef OS_WIN32
    2.18  ConVar mm_pluginsfile("mm_pluginsfile", "addons\\metamod\\metaplugins.ini", FCVAR_SPONLY, "Metamod:Source Plugins File");
    2.19  ConVar mm_basedir("mm_basedir", "addons\\metamod", FCVAR_SPONLY, "Metamod:Source base folder");
    2.20 @@ -140,8 +141,8 @@
    2.21  			
    2.22  			return;
    2.23  		} else if (strcmp(command, "version") == 0) {
    2.24 -			CONMSG("Metamod:Source version %s\n", MMS_FULL_VERSION);
    2.25 -			CONMSG("Build ID: %s\n", MMS_BUILD_UNIQUEID);
    2.26 +			CONMSG("Metamod:Source version %s\n", METAMOD_VERSION);
    2.27 +			CONMSG("Build ID: %s\n", METAMOD_BUILD_ID);
    2.28  			if (g_GameDll.loaded)
    2.29  			{
    2.30  				CONMSG("Loaded As: GameDLL (gameinfo.txt)\n");
    2.31 @@ -644,7 +645,7 @@
    2.32  
    2.33  				RETURN_META(MRES_SUPERCEDE);
    2.34  			} else if(strcmp(subcmd, "version") == 0) {
    2.35 -				CLIENT_CONMSG(client, "Metamod:Source version %s\n", MMS_FULL_VERSION);
    2.36 +				CLIENT_CONMSG(client, "Metamod:Source version %s\n", METAMOD_VERSION);
    2.37  				CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE);
    2.38  				CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", PLAPI_VERSION, PLAPI_MIN_VERSION);
    2.39  				CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SourceHook.GetIfaceVersion(), g_SourceHook.GetImplVersion());
     3.1 --- a/core-legacy/sourcemm.cpp	Mon Nov 18 12:57:33 2013 -0800
     3.2 +++ b/core-legacy/sourcemm.cpp	Sat Nov 23 19:10:27 2013 -0800
     3.3 @@ -475,7 +475,7 @@
     3.4  	}
     3.5  
     3.6  	char buffer[255], error[255], full_path[PATH_SIZE];
     3.7 -	const char *ptr, *ext, *file;
     3.8 +	const char *file;
     3.9  	size_t length;
    3.10  	while (!feof(fp) && fgets(buffer, sizeof(buffer), fp) != NULL)
    3.11  	{
     4.1 --- a/core-legacy/sourcemm.h	Mon Nov 18 12:57:33 2013 -0800
     4.2 +++ b/core-legacy/sourcemm.h	Sat Nov 23 19:10:27 2013 -0800
     4.3 @@ -23,7 +23,6 @@
     4.4  #include "ISmmAPI.h"
     4.5  #include "CPlugin.h"
     4.6  #include "oslink.h"
     4.7 -#include <metamod_version.h>
     4.8  #include "loader_bridge.h"
     4.9  
    4.10  /**
     5.1 --- a/core-legacy/vsp_bridge.cpp	Mon Nov 18 12:57:33 2013 -0800
     5.2 +++ b/core-legacy/vsp_bridge.cpp	Sat Nov 23 19:10:27 2013 -0800
     5.3 @@ -28,13 +28,15 @@
     5.4  #include "concommands.h"
     5.5  #include "util.h"
     5.6  #include <loader_bridge.h>
     5.7 +#include <sh_string.h>
     5.8 +#include <versionlib.h>
     5.9  
    5.10  SH_DECL_HOOK0_void(ConCommand, Dispatch, SH_NOATTRIB, false);
    5.11  
    5.12  ConCommand *g_plugin_unload = NULL;
    5.13  bool g_bIsTryingToUnload;
    5.14  bool g_bIsBridgedAsVsp;
    5.15 -const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION;
    5.16 +SourceHook::String vsp_desc("Metamod:Source");
    5.17  
    5.18  void InterceptPluginUnloads()
    5.19  {
    5.20 @@ -54,6 +56,9 @@
    5.21  
    5.22  		if (!g_GameDll.loaded)
    5.23  		{
    5.24 +			vsp_desc.append(" ");
    5.25 +			vsp_desc.append(METAMOD_VERSION);
    5.26 +
    5.27  			CreateInterfaceFn engineFactory = (CreateInterfaceFn)info->engineFactory;
    5.28  			CreateInterfaceFn gsFactory = (CreateInterfaceFn)info->gsFactory;
    5.29  
    5.30 @@ -68,7 +73,8 @@
    5.31  		}
    5.32  		else
    5.33  		{
    5.34 -			vsp_desc = "Metamod:Source Interface " MMS_FULL_VERSION;
    5.35 +			vsp_desc.append(" Interface ");
    5.36 +			vsp_desc.append(METAMOD_VERSION);
    5.37  		}
    5.38  
    5.39  		ConCommandBase *pBase = g_Engine.icvar->GetCommands();
    5.40 @@ -119,7 +125,7 @@
    5.41  
    5.42  	virtual const char *GetDescription()
    5.43  	{
    5.44 -		return vsp_desc;
    5.45 +		return vsp_desc.c_str();
    5.46  	}
    5.47  };
    5.48  
     6.1 --- a/core/metamod.cpp	Mon Nov 18 12:57:33 2013 -0800
     6.2 +++ b/core/metamod.cpp	Sat Nov 23 19:10:27 2013 -0800
     6.3 @@ -28,6 +28,7 @@
     6.4  #include "metamod.h"
     6.5  #include <interface.h>
     6.6  #include <eiface.h>
     6.7 +#include <versionlib.h>
     6.8  #include "metamod_provider.h"
     6.9  #include "metamod_plugins.h"
    6.10  #include "metamod_util.h"
    6.11 @@ -430,11 +431,11 @@
    6.12  	UTIL_Format(buffer,
    6.13  		sizeof(buffer),
    6.14  		"%s%s",
    6.15 -		MMS_FULL_VERSION,
    6.16 +		METAMOD_VERSION,
    6.17  		is_vsp_load ? "V" : "");
    6.18  
    6.19  	metamod_version = provider->CreateConVar("metamod_version", 
    6.20 -		MMS_FULL_VERSION, 
    6.21 +		METAMOD_VERSION, 
    6.22  		"Metamod:Source Version",
    6.23  		ConVarFlag_Notify|ConVarFlag_SpOnly);
    6.24  
     7.1 --- a/core/metamod.h	Mon Nov 18 12:57:33 2013 -0800
     7.2 +++ b/core/metamod.h	Sat Nov 23 19:10:27 2013 -0800
     7.3 @@ -38,7 +38,6 @@
     7.4  #include <sourcehook/sourcehook.h>
     7.5  #include <ISmmPlugin.h>
     7.6  #include "metamod_provider.h"
     7.7 -#include <metamod_version.h>
     7.8  
     7.9  using namespace SourceMM;
    7.10  
     8.1 --- a/core/metamod_console.cpp	Mon Nov 18 12:57:33 2013 -0800
     8.2 +++ b/core/metamod_console.cpp	Sat Nov 23 19:10:27 2013 -0800
     8.3 @@ -26,6 +26,7 @@
     8.4  #include <stdio.h>
     8.5  #include "metamod_oslink.h"
     8.6  #include <ctype.h>
     8.7 +#include <versionlib.h>
     8.8  #include "metamod.h"
     8.9  #include "metamod_util.h"
    8.10  #include "metamod_console.h"
    8.11 @@ -68,8 +69,8 @@
    8.12  		}
    8.13  		else if (strcmp(command, "version") == 0)
    8.14  		{
    8.15 -			CONMSG("Metamod:Source version %s\n", MMS_FULL_VERSION);
    8.16 -			CONMSG("Build ID: %s\n", MMS_BUILD_UNIQUEID);
    8.17 +			CONMSG("Metamod:Source version %s\n", METAMOD_VERSION);
    8.18 +			CONMSG("Build ID: %s\n", METAMOD_BUILD_ID);
    8.19  
    8.20  			if (g_Metamod.IsLoadedAsGameDLL())
    8.21  			{
    8.22 @@ -699,7 +700,7 @@
    8.23  			}
    8.24  			else if(strcmp(subcmd, "version") == 0)
    8.25  			{
    8.26 -				CLIENT_CONMSG(client, "Metamod:Source version %s\n", MMS_FULL_VERSION);
    8.27 +				CLIENT_CONMSG(client, "Metamod:Source version %s\n", METAMOD_VERSION);
    8.28  				CLIENT_CONMSG(client, "Compiled on: %s\n", SOURCEMM_DATE);
    8.29  				CLIENT_CONMSG(client, "Plugin interface version: %d:%d\n", METAMOD_PLAPI_VERSION, PLAPI_MIN_VERSION);
    8.30  				CLIENT_CONMSG(client, "SourceHook version: %d:%d\n", g_SHPtr->GetIfaceVersion(), g_SHPtr->GetImplVersion());
     9.1 --- a/core/vsp_bridge.cpp	Mon Nov 18 12:57:33 2013 -0800
     9.2 +++ b/core/vsp_bridge.cpp	Sat Nov 23 19:10:27 2013 -0800
     9.3 @@ -30,6 +30,8 @@
     9.4  #include <iplayerinfo.h>
     9.5  #include <assert.h>
     9.6  #include <loader_bridge.h>
     9.7 +#include <versionlib.h>
     9.8 +#include <sh_string.h>
     9.9  #include "provider/provider_ep2.h"
    9.10  
    9.11  #if SOURCE_ENGINE == SE_DOTA
    9.12 @@ -42,7 +44,7 @@
    9.13  
    9.14  ConCommand *g_plugin_unload = NULL;
    9.15  bool g_bIsTryingToUnload;
    9.16 -const char *vsp_desc = "Metamod:Source " MMS_FULL_VERSION;
    9.17 +SourceHook::String vsp_desc("Metamod:Source");
    9.18  
    9.19  #if SOURCE_ENGINE == SE_DOTA
    9.20  void InterceptPluginUnloads(const CCommandContext &context, const CCommand &args)
    9.21 @@ -73,6 +75,9 @@
    9.22  	{
    9.23  		if (!g_Metamod.IsLoadedAsGameDLL())
    9.24  		{
    9.25 +			vsp_desc.append(" ");
    9.26 +			vsp_desc.append(METAMOD_VERSION);
    9.27 +
    9.28  			CGlobalVars *pGlobals;
    9.29  			IPlayerInfoManager *playerInfoManager;
    9.30  
    9.31 @@ -126,7 +131,9 @@
    9.32  		}
    9.33  		else
    9.34  		{
    9.35 -			vsp_desc = "Metamod:Source Interface " MMS_FULL_VERSION;
    9.36 +			vsp_desc.append(" Interface ");
    9.37 +			vsp_desc.append(METAMOD_VERSION);
    9.38 +
    9.39  			g_Metamod.NotifyVSPListening(info->vsp_callbacks, info->vsp_version);
    9.40  		}
    9.41  
    9.42 @@ -175,7 +182,7 @@
    9.43  
    9.44  	virtual const char *GetDescription()
    9.45  	{
    9.46 -		return vsp_desc;
    9.47 +		return vsp_desc.c_str();
    9.48  	}
    9.49  };
    9.50  
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/versionlib/AMBuildScript	Sat Nov 23 19:10:27 2013 -0800
    10.3 @@ -0,0 +1,11 @@
    10.4 +# vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
    10.5 +
    10.6 +lib = builder.compiler.StaticLibrary("version")
    10.7 +lib.compiler.sourcedeps += MMS.generated_headers
    10.8 +lib.sources += [
    10.9 +  'versionlib.cpp'
   10.10 +]
   10.11 +cmd = builder.Add(lib)
   10.12 +
   10.13 +rvalue = cmd.binary
   10.14 +
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/versionlib/versionlib.cpp	Sat Nov 23 19:10:27 2013 -0800
    11.3 @@ -0,0 +1,31 @@
    11.4 +/**
    11.5 + * vim: set ts=4 sw=4 tw=99 noet :
    11.6 + * ======================================================
    11.7 + * Metamod:Source
    11.8 + * Copyright (C) 2004-2010 AlliedModders LLC and authors.
    11.9 + * All rights reserved.
   11.10 + * ======================================================
   11.11 + *
   11.12 + * This software is provided 'as-is', without any express or implied warranty.
   11.13 + * In no event will the authors be held liable for any damages arising from 
   11.14 + * the use of this software.
   11.15 + * 
   11.16 + * Permission is granted to anyone to use this software for any purpose, 
   11.17 + * including commercial applications, and to alter it and redistribute it 
   11.18 + * freely, subject to the following restrictions:
   11.19 + *
   11.20 + * 1. The origin of this software must not be misrepresented; you must not 
   11.21 + * claim that you wrote the original software. If you use this software in a 
   11.22 + * product, an acknowledgment in the product documentation would be 
   11.23 + * appreciated but is not required.
   11.24 + * 2. Altered source versions must be plainly marked as such, and must not be
   11.25 + * misrepresented as being the original software.
   11.26 + * 3. This notice may not be removed or altered from any source distribution.
   11.27 + */
   11.28 +
   11.29 +#include <metamod_version.h>
   11.30 +#include <versionlib.h>
   11.31 +
   11.32 +const char *METAMOD_BUILD_ID = MMS_BUILD_UNIQUEID;
   11.33 +const char *METAMOD_VERSION = MMS_FULL_VERSION;
   11.34 +
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/versionlib/versionlib.h	Sat Nov 23 19:10:27 2013 -0800
    12.3 @@ -0,0 +1,31 @@
    12.4 +/**
    12.5 + * vim: set ts=4 sw=4 tw=99 noet :
    12.6 + * ======================================================
    12.7 + * Metamod:Source
    12.8 + * Copyright (C) 2004-2010 AlliedModders LLC and authors.
    12.9 + * All rights reserved.
   12.10 + * ======================================================
   12.11 + *
   12.12 + * This software is provided 'as-is', without any express or implied warranty.
   12.13 + * In no event will the authors be held liable for any damages arising from 
   12.14 + * the use of this software.
   12.15 + * 
   12.16 + * Permission is granted to anyone to use this software for any purpose, 
   12.17 + * including commercial applications, and to alter it and redistribute it 
   12.18 + * freely, subject to the following restrictions:
   12.19 + *
   12.20 + * 1. The origin of this software must not be misrepresented; you must not 
   12.21 + * claim that you wrote the original software. If you use this software in a 
   12.22 + * product, an acknowledgment in the product documentation would be 
   12.23 + * appreciated but is not required.
   12.24 + * 2. Altered source versions must be plainly marked as such, and must not be
   12.25 + * misrepresented as being the original software.
   12.26 + * 3. This notice may not be removed or altered from any source distribution.
   12.27 + */
   12.28 +#ifndef _INCLUDE_METAMOD_VERSIONLIB_H_
   12.29 +#define _INCLUDE_METAMOD_VERSIONLIB_H_
   12.30 +
   12.31 +extern "C" const char *METAMOD_BUILD_ID;
   12.32 +extern "C" const char *METAMOD_VERSION;
   12.33 +
   12.34 +#endif // _INCLUDE_METAMOD_VERSIONLIB_H_