diff --git a/AMBuildScript b/AMBuildScript new file mode 100644 index 00000000..b76f7b46 --- /dev/null +++ b/AMBuildScript @@ -0,0 +1,290 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os +import sys +from ambuild.command import SymlinkCommand + +class SM: + def __init__(self): + self.compiler = Cpp.Compiler() + + #Build SDK info + self.sdkInfo = { } + self.sdkInfo['ep1'] = {'sdk': 'HL2SDK', 'ext': '1.ep1', 'def': '1', + 'name': 'EPISODEONE'} + self.sdkInfo['ep2'] = {'sdk': 'HL2SDKOB', 'ext': '2.ep2', 'def': '3', + 'name': 'ORANGEBOX'} + self.sdkInfo['ep2v'] = {'sdk': 'HL2SDKOBVALVE', 'ext': '2.ep2v', 'def': '4', + 'name': 'ORANGEBOXVALVE'} + self.sdkInfo['l4d'] = {'sdk': 'HL2SDKL4D', 'ext': '2.l4d', 'def': '5', + 'name': 'LEFT4DEAD'} + if AMBuild.target['platform'] == 'windows': + self.sdkInfo['darkm'] = {'sdk': 'HL2SDK-DARKM', 'ext': '2.darkm', 'def': '2', + 'name': 'DARKMESSIAH'} + + if AMBuild.mode == 'config': + #Detect compilers + self.compiler.DetectAll(AMBuild) + + #Detect variables + envvars = { 'MMSOURCE17': 'mmsource-1.7', + 'HL2SDK': 'hl2sdk', + 'HL2SDKOB': 'hl2sdk-ob', + 'HL2SDKL4D': 'hl2sdk-l4d', + 'HL2SDKOBVALVE': 'hl2sdk-ob-valve', + 'MYSQL5': 'mysql-5.0' + } + + #Dark Messiah is Windows-only + if AMBuild.target['platform'] == 'windows': + envvars['HL2SDK-DARKM'] = 'hl2sdk-darkm' + + #Must have a path for each envvar (file a bug if you don't like this) + for i in envvars: + if i in os.environ: + path = os.environ[i] + if not os.path.isdir(path): + raise Exception('Path for {0} was not found: {1}'.format(i, path)) + else: + head = os.getcwd() + while head != None and head != '/': + path = os.path.join(head, envvars[i]) + if os.path.isdir(path): + break + head, tail = os.path.split(head) + if head == None or head == '/': + raise Exception('Could not find a valid path for {0}'.format(i)) + AMBuild.cache.CacheVariable(i, path) + + #Set up defines + cxx = self.compiler.cxx + if isinstance(cxx, Cpp.GCC): + self.vendor = 'gcc' + self.compiler.AddToListVar('CDEFINES', 'stricmp=strcasecmp') + self.compiler.AddToListVar('CDEFINES', '_stricmp=strcasecmp') + self.compiler.AddToListVar('CDEFINES', '_snprintf=snprintf') + self.compiler.AddToListVar('CDEFINES', '_vsnprintf=vsnprintf') + self.compiler.AddToListVar('CFLAGS', '-pipe') + self.compiler.AddToListVar('CFLAGS', '-fno-strict-aliasing') + if cxx.majorVersion >= 4: + self.compiler.AddToListVar('CFLAGS', '-fvisibility=hidden') + self.compiler.AddToListVar('CXXFLAGS', '-fvisibility-inlines-hidden') + self.compiler.AddToListVar('CFLAGS', '-Wall') + self.compiler.AddToListVar('CFLAGS', '-Werror') + self.compiler.AddToListVar('CFLAGS', '-Wno-uninitialized') + self.compiler.AddToListVar('CFLAGS', '-Wno-unused') + self.compiler.AddToListVar('CFLAGS', '-Wno-switch') + self.compiler.AddToListVar('CFLAGS', '-mfpmath=sse') + self.compiler.AddToListVar('CFLAGS', '-msse') + self.compiler.AddToListVar('CFLAGS', '-m32') + self.compiler.AddToListVar('CFLAGS', '-static-libgcc') + self.compiler.AddToListVar('CXXFLAGS', '-fno-exceptions') + self.compiler.AddToListVar('CXXFLAGS', '-fno-rtti') + self.compiler.AddToListVar('CXXFLAGS', '-fno-threadsafe-statics') + self.compiler.AddToListVar('CXXFLAGS', '-Wno-non-virtual-dtor') + self.compiler.AddToListVar('CDEFINES', 'HAVE_STDINT_H') + elif isinstance(cxx, Cpp.MSVC): + self.vendor = 'msvc' + if AMBuild.options.debug == '1': + self.compiler.AddToListVar('CFLAGS', '/MTd') + else: + self.compiler.AddToListVar('CFLAGS', '/MT') + self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_DEPRECATE') + self.compiler.AddToListVar('CDEFINES', '_CRT_SECURE_NO_WARNINGS') + self.compiler.AddToListVar('CDEFINES', '_CRT_NONSTDC_NO_DEPRECATE') + self.compiler.AddToListVar('CXXFLAGS', '/EHsc') + self.compiler.AddToListVar('CXXFLAGS', '/GR-') + self.compiler.AddToListVar('CFLAGS', '/W3') + self.compiler.AddToListVar('CFLAGS', '/nologo') + self.compiler.AddToListVar('CFLAGS', '/Zi') + self.compiler.AddToListVar('CXXFLAGS', '/TP') + self.compiler.AddToListVar('POSTLINKFLAGS', '/MACHINE:X86') + self.compiler.AddToListVar('POSTLINKFLAGS', '/SUBSYSTEM:WINDOWS') + self.compiler.AddToListVar('POSTLINKFLAGS', 'kernel32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'user32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'gdi32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'winspool.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'comdlg32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'advapi32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'shell32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'ole32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'oleaut32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'uuid.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'odbc32.lib') + self.compiler.AddToListVar('POSTLINKFLAGS', 'odbccp32.lib') + + #Optimization + if AMBuild.options.opt == '1': + self.compiler.AddToListVar('CDEFINES', 'NDEBUG') + if self.vendor == 'gcc': + self.compiler.AddToListVar('CFLAGS', '-O3') + elif self.vendor == 'msvc': + self.compiler.AddToListVar('CFLAGS', '/Ot') + self.compiler.AddToListVar('POSTLINKFLAGS', '/OPT:ICF') + + #Debugging + if AMBuild.options.debug == '1': + self.compiler.AddToListVar('CDEFINES', 'DEBUG') + self.compiler.AddToListVar('CDEFINES', '_DEBUG') + if self.vendor == 'gcc': + self.compiler.AddToListVar('CFLAGS', '-g3') + elif self.vendor == 'msvc': + self.compiler.AddToListVar('CFLAGS', '/Od') + self.compiler.AddToListVar('CFLAGS', '/RTC1') + + #Platform-specifics + if AMBuild.target['platform'] == 'linux': + self.compiler.AddToListVar('CDEFINES', '_LINUX') + elif AMBuild.target['platform'] == 'windows': + self.compiler.AddToListVar('CDEFINES', 'WIN32') + self.compiler.AddToListVar('CDEFINES', '_WINDOWS') + + #Finish up + self.compiler.AddToListVar('CDEFINES', 'SOURCEMOD_BUILD') + self.compiler.AddToListVar('CDEFINES', 'SM_GENERATED_BUILD') + self.compiler.AddToListVar('CINCLUDES', + os.path.join(AMBuild.outputFolder, 'includes')) + self.compiler.ToConfig(AMBuild, 'compiler') + AMBuild.cache.CacheVariable('vendor', self.vendor) + self.targetMap = { } + AMBuild.cache.CacheVariable('targetMap', self.targetMap) + else: + self.compiler.FromConfig(AMBuild, 'compiler') + self.targetMap = AMBuild.cache['targetMap'] + + if AMBuild.target['platform'] == 'windows': + self.compiler.AddToListVar('RCINCLUDES', os.path.join(AMBuild.sourceFolder, 'public')) + self.mmsPath = AMBuild.cache['MMSOURCE17'] + + def DefaultCompiler(self): + return self.compiler.Clone() + + def JobMatters(self, jobname): + file = sys._getframe().f_code.co_filename + if AMBuild.mode == 'config': + self.targetMap[jobname] = file + return True + if len(AMBuild.args) == 0: + return True + if not jobname in AMBuild.args: + return False + + def DefaultExtCompiler(self, path): + compiler = self.DefaultCompiler() + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, path)) + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, path, 'sdk')) + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public')) + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'extensions')) + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'sourcepawn')) + return compiler + + def AutoVersion(self, folder, binary): + if AMBuild.target['platform'] != 'windows': + return + env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"']} + binary.AddResourceFile(os.path.join(folder, 'version.rc' ), env) + + def PreSetupHL2Job(self, job, builder, sdk): + info = self.sdkInfo[sdk] + sdkPath = AMBuild.cache[info['sdk']] + if AMBuild.target['platform'] == 'linux': + if sdk == 'ep1': + staticLibs = os.path.join(sdkPath, 'linux_sdk') + else: + staticLibs = os.path.join(sdkPath, 'lib', 'linux') + workFolder = os.path.join(AMBuild.outputFolder, job.workFolder) + for i in ['tier1_i486.a', 'mathlib_i486.a', 'vstdlib_i486.so', 'tier0_i486.so']: + link = os.path.join(workFolder, i) + target = os.path.join(staticLibs, i) + try: + os.lstat(link) + except: + job.AddCommand(SymlinkCommand(link, target)) + elif AMBuild.target['platform'] == 'windows': + for lib in ['tier0', 'tier1', 'vstdlib', 'mathlib']: + libPath = os.path.join(sdkPath, 'lib', 'public', lib) + '.lib' + builder.RebuildIfNewer(libPath) + builder['POSTLINKFLAGS'].append(libPath) + + def PostSetupHL2Job(self, job, builder, sdk): + if AMBuild.target['platform'] == 'linux': + builder.AddObjectFiles(['tier1_i486.a', 'mathlib_i486.a']) + + def DefaultHL2Compiler(self, path, sdk, noLink = False, oldMms = '-legacy'): + compiler = self.DefaultExtCompiler(path) + + mms = 'core' + if sdk == 'ep1': + mms += oldMms + + compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms)) + compiler['CXXINCLUDES'].append(os.path.join(self.mmsPath, mms, 'sourcehook')) + + info = self.sdkInfo + compiler['CDEFINES'].extend(['SE_' + info[i]['name'] + '=' + info[i]['def'] for i in info]) + compiler['CDEFINES'].append('SE_DARKMESSIAH=2') + + paths = [['public'], ['public', 'engine'], ['public', 'mathlib'], ['public', 'vstdlib'], + ['public', 'tier0'], ['public', 'tier1']] + if sdk == 'ep1' or sdk == 'darkm': + paths.append(['public', 'dlls']) + paths.append(['game_shared']) + else: + paths.append(['public', 'game', 'server']) + paths.append(['public', 'game', 'shared']) + paths.append(['common']) + + info = self.sdkInfo[sdk] + sdkPath = AMBuild.cache[info['sdk']] + + compiler['CDEFINES'].append('SOURCE_ENGINE=' + info['def']) + + if sdk == 'ep1': + if AMBuild.target['platform'] == 'linux': + staticLibs = os.path.join(sdkPath, 'linux_sdk') + else: + if AMBuild.target['platform'] == 'linux': + staticLibs = os.path.join(sdkPath, 'lib', 'linux') + + for i in paths: + compiler['CXXINCLUDES'].append(os.path.join(sdkPath, *i)) + + if not noLink: + if AMBuild.target['platform'] == 'linux': + compiler['POSTLINKFLAGS'][0:0] = ['-lm'] + compiler['POSTLINKFLAGS'][0:0] = ['tier0_i486.so'] + compiler['POSTLINKFLAGS'][0:0] = ['vstdlib_i486.so'] + + return compiler + +sm = SM() +globals = { + 'SM': sm +} + +AMBuild.Include(os.path.join('tools', 'buildbot', 'Versioning'), globals) + +FileList = [ + ['loader', 'AMBuilder'], + ['core', 'AMBuilder'], + ['core', 'logic', 'AMBuilder'], + ['extensions', 'bintools', 'AMBuilder'], + ['extensions', 'clientprefs', 'AMBuilder'], + ['extensions', 'cstrike', 'AMBuilder'], + ['extensions', 'curl', 'AMBuilder'], + ['extensions', 'geoip', 'AMBuilder'], + ['extensions', 'mysql', 'AMBuilder'], + ['extensions', 'sdktools', 'AMBuilder'], + ['extensions', 'topmenus', 'AMBuilder'], + ['extensions', 'updater', 'AMBuilder'], + ['extensions', 'sqlite', 'AMBuilder'], + ['extensions', 'regex', 'AMBuilder'], + ['extensions', 'tf2', 'AMBuilder'], + ['sourcepawn', 'jit', 'AMBuilder'], + ['sourcepawn', 'compiler', 'AMBuilder'], + ['plugins', 'AMBuilder'], + ['tools', 'buildbot', 'PackageScript'] + ] + +for parts in FileList: + AMBuild.Include(os.path.join(*parts), globals) + diff --git a/core/AMBuilder b/core/AMBuilder new file mode 100644 index 00000000..3c6746d6 --- /dev/null +++ b/core/AMBuilder @@ -0,0 +1,89 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +for i in SM.sdkInfo: + sdk = SM.sdkInfo[i] + name = 'sourcemod.' + sdk['ext'] + + compiler = SM.DefaultHL2Compiler('core', i) + + extension = AMBuild.AddJob(name) + binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler) + SM.PreSetupHL2Job(extension, binary, i) + files = [ + 'AdminCache.cpp', + 'ExtensionSys.cpp', + 'MenuStyle_Valve.cpp', + 'sm_crc32.cpp', + 'logic_bridge.cpp', + 'smn_entities.cpp', + 'sm_stringutil.cpp', + 'ADTFactory.cpp', + 'ForwardSys.cpp', + 'MenuVoting.cpp', + 'sm_memtable.cpp', + 'smn_events.cpp', + 'smn_menus.cpp', + 'sm_trie.cpp', + 'CDataPack.cpp', + 'frame_hooks.cpp', + 'NativeInvoker.cpp', + 'smn_admin.cpp', + 'smn_fakenatives.cpp', + 'smn_nextmap.cpp', + 'sourcemm_api.cpp', + 'ChatTriggers.cpp', + 'GameConfigs.cpp', + 'NativeOwner.cpp', + 'smn_filesystem.cpp', + 'smn_player.cpp', + 'sourcemod.cpp', + 'concmd_cleaner.cpp', + 'HalfLife2.cpp', + 'NextMap.cpp', + 'smn_profiler.cpp', + 'ConCmdManager.cpp', + 'HandleSys.cpp', + 'PhraseCollection.cpp', + 'ConVarManager.cpp', + 'LibrarySys.cpp', + 'PlayerManager.cpp', + 'smn_banning.cpp', + 'smn_gameconfigs.cpp', + 'smn_string.cpp', + 'TimerSys.cpp', + 'CoreConfig.cpp', + 'Logger.cpp', + 'PluginInfoDatabase.cpp', + 'smn_bitbuffer.cpp', + 'smn_halflife.cpp', + 'Translator.cpp', + 'MemoryUtils.cpp', + 'PluginSys.cpp', + 'smn_console.cpp', + 'smn_handles.cpp', + 'smn_timers.cpp', + 'UserMessages.cpp', + 'Database.cpp', + 'MenuManager.cpp', + 'smn_core.cpp', + 'smn_hudtext.cpp', + 'smn_usermsgs.cpp', + 'DebugReporter.cpp', + 'MenuStyle_Base.cpp', + 'ShareSys.cpp', + 'smn_database.cpp', + 'smn_keyvalues.cpp', + 'smn_vector.cpp', + 'EventManager.cpp', + 'MenuStyle_Radio.cpp', + 'sm_autonatives.cpp', + 'smn_datapacks.cpp', + 'smn_lang.cpp', + 'sm_srvcmds.cpp', + ] + binary.AddSourceFiles('core', files) + SM.PostSetupHL2Job(extension, binary, i) + SM.AutoVersion('core', binary) + binary.SendToJob() + diff --git a/core/CoreConfig.cpp b/core/CoreConfig.cpp index e9c1df6b..0078dfaf 100644 --- a/core/CoreConfig.cpp +++ b/core/CoreConfig.cpp @@ -34,7 +34,7 @@ #include "sourcemod.h" #include "sourcemm_api.h" #include "sm_srvcmds.h" -#include "sm_version.h" +#include #include "sm_stringutil.h" #include "LibrarySys.h" #include "Logger.h" @@ -395,7 +395,7 @@ bool SM_ExecuteConfig(CPlugin *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", SVN_FULL_VERSION); + fprintf(fp, "// This file was auto-generated by SourceMod (v%s)\n", SM_FULL_VERSION); fprintf(fp, "// ConVars for plugin \"%s\"\n", pl->GetFilename()); fprintf(fp, "\n\n"); diff --git a/core/Logger.cpp b/core/Logger.cpp index f3a80f0d..89fdbced 100644 --- a/core/Logger.cpp +++ b/core/Logger.cpp @@ -36,7 +36,7 @@ #include "Logger.h" #include "LibrarySys.h" #include "TimerSys.h" -#include "sm_version.h" +#include Logger g_Logger; @@ -149,7 +149,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, SVN_FULL_VERSION); + 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_FULL_VERSION); fclose(fp); } } @@ -356,7 +356,7 @@ void Logger::LogMessage(const char *vafmt, ...) 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, SVN_FULL_VERSION); + 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_FULL_VERSION); } va_list ap; va_start(ap, vafmt); diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index afdd3991..1215c675 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -47,7 +47,7 @@ #include #include "GameConfigs.h" #include "ExtensionSys.h" -#include "sm_version.h" +#include PlayerManager g_Players; bool g_OnMapStarted = false; @@ -698,7 +698,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity) } ClientConsolePrint(pEntity, - "SourceMod %s, by AlliedModders LLC", SVN_FULL_VERSION); + "SourceMod %s, by AlliedModders LLC", SM_FULL_VERSION); ClientConsolePrint(pEntity, "To see running plugins, type \"sm plugins\""); ClientConsolePrint(pEntity, diff --git a/core/logic/AMBuilder b/core/logic/AMBuilder new file mode 100644 index 00000000..597fefef --- /dev/null +++ b/core/logic/AMBuilder @@ -0,0 +1,38 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultCompiler() +base = AMBuild.sourceFolder +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'core', 'logic')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'public')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'public', 'sourcepawn')) +compiler['CDEFINES'].append('SM_DEFAULT_THREADER') +compiler['CDEFINES'].append('SM_LOGIC') + +extension = AMBuild.AddJob('sourcemod.logic') +binary = Cpp.LibraryBuilder('sourcemod.logic', AMBuild, extension, compiler) +files = [ + 'common_logic.cpp', + 'smn_adt_array.cpp', + 'smn_sorting.cpp', + 'smn_maplists.cpp', + 'smn_adt_stack.cpp', + 'thread/ThreadWorker.cpp', + 'thread/BaseWorker.cpp', + 'ThreadSupport.cpp', + 'smn_float.cpp', + 'TextParsers.cpp', + 'smn_textparse.cpp', + 'smn_adt_trie.cpp', + 'Profiler.cpp', + 'smn_functions.cpp' + ] +if AMBuild.target['platform'] == 'windows': + files.append('thread/WinThreads.cpp') +else: + files.append('thread/PosixThreads.cpp') +binary.AddSourceFiles('core/logic', files) +SM.AutoVersion('core/logic', binary) +binary.SendToJob() + diff --git a/core/logic/version.rc b/core/logic/version.rc index bb5b594f..01159866 100755 --- a/core/logic/version.rc +++ b/core/logic/version.rc @@ -9,7 +9,7 @@ // #include "winres.h" -#include "svn_version.h" +#include ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS @@ -29,8 +29,8 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US // VS_VERSION_INFO VERSIONINFO - FILEVERSION SVN_FILE_VERSION - PRODUCTVERSION SVN_FILE_VERSION + FILEVERSION SM_FILE_VERSION + PRODUCTVERSION SM_FILE_VERSION FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L @@ -47,12 +47,12 @@ BEGIN BEGIN VALUE "Comments", "SourceMod" VALUE "FileDescription", "SourceMod Core Logic" - VALUE "FileVersion", SVN_FULL_VERSION + VALUE "FileVersion", SM_FULL_VERSION VALUE "InternalName", "sourcemod" VALUE "LegalCopyright", "Copyright (c) 2004-2009, AlliedModders LLC" VALUE "OriginalFilename", "sourcemod.logic.dll" VALUE "ProductName", "SourceMod" - VALUE "ProductVersion", SVN_FULL_VERSION + VALUE "ProductVersion", SM_FULL_VERSION END END BLOCK "VarFileInfo" diff --git a/core/sm_srvcmds.cpp b/core/sm_srvcmds.cpp index 785dee95..0ecfeea0 100644 --- a/core/sm_srvcmds.cpp +++ b/core/sm_srvcmds.cpp @@ -30,7 +30,7 @@ */ #include "sm_srvcmds.h" -#include "sm_version.h" +#include #include "sm_stringutil.h" #include "HandleSys.h" #include "CoreConfig.h" @@ -39,7 +39,7 @@ RootConsoleMenu g_RootMenu; -ConVar sourcemod_version("sourcemod_version", SVN_FULL_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, "SourceMod Version"); +ConVar sourcemod_version("sourcemod_version", SM_FULL_VERSION, FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY, "SourceMod Version"); RootConsoleMenu::RootConsoleMenu() { @@ -337,7 +337,7 @@ void RootConsoleMenu::OnRootConsoleCommand(const char *cmdname, const CCommand & else if (strcmp(cmdname, "version") == 0) { ConsolePrint(" SourceMod Version Information:"); - ConsolePrint(" SourceMod Version: %s", SVN_FULL_VERSION); + ConsolePrint(" SourceMod Version: %s", SM_FULL_VERSION); ConsolePrint(" SourcePawn Engine: %s (build %s)", 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__); diff --git a/core/sourcemm_api.cpp b/core/sourcemm_api.cpp index 94f92b7b..916fa60f 100644 --- a/core/sourcemm_api.cpp +++ b/core/sourcemm_api.cpp @@ -31,7 +31,7 @@ #include "sourcemod.h" #include "sourcemm_api.h" -#include "sm_version.h" +#include #include "Logger.h" #include "ExtensionSys.h" #include "concmd_cleaner.h" @@ -145,7 +145,7 @@ const char *SourceMod_Core::GetLicense() const char *SourceMod_Core::GetVersion() { - return SVN_FULL_VERSION; + return SM_FULL_VERSION; } const char *SourceMod_Core::GetDate() diff --git a/extensions/bintools/AMBuilder b/extensions/bintools/AMBuilder new file mode 100644 index 00000000..611006c2 --- /dev/null +++ b/extensions/bintools/AMBuilder @@ -0,0 +1,30 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +for i in SM.sdkInfo: + sdk = SM.sdkInfo[i] + 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')) + + 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() + diff --git a/extensions/clientprefs/AMBuilder b/extensions/clientprefs/AMBuilder new file mode 100644 index 00000000..09d26f0d --- /dev/null +++ b/extensions/clientprefs/AMBuilder @@ -0,0 +1,19 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultExtCompiler('extensions/clientprefs') +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) + +extension = AMBuild.AddJob('clientprefs.ext') +binary = Cpp.LibraryBuilder('clientprefs.ext', AMBuild, extension, compiler) +binary.AddSourceFiles('extensions/clientprefs', [ + 'extension.cpp', + 'cookie.cpp', + 'menus.cpp', + 'natives.cpp', + 'query.cpp', + 'sdk/smsdk_ext.cpp' + ]) +SM.AutoVersion('extensions/clientprefs', binary) +binary.SendToJob() + diff --git a/extensions/cstrike/AMBuilder b/extensions/cstrike/AMBuilder new file mode 100644 index 00000000..89c33d19 --- /dev/null +++ b/extensions/cstrike/AMBuilder @@ -0,0 +1,21 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +sdk = SM.sdkInfo['ep1'] +compiler = SM.DefaultHL2Compiler('extensions/cstrike', 'ep1') + +name = 'game.cstrike.ext.' + sdk['ext'] +extension = AMBuild.AddJob(name) +binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler) +SM.PreSetupHL2Job(extension, binary, 'ep1') +binary.AddSourceFiles('extensions/cstrike', [ + 'extension.cpp', + 'natives.cpp', + 'RegNatives.cpp', + 'timeleft.cpp', + 'sdk/smsdk_ext.cpp' + ]) +SM.PostSetupHL2Job(extension, binary, 'ep1') +SM.AutoVersion('extensions/cstrike', binary) +binary.SendToJob() + diff --git a/extensions/curl/AMBuilder b/extensions/curl/AMBuilder new file mode 100644 index 00000000..ccc276cb --- /dev/null +++ b/extensions/curl/AMBuilder @@ -0,0 +1,67 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python : +import os.path +import ambuild.command as command +import ambuild.osutil as osutil + +def BuildCURL(): + curl = AMBuild.AddJob('curl') + if AMBuild.target['platform'] == 'linux': + if not osutil.FileExists(os.path.join(AMBuild.outputFolder, 'curl', 'Makefile')): + args = ['/bin/bash', + os.path.join(AMBuild.sourceFolder, 'extensions', 'curl', 'curl-src', 'configure'), + '--enable-static', + '--disable-shared', + '--disable-ldap', + '--without-ssl', + '--without-libidn', + '--without-libssh2', + '--without-zlib'] + curl.AddCommand(command.DirectCommand(args)) + curl.AddCommand(command.DirectCommand(['make'])) + else: + args = ['vcbuild', + os.path.join(AMBuild.sourceFolder, 'extensions', 'curl', 'curl-src', 'lib', + 'build_libcurl.vcproj'), + 'LIB Release'] + curl.AddCommand(command.DirectCommand(args)) + #die "Unable to find libcurl.lib!\n" unless (-f "LIB-Release\\libcurl.lib"); + +BuildCURL() + +compiler = SM.DefaultExtCompiler('extensions/curl') +extension = AMBuild.AddJob('webternet.ext') +binary = Cpp.LibraryBuilder('webternet.ext', AMBuild, extension, compiler) + +curlPath = [AMBuild.sourceFolder, 'extensions', 'curl', 'curl-src', 'include'] +compiler['CXXINCLUDES'].append(os.path.join(*curlPath)) +compiler['CDEFINES'].append('CURL_STATICLIB') + +binary.AddSourceFiles('extensions/curl', [ + 'extension.cpp', + 'curlapi.cpp', + 'sdk/smsdk_ext.cpp', + ]) + +if AMBuild.target['platform'] == 'linux': + path = os.path.join(AMBuild.outputFolder, + 'curl', + 'lib', + '.libs', + 'libcurl.a') + binary['POSTLINKFLAGS'].append('-lrt') + binary.AddObjectFiles([path]) +elif AMBuild.target['platform'] == 'windows': + path = os.path.join(AMBuild.sourceFolder, + 'extensions', + 'curl', + 'curl-src', + 'lib', + 'LIB-Release', + 'libcurl.lib') + if os.path.isfile(path): + binary.RelinkIfNewer(path) + binary['POSTLINKFLAGS'].extend([path, 'ws2_32.lib']) + +SM.AutoVersion('extensions/curl', binary) +binary.SendToJob() + diff --git a/extensions/geoip/AMBuilder b/extensions/geoip/AMBuilder new file mode 100644 index 00000000..e9df90d8 --- /dev/null +++ b/extensions/geoip/AMBuilder @@ -0,0 +1,15 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +compiler = SM.DefaultExtCompiler('extensions/geoip') + +extension = AMBuild.AddJob('geoip.ext') +binary = Cpp.LibraryBuilder('geoip.ext', AMBuild, extension, compiler) +binary.AddSourceFiles('extensions/geoip', [ + 'extension.cpp', + 'GeoIP.c', + 'sdk/smsdk_ext.cpp' + ]) +if AMBuild.target['platform'] == 'windows': + binary['POSTLINKFLAGS'].append('wsock32.lib') +SM.AutoVersion('extensions/geoip', binary) +binary.SendToJob() + diff --git a/extensions/mysql/AMBuilder b/extensions/mysql/AMBuilder new file mode 100644 index 00000000..1ad18d78 --- /dev/null +++ b/extensions/mysql/AMBuilder @@ -0,0 +1,38 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultExtCompiler('extensions/mysql') +compiler['CXXINCLUDES'].append(os.path.join(AMBuild.cache['MYSQL5'], 'include')) +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) + +extension = AMBuild.AddJob('dbi.mysql.ext') +binary = Cpp.LibraryBuilder('dbi.mysql.ext', AMBuild, extension, compiler) + +if AMBuild.target['platform'] == 'linux': + lib = os.path.join(AMBuild.cache['MYSQL5'], 'lib', 'libmysqlclient_r.a') + link = [lib, + '-lz', + '-lpthread', + '-lm'] + binary.RelinkIfNewer(lib) + binary['POSTLINKFLAGS'].extend(link) +elif AMBuild.target['platform'] == 'windows': + mylib = os.path.join(AMBuild.cache['MYSQL5'], 'lib', 'opt', 'mysqlclient.lib') + zlib = os.path.join(AMBuild.cache['MYSQL5'], 'lib', 'opt', 'zlib.lib') + binary.RelinkIfNewer(mylib) + binary.RelinkIfNewer(zlib) + binary['POSTLINKFLAGS'].extend([mylib, zlib, 'wsock32.lib']) + + +binary.AddSourceFiles('extensions/mysql', [ + 'sdk/smsdk_ext.cpp', + 'mysql/MyBasicResults.cpp', + 'mysql/MyBoundResults.cpp', + 'mysql/MyDatabase.cpp', + 'mysql/MyDriver.cpp', + 'mysql/MyStatement.cpp', + 'extension.cpp' + ]) +SM.AutoVersion('extensions/mysql', binary) +binary.SendToJob() + diff --git a/extensions/regex/AMBuilder b/extensions/regex/AMBuilder new file mode 100644 index 00000000..4e4db7ce --- /dev/null +++ b/extensions/regex/AMBuilder @@ -0,0 +1,25 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultExtCompiler('extensions/regex') +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) + +extension = AMBuild.AddJob('regex.ext') +binary = Cpp.LibraryBuilder('regex.ext', AMBuild, extension, compiler) + +if AMBuild.target['platform'] == 'linux': + path = os.path.join(AMBuild.sourceFolder, 'extensions', 'regex', 'lib_linux', 'libpcre.a') +elif AMBuild.target['platform'] == 'windows': + path = os.path.join(AMBuild.sourceFolder, 'extensions', 'regex', 'lib_win', 'pcre.lib') + +binary.RelinkIfNewer(path) +binary['POSTLINKFLAGS'].append(path) + +binary.AddSourceFiles('extensions/regex', [ + 'extension.cpp', + 'CRegEx.cpp', + 'sdk/smsdk_ext.cpp', + ]) +SM.AutoVersion('extensions/regex', binary) +binary.SendToJob() + diff --git a/extensions/sdktools/AMBuilder b/extensions/sdktools/AMBuilder new file mode 100644 index 00000000..bd4d8556 --- /dev/null +++ b/extensions/sdktools/AMBuilder @@ -0,0 +1,40 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +for i in SM.sdkInfo: + compiler = SM.DefaultHL2Compiler('extensions/sdktools', i) + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit')) + compiler['CXXINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'jit', 'x86')) + + if i != 'ep1': + compiler['CDEFINES'].append('HOOKING_ENABLED') + + sdk = SM.sdkInfo[i] + name = 'sdktools.ext.' + sdk['ext'] + extension = AMBuild.AddJob(name) + binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler) + SM.PreSetupHL2Job(extension, binary, i) + binary.AddSourceFiles('extensions/sdktools', [ + 'extension.cpp', + 'inputnatives.cpp', + 'output.cpp', + 'outputnatives.cpp', + 'tempents.cpp', + 'tenatives.cpp', + 'teamnatives.cpp', + 'trnatives.cpp', + 'vcaller.cpp', + 'vcallbuilder.cpp', + 'vdecoder.cpp', + 'vglobals.cpp', + 'vhelpers.cpp', + 'vnatives.cpp', + 'voice.cpp', + 'vsound.cpp', + 'vstringtable.cpp', + 'sdk/smsdk_ext.cpp' + ]) + SM.PostSetupHL2Job(extension, binary, i) + SM.AutoVersion('extensions/sdktools', binary) + binary.SendToJob() + diff --git a/extensions/sqlite/AMBuilder b/extensions/sqlite/AMBuilder new file mode 100644 index 00000000..883a54cb --- /dev/null +++ b/extensions/sqlite/AMBuilder @@ -0,0 +1,40 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultExtCompiler('extensions/sqlite') +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) + +compiler['CDEFINES'].extend(['SQLITE_OMIT_LOAD_EXTENSION', 'SQLITE_THREADSAFE']) +if AMBuild.target['platform'] == 'linux': + compiler['POSTLINKFLAGS'].extend(['-ldl', '-lpthread']) + +extension = AMBuild.AddJob('dbi.sqlite.ext') +binary = Cpp.LibraryBuilder('dbi.sqlite.ext', AMBuild, extension, compiler) +files = [ + 'sdk/smsdk_ext.cpp', 'sdk/sm_memtable.cpp', 'extension.cpp', + 'driver/SqDatabase.cpp', 'driver/SqDriver.cpp', 'driver/SqQuery.cpp', + 'driver/SqResults.cpp', 'sqlite-source/alter.c', 'sqlite-source/analyze.c', + 'sqlite-source/attach.c', 'sqlite-source/auth.c', 'sqlite-source/btree.c', + 'sqlite-source/build.c', 'sqlite-source/callback.c', 'sqlite-source/complete.c', + 'sqlite-source/date.c', 'sqlite-source/delete.c', 'sqlite-source/expr.c', + 'sqlite-source/func.c', 'sqlite-source/hash.c', 'sqlite-source/insert.c', + 'sqlite-source/legacy.c', 'sqlite-source/main.c', 'sqlite-source/malloc.c', + 'sqlite-source/opcodes.c', 'sqlite-source/os.c', + 'sqlite-source/pager.c', 'sqlite-source/parse.c', 'sqlite-source/pragma.c', + 'sqlite-source/prepare.c', 'sqlite-source/printf.c', 'sqlite-source/random.c', + 'sqlite-source/select.c', 'sqlite-source/table.c', 'sqlite-source/tokenize.c', + 'sqlite-source/trigger.c', 'sqlite-source/update.c', 'sqlite-source/utf.c', + 'sqlite-source/util.c', 'sqlite-source/vacuum.c', 'sqlite-source/vdbe.c', + 'sqlite-source/vdbeapi.c', 'sqlite-source/vdbeaux.c', 'sqlite-source/vdbeblob.c', + 'sqlite-source/vdbefifo.c', 'sqlite-source/vdbemem.c', 'sqlite-source/vtab.c', + 'sqlite-source/where.c', 'sqlite-source/btmutex.c', 'sqlite-source/journal.c', + 'sqlite-source/mem1.c', 'sqlite-source/mem2.c', 'sqlite-source/mutex.c' + ] +if AMBuild.target['platform'] == 'windows': + files.extend(['sqlite-source/mutex_w32.c', 'sqlite-source/os_win.c']) +elif AMBuild.target['platform'] == 'linux': + files.extend(['sqlite-source/mutex_unix.c', 'sqlite-source/os_unix.c']) +binary.AddSourceFiles('extensions/sqlite', files) +SM.AutoVersion('extensions/sqlite', binary) +binary.SendToJob() + diff --git a/extensions/tf2/AMBuilder b/extensions/tf2/AMBuilder new file mode 100644 index 00000000..88bc5787 --- /dev/null +++ b/extensions/tf2/AMBuilder @@ -0,0 +1,26 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +sdk = SM.sdkInfo['ep2v'] +compiler = SM.DefaultHL2Compiler('extensions/tf2', 'ep2v') +if compiler.cc.name == 'gcc': + compiler['CFLAGS'].append('-Wno-parentheses') + +name = 'game.tf2.ext.' + sdk['ext'] +extension = AMBuild.AddJob(name) +binary = Cpp.LibraryBuilder(name, AMBuild, extension, compiler) +SM.PreSetupHL2Job(extension, binary, 'ep2v') +binary.AddSourceFiles('extensions/tf2', [ + 'extension.cpp', + 'natives.cpp', + 'RegNatives.cpp', + 'util.cpp', + 'criticals.cpp', + 'CDetour/detours.cpp', + 'sdk/smsdk_ext.cpp', + 'asm/asm.c' + ]) +SM.PostSetupHL2Job(extension, binary, 'ep2v') +SM.AutoVersion('extensions/tf2', binary) +binary.SendToJob() + diff --git a/extensions/topmenus/AMBuilder b/extensions/topmenus/AMBuilder new file mode 100644 index 00000000..ce393598 --- /dev/null +++ b/extensions/topmenus/AMBuilder @@ -0,0 +1,19 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultExtCompiler('extensions/topmenus') +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) + +extension = AMBuild.AddJob('topmenus.ext') +binary = Cpp.LibraryBuilder('topmenus.ext', AMBuild, extension, compiler) +binary.AddSourceFiles('extensions/topmenus', [ + 'extension.cpp', + 'smn_topmenus.cpp', + 'TopMenu.cpp', + 'TopMenuManager.cpp', + 'sdk/smsdk_ext.cpp', + 'sdk/sm_memtable.cpp' + ]) +SM.AutoVersion('extensions/topmenus', binary) +binary.SendToJob() + diff --git a/extensions/updater/AMBuilder b/extensions/updater/AMBuilder new file mode 100644 index 00000000..3e1f9711 --- /dev/null +++ b/extensions/updater/AMBuilder @@ -0,0 +1,18 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultExtCompiler('extensions/updater') +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) + +extension = AMBuild.AddJob('updater.ext') +binary = Cpp.LibraryBuilder('updater.ext', AMBuild, extension, compiler) +binary.AddSourceFiles('extensions/updater', [ + 'extension.cpp', + 'MemoryDownloader.cpp', + 'Updater.cpp', + 'md5.cpp', + 'sdk/smsdk_ext.cpp' + ]) +SM.AutoVersion('extensions/updater', binary) +binary.SendToJob() + diff --git a/loader/AMBuilder b/loader/AMBuilder new file mode 100644 index 00000000..ddad32fc --- /dev/null +++ b/loader/AMBuilder @@ -0,0 +1,21 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os.path + +compiler = SM.DefaultCompiler() +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core')) +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) + +if AMBuild.target['platform'] == 'windows': + name = 'sourcemod_mm' +elif AMBuild.target['platform'] == 'linux': + name = 'sourcemod_mm_i486' + compiler['POSTLINKFLAGS'].extend(['-ldl']) + +loader = AMBuild.AddJob('loader') +binary = Cpp.LibraryBuilder(name, AMBuild, loader, compiler) +binary.AddSourceFiles('loader', [ + 'loader.cpp' + ]) +SM.AutoVersion('loader', binary) +binary.SendToJob() + diff --git a/plugins/AMBuilder b/plugins/AMBuilder new file mode 100644 index 00000000..6763f4c1 --- /dev/null +++ b/plugins/AMBuilder @@ -0,0 +1,50 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os +import os.path +import ambuild.osutil as osutil +import ambuild.command as command + +files = [ + 'adminhelp.sp', + 'antiflood.sp', + 'basecomm.sp', + 'clientprefs.sp', + 'nextmap.sp', + 'reservedslots.sp', + 'adminmenu.sp', + 'basebans.sp', + 'basetriggers.sp', + 'funcommands.sp', + 'nominations.sp', + 'rockthevote.sp', + 'admin-sql-prefetch.sp', + 'basechat.sp', + 'basevotes.sp', + 'funvotes.sp', + 'playercommands.sp', + 'sounds.sp', + 'admin-sql-threaded.sp', + 'basecommands.sp', + 'mapchooser.sp', + 'randomcycle.sp', + 'sql-admin-manager.sp' + ] + +plugins = AMBuild.AddJob('plugins') + +spcomp = os.path.join(AMBuild.outputFolder, 'spcomp', 'spcomp') +includes = os.path.relpath(os.path.join(AMBuild.sourceFolder, 'plugins', 'include'), + os.path.join(AMBuild.outputFolder, 'plugins')) + +#This one has to be special +sp = os.path.join(AMBuild.sourceFolder, 'plugins', 'admin-flatfile', 'admin-flatfile.sp') +args = [spcomp, '-i' + includes, sp] +plugins.AddCommand(command.DirectCommand(args)) + +#Do the normal ones +for file in files: + sp = os.path.join(AMBuild.sourceFolder, 'plugins', file) + args = [spcomp, '-i' + includes, sp] + plugins.AddCommand(command.DirectCommand(args)) + + diff --git a/sourcepawn/compiler/AMBuilder b/sourcepawn/compiler/AMBuilder new file mode 100644 index 00000000..ff5ed2c8 --- /dev/null +++ b/sourcepawn/compiler/AMBuilder @@ -0,0 +1,64 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultCompiler() +compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public')) +compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'public', 'sourcepawn')) +compiler['CINCLUDES'].append(os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'compiler')) +compiler['CINCLUDES'].append(os.path.join(AMBuild.outputFolder, 'includes')) + +if compiler.cc.name == 'gcc': + compiler['CFLAGS'].extend(['-Wno-parentheses', '-Wno-format']) + compiler['POSTLINKFLAGS'].extend(['-lgcc', '-lm']) +elif compiler.cc.name == 'msvc': + compiler['POSTLINKFLAGS'].remove('/SUBSYSTEM:WINDOWS') + compiler['POSTLINKFLAGS'].append('/SUBSYSTEM:CONSOLE') + +if AMBuild.target['platform'] == 'linux': + compiler['CDEFINES'].extend(['LINUX', 'HAVE_STDINT_H', 'AMX_ANSIONLY', 'ENABLE_BINRELOC']) + +extension = AMBuild.AddJob('spcomp') +binary = Cpp.ExecutableBuilder('spcomp', AMBuild, extension, compiler) +files = [ + 'libpawnc.c', + 'lstring.c', + 'memfile.c', + 'pawncc.c', + 'sc1.c', + 'sc2.c', + 'sc3.c', + 'sc4.c', + 'sc5.c', + 'sc6.c', + 'sc7.c', + 'scexpand.c', + 'sci18n.c', + 'sclist.c', + 'scmemfil.c', + 'scstate.c', + 'sctracker.c', + 'scvars.c', + 'sp_file.c', + 'zlib/adler32.c', + 'zlib/compress.c', + 'zlib/crc32.c', + 'zlib/deflate.c', + 'zlib/gzio.c', + 'zlib/infback.c', + 'zlib/inffast.c', + 'zlib/inflate.c', + 'zlib/inftrees.c', + 'zlib/trees.c', + 'zlib/uncompr.c', + 'zlib/zutil.c' + ] +if AMBuild.target['platform'] == 'linux': + files.append('binreloc.c') +binary.AddSourceFiles('sourcepawn/compiler', files) + +if AMBuild.target['platform'] == 'windows': + env = {'RCDEFINES': ['BINARY_NAME="' + binary.binaryFile + '"']} + binary.AddResourceFile('sourcepawn/compiler/libpawnc.rc', env) + +binary.SendToJob() + diff --git a/sourcepawn/jit/AMBuilder b/sourcepawn/jit/AMBuilder new file mode 100644 index 00000000..e3ce4282 --- /dev/null +++ b/sourcepawn/jit/AMBuilder @@ -0,0 +1,43 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os + +compiler = SM.DefaultCompiler() +base = AMBuild.sourceFolder +compiler['CXXINCLUDES'].append(os.path.join(SM.mmsPath, 'core', 'sourcehook')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'sourcepawn', 'jit')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'sourcepawn', 'jit', 'x86')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'public')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'public', 'sourcepawn')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'public', 'jit')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'public', 'jit', 'x86')) +compiler['CXXINCLUDES'].append(os.path.join(base, 'knight', 'shared')) + +extension = AMBuild.AddJob('sourcepawn.jit.x86') +binary = Cpp.LibraryBuilder('sourcepawn.jit.x86', AMBuild, extension, compiler) +binary.AddSourceFiles('sourcepawn/jit', [ + 'BaseRuntime.cpp', + 'engine2.cpp', + 'dll_exports.cpp', + 'jit_function.cpp', + 'sp_vm_basecontext.cpp', + 'sp_vm_engine.cpp', + 'sp_vm_function.cpp', + 'x86/jit_x86.cpp', + 'x86/opcode_helpers.cpp', + 'zlib/adler32.c', + 'zlib/compress.c', + 'zlib/crc32.c', + 'zlib/deflate.c', + 'zlib/gzio.c', + 'zlib/infback.c', + 'zlib/inffast.c', + 'zlib/inflate.c', + 'zlib/inftrees.c', + 'zlib/trees.c', + 'zlib/uncompr.c', + 'zlib/zutil.c', + '../../knight/shared/KeCodeAllocator.cpp' + ]) +SM.AutoVersion('sourcepawn/jit', binary) +binary.SendToJob() + diff --git a/tools/buildbot/PackageScript b/tools/buildbot/PackageScript new file mode 100644 index 00000000..2d788f3f --- /dev/null +++ b/tools/buildbot/PackageScript @@ -0,0 +1,234 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os +import shutil +import ambuild.osutil as osutil +from ambuild.command import Command + +job = AMBuild.AddJob('package') + +class DestroyPath(Command): + def __init__(self, folder): + Command.__init__(self) + self.folder = folder + + def destroy(self, path): + entries = os.listdir(path) + for entry in entries: + newpath = os.path.join(path, entry) + if os.path.isdir(newpath): + self.destroy(newpath) + os.rmdir(newpath) + elif os.path.isfile(newpath): + os.remove(newpath) + + def run(self, runner, job): + runner.PrintOut('rm -rf {0}/*'.format(self.folder)) + self.destroy(self.folder) + +class CreateFolders(Command): + def __init__(self, folders): + Command.__init__(self) + self.folders = folders + + def run(self, runner, job): + for folder in self.folders: + path = os.path.join(*folder) + runner.PrintOut('mkdir {0}'.format(path)) + os.makedirs(path) + +#Shallow folder copy +class CopyFolder(Command): + def __init__(self, fromList, toList, excludes = []): + Command.__init__(self) + self.fromPath = os.path.join(AMBuild.sourceFolder, *fromList) + self.toPath = os.path.join(*toList) + self.excludes = excludes + + def run(self, runner, job): + entries = os.listdir(self.fromPath) + for entry in entries: + if entry in self.excludes: + continue + path = os.path.join(self.fromPath, entry) + if not os.path.isfile(path): + continue + runner.PrintOut('copy {0} to {1}'.format(path, self.toPath)) + shutil.copy(path, self.toPath) + +#Single file copy +class CopyFile(Command): + def __init__(self, fromFile, toPath): + Command.__init__(self) + self.fromFile = fromFile + self.toPath = toPath + + def run(self, runner, job): + runner.PrintOut('copy {0} to {1}'.format(self.fromFile, self.toPath)) + shutil.copy(self.fromFile, self.toPath) + + +folders = [['addons', 'sourcemod', 'bin'], + ['addons', 'sourcemod', 'plugins', 'disabled'], + ['addons', 'sourcemod', 'gamedata'], + ['addons', 'sourcemod', 'gamedata', 'core.games'], + ['addons', 'sourcemod', 'gamedata', 'sdktools.games'], + ['addons', 'sourcemod', 'configs', 'geoip'], + ['addons', 'sourcemod', 'translations'], + ['addons', 'sourcemod', 'logs'], + ['addons', 'sourcemod', 'extensions'], + ['addons', 'sourcemod', 'data'], + ['addons', 'sourcemod', 'scripting', 'include'], + ['addons', 'sourcemod', 'scripting', 'admin-flatfile'], + ['addons', 'sourcemod', 'scripting', 'adminmenu'], + ['addons', 'sourcemod', 'scripting', 'testsuite'], + ['cfg', 'sourcemod'], + ['addons', 'sourcemod', 'configs', 'sql-init-scripts'], + ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql'], + ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite'], + ['addons', 'sourcemod', 'scripting', 'basecommands'], + ['addons', 'sourcemod', 'scripting', 'basecomm'], + ['addons', 'sourcemod', 'scripting', 'funvotes'], + ['addons', 'sourcemod', 'scripting', 'basevotes'], + ['addons', 'sourcemod', 'scripting', 'basebans'], + ['addons', 'sourcemod', 'scripting', 'funcommands'], + ['addons', 'sourcemod', 'scripting', 'playercommands'], + ['addons', 'metamod'], + ] + +#Setup +job.AddCommand(DestroyPath(os.path.join(AMBuild.outputFolder, 'package'))) +job.AddCommand(CreateFolders(folders)) + +#Copy Folders +job.AddCommand(CopyFolder(['configs'], ['addons', 'sourcemod', 'configs'])) +job.AddCommand(CopyFolder(['configs', 'geoip'], ['addons', 'sourcemod', 'configs', 'geoip'])) +job.AddCommand(CopyFolder(['configs', 'cfg'], ['cfg', 'sourcemod'])) +job.AddCommand(CopyFolder(['configs', 'metamod'], ['addons', 'metamod'])) +job.AddCommand(CopyFolder(['configs', 'sql-init-scripts'], + ['addons', 'sourcemod', 'configs', 'sql-init-scripts'])) +job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'mysql'], + ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'mysql'])) +job.AddCommand(CopyFolder(['configs', 'sql-init-scripts', 'sqlite'], + ['addons', 'sourcemod', 'configs', 'sql-init-scripts', 'sqlite'])) +job.AddCommand(CopyFolder(['gamedata'], ['addons', 'sourcemod', 'gamedata'])) +job.AddCommand(CopyFolder(['gamedata', 'sdktools.games'], + ['addons', 'sourcemod', 'gamedata', 'sdktools.games'])) +job.AddCommand(CopyFolder(['gamedata', 'core.games'], + ['addons', 'sourcemod', 'gamedata', 'core.games'])) +job.AddCommand(CopyFolder(['plugins'], ['addons', 'sourcemod', 'scripting'], ['AMBuilder'])) +job.AddCommand(CopyFolder(['plugins', 'include'], + ['addons', 'sourcemod', 'scripting', 'include'])) +job.AddCommand(CopyFolder(['translations'], ['addons', 'sourcemod', 'translations'])) +job.AddCommand(CopyFolder(['public', 'licenses'], ['addons', 'sourcemod'])) +job.AddCommand(CopyFolder(['plugins', 'admin-flatfile'], + ['addons', 'sourcemod', 'scripting', 'admin-flatfile'])) +job.AddCommand(CopyFolder(['plugins', 'adminmenu'], + ['addons', 'sourcemod', 'scripting', 'adminmenu'])) +job.AddCommand(CopyFolder(['plugins', 'testsuite'], + ['addons', 'sourcemod', 'scripting', 'testsuite'])) +job.AddCommand(CopyFolder(['plugins', 'basecommands'], + ['addons', 'sourcemod', 'scripting', 'basecommands'])) +job.AddCommand(CopyFolder(['plugins', 'basecomm'], + ['addons', 'sourcemod', 'scripting', 'basecomm'])) +job.AddCommand(CopyFolder(['plugins', 'funvotes'], + ['addons', 'sourcemod', 'scripting', 'funvotes'])) +job.AddCommand(CopyFolder(['plugins', 'basevotes'], + ['addons', 'sourcemod', 'scripting', 'basevotes'])) +job.AddCommand(CopyFolder(['plugins', 'basebans'], + ['addons', 'sourcemod', 'scripting', 'basebans'])) +job.AddCommand(CopyFolder(['plugins', 'funcommands'], + ['addons', 'sourcemod', 'scripting', 'funcommands'])) +job.AddCommand(CopyFolder(['plugins', 'playercommands'], + ['addons', 'sourcemod', 'scripting', 'playercommands'])) + +defPlugins = [ + 'admin-flatfile', + 'adminhelp', + 'antiflood', + 'basecommands', + 'reservedslots', + 'basetriggers', + 'nextmap', + 'basechat', + 'funcommands', + 'basevotes', + 'funvotes', + 'basebans', + 'basecomm', + 'adminmenu', + 'playercommands', + 'clientprefs', + 'sounds' +] + +disPlugins = [ + 'admin-sql-prefetch', + 'admin-sql-threaded', + 'sql-admin-manager', + 'mapchooser', + 'randomcycle', + 'rockthevote', + 'nominations' +] + +commands = [] +for plugin in defPlugins: + commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'), + os.path.join('addons', 'sourcemod', 'plugins'))) + +for plugin in disPlugins: + commands.append(CopyFile(os.path.join('..', 'plugins', plugin + '.smx'), + os.path.join('addons', 'sourcemod', 'plugins', 'disabled'))) +job.AddCommandGroup(commands) + +bincopies = [] + +def AddNormalLibrary(name, dest): + dest = os.path.join('addons', 'sourcemod', dest) + bincopies.append(CopyFile(os.path.join('..', name, name + osutil.SharedLibSuffix()), dest)) + pdb_list.append(name + '\\' + name + '.pdb') + +def AddHL2Library(name, dest): + for i in SM.sdkInfo: + sdk = SM.sdkInfo[i] + AddNormalLibrary(name + '.' + sdk['ext'], dest) + +pdb_list = [] + +if AMBuild.target['platform'] == 'linux': + bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm_i486.so'), + os.path.join('addons', 'sourcemod', 'bin'))) +elif AMBuild.target['platform'] == 'windows': + bincopies.append(CopyFile(os.path.join('..', 'loader', 'sourcemod_mm.dll'), + os.path.join('addons', 'sourcemod', 'bin'))) + pdb_list.append('loader\\sourcemod_mm.pdb') + +AddHL2Library('sourcemod', 'bin') +AddNormalLibrary('sourcepawn.jit.x86', 'bin') +AddNormalLibrary('geoip.ext', 'extensions') +AddNormalLibrary('dbi.mysql.ext', 'extensions') +AddNormalLibrary('dbi.sqlite.ext', 'extensions') +AddNormalLibrary('game.cstrike.ext.1.ep1', 'extensions') +AddNormalLibrary('game.tf2.ext.2.ep2v', 'extensions') +AddNormalLibrary('topmenus.ext', 'extensions') +AddNormalLibrary('regex.ext', 'extensions') +AddNormalLibrary('webternet.ext', 'extensions') +AddNormalLibrary('clientprefs.ext', 'extensions') +AddNormalLibrary('updater.ext', 'extensions') +AddHL2Library('bintools.ext', 'extensions') +AddHL2Library('sdktools.ext', 'extensions') + +bincopies.append(CopyFile(os.path.join('..', 'spcomp', 'spcomp' + osutil.ExecutableSuffix()), + os.path.join('addons', 'sourcemod', 'scripting'))) + +job.AddCommandGroup(bincopies) + +if AMBuild.target['platform'] == 'windows': + job.AddCommand(CopyFile( + os.path.join(AMBuild.sourceFolder, 'sourcepawn', 'batchtool', 'compile.exe'), + os.path.join('addons', 'sourcemod', 'scripting'))) + pdblog = open(os.path.join(AMBuild.outputFolder, 'pdblog.txt'), 'wt') + for pdb in pdb_list: + pdblog.write(pdb + '\n') + pdblog.close() + diff --git a/tools/buildbot/Versioning b/tools/buildbot/Versioning new file mode 100644 index 00000000..73961e18 --- /dev/null +++ b/tools/buildbot/Versioning @@ -0,0 +1,57 @@ +# vim: set ts=2 sw=2 tw=99 noet ft=python: +import os +import re +import subprocess +from ambuild.cache import Cache +import ambuild.command as command + +#Quickly try to ascertain the current repository revision +def GetVersion(): + args = ['hg', 'parent', '-R', AMBuild.sourceFolder] + p = command.RunDirectCommand(AMBuild, args) + m = re.match('changeset:\s+(\d+):(.+)', p.stdoutText) + if m == None: + raise Exception('Could not determine repository version') + return m.groups() + +def PerformReversioning(): + rev, cset = GetVersion() + cacheFile = os.path.join(AMBuild.outputFolder, '.ambuild', 'hgcache') + cache = Cache(cacheFile) + if os.path.isfile(cacheFile): + cache.LoadCache() + if cache.HasVariable('cset') and cache['cset'] == cset: + return False + cache.CacheVariable('cset', cset) + + productFile = open(os.path.join(AMBuild.sourceFolder, 'product.version'), 'r') + productContents = productFile.read() + productFile.close() + m = re.match('(\d+)\.(\d+)\.(\d+)(.*)', productContents) + if m == None: + raise Exception('Could not detremine product version') + major, minor, release, tag = m.groups() + + incFolder = os.path.join(AMBuild.outputFolder, 'includes') + if not os.path.isdir(incFolder): + os.makedirs(incFolder) + incFile = open(os.path.join(incFolder, 'sourcemod_version_auto.h'), 'w') + incFile.write(""" +#ifndef _SOURCEMOD_AUTO_VERSION_INFORMATION_H_ +#define _SOURCEMOD_AUTO_VERSION_INFORMATION_H_ + +#define SM_BUILD_STRING \"{0}\" +#define SM_BUILD_UNIQUEID \"{1}:{2}\" SM_BUILD_STRING +#define SM_FULL_VERSION \"{3}.{4}.{5}\" SM_BUILD_STRING +#define SM_FILE_VERSION {6},{7},{8},0 + +#endif /* _SOURCEMOD_AUTO_VERSION_INFORMATION_H_ */ + +""".format(tag, rev, cset, major, minor, release, major, minor, release)) + incFile.close() + + cache.WriteCache() + +PerformReversioning() + +