Move versioning to a static library to improve trivial build speed (bug 5997 part 9, r=ds).

This commit is contained in:
David Anderson 2013-12-30 17:51:00 -05:00
parent c2cfe60102
commit f82224eba0
27 changed files with 164 additions and 46 deletions

View File

@ -68,6 +68,7 @@ class SMConfig(object):
self.mysql_root = None
self.spcomp = None
self.smx_files = {}
self.versionlib = None
def detectProductVersion(self):
builder.AddConfigureFile('product.version')
@ -245,8 +246,10 @@ class SMConfig(object):
cfg.defines += [
'SOURCEMOD_BUILD',
'SM_GENERATED_BUILD',
'SM_USE_VERSIONLIB',
]
cfg.includes += [os.path.join(builder.buildPath, 'includes')]
cfg.includes += [os.path.join(builder.sourcePath, 'versionlib')]
def LibraryBuilder(self, compiler, name):
binary = compiler.Library(name)
@ -261,6 +264,7 @@ class SMConfig(object):
'-compatibility_version', '1.0.0',
'-current_version', self.productVersion
]
binary.compiler.linkflags += [self.versionlib]
binary.compiler.sourcedeps += SM.generated_headers
return binary
@ -272,6 +276,7 @@ class SMConfig(object):
'BINARY_NAME="{0}"'.format(binary.outputFile),
'SM_GENERATED_BUILD'
]
binary.compiler.linkflags += [self.versionlib]
binary.compiler.sourcedeps += SM.generated_headers
return binary
@ -432,6 +437,10 @@ SM.generated_headers = builder.RunScript(
'tools/buildbot/Versioning',
{ 'SM': SM }
)
SM.versionlib = builder.RunScript(
'versionlib/AMBuilder',
{ 'SM': SM }
)
builder.RunBuildScripts(
[

View File

@ -34,12 +34,12 @@
#include "sourcemod.h"
#include "sourcemm_api.h"
#include "sm_srvcmds.h"
#include <sourcemod_version.h>
#include "sm_stringutil.h"
#include "LibrarySys.h"
#include "Logger.h"
#include "frame_hooks.h"
#include "logic_bridge.h"
#include <sourcemod_version.h>
#ifdef PLATFORM_WINDOWS
ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
@ -410,7 +410,7 @@ bool SM_ExecuteConfig(IPlugin *pl, AutoConfig *cfg, bool can_create)
FILE *fp = fopen(file, "wt");
if (fp)
{
fprintf(fp, "// This file was auto-generated by SourceMod (v%s)\n", SM_VERSION_STRING);
fprintf(fp, "// This file was auto-generated by SourceMod (v%s)\n", SOURCEMOD_VERSION);
fprintf(fp, "// ConVars for plugin \"%s\"\n", pl->GetFilename());
fprintf(fp, "\n\n");

View File

@ -36,8 +36,8 @@
#include "Logger.h"
#include "LibrarySys.h"
#include "TimerSys.h"
#include <sourcemod_version.h>
#include "logic_bridge.h"
#include <sourcemod_version.h>
Logger g_Logger;
@ -165,7 +165,7 @@ void Logger::_NewMapFile()
} else {
char date[32];
strftime(date, sizeof(date), "%m/%d/%Y - %H:%M:%S", curtime);
fprintf(fp, "L %s: SourceMod log file started (file \"L%02d%02d%03d.log\") (Version \"%s\")\n", date, curtime->tm_mon + 1, curtime->tm_mday, i, SM_VERSION_STRING);
fprintf(fp, "L %s: SourceMod log file started (file \"L%02d%02d%03d.log\") (Version \"%s\")\n", date, curtime->tm_mon + 1, curtime->tm_mday, i, SOURCEMOD_VERSION);
fclose(fp);
}
}
@ -384,7 +384,7 @@ void Logger::LogMessageEx(const char *vafmt, va_list ap)
char date[32];
m_DailyPrintHdr = false;
strftime(date, sizeof(date), "%m/%d/%Y - %H:%M:%S", curtime);
fprintf(fp, "L %s: SourceMod log file session started (file \"L%04d%02d%02d.log\") (Version \"%s\")\n", date, curtime->tm_year + 1900, curtime->tm_mon + 1, curtime->tm_mday, SM_VERSION_STRING);
fprintf(fp, "L %s: SourceMod log file session started (file \"L%04d%02d%02d.log\") (Version \"%s\")\n", date, curtime->tm_year + 1900, curtime->tm_mon + 1, curtime->tm_mday, SOURCEMOD_VERSION);
}
LogToOpenFileEx(fp, vafmt, ap);
fclose(fp);

