Skip to content

Commit

Permalink
Merge pull request #66 from PlayBoy31/patch-1
Browse files Browse the repository at this point in the history
Build against available metamod and all possible sdks
  • Loading branch information
dvander authored Sep 2, 2020
2 parents a4aafd7 + a26a25d commit b8d1fd4
Showing 1 changed file with 30 additions and 9 deletions.
39 changes: 30 additions & 9 deletions sample_mm/AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ proj_c_flags = [
'-Wno-non-virtual-dtor',
'-Wno-overloaded-virtual',
'-Werror',
'-Wno-unused',
]
proj_c_flags_opt = [
'-O3',
Expand Down Expand Up @@ -98,6 +99,9 @@ def ResolveEnvPath(env, folder):
head, tail = os.path.split(head)
return None

def Normalize(path):
return os.path.abspath(os.path.normpath(path))

def SetArchFlags(compiler, arch, platform):
if compiler.behavior == 'gcc':
if arch == 'x86':
Expand Down Expand Up @@ -125,6 +129,7 @@ class MMSConfig(object):
self.sdks = {}
self.binaries = []
self.generated_headers = None
self.mms_root = None
self.archs = builder.target.arch.replace('x86_64', 'x64').split(',')

def detectProductVersion(self):
Expand Down Expand Up @@ -167,6 +172,19 @@ class MMSConfig(object):
raise Exception('No SDKs were found that build on {0}-{1}, nothing to do.'.format(
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):
if not set(self.archs).issubset(['x86', 'x64']):
raise Exception('Unknown target architecture: {0}'.format(builder.target.arch))
Expand Down Expand Up @@ -255,8 +273,18 @@ class MMSConfig(object):

def HL2Compiler(self, context, sdk, arch):
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]
Expand All @@ -270,17 +298,10 @@ class MMSConfig(object):
['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':
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:
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]

Expand Down

0 comments on commit b8d1fd4

Please sign in to comment.