Bintools extension no longer needs a separate build for each engine (bug 4548, r=dvander).

This commit is contained in:
Scott Ehlert 2010-08-01 14:57:54 -05:00
parent 0ae2d99599
commit 89334bb459
8 changed files with 59 additions and 43 deletions

View File

@ -87,6 +87,12 @@ CLocalExtension::CLocalExtension(const char *filename)
char path[PLATFORM_MAX_PATH];
/* Special case for new bintools binary */
if (strcmp(filename, "bintools.ext") == 0)
{
goto normal;
}
/* Zeroth, see if there is an engine specific build in the new place. */
g_SourceMod.BuildPath(Path_SM,
path,
@ -106,6 +112,7 @@ CLocalExtension::CLocalExtension(const char *filename)
"extensions/auto." GAMEFIX "/%s." PLATFORM_LIB_EXT,
filename);
normal:
/* Try the "normal" version */
if (!g_LibSys.IsPathFile(path))
{

View File

@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2009 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@ -737,5 +737,13 @@ int SourceModBase::GetPluginId()
return g_PLID;
}
int SourceModBase::GetShApiVersion()
{
int api, impl;
g_SMAPI->GetShVersions(api, impl);
return api;
}
SMGlobalClass *SMGlobalClass::head = NULL;

View File

@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@ -134,6 +134,7 @@ public: // ISourceMod
void AddFrameAction(FRAMEACTION fn, void *data);
const char *GetCoreConfigValue(const char *key);
int GetPluginId();
int GetShApiVersion();
private:
CStack<CDataPack *> m_freepacks;
char m_SMBaseDir[PLATFORM_MAX_PATH];

View File

@ -1,33 +1,24 @@
# vim: set ts=2 sw=2 tw=99 noet ft=python:
import os
for i in SM.sdkInfo:
sdk = SM.sdkInfo[i]
if AMBuild.target['platform'] not in sdk['platform']:
continue
compiler = SM.DefaultExtCompiler('extensions/bintools')
compiler['CDEFINES'].append('HOOKING_ENABLED')
compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit', 'x86'))
name = 'bintools.ext.' + sdk['ext']
compiler = SM.DefaultHL2Compiler('extensions/bintools', i, True, '')
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit'))
compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit', 'x86'))
extension = AMBuild.AddJob('bintools.ext')
binary = Cpp.LibraryBuilder('bintools.ext', AMBuild, extension, compiler)
binary.AddSourceFiles('extensions/bintools', [
'extension.cpp',
'CallMaker.cpp',
'CallWrapper.cpp',
'HookWrapper.cpp',
'jit_call.cpp',
'jit_hook.cpp',
'sdk/smsdk_ext.cpp'
])
SM.AutoVersion('extensions/bintools', binary)
binary.SendToJob()
if i != 'ep1':
compiler['CDEFINES'].append('HOOKING_ENABLED')
extension = AMBuild.AddJob(name)
binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler)
SM.PreSetupHL2Job(extension, binary, i)
binary.AddSourceFiles('extensions/bintools', [
'extension.cpp',
'CallMaker.cpp',
'CallWrapper.cpp',
'HookWrapper.cpp',
'jit_call.cpp',
'jit_hook.cpp',
'sdk/smsdk_ext.cpp'
])
SM.PostSetupHL2Job(extension, binary, i)
SM.AutoVersion('extensions/bintools', binary)
binary.SendToJob()

View File

@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod BinTools Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@ -128,17 +128,17 @@ unsigned int HookWrapper::GetParamOffset(unsigned int argnum, unsigned int *size
void HookWrapper::PerformRecall(void *params, void *retval)
{
/* Notify SourceHook of the upcoming recall */
SH_GLOB_SHPTR->DoRecall();
m_pSH->DoRecall();
/* Add thisptr into params buffer */
unsigned char *newparams = new unsigned char[sizeof(void *) + m_ParamSize];
*(void **)newparams = META_IFACEPTR(void);
*(void **)newparams = m_pSH->GetIfacePtr();
memcpy(newparams + sizeof(void *), params, m_ParamSize);
/* Execute the call */
m_CallWrapper->Execute(newparams, retval);
SET_META_RESULT(MRES_SUPERCEDE);
m_pSH->SetRes(MRES_SUPERCEDE);
return;
}

View File

@ -2,7 +2,7 @@
* vim: set ts=4 sw=4 tw=99 noet:
* =============================================================================
* SourceMod BinTools Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@ -49,9 +49,12 @@ bool BinTools::SDK_OnLoad(char *error, size_t maxlength, bool late)
{
g_SPEngine = g_pSM->GetScriptingEngine();
g_pShareSys->AddInterface(myself, &g_CallMaker);
#if defined METAMOD_PLAPI_VERSION
g_pShareSys->AddInterface(myself, &g_CallMaker2);
#endif
/* IBinTools2 is only compatible with SH v5 */
if (g_pSM->GetShApiVersion() >= 5)
{
g_pShareSys->AddInterface(myself, &g_CallMaker2);
}
return true;
}

View File

@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod BinTools Extension
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@ -56,9 +56,7 @@
* @brief Sets whether or not this plugin required Metamod.
* NOTE: Uncomment to enable, comment to disable.
*/
#if defined HOOKING_ENABLED
#define SMEXT_CONF_METAMOD
#endif
//#define SMEXT_CONF_METAMOD
/** Enable interfaces you want to use here by uncommenting lines */
//#define SMEXT_ENABLE_FORWARDSYS

View File

@ -2,7 +2,7 @@
* vim: set ts=4 :
* =============================================================================
* SourceMod
* Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
* Copyright (C) 2004-2010 AlliedModders LLC. All rights reserved.
* =============================================================================
*
* This program is free software; you can redistribute it and/or modify it under
@ -43,7 +43,7 @@
#include <time.h>
#define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
#define SMINTERFACE_SOURCEMOD_VERSION 11
#define SMINTERFACE_SOURCEMOD_VERSION 12
/**
* @brief Forward declaration of the KeyValues class.
@ -303,6 +303,14 @@ namespace SourceMod
* @return Metamod:Source PluginId.
*/
virtual int GetPluginId() = 0;
/**
* @brief Returns SourceHook's API version.
*
* @return SourceHook API version number.
*/
virtual int GetShApiVersion() = 0;
};
}