View File

@ -43,9 +43,9 @@
#include <inetchannel.h>
#include <iclient.h>
#include <IGameConfigs.h>
#include <sourcemod_version.h>
#include "ConsoleDetours.h"
#include "logic_bridge.h"
#include <sourcemod_version.h>
PlayerManager g_Players;
bool g_OnMapStarted = false;
@ -1065,7 +1065,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity)
}
ClientConsolePrint(pEntity,
"SourceMod %s, by AlliedModders LLC", SM_VERSION_STRING);
"SourceMod %s, by AlliedModders LLC", SOURCEMOD_VERSION);
ClientConsolePrint(pEntity,
"To see running plugins, type \"sm plugins\"");
ClientConsolePrint(pEntity,

View File

@ -30,15 +30,15 @@
*/
#include "sm_srvcmds.h"
#include <sourcemod_version.h>
#include "sm_stringutil.h"
#include "CoreConfig.h"
#include "ConVarManager.h"
#include "logic_bridge.h"
#include <sourcemod_version.h>
RootConsoleMenu g_RootMenu;
ConVar sourcemod_version("sourcemod_version", SM_VERSION_STRING, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, "SourceMod Version");
ConVar sourcemod_version("sourcemod_version", SOURCEMOD_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, "SourceMod Version");
RootConsoleMenu::RootConsoleMenu()
{
@ -333,14 +333,14 @@ void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand &
else if (strcmp(cmdname, "version") == 0)
{
ConsolePrint(" SourceMod Version Information:");
ConsolePrint(" SourceMod Version: %s", SM_VERSION_STRING);
ConsolePrint(" SourceMod Version: %s", SOURCEMOD_VERSION);
if (g_pSourcePawn2->IsJitEnabled())
ConsolePrint(" SourcePawn Engine: %s (build %s)", g_pSourcePawn2->GetEngineName(), g_pSourcePawn2->GetVersionString());
else
ConsolePrint(" SourcePawn Engine: %s (build %s NO JIT)", g_pSourcePawn2->GetEngineName(), g_pSourcePawn2->GetVersionString());
ConsolePrint(" SourcePawn API: v1 = %d, v2 = %d", g_pSourcePawn->GetEngineAPIVersion(), g_pSourcePawn2->GetAPIVersion());
ConsolePrint(" Compiled on: %s %s", __DATE__, __TIME__);
ConsolePrint(" Build ID: %s", SM_BUILD_UNIQUEID);
ConsolePrint(" Build ID: %s", SOURCEMOD_BUILD_ID);
ConsolePrint(" http://www.sourcemod.net/");
}
}

View File

@ -31,11 +31,11 @@
#include "sourcemod.h"
#include "sourcemm_api.h"
#include <sourcemod_version.h>
#include "Logger.h"
#include "concmd_cleaner.h"
#include "compat_wrappers.h"
#include "logic_bridge.h"
#include <sourcemod_version.h>
SourceMod_Core g_SourceMod_Core;
IVEngineServer *engine = NULL;
@ -149,7 +149,7 @@ const char *SourceMod_Core::GetLicense()
const char *SourceMod_Core::GetVersion()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *SourceMod_Core::GetDate()

View File

@ -61,11 +61,11 @@ bool BinTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
const char *BinTools::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *BinTools::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}

View File

@ -496,12 +496,12 @@ IdentityToken_t *ClientPrefs::GetIdentity() const
const char *ClientPrefs::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *ClientPrefs::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}
ClientPrefs::ClientPrefs()

