1
0
mirror of https://github.com/alliedmodders/metamod-source.git synced 2025-02-21 14:54:14 +01:00

Merge pull request #66 from PlayBoy31/patch-1

Build against available metamod and all possible sdks
This commit is contained in:
David Anderson 2020-09-01 17:14:19 -07:00 committed by GitHub
commit b8d1fd401d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -7,6 +7,7 @@ proj_c_flags = [
'-Wno-non-virtual-dtor', '-Wno-non-virtual-dtor',
'-Wno-overloaded-virtual', '-Wno-overloaded-virtual',
'-Werror', '-Werror',
'-Wno-unused',
] ]
proj_c_flags_opt = [ proj_c_flags_opt = [
'-O3', '-O3',
@ -98,6 +99,9 @@ def ResolveEnvPath(env, folder):
head, tail = os.path.split(head) head, tail = os.path.split(head)
return None return None
def Normalize(path):
return os.path.abspath(os.path.normpath(path))
def SetArchFlags(compiler, arch, platform): def SetArchFlags(compiler, arch, platform):
if compiler.behavior == 'gcc': if compiler.behavior == 'gcc':
if arch == 'x86': if arch == 'x86':
@ -125,6 +129,7 @@ class MMSConfig(object):
self.sdks = {} self.sdks = {}
self.binaries = [] self.binaries = []
self.generated_headers = None self.generated_headers = None
self.mms_root = None
self.archs = builder.target.arch.replace('x86_64', 'x64').split(',') self.archs = builder.target.arch.replace('x86_64', 'x64').split(',')
def detectProductVersion(self): def detectProductVersion(self):
@ -167,6 +172,19 @@ class MMSConfig(object):
raise Exception('No SDKs were found that build on {0}-{1}, nothing to do.'.format( raise Exception('No SDKs were found that build on {0}-{1}, nothing to do.'.format(
builder.target.platform, builder.target.arch)) builder.target.platform, builder.target.arch))
if builder.options.mms_path:
self.mms_root = builder.options.mms_path
else:
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
if not self.mms_root:
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)
def configure(self): def configure(self):
if not set(self.archs).issubset(['x86', 'x64']): if not set(self.archs).issubset(['x86', 'x64']):
raise Exception('Unknown target architecture: {0}'.format(builder.target.arch)) raise Exception('Unknown target architecture: {0}'.format(builder.target.arch))
@ -255,8 +273,18 @@ class MMSConfig(object):
def HL2Compiler(self, context, sdk, arch): def HL2Compiler(self, context, sdk, arch):
compiler = context.cxx.clone() compiler = context.cxx.clone()
compiler.cxxincludes += [
os.path.join(context.currentSourcePath), if sdk.name == 'episode1' or sdk.name == 'darkm':
compiler.cxxincludes += [
os.path.join(context.currentSourcePath),
os.path.join(self.mms_root, 'core-legacy'),
os.path.join(self.mms_root, 'core-legacy', 'sourcehook'),
]
else:
compiler.cxxincludes += [
os.path.join(context.currentSourcePath),
os.path.join(self.mms_root, 'core'),
os.path.join(self.mms_root, 'core', 'sourcehook'),
] ]
defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs] defines = ['SE_' + PossibleSDKs[i].define + '=' + PossibleSDKs[i].code for i in PossibleSDKs]
@ -270,17 +298,10 @@ class MMSConfig(object):
['public', 'tier1'], ['public', 'tier1'],
] ]
if not builder.options.mms_path:
raise Exception('Metamod:Source path is missing. Supply a --mms_path flag')
if sdk.name == 'episode1' or sdk.name == 'darkm': if sdk.name == 'episode1' or sdk.name == 'darkm':
paths.append(['public', 'dlls']) paths.append(['public', 'dlls'])
compiler.cxxincludes.append(os.path.join(builder.options.mms_path, 'core-legacy'))
compiler.cxxincludes.append(os.path.join(builder.options.mms_path, 'core-legacy', 'sourcehook'))
else: else:
paths.append(['public', 'game', 'server']) paths.append(['public', 'game', 'server'])
compiler.cxxincludes.append(os.path.join(builder.options.mms_path, 'core'))
compiler.cxxincludes.append(os.path.join(builder.options.mms_path, 'core', 'sourcehook'))
compiler.defines += ['SOURCE_ENGINE=' + sdk.code] compiler.defines += ['SOURCE_ENGINE=' + sdk.code]