2013-12-30 23:50:56 +01:00
|
|
|
# vim: set sts=2 ts=8 sw=2 tw=99 et ft=python:
|
|
|
|
import os, sys
|
2020-08-16 06:25:25 +02:00
|
|
|
import traceback
|
2013-12-30 23:50:56 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def shouldBuild(self, targets):
|
|
|
|
for cxx in targets:
|
|
|
|
if cxx.target.platform in self.platformSpec:
|
|
|
|
if cxx.target.arch in self.platformSpec[cxx.target.platform]:
|
|
|
|
return True
|
|
|
|
return False
|
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'],
|
2020-08-16 06:25:25 +02:00
|
|
|
'linux': ['x86', 'x86_64'],
|
|
|
|
'mac': ['x86_64']
|
2017-12-20 08:56:23 +01:00
|
|
|
}
|
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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def SetArchFlags(compiler):
|
2017-12-20 08:56:23 +01:00
|
|
|
if compiler.behavior == 'gcc':
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.arch == 'x86_64':
|
|
|
|
compiler.cflags += ['-fPIC']
|
2017-12-20 08:56:23 +01:00
|
|
|
elif compiler.like('msvc'):
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.arch == 'x86_64':
|
2020-08-07 04:53:06 +02:00
|
|
|
compiler.defines += ['WIN64']
|
2017-12-20 08:56:23 +01:00
|
|
|
|
2013-12-30 23:50:56 +01:00
|
|
|
class SMConfig(object):
|
|
|
|
def __init__(self):
|
|
|
|
self.sdks = {}
|
|
|
|
self.binaries = []
|
2020-08-16 06:25:25 +02:00
|
|
|
self.spvm = []
|
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
|
2020-08-16 06:25:25 +02:00
|
|
|
self.all_targets = []
|
|
|
|
self.target_archs = set()
|
|
|
|
|
|
|
|
|
|
|
|
if builder.options.targets:
|
|
|
|
target_archs = builder.options.targets.split(',')
|
|
|
|
else:
|
|
|
|
target_archs = ['x86']
|
|
|
|
if builder.backend != 'amb2':
|
|
|
|
target_archs.append('x86_64')
|
|
|
|
|
|
|
|
for arch in target_archs:
|
|
|
|
try:
|
|
|
|
cxx = builder.DetectCxx(target_arch = arch)
|
|
|
|
self.target_archs.add(cxx.target.arch)
|
|
|
|
except Exception as e:
|
|
|
|
# Error if archs were manually overridden.
|
|
|
|
if builder.options.targets:
|
|
|
|
raise
|
|
|
|
print('Skipping target {}: {}'.format(arch, e))
|
|
|
|
continue
|
|
|
|
self.all_targets.append(cxx)
|
|
|
|
|
|
|
|
if not self.all_targets:
|
|
|
|
raise Exception('No suitable C/C++ compiler was found.')
|
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'
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
not_found = []
|
2013-12-30 23:50:56 +01:00
|
|
|
for sdk_name in PossibleSDKs:
|
|
|
|
sdk = PossibleSDKs[sdk_name]
|
2020-08-16 06:25:25 +02:00
|
|
|
if sdk.shouldBuild(self.all_targets):
|
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))
|
2020-08-16 06:25:25 +02:00
|
|
|
not_found.append(sdk_name)
|
2013-12-30 23:50:56 +01:00
|
|
|
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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
for sdk in not_found:
|
|
|
|
print('Warning: hl2sdk-{} was not found, and will not be included in build.'.format(sdk))
|
|
|
|
|
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:
|
2020-08-16 06:25:25 +02:00
|
|
|
if 'x86' in self.target_archs:
|
2020-08-07 04:53:06 +02:00
|
|
|
if builder.options.mysql_path:
|
|
|
|
self.mysql_root['x86'] = builder.options.mysql_path
|
|
|
|
else:
|
|
|
|
for i in range(10):
|
|
|
|
self.mysql_root['x86'] = ResolveEnvPath('MYSQL55', 'mysql-5.' + str(i))
|
|
|
|
if self.mysql_root['x86']:
|
|
|
|
break
|
|
|
|
if not self.mysql_root['x86'] or not os.path.isdir(self.mysql_root['x86']):
|
2020-08-16 06:25:25 +02:00
|
|
|
raise Exception('Could not find a path to MySQL. Configure with --no-mysql to disable it.')
|
2020-08-07 04:53:06 +02:00
|
|
|
self.mysql_root['x86'] = Normalize(self.mysql_root['x86'])
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
if 'x86_64' in self.target_archs:
|
2018-06-05 15:29:11 +02:00
|
|
|
if builder.options.mysql64_path:
|
2020-08-16 06:25:25 +02:00
|
|
|
self.mysql_root['x86_64'] = builder.options.mysql64_path
|
2017-12-20 08:56:23 +01:00
|
|
|
else:
|
2018-06-05 15:29:11 +02:00
|
|
|
for i in range(10):
|
2020-08-16 06:25:25 +02:00
|
|
|
self.mysql_root['x86_64'] = ResolveEnvPath('MYSQL55_64', 'mysql-5.' + str(i) + '-x86_64')
|
|
|
|
if self.mysql_root['x86_64']:
|
2017-12-20 08:56:23 +01:00
|
|
|
break
|
2020-08-16 06:25:25 +02:00
|
|
|
if not self.mysql_root['x86_64'] or not os.path.isdir(self.mysql_root['x86_64']):
|
2017-12-20 08:56:23 +01:00
|
|
|
raise Exception('Could not find a path to 64-bit MySQL!')
|
2020-08-16 06:25:25 +02:00
|
|
|
self.mysql_root['x86_64'] = Normalize(self.mysql_root['x86_64'])
|
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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
if not set(self.target_archs).issubset(['x86', 'x86_64']):
|
2017-12-20 08:56:23 +01:00
|
|
|
raise Exception('Unknown target architecture: {0}'.format(builder.target.arch))
|
2014-01-09 00:09:50 +01:00
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
for cxx in self.all_targets:
|
|
|
|
self.configure_cxx(cxx)
|
2013-12-30 23:50:56 +01:00
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def configure_cxx(self, cxx):
|
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
|
2020-08-16 06:25:25 +02:00
|
|
|
if cxx.target.platform == 'linux':
|
2015-10-08 23:36:24 +02:00
|
|
|
self.configure_linux(cxx)
|
2020-08-16 06:25:25 +02:00
|
|
|
elif cxx.target.platform == 'mac':
|
2015-10-08 23:36:24 +02:00
|
|
|
self.configure_mac(cxx)
|
2020-08-16 06:25:25 +02:00
|
|
|
elif cxx.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 = {}
|
2020-08-16 06:25:25 +02:00
|
|
|
for cxx in self.all_targets:
|
|
|
|
def get_configure_fn(cxx):
|
|
|
|
return lambda builder, name: self.StaticLibrary(builder, cxx, name)
|
|
|
|
extra_vars = {'Configure': get_configure_fn(cxx)}
|
2019-10-29 05:19:22 +01:00
|
|
|
libamtl = builder.Build('public/amtl/amtl/AMBuilder', extra_vars)
|
2020-08-16 06:25:25 +02:00
|
|
|
self.libamtl[cxx.target.arch] = libamtl.binary
|
2019-10-29 05:19:22 +01:00
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def AddVersioning(self, binary):
|
|
|
|
if binary.compiler.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']
|
2020-08-16 06:25:25 +02:00
|
|
|
elif binary.compiler.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():
|
2020-08-16 06:25:25 +02:00
|
|
|
binary.compiler.linkflags += [self.versionlib[binary.compiler.target.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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def LibraryBuilder(self, compiler, name):
|
2017-10-02 14:18:57 +02:00
|
|
|
binary = compiler.Library(name)
|
2020-08-16 06:25:25 +02:00
|
|
|
self.AddVersioning(binary)
|
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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def ProgramBuilder(self, compiler, name):
|
2017-10-02 14:18:57 +02:00
|
|
|
binary = compiler.Program(name)
|
2020-08-16 06:25:25 +02:00
|
|
|
self.AddVersioning(binary)
|
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
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def StaticLibraryBuilder(self, compiler, name):
|
|
|
|
return compiler.StaticLibrary(name)
|
|
|
|
|
|
|
|
def Library(self, context, compiler, name):
|
|
|
|
compiler = compiler.clone()
|
|
|
|
SetArchFlags(compiler)
|
|
|
|
return self.LibraryBuilder(compiler, name)
|
|
|
|
|
|
|
|
def Program(self, context, compiler, name):
|
|
|
|
compiler = compiler.clone()
|
|
|
|
SetArchFlags(compiler)
|
|
|
|
return self.ProgramBuilder(compiler, name)
|
2017-10-02 14:18:57 +02:00
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def StaticLibrary(self, context, compiler, name):
|
|
|
|
compiler = compiler.clone()
|
|
|
|
SetArchFlags(compiler)
|
|
|
|
return self.StaticLibraryBuilder(compiler, name)
|
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
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def ExtLibrary(self, context, compiler, name):
|
|
|
|
binary = self.Library(context, compiler, name)
|
|
|
|
SetArchFlags(compiler)
|
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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def ConfigureForHL2(self, binary, sdk):
|
2014-06-01 04:56:42 +02:00
|
|
|
compiler = binary.compiler
|
2020-08-16 06:25:25 +02:00
|
|
|
SetArchFlags(compiler)
|
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'):
|
2020-08-07 04:53:06 +02:00
|
|
|
compiler.defines += ['COMPILER_MSVC']
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.arch == 'x86':
|
2020-08-07 04:53:06 +02:00
|
|
|
compiler.defines += ['COMPILER_MSVC32']
|
2020-08-16 06:25:25 +02:00
|
|
|
elif compiler.target.arch == 'x86_64':
|
2020-08-07 04:53:06 +02:00
|
|
|
compiler.defines += ['COMPILER_MSVC64']
|
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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.arch == 'x86_64':
|
2017-12-20 08:56:23 +01:00
|
|
|
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']:
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.platform == 'linux':
|
2020-05-22 00:12:38 +02:00
|
|
|
if sdk.name in ['csgo', 'blade']:
|
|
|
|
compiler.linkflags.remove('-static-libstdc++')
|
|
|
|
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)]
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.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')
|
2020-08-16 06:25:25 +02:00
|
|
|
elif compiler.target.arch == 'x86_64':
|
2017-12-20 08:56:23 +01:00
|
|
|
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')
|
2020-08-16 06:25:25 +02:00
|
|
|
elif compiler.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')
|
2020-08-16 06:25:25 +02:00
|
|
|
elif compiler.target.arch == 'x86_64':
|
2017-12-20 08:56:23 +01:00
|
|
|
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')
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.platform in ['linux', 'mac']:
|
|
|
|
if sdk.name in ['sdk2013', 'bms'] or compiler.target.arch == 'x86_64':
|
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']:
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.arch == 'x86_64':
|
2017-12-20 08:56:23 +01:00
|
|
|
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 = []
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.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-08-16 06:25:25 +02:00
|
|
|
elif compiler.target.arch == 'x86_64' 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']
|
2020-08-16 06:25:25 +02:00
|
|
|
elif compiler.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']
|
2020-08-16 06:25:25 +02:00
|
|
|
elif compiler.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:
|
2020-08-16 06:25:25 +02:00
|
|
|
if compiler.target.arch == 'x86':
|
2020-08-07 04:53:06 +02:00
|
|
|
lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib'
|
2020-08-16 06:25:25 +02:00
|
|
|
elif compiler.target.arch == 'x86_64':
|
2020-08-07 04:53:06 +02:00
|
|
|
lib_path = os.path.join(sdk.path, 'lib', 'public', 'win64', 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
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
def HL2Library(self, context, compiler, name, sdk):
|
|
|
|
binary = self.Library(context, compiler, name)
|
2014-06-01 04:56:42 +02:00
|
|
|
self.ConfigureForExtension(context, binary.compiler)
|
2020-08-16 06:25:25 +02:00
|
|
|
return self.ConfigureForHL2(binary, sdk)
|
|
|
|
|
|
|
|
def HL2Config(self, project, compiler, name, sdk):
|
|
|
|
binary = project.Configure(compiler, name,
|
|
|
|
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
|
|
|
|
self.AddVersioning(binary)
|
|
|
|
return self.ConfigureForHL2(binary, sdk)
|
|
|
|
|
|
|
|
def HL2ExtConfig(self, project, context, compiler, name, sdk):
|
|
|
|
binary = project.Configure(compiler, name,
|
|
|
|
'{0} - {1} {2}'.format(self.tag, sdk.name, compiler.target.arch))
|
|
|
|
self.AddVersioning(binary)
|
|
|
|
self.ConfigureForHL2(binary, sdk)
|
|
|
|
self.ConfigureForExtension(context, binary.compiler)
|
|
|
|
return binary
|
2014-06-01 04:56:42 +02:00
|
|
|
|
2020-08-19 09:39:54 +02:00
|
|
|
if getattr(builder, 'target', None) is not None:
|
|
|
|
sys.stderr.write("Your output folder was configured for AMBuild 2.1, and SourceMod is now\n")
|
|
|
|
sys.stderr.write("configured to use AMBuild 2.2. Please remove your output folder and\n")
|
|
|
|
sys.stderr.write("reconfigure to continue.\n")
|
|
|
|
os._exit(1)
|
|
|
|
|
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
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
# This will clone the list and each cxx object as we recurse, preventing child
|
|
|
|
# scripts from messing up global state.
|
|
|
|
builder.targets = builder.CloneableList(SM.all_targets)
|
|
|
|
|
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 }
|
|
|
|
)
|
|
|
|
|
2020-08-16 06:25:25 +02:00
|
|
|
class SPRoot(object):
|
|
|
|
# SourcePawn's build scripts are always one-offs, and attach the current target
|
|
|
|
# to the builder, so we have to provide a shim to our StaticLibrary() method.
|
|
|
|
def StaticLibrary(self, builder, name):
|
|
|
|
return SM.StaticLibrary(builder, builder.cxx, name)
|
|
|
|
def Program(self, builder, name):
|
|
|
|
return SM.Program(builder, builder.cxx, name)
|
|
|
|
def Library(self, builder, name):
|
|
|
|
return SM.Library(builder, builder.cxx, name)
|
|
|
|
|
|
|
|
@property
|
|
|
|
def targets(self):
|
|
|
|
return SM.all_targets
|
|
|
|
|
|
|
|
@property
|
|
|
|
def libamtl(self):
|
|
|
|
return SM.libamtl
|
|
|
|
|
2015-03-08 20:37:10 +01:00
|
|
|
# Build SourcePawn externally.
|
2017-10-02 14:18:57 +02:00
|
|
|
SP = builder.Build('sourcepawn/AMBuildScript', {
|
2020-08-16 06:25:25 +02:00
|
|
|
'external_root': SPRoot(),
|
2017-10-02 14:18:57 +02:00
|
|
|
'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())
|
2020-08-16 06:25:25 +02:00
|
|
|
for cxx in SM.all_targets:
|
|
|
|
SM.spvm += [
|
|
|
|
SP.libsourcepawn[cxx.target.arch]
|
2017-12-20 08:56:23 +01:00
|
|
|
]
|
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 })
|