View File

@ -283,12 +283,12 @@ bool CStrike::ProcessCommandTarget(cmd_target_info_t *info)
const char *CStrike::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *CStrike::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}
void CStrike::OnPluginLoaded(IPlugin *plugin)

View File

@ -78,11 +78,11 @@ void CurlExt::SDK_OnUnload()
const char *CurlExt::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *CurlExt::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}

View File

@ -70,12 +70,12 @@ void GeoIP_Extension::SDK_OnUnload()
const char *GeoIP_Extension::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *GeoIP_Extension::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}
/*******************************

View File

@ -62,11 +62,11 @@ void DBI_MySQL::SDK_OnUnload()
const char *DBI_MySQL::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *DBI_MySQL::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}

View File

@ -65,12 +65,12 @@ void RegexExtension::SDK_OnUnload()
const char *RegexExtension::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *RegexExtension::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}
static cell_t CompileRegex(IPluginContext *pCtx, const cell_t *params)

View File

@ -354,12 +354,12 @@ bool SDKHooks::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
const char *SDKHooks::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *SDKHooks::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}
void SDKHooks::OnPluginLoaded(IPlugin *plugin)

View File

@ -437,12 +437,12 @@ bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
const char *SDKTools::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *SDKTools::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}
void SDKTools::OnClientPutInServer(int client)

View File

@ -89,10 +89,11 @@ else
endif
LINK += -lpthread -m32 -ldl -lm
INCLUDE += -I$(SMSDK)/public/amtl
CFLAGS += -D_LINUX -Dstricmp=strcasecmp -D_stricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp \
-D_snprintf=snprintf -D_vsnprintf=vsnprintf -D_alloca=alloca -Dstrcmpi=strcasecmp -Wall -Werror \
-Wno-uninitialized -mfpmath=sse -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DSQLITE_THREADSAFE \
-Wno-uninitialized -msse -DSOURCEMOD_BUILD -DHAVE_STDINT_H -DSQLITE_THREADSAFE \
-DSQLITE_OMIT_LOAD_EXTENSION -m32
CPPFLAGS += -Wno-non-virtual-dtor -fno-exceptions -fno-rtti

View File

@ -74,11 +74,11 @@ size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
const char *SqliteExt::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *SqliteExt::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}

View File

@ -136,12 +136,12 @@ bool TF2Tools::SDK_OnLoad(char *error, size_t maxlength, bool late)
const char *TF2Tools::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *TF2Tools::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}
bool TF2Tools::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)

View File

@ -67,11 +67,11 @@ void TopMenuExtension::SDK_OnUnload()
const char *TopMenuExtension::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *TopMenuExtension::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}

View File

@ -29,11 +29,11 @@
* Version: $Id$
*/
#include <sourcemod_version.h>
#include <stdlib.h>
#include "extension.h"
#include "Updater.h"
#include "md5.h"
#include <sourcemod_version.h>
#define USTATE_NONE 0
#define USTATE_FOLDERS 1
@ -356,7 +356,7 @@ void UpdateReader::PerformUpdate(const char *url)
xfer = webternet->CreateSession();
xfer->SetFailOnHTTPError(true);
form->AddString("version", SM_VERSION_STRING);
form->AddString("version", SOURCEMOD_VERSION);
unsigned int num_files = 0;
add_folders(form, "gamedata", num_files);

View File

@ -249,11 +249,11 @@ void AddUpdateError(const char *fmt, ...)
const char *SmUpdater::GetExtensionVerString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
const char *SmUpdater::GetExtensionDateString()
{
return SM_BUILD_TIMESTAMP;
return SOURCEMOD_BUILD_TIME;
}

View File

