2013-12-30 23:50:56 +01:00
|
|
|
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
|
|
|
import os, sys
|
|
|
|
|
|
|
|
class SDK(object):
|
|
|
|
def __init__(self, sdk, ext, aDef, name, platform, dir):
|
2014-05-25 10:53:58 +02:00
|
|
|
self.folder = 'hl2sdk-' + dir
|
2013-12-30 23:50:56 +01:00
|
|
|
self.envvar = sdk
|
|
|
|
self.ext = ext
|
|
|
|
self.code = aDef
|
|
|
|
self.define = name
|
|
|
|
self.platform = platform
|
|
|
|
self.name = dir
|
|
|
|
self.path = None # Actual path
|
2017-12-20 08:56:23 +01:00
|
|
|
self.platformSpec = platform
|
|
|
|
|
|
|
|
# By default, nothing supports x64.
|
|
|
|
if type(platform) is list:
|
|
|
|
self.platformSpec = {p: ['x86'] for p in platform}
|
|
|
|
else:
|
|
|
|
self.platformSpec = platform
|
|
|
|
|
|
|
|
def shouldBuild(self, target, archs):
|
|
|
|
if target.platform not in self.platformSpec:
|
|
|
|
return False
|
|
|
|
if not len([i for i in self.platformSpec[target.platform] if i in archs]):
|
|
|
|
return False
|
|
|
|
return True
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
WinOnly = ['windows']
|
|
|
|
WinLinux = ['windows', 'linux']
|
|
|
|
WinLinuxMac = ['windows', 'linux', 'mac']
|
2017-12-20 08:56:23 +01:00
|
|
|
CSGO = {
|
|
|
|
'windows': ['x86'],
|
|
|
|
'linux': ['x86', 'x64'],
|
|
|
|
'mac': ['x64']
|
|
|
|
}
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
PossibleSDKs = {
|
2017-01-12 03:25:00 +01:00
|
|
|
'episode1': SDK('HL2SDK', '2.ep1', '1', 'EPISODEONE', WinLinux, 'episode1'),
|
2014-05-25 10:53:58 +02:00
|
|
|
'ep2': SDK('HL2SDKOB', '2.ep2', '3', 'ORANGEBOX', WinLinux, 'orangebox'),
|
2013-12-30 23:50:56 +01:00
|
|
|
'css': SDK('HL2SDKCSS', '2.css', '6', 'CSS', WinLinuxMac, 'css'),
|
|
|
|
'hl2dm': SDK('HL2SDKHL2DM', '2.hl2dm', '7', 'HL2DM', WinLinuxMac, 'hl2dm'),
|
|
|
|
'dods': SDK('HL2SDKDODS', '2.dods', '8', 'DODS', WinLinuxMac, 'dods'),
|
2014-05-25 10:53:58 +02:00
|
|
|
'sdk2013': SDK('HL2SDK2013', '2.sdk2013', '9', 'SDK2013', WinLinuxMac, 'sdk2013'),
|
2015-05-07 03:12:13 +02:00
|
|
|
'tf2': SDK('HL2SDKTF2', '2.tf2', '11', 'TF2', WinLinuxMac, 'tf2'),
|
|
|
|
'l4d': SDK('HL2SDKL4D', '2.l4d', '12', 'LEFT4DEAD', WinLinuxMac, 'l4d'),
|
|
|
|
'nucleardawn': SDK('HL2SDKND', '2.nd', '13', 'NUCLEARDAWN', WinLinuxMac, 'nucleardawn'),
|
|
|
|
'l4d2': SDK('HL2SDKL4D2', '2.l4d2', '15', 'LEFT4DEAD2', WinLinuxMac, 'l4d2'),
|
2013-12-30 23:50:56 +01:00
|
|
|
'darkm': SDK('HL2SDK-DARKM', '2.darkm', '2', 'DARKMESSIAH', WinOnly, 'darkm'),
|
2015-05-07 03:12:13 +02:00
|
|
|
'swarm': SDK('HL2SDK-SWARM', '2.swarm', '16', 'ALIENSWARM', WinOnly, 'swarm'),
|
2013-12-30 23:50:56 +01:00
|
|
|
'bgt': SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'),
|
|
|
|
'eye': SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'),
|
2017-12-20 08:56:23 +01:00
|
|
|
'csgo': SDK('HL2SDKCSGO', '2.csgo', '21', 'CSGO', CSGO, 'csgo'),
|
2015-05-07 03:12:13 +02:00
|
|
|
'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '17', 'PORTAL2', [], 'portal2'),
|
2020-03-11 23:36:25 +01:00
|
|
|
'blade': SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', WinOnly, 'blade'),
|
2015-05-07 03:12:13 +02:00
|
|
|
'insurgency': SDK('HL2SDKINSURGENCY', '2.insurgency', '19', 'INSURGENCY', WinLinuxMac, 'insurgency'),
|
|
|
|
'contagion': SDK('HL2SDKCONTAGION', '2.contagion', '14', 'CONTAGION', WinOnly, 'contagion'),
|
|
|
|
'bms': SDK('HL2SDKBMS', '2.bms', '10', 'BMS', WinLinux, 'bms'),
|
2017-11-03 20:45:16 +01:00
|
|
|
'doi': SDK('HL2SDKDOI', '2.doi', '20', 'DOI', WinLinuxMac, 'doi'),
|
2009-08-30 09:46:56 +02:00
|
|
|
}
|
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
def ResolveEnvPath(env, folder):
|
|
|
|
if env in os.environ:
|
|
|
|
path = os.environ[env]
|
|
|
|
if os.path.isdir(path):
|
|
|
|
return path
|
2014-05-27 06:30:43 +02:00
|
|
|
return None
|
|
|
|
|
|
|
|
head = os.getcwd()
|
|
|
|
oldhead = None
|
|
|
|
while head != None and head != oldhead:
|
|
|
|
path = os.path.join(head, folder)
|
|
|
|
if os.path.isdir(path):
|
|
|
|
return path
|
|
|
|
oldhead = head
|
|
|
|
head, tail = os.path.split(head)
|
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
return None
|
|
|
|
|
2014-05-27 06:30:43 +02:00
|
|
|
def Normalize(path):
|
|
|
|
return os.path.abspath(os.path.normpath(path))
|
2017-12-20 08:56:23 +01:00
|
|
|
|
|
|
|
def SetArchFlags(compiler, arch, platform):
|
|
|
|
if compiler.behavior == 'gcc':
|
|
|
|
if arch == 'x86':
|
|
|
|
compiler.cflags += ['-m32']
|
|
|
|
compiler.linkflags += ['-m32']
|
|
|
|
if platform == 'mac':
|
|
|
|
compiler.linkflags += ['-arch', 'i386']
|
|
|
|
elif arch == 'x64':
|
|
|
|
compiler.cflags += ['-m64', '-fPIC']
|
|
|
|
compiler.linkflags += ['-m64']
|
|
|
|
if platform == 'mac':
|
|
|
|
compiler.linkflags += ['-arch', 'x86_64']
|
|
|
|
elif compiler.like('msvc'):
|
|
|
|
if builder.target.arch == 'x86':
|
|
|
|
compiler.linkflags += ['/MACHINE:X86']
|
|
|
|
elif builder.target.arch == 'x64':
|
|
|
|
compiler.linkflags += ['/MACHINE:X64']
|
|
|
|
|
|
|
|
def AppendArchSuffix(binary, name, arch):
|
|
|
|
if arch == 'x64':
|
|
|
|
binary.localFolder = name + '.x64'
|
2014-05-27 06:30:43 +02:00
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
class SMConfig(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.sdks = {}
|
|
|
|
self.binaries = []
|
2013-12-30 23:50:59 +01:00
|
|
|
self.extensions = []
|
2013-12-30 23:50:59 +01:00
|
|
|
self.generated_headers = None
|
2013-12-30 23:50:56 +01:00
|
|
|
self.mms_root = None
|
2017-12-20 08:56:23 +01:00
|
|
|
self.mysql_root = {}
|
2013-12-30 23:50:58 +01:00
|
|
|
self.spcomp = None
|
2017-12-20 08:56:23 +01:00
|
|
|
self.spcomp_bins = None
|
2013-12-30 23:50:58 +01:00
|
|
|
self.smx_files = {}
|
2013-12-30 23:51:00 +01:00
|
|
|
self.versionlib = None
|
2017-12-20 08:56:23 +01:00
|
|
|
self.archs = builder.target.arch.replace('x86_64', 'x64').split(',')
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2014-05-31 04:07:56 +02:00
|
|
|
def use_auto_versioning(self):
|
2014-07-05 22:28:55 +02:00
|
|
|
if builder.backend != 'amb2':
|
|
|
|
return False
|
|
|
|
return not getattr(builder.options, 'disable_auto_versioning', False)
|
2014-05-31 04:07:56 +02:00
|
|
|
|
2014-06-01 04:59:02 +02:00
|
|
|
@property
|
|
|
|
def tag(self):
|
2014-06-01 04:56:42 +02:00
|
|
|
if builder.options.debug == '1':
|
2014-06-01 04:59:02 +02:00
|
|
|
return 'Debug'
|
|
|
|
return 'Release'
|
2014-06-01 04:56:42 +02:00
|
|
|
|
2013-12-30 23:50:59 +01:00
|
|
|
def detectProductVersion(self):
|
|
|
|
builder.AddConfigureFile('product.version')
|
|
|
|
|
|
|
|
# For OS X dylib versioning
|
|
|
|
import re
|
|
|
|
with open(os.path.join(builder.sourcePath, 'product.version'), 'r') as fp:
|
|
|
|
productContents = fp.read()
|
|
|
|
m = re.match('(\d+)\.(\d+)\.(\d+).*', productContents)
|
|
|
|
if m == None:
|
|
|
|
self.productVersion = '1.0.0'
|
|
|
|
else:
|
|
|
|
major, minor, release = m.groups()
|
|
|
|
self.productVersion = '{0}.{1}.{2}'.format(major, minor, release)
|
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
def detectSDKs(self):
|
|
|
|
sdk_list = builder.options.sdks.split(',')
|
2020-03-04 22:52:07 +01:00
|
|
|
use_none = sdk_list[0] == 'none'
|
2013-12-30 23:50:56 +01:00
|
|
|
use_all = sdk_list[0] == 'all'
|
|
|
|
use_present = sdk_list[0] == 'present'
|
|
|
|
|
|
|
|
for sdk_name in PossibleSDKs:
|
|
|
|
sdk = PossibleSDKs[sdk_name]
|
2017-12-20 08:56:23 +01:00
|
|
|
if sdk.shouldBuild(builder.target, self.archs):
|
2014-05-27 06:30:43 +02:00
|
|
|
if builder.options.hl2sdk_root:
|
|
|
|
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
|
|
|
|
else:
|
|
|
|
sdk_path = ResolveEnvPath(sdk.envvar, sdk.folder)
|
|
|
|
if sdk_path is None or not os.path.isdir(sdk_path):
|
2013-12-30 23:50:56 +01:00
|
|
|
if use_all or sdk_name in sdk_list:
|
|
|
|
raise Exception('Could not find a valid path for {0}'.format(sdk.envvar))
|
|
|
|
continue
|
|
|
|
if use_all or use_present or sdk_name in sdk_list:
|
2014-05-27 06:30:43 +02:00
|
|
|
sdk.path = Normalize(sdk_path)
|
2013-12-30 23:50:56 +01:00
|
|
|
self.sdks[sdk_name] = sdk
|
|
|
|
|
2020-03-04 22:52:07 +01:00
|
|
|
if len(self.sdks) < 1 and len(sdk_list) and not use_none:
|
2017-12-20 08:56:23 +01:00
|
|
|
raise Exception('No SDKs were found that build on {0}-{1}, nothing to do.'.format(
|
|
|
|
builder.target.platform, builder.target.arch))
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2014-05-27 06:30:43 +02:00
|
|
|
if builder.options.mms_path:
|
|
|
|
self.mms_root = builder.options.mms_path
|
|
|
|
else:
|
|
|
|
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
|
2014-05-27 06:38:08 +02:00
|
|
|
if not self.mms_root:
|
|
|
|
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
|
2013-12-30 23:50:56 +01:00
|
|
|
if not self.mms_root:
|
2014-05-27 06:30:43 +02:00
|
|
|
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'mmsource-central')
|
|
|
|
|
|
|
|
if not self.mms_root or not os.path.isdir(self.mms_root):
|
|
|
|
raise Exception('Could not find a source copy of Metamod:Source')
|
|
|
|
self.mms_root = Normalize(self.mms_root)
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
if builder.options.hasMySql:
|
2014-05-27 06:30:43 +02:00
|
|
|
if builder.options.mysql_path:
|
2017-12-20 08:56:23 +01:00
|
|
|
self.mysql_root['x86'] = builder.options.mysql_path
|
2014-05-27 06:30:43 +02:00
|
|
|
else:
|
2018-06-05 15:29:11 +02:00
|
|
|
for i in range(10):
|
2018-03-20 22:12:30 +01:00
|
|
|
self.mysql_root['x86'] = ResolveEnvPath('MYSQL55', 'mysql-5.' + str(i))
|
2017-12-20 08:56:23 +01:00
|
|
|
if self.mysql_root['x86']:
|
2014-05-27 06:30:43 +02:00
|
|
|
break
|
2017-12-20 08:56:23 +01:00
|
|
|
if not self.mysql_root['x86'] or not os.path.isdir(self.mysql_root['x86']):
|
2013-12-30 23:50:56 +01:00
|
|
|
raise Exception('Could not find a path to MySQL!')
|
2017-12-20 08:56:23 +01:00
|
|
|
self.mysql_root['x86'] = Normalize(self.mysql_root['x86'])
|
|
|
|
|
|
|
|
# For now, ignore 64-bit MySQL on Windows
|
|
|
|
if 'x64' in self.archs and builder.target.platform != 'windows':
|
2018-06-05 15:29:11 +02:00
|
|
|
if builder.options.mysql64_path:
|
2017-12-20 08:56:23 +01:00
|
|
|
self.mysql_root['x64'] = builder.options.mysql64_path
|
|
|
|
else:
|
2018-06-05 15:29:11 +02:00
|
|
|
for i in range(10):
|
2018-03-20 22:12:30 +01:00
|
|
|
self.mysql_root['x64'] = ResolveEnvPath('MYSQL55_64', 'mysql-5.' + str(i) + '-x86_64')
|
2017-12-20 08:56:23 +01:00
|
|
|
if self.mysql_root['x64']:
|
|
|
|
break
|
|
|
|
if not self.mysql_root['x64'] or not os.path.isdir(self.mysql_root['x64']):
|
|
|
|
raise Exception('Could not find a path to 64-bit MySQL!')
|
|
|
|
self.mysql_root['x64'] = Normalize(self.mysql_root['x64'])
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
def configure(self):
|
2014-01-09 00:09:50 +01:00
|
|
|
builder.AddConfigureFile('pushbuild.txt')
|
2017-12-20 08:56:23 +01:00
|
|
|
|
|
|
|
if not set(self.archs).issubset(['x86', 'x64']):
|
|
|
|
raise Exception('Unknown target architecture: {0}'.format(builder.target.arch))
|
2014-01-09 00:09:50 +01:00
|
|
|
|
2017-10-02 14:18:57 +02:00
|
|
|
cxx = builder.DetectCxx()
|
2017-12-20 08:56:23 +01:00
|
|
|
|
|
|
|
if cxx.like('msvc') and len(self.archs) > 1:
|
|
|
|
raise Exception('Building multiple archs with MSVC is not currently supported')
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2019-11-16 01:40:39 +01:00
|
|
|
if cxx.family == 'msvc':
|
|
|
|
if cxx.version < 1900:
|
|
|
|
raise Exception('Only MSVC 2015 and later are supported, c++14 support is required.')
|
|
|
|
if cxx.family == 'gcc':
|
|
|
|
if cxx.version < 'gcc-4.9':
|
|
|
|
raise Exception('Only GCC versions 4.9 or greater are supported, c++14 support is required.')
|
|
|
|
if cxx.family == 'clang':
|
|
|
|
if cxx.version < 'clang-3.4':
|
|
|
|
raise Exception('Only clang versions 3.4 or greater are supported, c++14 support is required.')
|
|
|
|
|
2014-05-31 07:50:35 +02:00
|
|
|
if cxx.like('gcc'):
|
2015-10-08 23:36:24 +02:00
|
|
|
self.configure_gcc(cxx)
|
2017-10-02 14:18:57 +02:00
|
|
|
elif cxx.family == 'msvc':
|
2015-10-08 23:36:24 +02:00
|
|
|
self.configure_msvc(cxx)
|
|
|
|
|
|
|
|
# Optimizaiton
|
2013-12-30 23:50:56 +01:00
|
|
|
if builder.options.opt == '1':
|
2014-05-31 07:50:35 +02:00
|
|
|
cxx.defines += ['NDEBUG']
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
# Debugging
|
|
|
|
if builder.options.debug == '1':
|
2014-05-31 07:50:35 +02:00
|
|
|
cxx.defines += ['DEBUG', '_DEBUG']
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
# Platform-specifics
|
2017-10-02 14:18:57 +02:00
|
|
|
if builder.target.platform == 'linux':
|
2015-10-08 23:36:24 +02:00
|
|
|
self.configure_linux(cxx)
|
2017-10-02 14:18:57 +02:00
|
|
|
elif builder.target.platform == 'mac':
|
2015-10-08 23:36:24 +02:00
|
|
|
self.configure_mac(cxx)
|
2017-10-02 14:18:57 +02:00
|
|
|
elif builder.target.platform == 'windows':
|
2015-10-08 23:36:24 +02:00
|
|
|
self.configure_windows(cxx)
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
# Finish up.
|
2014-05-31 07:50:35 +02:00
|
|
|
cxx.defines += [
|
2013-12-30 23:50:56 +01:00
|
|
|
'SOURCEMOD_BUILD',
|
2013-12-30 23:51:00 +01:00
|
|
|
'SM_USE_VERSIONLIB',
|
2013-12-30 23:50:56 +01:00
|
|
|
]
|
2015-03-08 20:37:10 +01:00
|
|
|
cxx.includes += [
|
|
|
|
os.path.join(builder.sourcePath, 'public'),
|
|
|
|
]
|
2014-05-31 04:07:56 +02:00
|
|
|
if self.use_auto_versioning():
|
2014-05-31 07:50:35 +02:00
|
|
|
cxx.defines += ['SM_GENERATED_BUILD']
|
2015-03-08 20:37:10 +01:00
|
|
|
cxx.includes += [
|
|
|
|
os.path.join(builder.buildPath, 'includes'),
|
|
|
|
os.path.join(builder.sourcePath, 'versionlib'),
|
|
|
|
]
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2015-10-08 23:36:24 +02:00
|
|
|
def configure_gcc(self, cxx):
|
|
|
|
cxx.defines += [
|
|
|
|
'stricmp=strcasecmp',
|
|
|
|
'_stricmp=strcasecmp',
|
|
|
|
'_snprintf=snprintf',
|
|
|
|
'_vsnprintf=vsnprintf',
|
|
|
|
'HAVE_STDINT_H',
|
|
|
|
'GNUC',
|
|
|
|
]
|
|
|
|
cxx.cflags += [
|
|
|
|
'-pipe',
|
|
|
|
'-fno-strict-aliasing',
|
|
|
|
'-Wall',
|
|
|
|
'-Werror',
|
|
|
|
'-Wno-unused',
|
|
|
|
'-Wno-switch',
|
|
|
|
'-Wno-array-bounds',
|
|
|
|
'-msse',
|
|
|
|
'-fvisibility=hidden',
|
|
|
|
]
|
Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.
This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).
IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.
ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.
This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:40:39 +02:00
|
|
|
|
2020-05-14 01:51:31 +02:00
|
|
|
if cxx.version == 'apple-clang-6.0' or cxx.version == 'clang-3.4':
|
Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.
This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).
IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.
ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.
This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:40:39 +02:00
|
|
|
cxx.cxxflags += ['-std=c++1y']
|
|
|
|
else:
|
|
|
|
cxx.cxxflags += ['-std=c++14']
|
|
|
|
|
2015-10-08 23:36:24 +02:00
|
|
|
cxx.cxxflags += [
|
|
|
|
'-fno-threadsafe-statics',
|
|
|
|
'-Wno-non-virtual-dtor',
|
|
|
|
'-Wno-overloaded-virtual',
|
|
|
|
'-fvisibility-inlines-hidden',
|
|
|
|
]
|
|
|
|
|
2017-10-02 14:18:57 +02:00
|
|
|
have_gcc = cxx.family == 'gcc'
|
|
|
|
have_clang = cxx.family == 'clang'
|
2020-05-14 01:51:31 +02:00
|
|
|
if cxx.version >= 'clang-3.9' or cxx.version == 'clang-3.4' or cxx.version > 'apple-clang-6.0':
|
2017-10-10 01:53:19 +02:00
|
|
|
cxx.cxxflags += ['-Wno-expansion-to-defined']
|
|
|
|
if cxx.version == 'clang-3.9' or cxx.version == 'apple-clang-8.0':
|
|
|
|
cxx.cflags += ['-Wno-varargs']
|
2020-05-14 01:51:31 +02:00
|
|
|
if cxx.version >= 'clang-3.4' or cxx.version >= 'apple-clang-7.0':
|
2015-10-08 23:36:24 +02:00
|
|
|
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
|
2017-10-02 14:18:57 +02:00
|
|
|
if cxx.version >= 'clang-2.9' or cxx.version >= 'apple-clang-3.0':
|
|
|
|
cxx.cxxflags += ['-Wno-null-dereference']
|
2015-10-08 23:36:24 +02:00
|
|
|
if have_clang or (cxx.version >= 'gcc-4.6'):
|
|
|
|
cxx.cflags += ['-Wno-narrowing']
|
|
|
|
if have_clang or (cxx.version >= 'gcc-4.7'):
|
|
|
|
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
|
|
|
if cxx.version >= 'gcc-4.8':
|
|
|
|
cxx.cflags += ['-Wno-unused-result']
|
2019-05-29 02:57:40 +02:00
|
|
|
if cxx.version >= 'gcc-9.0':
|
|
|
|
cxx.cxxflags += ['-Wno-class-memaccess', '-Wno-packed-not-aligned']
|
2015-10-08 23:36:24 +02:00
|
|
|
if have_clang:
|
|
|
|
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
|
|
|
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
|
|
|
cxx.cxxflags += ['-Wno-deprecated-register']
|
|
|
|
else:
|
|
|
|
cxx.cxxflags += ['-Wno-deprecated']
|
|
|
|
cxx.cflags += ['-Wno-sometimes-uninitialized']
|
|
|
|
|
2020-05-13 00:40:50 +02:00
|
|
|
# Work around SDK warnings.
|
|
|
|
if cxx.version >= 'clang-10.0':
|
|
|
|
cxx.cflags += [
|
|
|
|
'-Wno-implicit-int-float-conversion',
|
|
|
|
'-Wno-tautological-overlap-compare',
|
|
|
|
]
|
|
|
|
|
2015-10-08 23:36:24 +02:00
|
|
|
if have_gcc:
|
|
|
|
cxx.cflags += ['-mfpmath=sse']
|
2017-10-10 01:53:19 +02:00
|
|
|
cxx.cflags += ['-Wno-maybe-uninitialized']
|
2015-10-08 23:36:24 +02:00
|
|
|
|
|
|
|
if builder.options.opt == '1':
|
|
|
|
cxx.cflags += ['-O3']
|
|
|
|
|
2020-03-04 22:43:13 +01:00
|
|
|
# Don't omit the frame pointer.
|
|
|
|
cxx.cflags += ['-fno-omit-frame-pointer']
|
|
|
|
|
2015-10-08 23:36:24 +02:00
|
|
|
def configure_msvc(self, cxx):
|
|
|
|
if builder.options.debug == '1':
|
|
|
|
cxx.cflags += ['/MTd']
|
|
|
|
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
|
|
|
else:
|
|
|
|
cxx.cflags += ['/MT']
|
|
|
|
cxx.defines += [
|
|
|
|
'_CRT_SECURE_NO_DEPRECATE',
|
|
|
|
'_CRT_SECURE_NO_WARNINGS',
|
|
|
|
'_CRT_NONSTDC_NO_DEPRECATE',
|
|
|
|
'_ITERATOR_DEBUG_LEVEL=0',
|
|
|
|
]
|
|
|
|
cxx.cflags += [
|
|
|
|
'/W3',
|
|
|
|
]
|
|
|
|
cxx.cxxflags += [
|
|
|
|
'/EHsc',
|
|
|
|
'/GR-',
|
|
|
|
'/TP',
|
|
|
|
]
|
|
|
|
cxx.linkflags += [
|
|
|
|
'kernel32.lib',
|
|
|
|
'user32.lib',
|
|
|
|
'gdi32.lib',
|
|
|
|
'winspool.lib',
|
|
|
|
'comdlg32.lib',
|
|
|
|
'advapi32.lib',
|
|
|
|
'shell32.lib',
|
|
|
|
'ole32.lib',
|
|
|
|
'oleaut32.lib',
|
|
|
|
'uuid.lib',
|
|
|
|
'odbc32.lib',
|
|
|
|
'odbccp32.lib',
|
|
|
|
]
|
|
|
|
|
|
|
|
if builder.options.opt == '1':
|
|
|
|
cxx.cflags += ['/Ox', '/Zo']
|
|
|
|
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
|
|
|
|
|
|
|
|
if builder.options.debug == '1':
|
|
|
|
cxx.cflags += ['/Od', '/RTC1']
|
|
|
|
|
|
|
|
# This needs to be after our optimization flags which could otherwise disable it.
|
|
|
|
# Don't omit the frame pointer.
|
|
|
|
cxx.cflags += ['/Oy-']
|
|
|
|
|
|
|
|
def configure_linux(self, cxx):
|
2016-04-27 05:17:36 +02:00
|
|
|
cxx.defines += ['_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
|
2017-12-06 02:44:53 +01:00
|
|
|
cxx.linkflags += ['-lm']
|
2017-10-02 14:18:57 +02:00
|
|
|
if cxx.family == 'gcc':
|
2015-10-08 23:36:24 +02:00
|
|
|
cxx.linkflags += ['-static-libgcc']
|
2017-10-02 14:18:57 +02:00
|
|
|
elif cxx.family == 'clang':
|
2015-10-08 23:36:24 +02:00
|
|
|
cxx.linkflags += ['-lgcc_eh']
|
2020-05-27 05:04:55 +02:00
|
|
|
cxx.linkflags += ['-static-libstdc++']
|
2015-10-08 23:36:24 +02:00
|
|
|
|
|
|
|
def configure_mac(self, cxx):
|
2017-10-27 03:38:25 +02:00
|
|
|
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
|
Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.
This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).
IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.
ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.
This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:40:39 +02:00
|
|
|
cxx.cflags += ['-mmacosx-version-min=10.7']
|
2015-10-08 23:36:24 +02:00
|
|
|
cxx.linkflags += [
|
Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.
This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).
IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.
ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.
This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:40:39 +02:00
|
|
|
'-mmacosx-version-min=10.7',
|
|
|
|
'-stdlib=libc++',
|
2020-05-21 07:37:58 +02:00
|
|
|
'-lc++',
|
2015-10-08 23:36:24 +02:00
|
|
|
]
|
Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.
This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).
IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.
ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.
This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:40:39 +02:00
|
|
|
cxx.cxxflags += ['-stdlib=libc++']
|
2015-10-08 23:36:24 +02:00
|
|
|
|
|
|
|
def configure_windows(self, cxx):
|
|
|
|
cxx.defines += ['WIN32', '_WINDOWS']
|
|
|
|
|
2019-10-29 05:19:22 +01:00
|
|
|
def add_libamtl(self):
|
|
|
|
# Add libamtl.
|
|
|
|
self.libamtl = {}
|
|
|
|
for arch in self.archs:
|
|
|
|
def get_configure_fn(arch):
|
|
|
|
return lambda builder, name: self.StaticLibrary(builder, name, arch)
|
|
|
|
extra_vars = {'Configure': get_configure_fn(arch)}
|
|
|
|
libamtl = builder.Build('public/amtl/amtl/AMBuilder', extra_vars)
|
|
|
|
self.libamtl[arch] = libamtl.binary
|
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def AddVersioning(self, binary, arch):
|
2017-10-02 14:18:57 +02:00
|
|
|
if builder.target.platform == 'windows':
|
2013-12-30 23:50:59 +01:00
|
|
|
binary.sources += ['version.rc']
|
|
|
|
binary.compiler.rcdefines += [
|
|
|
|
'BINARY_NAME="{0}"'.format(binary.outputFile),
|
2013-12-30 23:51:00 +01:00
|
|
|
'RC_COMPILE',
|
2013-12-30 23:50:59 +01:00
|
|
|
]
|
2014-05-31 04:07:56 +02:00
|
|
|
if self.use_auto_versioning():
|
|
|
|
binary.compiler.rcdefines += ['SM_GENERATED_BUILD']
|
2017-10-02 14:18:57 +02:00
|
|
|
elif builder.target.platform == 'mac':
|
2014-06-01 04:56:42 +02:00
|
|
|
if binary.type == 'library':
|
|
|
|
binary.compiler.postlink += [
|
|
|
|
'-compatibility_version', '1.0.0',
|
|
|
|
'-current_version', self.productVersion
|
|
|
|
]
|
2014-05-31 04:07:56 +02:00
|
|
|
if self.use_auto_versioning():
|
2017-12-20 08:56:23 +01:00
|
|
|
binary.compiler.linkflags += [self.versionlib[arch]]
|
2014-05-31 04:07:56 +02:00
|
|
|
binary.compiler.sourcedeps += SM.generated_headers
|
2013-12-30 23:50:56 +01:00
|
|
|
return binary
|
2017-10-02 14:18:57 +02:00
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def LibraryBuilder(self, compiler, name, arch):
|
2017-10-02 14:18:57 +02:00
|
|
|
binary = compiler.Library(name)
|
2017-12-20 08:56:23 +01:00
|
|
|
AppendArchSuffix(binary, name, arch)
|
|
|
|
self.AddVersioning(binary, arch)
|
2015-03-08 20:37:10 +01:00
|
|
|
if binary.compiler.like('msvc'):
|
|
|
|
binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS']
|
2017-10-02 14:18:57 +02:00
|
|
|
return binary
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def ProgramBuilder(self, compiler, name, arch):
|
2017-10-02 14:18:57 +02:00
|
|
|
binary = compiler.Program(name)
|
2017-12-20 08:56:23 +01:00
|
|
|
AppendArchSuffix(binary, name, arch)
|
|
|
|
self.AddVersioning(binary, arch)
|
2017-10-02 14:18:57 +02:00
|
|
|
if '-static-libgcc' in binary.compiler.linkflags:
|
|
|
|
binary.compiler.linkflags.remove('-static-libgcc')
|
|
|
|
if '-lgcc_eh' in binary.compiler.linkflags:
|
|
|
|
binary.compiler.linkflags.remove('-lgcc_eh')
|
|
|
|
if binary.compiler.like('gcc'):
|
2019-07-24 15:47:13 +02:00
|
|
|
binary.compiler.linkflags += ['-lstdc++', '-lpthread']
|
2015-03-08 20:37:10 +01:00
|
|
|
if binary.compiler.like('msvc'):
|
|
|
|
binary.compiler.linkflags += ['/SUBSYSTEM:CONSOLE']
|
2017-10-02 14:18:57 +02:00
|
|
|
return binary
|
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def StaticLibraryBuilder(self, compiler, name, arch):
|
2017-10-02 14:18:57 +02:00
|
|
|
binary = compiler.StaticLibrary(name)
|
2017-12-20 08:56:23 +01:00
|
|
|
AppendArchSuffix(binary, name, arch)
|
2017-10-02 14:18:57 +02:00
|
|
|
return binary;
|
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def Library(self, context, name, arch):
|
2017-10-02 14:18:57 +02:00
|
|
|
compiler = context.cxx.clone()
|
2017-12-20 08:56:23 +01:00
|
|
|
SetArchFlags(compiler, arch, builder.target.platform)
|
|
|
|
return self.LibraryBuilder(compiler, name, arch)
|
2017-10-02 14:18:57 +02:00
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def Program(self, context, name, arch):
|
2017-10-02 14:18:57 +02:00
|
|
|
compiler = context.cxx.clone()
|
2017-12-20 08:56:23 +01:00
|
|
|
SetArchFlags(compiler, arch, builder.target.platform)
|
|
|
|
return self.ProgramBuilder(compiler, name, arch)
|
2017-10-02 14:18:57 +02:00
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def StaticLibrary(self, context, name, arch):
|
2017-10-02 14:18:57 +02:00
|
|
|
compiler = context.cxx.clone()
|
2017-12-20 08:56:23 +01:00
|
|
|
SetArchFlags(compiler, arch, builder.target.platform)
|
|
|
|
return self.StaticLibraryBuilder(compiler, name, arch)
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2014-06-01 04:56:42 +02:00
|
|
|
def ConfigureForExtension(self, context, compiler):
|
2013-12-30 23:50:56 +01:00
|
|
|
compiler.cxxincludes += [
|
|
|
|
os.path.join(context.currentSourcePath),
|
|
|
|
os.path.join(context.currentSourcePath, 'sdk'),
|
|
|
|
os.path.join(builder.sourcePath, 'public', 'extensions'),
|
2015-03-07 20:13:32 +01:00
|
|
|
os.path.join(builder.sourcePath, 'sourcepawn', 'include'),
|
2015-08-26 21:54:55 +02:00
|
|
|
os.path.join(builder.sourcePath, 'public', 'amtl', 'amtl'),
|
|
|
|
os.path.join(builder.sourcePath, 'public', 'amtl'),
|
2013-12-30 23:50:56 +01:00
|
|
|
]
|
|
|
|
return compiler
|
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def ExtLibrary(self, context, name, arch):
|
|
|
|
binary = self.Library(context, name, arch)
|
2014-06-01 04:56:42 +02:00
|
|
|
self.ConfigureForExtension(context, binary.compiler)
|
2017-10-02 14:18:57 +02:00
|
|
|
return binary
|
2014-06-01 04:56:42 +02:00
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def ConfigureForHL2(self, binary, sdk, arch):
|
2014-06-01 04:56:42 +02:00
|
|
|
compiler = binary.compiler
|
2017-12-20 08:56:23 +01:00
|
|
|
|
|
|
|
SetArchFlags(compiler, arch, builder.target.platform)
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
compiler.cxxincludes += [
|
2017-01-12 03:25:00 +01:00
|
|
|
os.path.join(self.mms_root, 'core'),
|
|
|
|
os.path.join(self.mms_root, 'core', 'sourcehook'),
|
2013-12-30 23:50:56 +01:00
|
|
|
]
|
|
|
|
|
|
|
|
defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs]
|
|
|
|
compiler.defines += defines
|
2014-06-01 04:56:42 +02:00
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
paths = [
|
|
|
|
['public'],
|
|
|
|
['public', 'engine'],
|
|
|
|
['public', 'mathlib'],
|
|
|
|
['public', 'vstdlib'],
|
|
|
|
['public', 'tier0'],
|
|
|
|
['public', 'tier1']
|
|
|
|
]
|
2014-05-25 10:53:58 +02:00
|
|
|
if sdk.name == 'episode1' or sdk.name == 'darkm':
|
2013-12-30 23:50:56 +01:00
|
|
|
paths.append(['public', 'dlls'])
|
|
|
|
paths.append(['game_shared'])
|
|
|
|
else:
|
|
|
|
paths.append(['public', 'game', 'server'])
|
|
|
|
paths.append(['public', 'toolframework'])
|
|
|
|
paths.append(['game', 'shared'])
|
|
|
|
paths.append(['common'])
|
|
|
|
|
|
|
|
compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
|
|
|
|
|
2015-05-07 03:12:13 +02:00
|
|
|
if sdk.name in ['sdk2013', 'bms'] and compiler.like('gcc'):
|
2013-12-30 23:50:56 +01:00
|
|
|
# The 2013 SDK already has these in public/tier0/basetypes.h
|
|
|
|
compiler.defines.remove('stricmp=strcasecmp')
|
|
|
|
compiler.defines.remove('_stricmp=strcasecmp')
|
|
|
|
compiler.defines.remove('_snprintf=snprintf')
|
|
|
|
compiler.defines.remove('_vsnprintf=vsnprintf')
|
|
|
|
|
2014-05-31 07:50:35 +02:00
|
|
|
if compiler.like('msvc'):
|
2014-03-01 02:43:07 +01:00
|
|
|
compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32']
|
2019-11-16 01:40:39 +01:00
|
|
|
compiler.linkflags += ['legacy_stdio_definitions.lib']
|
2014-03-01 02:43:07 +01:00
|
|
|
else:
|
|
|
|
compiler.defines += ['COMPILER_GCC']
|
2014-05-27 06:30:43 +02:00
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
if arch == 'x64':
|
|
|
|
compiler.defines += ['X64BITS', 'PLATFORM_64BITS']
|
|
|
|
|
2014-05-27 06:30:43 +02:00
|
|
|
# For everything after Swarm, this needs to be defined for entity networking
|
|
|
|
# to work properly with sendprop value changes.
|
2017-11-03 20:45:16 +01:00
|
|
|
if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']:
|
2014-02-11 03:04:01 +01:00
|
|
|
compiler.defines += ['NETWORK_VARS_ENABLED']
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2016-04-27 05:18:47 +02:00
|
|
|
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2']:
|
2017-10-02 14:18:57 +02:00
|
|
|
if builder.target.platform in ['linux', 'mac']:
|
2014-04-20 18:00:04 +02:00
|
|
|
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']
|
2013-12-30 23:50:56 +01:00
|
|
|
|
Pare down ThreadSupport and remove ancient thread code.
This patch removes almost all of the existing platform-specific
ThreadSupport code, as well as code derived from it. It is now
implemented on top of C++11 threads and is much simpler.
This is the first inclusion of STL in SourceMod. Mac and Windows are
allowed to dynamically link to their respective implementations. On
Linux, libstdc++ is statically linked, except in the cases where it was
already dynamically linked (csgo, blade).
IEventSignal has been retained because sourcemod-curl-extension relies
on it. As written, it is impossible to use as a condition variable,
because the caller does not have access to the underlying mutex. There
is no way to make this API safe or non-racy, so extensions relying on
it should switch to C++11 threads.
ThreadWorker is now pared down and does not interact or inherit from
BaseWorker in any way. Basic functionality has been tested. Since it is
not used anywhere in SourceMod, or seemingly in any repository on
GitHub, it's unclear whether it should even exist. But it has been
tested in this patch.
This change bumps the minimum macOS version to OS X 10.7, and the
minimum C++ standard level to C++14.
2020-05-13 00:40:39 +02:00
|
|
|
if builder.target.platform == 'linux':
|
|
|
|
if sdk.name in ['csgo', 'blade']:
|
|
|
|
compiler.linkflags.remove('-static-libstdc++')
|
|
|
|
compiler.linkflags += ['-lstdc++']
|
|
|
|
compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']
|
2014-09-12 01:23:10 +02:00
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
for path in paths:
|
|
|
|
compiler.cxxincludes += [os.path.join(sdk.path, *path)]
|
|
|
|
|
2017-10-02 14:18:57 +02:00
|
|
|
if builder.target.platform == 'linux':
|
2014-05-25 10:53:58 +02:00
|
|
|
if sdk.name == 'episode1':
|
2013-12-30 23:50:56 +01:00
|
|
|
lib_folder = os.path.join(sdk.path, 'linux_sdk')
|
2015-05-07 03:12:13 +02:00
|
|
|
elif sdk.name in ['sdk2013', 'bms']:
|
2013-12-30 23:50:56 +01:00
|
|
|
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32')
|
2017-12-20 08:56:23 +01:00
|
|
|
elif arch == 'x64':
|
|
|
|
lib_folder = os.path.join(sdk.path, 'lib', 'linux64')
|
2013-12-30 23:50:56 +01:00
|
|
|
else:
|
|
|
|
lib_folder = os.path.join(sdk.path, 'lib', 'linux')
|
2017-10-02 14:18:57 +02:00
|
|
|
elif builder.target.platform == 'mac':
|
2015-05-07 03:12:13 +02:00
|
|
|
if sdk.name in ['sdk2013', 'bms']:
|
2013-12-30 23:50:56 +01:00
|
|
|
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
|
2017-12-20 08:56:23 +01:00
|
|
|
elif arch == 'x64':
|
|
|
|
lib_folder = os.path.join(sdk.path, 'lib', 'osx64')
|
2013-12-30 23:50:56 +01:00
|
|
|
else:
|
|
|
|
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
|
|
|
|
|
2017-10-02 14:18:57 +02:00
|
|
|
if builder.target.platform in ['linux', 'mac']:
|
2017-12-20 08:56:23 +01:00
|
|
|
if sdk.name in ['sdk2013', 'bms'] or arch == 'x64':
|
2013-12-30 23:50:56 +01:00
|
|
|
compiler.postlink += [
|
|
|
|
compiler.Dep(os.path.join(lib_folder, 'tier1.a')),
|
|
|
|
compiler.Dep(os.path.join(lib_folder, 'mathlib.a'))
|
|
|
|
]
|
|
|
|
else:
|
|
|
|
compiler.postlink += [
|
|
|
|
compiler.Dep(os.path.join(lib_folder, 'tier1_i486.a')),
|
|
|
|
compiler.Dep(os.path.join(lib_folder, 'mathlib_i486.a'))
|
|
|
|
]
|
|
|
|
|
2017-11-03 20:45:16 +01:00
|
|
|
if sdk.name in ['blade', 'insurgency', 'doi', 'csgo']:
|
2017-12-20 08:56:23 +01:00
|
|
|
if arch == 'x64':
|
|
|
|
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces.a'))]
|
|
|
|
else:
|
|
|
|
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))]
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
dynamic_libs = []
|
2017-10-02 14:18:57 +02:00
|
|
|
if builder.target.platform == 'linux':
|
2017-11-03 20:45:16 +01:00
|
|
|
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency', 'doi']:
|
2013-12-30 23:50:56 +01:00
|
|
|
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
|
2020-03-11 23:36:25 +01:00
|
|
|
elif arch == 'x64' and sdk.name in ['csgo', 'blade']:
|
2017-12-20 08:56:23 +01:00
|
|
|
dynamic_libs = ['libtier0_client.so', 'libvstdlib_client.so']
|
2017-11-03 20:45:16 +01:00
|
|
|
elif sdk.name in ['l4d', 'blade', 'insurgency', 'doi', 'csgo']:
|
2013-12-30 23:50:56 +01:00
|
|
|
dynamic_libs = ['libtier0.so', 'libvstdlib.so']
|
|
|
|
else:
|
|
|
|
dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so']
|
2017-10-02 14:18:57 +02:00
|
|
|
elif builder.target.platform == 'mac':
|
2014-06-01 04:56:42 +02:00
|
|
|
compiler.linkflags.append('-liconv')
|
2013-12-30 23:50:56 +01:00
|
|
|
dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
|
2017-10-02 14:18:57 +02:00
|
|
|
elif builder.target.platform == 'windows':
|
2013-12-30 23:50:56 +01:00
|
|
|
libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
|
2017-11-03 20:45:16 +01:00
|
|
|
if sdk.name in ['swarm', 'blade', 'insurgency', 'doi', 'csgo']:
|
2013-12-30 23:50:56 +01:00
|
|
|
libs.append('interfaces')
|
|
|
|
for lib in libs:
|
|
|
|
lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib'
|
2014-06-01 04:56:42 +02:00
|
|
|
compiler.linkflags.append(compiler.Dep(lib_path))
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
for library in dynamic_libs:
|
|
|
|
source_path = os.path.join(lib_folder, library)
|
|
|
|
output_path = os.path.join(binary.localFolder, library)
|
|
|
|
|
|
|
|
def make_linker(source_path, output_path):
|
|
|
|
def link(context, binary):
|
|
|
|
cmd_node, (output,) = context.AddSymlink(source_path, output_path)
|
|
|
|
return output
|
|
|
|
return link
|
|
|
|
|
|
|
|
linker = make_linker(source_path, output_path)
|
2014-06-01 04:56:42 +02:00
|
|
|
compiler.linkflags[0:0] = [compiler.Dep(library, linker)]
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
return binary
|
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def HL2Library(self, context, name, sdk, arch):
|
|
|
|
binary = self.Library(context, name, arch)
|
2014-06-01 04:56:42 +02:00
|
|
|
self.ConfigureForExtension(context, binary.compiler)
|
2017-12-20 08:56:23 +01:00
|
|
|
return self.ConfigureForHL2(binary, sdk, arch)
|
2014-06-01 04:56:42 +02:00
|
|
|
|
|
|
|
def HL2Project(self, context, name):
|
2017-10-02 14:18:57 +02:00
|
|
|
project = context.cxx.LibraryProject(name)
|
2014-06-01 04:56:42 +02:00
|
|
|
self.ConfigureForExtension(context, project.compiler)
|
|
|
|
return project
|
|
|
|
|
2017-12-20 08:56:23 +01:00
|
|
|
def HL2Config(self, project, name, sdk, arch):
|
2014-06-01 04:59:02 +02:00
|
|
|
binary = project.Configure(name, '{0} - {1}'.format(self.tag, sdk.name))
|
2017-12-20 08:56:23 +01:00
|
|
|
AppendArchSuffix(binary, name, arch)
|
|
|
|
self.AddVersioning(binary, arch)
|
|
|
|
return self.ConfigureForHL2(binary, sdk, arch)
|
2014-06-01 04:56:42 +02:00
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
SM = SMConfig()
|
2013-12-30 23:50:59 +01:00
|
|
|
SM.detectProductVersion()
|
2013-12-30 23:50:56 +01:00
|
|
|
SM.detectSDKs()
|
|
|
|
SM.configure()
|
2019-10-29 05:19:22 +01:00
|
|
|
SM.add_libamtl()
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2014-05-31 04:07:56 +02:00
|
|
|
if SM.use_auto_versioning():
|
2017-10-02 14:18:57 +02:00
|
|
|
SM.generated_headers = builder.Build(
|
2014-05-31 04:07:56 +02:00
|
|
|
'tools/buildbot/Versioning',
|
|
|
|
{ 'SM': SM }
|
|
|
|
)
|
2017-10-02 14:18:57 +02:00
|
|
|
SM.versionlib = builder.Build(
|
2014-05-31 04:07:56 +02:00
|
|
|
'versionlib/AMBuilder',
|
|
|
|
{ 'SM': SM }
|
|
|
|
)
|
|
|
|
|
2015-03-08 20:37:10 +01:00
|
|
|
# Build SourcePawn externally.
|
2017-10-02 14:18:57 +02:00
|
|
|
SP = builder.Build('sourcepawn/AMBuildScript', {
|
|
|
|
'external_root': SM,
|
|
|
|
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
|
|
|
|
'external_build': ['core'],
|
|
|
|
})
|
2017-12-20 08:56:23 +01:00
|
|
|
if len(SP.spcomp) > 1:
|
|
|
|
SM.spcomp = SP.spcomp['x86']
|
|
|
|
else:
|
|
|
|
SM.spcomp = SP.spcomp[list(SP.spcomp.keys())[0]]
|
|
|
|
SM.spcomp_bins = list(SP.spcomp.values())
|
|
|
|
for arch in SM.archs:
|
|
|
|
SM.binaries += [
|
|
|
|
SP.libsourcepawn[arch]
|
|
|
|
]
|
2015-03-08 20:37:10 +01:00
|
|
|
|
2018-10-04 19:59:40 +02:00
|
|
|
BuildScripts = [
|
|
|
|
'loader/AMBuilder',
|
|
|
|
'core/AMBuilder',
|
2014-05-31 04:07:56 +02:00
|
|
|
'core/logic/AMBuilder',
|
|
|
|
'extensions/bintools/AMBuilder',
|
|
|
|
'extensions/clientprefs/AMBuilder',
|
|
|
|
'extensions/curl/AMBuilder',
|
2018-10-04 19:59:40 +02:00
|
|
|
'extensions/cstrike/AMBuilder',
|
2014-05-31 04:07:56 +02:00
|
|
|
'extensions/geoip/AMBuilder',
|
2018-10-04 19:59:40 +02:00
|
|
|
'extensions/mysql/AMBuilder',
|
2014-05-31 04:07:56 +02:00
|
|
|
'extensions/regex/AMBuilder',
|
2018-09-30 18:59:28 +02:00
|
|
|
'extensions/sdkhooks/AMBuilder',
|
|
|
|
'extensions/sdktools/AMBuilder',
|
2018-10-04 19:59:40 +02:00
|
|
|
'extensions/sqlite/AMBuilder',
|
2018-09-30 18:59:28 +02:00
|
|
|
'extensions/tf2/AMBuilder',
|
2018-10-04 19:59:40 +02:00
|
|
|
'extensions/topmenus/AMBuilder',
|
|
|
|
'extensions/updater/AMBuilder',
|
2018-09-30 18:59:28 +02:00
|
|
|
]
|
2014-05-31 04:07:56 +02:00
|
|
|
|
|
|
|
if builder.backend == 'amb2':
|
2018-10-04 19:59:40 +02:00
|
|
|
BuildScripts += [
|
2013-12-30 23:50:58 +01:00
|
|
|
'plugins/AMBuilder',
|
2013-12-30 23:50:59 +01:00
|
|
|
'tools/buildbot/PackageScript',
|
2014-05-31 04:07:56 +02:00
|
|
|
]
|
2018-10-04 19:59:40 +02:00
|
|
|
|
|
|
|
builder.Build(BuildScripts, { 'SM': SM })
|
2013-12-30 23:51:02 +01:00
|
|
|
|
|
|
|
if builder.options.breakpad_dump:
|
2017-10-02 14:18:57 +02:00
|
|
|
builder.Build('tools/buildbot/BreakpadSymbols', { 'SM': SM })
|