@ -39,7 +39,11 @@
*/
#if defined SM_GENERATED_BUILD
#include <sourcemod_version_auto.h>
# if defined SM_USE_VERSIONLIB
# include <versionlib.h>
# else
# include <sourcemod_version_auto.h>
# endif
#else
#define SM_BUILD_TAG "manual"
#define SM_BUILD_REV "0"
@ -55,5 +59,11 @@
#endif
#define SM_BUILD_TIMESTAMP __DATE__ " " __TIME__
#if !defined(SM_GENERATED_BUILD) || !defined(SM_USE_VERSIONLIB)
# define SOURCEMOD_VERSION SM_VERSION_STRING
# define SOURCEMOD_BUILD_ID SM_BUILD_UNIQUEID
# define SOURCEMOD_BUILD_TIME SM_BUILD_TIMESTAMP
#endif
#endif /* _INCLUDE_SOURCEMOD_VERSION_INFORMATION_H_ */

View File

@ -1244,7 +1244,7 @@ static void setconfig(char *root)
static void setcaption(void)
{
pc_printf("SourcePawn Compiler " SM_VERSION_STRING "\n");
pc_printf("SourcePawn Compiler %s\n", SOURCEMOD_VERSION);
pc_printf("Copyright (c) 1997-2006, ITB CompuPhase, (C)2004-2008 AlliedModders, LLC\n\n");
}

View File

@ -1,5 +1,4 @@
// vim: set ts=4 sw=4 tw=99 noet:
#include <sourcemod_version.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@ -9,6 +8,7 @@
#include "BaseRuntime.h"
#include "sp_vm_engine.h"
#include "watchdog_timer.h"
#include <sourcemod_version.h>
using namespace SourcePawn;
@ -152,7 +152,7 @@ const char *SourcePawnEngine2::GetEngineName()
const char *SourcePawnEngine2::GetVersionString()
{
return SM_VERSION_STRING;
return SOURCEMOD_VERSION;
}
IProfiler *SourcePawnEngine2::GetProfiler()

15
versionlib/AMBuilder Normal file
View File

@ -0,0 +1,15 @@
# vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
import os
lib = builder.compiler.StaticLibrary('version')
lib.compiler.includes += [
os.path.join(builder.sourcePath, 'public')
]
lib.compiler.defines.remove('SM_USE_VERSIONLIB')
lib.compiler.sourcedeps += SM.generated_headers
lib.sources += [
'versionlib.cpp'
]
task = builder.Add(lib)
rvalue = task.binary

34
versionlib/versionlib.cpp Normal file
View File

@ -0,0 +1,34 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2013 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*/
#include <sourcemod_version.h>
#include <versionlib.h>
const char *SOURCEMOD_BUILD_ID = SM_BUILD_UNIQUEID;
const char *SOURCEMOD_VERSION = SM_VERSION_STRING;
const char *SOURCEMOD_BUILD_TIME = __DATE__ " " __TIME__;

49
versionlib/versionlib.h Normal file
View File

@ -0,0 +1,49 @@
/**
* vim: set ts=4 sw=4 tw=99 noet :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2013 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*
* As a special exception, AlliedModders LLC gives you permission to link the
* code of this program (as well as its derivative works) to "Half-Life 2," the
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
* by the Valve Corporation. You must obey the GNU General Public License in
* all respects for all other code used. Additionally, AlliedModders LLC grants
* this exception to all derivative works. AlliedModders LLC defines further
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
* or <http://www.sourcemod.net/license.php>.
*/
#ifndef _INCLUDE_SOURCEMOD_VERSIONLIB_H_
#define _INCLUDE_SOURCEMOD_VERSIONLIB_H_
#if !defined(SM_USE_VERSIONLIB)
// These get defined in sourcemod_version.h since
// versionlib does not use versionlib.
# undef SOURCEMOD_BUILD_ID
# undef SOURCEMOD_VERSION
# undef SOURCEMOD_BUILD_TIME
#endif
#ifdef __cplusplus
# define EXTERN_C extern "C"
#else
# define EXTERN_C extern
#endif
EXTERN_C const char *SOURCEMOD_BUILD_ID;
EXTERN_C const char *SOURCEMOD_VERSION;
EXTERN_C const char *SOURCEMOD_BUILD_TIME;
#endif // _INCLUDE_SOURCEMOD_VERSIONLIB_H_