mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-02-26 19:54:14 +01:00
Make various AMBuild script changes to support 64-bit builds for CSGO.
This commit is contained in:
parent
1c3a32d921
commit
a805d4470f
120
AMBuildScript
120
AMBuildScript
@ -18,16 +18,21 @@ class SDK(object):
|
||||
else:
|
||||
self.platformSpec = platform
|
||||
|
||||
def shouldBuild(self, target):
|
||||
def shouldBuild(self, target, archs):
|
||||
if target.platform not in self.platformSpec:
|
||||
return False
|
||||
if target.arch not in self.platformSpec[target.platform]:
|
||||
if not len([i for i in self.platformSpec[target.platform] if i in archs]):
|
||||
return False
|
||||
return True
|
||||
|
||||
WinOnly = ['windows']
|
||||
WinLinux = ['windows', 'linux']
|
||||
WinLinuxMac = ['windows', 'linux', 'mac']
|
||||
CSGO = {
|
||||
'windows': ['x86'],
|
||||
'linux': ['x86', 'x86_64'],
|
||||
'mac': ['x86_64']
|
||||
}
|
||||
Source2 = {
|
||||
'windows': ['x86', 'x86_64'],
|
||||
'linux': ['x86_64'],
|
||||
@ -48,7 +53,7 @@ PossibleSDKs = {
|
||||
'swarm': SDK('HL2SDK-SWARM', '2.swarm', '16', 'ALIENSWARM', WinOnly, 'swarm'),
|
||||
'bgt': SDK('HL2SDK-BGT', '2.bgt', '4', 'BLOODYGOODTIME', WinOnly, 'bgt'),
|
||||
'eye': SDK('HL2SDK-EYE', '2.eye', '5', 'EYE', WinOnly, 'eye'),
|
||||
'csgo': SDK('HL2SDKCSGO', '2.csgo', '20', 'CSGO', WinLinuxMac, 'csgo'),
|
||||
'csgo': SDK('HL2SDKCSGO', '2.csgo', '20', 'CSGO', CSGO, 'csgo'),
|
||||
'dota': SDK('HL2SDKDOTA', '2.dota', '21', 'DOTA', Source2, 'dota'),
|
||||
'portal2': SDK('HL2SDKPORTAL2', '2.portal2', '17', 'PORTAL2', [], 'portal2'),
|
||||
'blade': SDK('HL2SDKBLADE', '2.blade', '18', 'BLADE', WinLinux, 'blade'),
|
||||
@ -73,12 +78,31 @@ def ResolveEnvPath(env, folder):
|
||||
head, tail = os.path.split(head)
|
||||
return None
|
||||
|
||||
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 == 'x86_64':
|
||||
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 == 'x86_64':
|
||||
compiler.linkflags += ['/MACHINE:X64']
|
||||
|
||||
class MMSConfig(object):
|
||||
def __init__(self):
|
||||
self.sdks = {}
|
||||
self.binaries = []
|
||||
self.generated_headers = None
|
||||
self.versionlib = None
|
||||
self.archs = builder.target.arch.split(',')
|
||||
|
||||
def use_auto_versioning(self):
|
||||
if builder.backend != 'amb2':
|
||||
@ -109,7 +133,7 @@ class MMSConfig(object):
|
||||
|
||||
for sdk_name in PossibleSDKs:
|
||||
sdk = PossibleSDKs[sdk_name]
|
||||
if sdk.shouldBuild(builder.target):
|
||||
if sdk.shouldBuild(builder.target, self.archs):
|
||||
if builder.options.hl2sdk_root:
|
||||
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
|
||||
else:
|
||||
@ -129,7 +153,7 @@ class MMSConfig(object):
|
||||
def configure(self):
|
||||
builder.AddConfigureFile('pushbuild.txt')
|
||||
|
||||
if builder.target.arch not in ['x86', 'x86_64']:
|
||||
if not set(self.archs).issubset(['x86', 'x86_64']):
|
||||
raise Exception('Unknown target architecture: {0}'.format(builder.target.arch))
|
||||
|
||||
cxx = builder.DetectCxx()
|
||||
@ -154,13 +178,6 @@ class MMSConfig(object):
|
||||
'-msse',
|
||||
]
|
||||
|
||||
if builder.target.arch == 'x86':
|
||||
cxx.cflags += ['-m32']
|
||||
cxx.linkflags += ['-m32']
|
||||
elif builder.target.arch == 'x86_64':
|
||||
cxx.cflags += ['-m64', '-fPIC']
|
||||
cxx.linkflags += ['-m64']
|
||||
|
||||
cxx.cxxflags += [ '-std=c++11' ]
|
||||
if (cxx.version >= 'gcc-4.0') or cxx.family == 'clang':
|
||||
cxx.cflags += ['-fvisibility=hidden']
|
||||
@ -178,7 +195,7 @@ class MMSConfig(object):
|
||||
cxx.cflags += ['-mfpmath=sse']
|
||||
if cxx.family == 'clang':
|
||||
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
||||
if cxx.version >= 'clang-3.6':
|
||||
if cxx.version >= 'clang-3.6' or cxx.version >= 'apple-clang-7.0':
|
||||
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
|
||||
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
||||
cxx.cxxflags += ['-Wno-deprecated-register']
|
||||
@ -202,11 +219,6 @@ class MMSConfig(object):
|
||||
]
|
||||
cxx.cxxflags += ['/TP']
|
||||
|
||||
if builder.target.arch == 'x86':
|
||||
cxx.linkflags += ['/MACHINE:X86']
|
||||
elif builder.target.arch == 'x86_64':
|
||||
cxx.linkflags += ['/MACHINE:X64']
|
||||
|
||||
cxx.linkflags += [
|
||||
'/SUBSYSTEM:WINDOWS',
|
||||
'kernel32.lib',
|
||||
@ -254,11 +266,10 @@ class MMSConfig(object):
|
||||
cxx.linkflags += ['-lgcc_eh']
|
||||
elif builder.target.platform == 'mac':
|
||||
cxx.defines += ['OSX', '_OSX', 'POSIX']
|
||||
cxx.cflags += ['-mmacosx-version-min=10.5']
|
||||
cxx.cflags += ['-mmacosx-version-min=10.9']
|
||||
cxx.linkflags += [
|
||||
'-mmacosx-version-min=10.5',
|
||||
'-arch', 'i386',
|
||||
'-lstdc++',
|
||||
'-mmacosx-version-min=10.9',
|
||||
'-lc++',
|
||||
]
|
||||
elif builder.target.platform == 'windows':
|
||||
cxx.defines += ['WIN32', '_WINDOWS']
|
||||
@ -275,7 +286,7 @@ class MMSConfig(object):
|
||||
os.path.join(builder.sourcePath, 'versionlib'),
|
||||
]
|
||||
|
||||
def HL2Compiler(self, context, sdk):
|
||||
def HL2Compiler(self, context, sdk, arch):
|
||||
compiler = context.cxx.clone()
|
||||
compiler.cxxincludes += [
|
||||
os.path.join(context.currentSourcePath),
|
||||
@ -309,9 +320,9 @@ class MMSConfig(object):
|
||||
|
||||
if compiler.family == 'msvc':
|
||||
compiler.defines += ['COMPILER_MSVC']
|
||||
if builder.target.arch == 'x86':
|
||||
if arch == 'x86':
|
||||
compiler.defines += ['COMPILER_MSVC32']
|
||||
elif builder.target.arch == 'x86_64':
|
||||
elif arch == 'x86_64':
|
||||
compiler.defines += ['COMPILER_MSVC64']
|
||||
|
||||
if compiler.version >= 1900:
|
||||
@ -319,7 +330,7 @@ class MMSConfig(object):
|
||||
else:
|
||||
compiler.defines += ['COMPILER_GCC']
|
||||
|
||||
if sdk.name == 'dota' and builder.target.arch == 'x86_64':
|
||||
if arch == 'x86_64':
|
||||
compiler.defines += ['X64BITS', 'PLATFORM_64BITS']
|
||||
|
||||
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2', 'dota']:
|
||||
@ -335,7 +346,7 @@ class MMSConfig(object):
|
||||
|
||||
return compiler
|
||||
|
||||
def AddVersioning(self, binary):
|
||||
def AddVersioning(self, binary, arch):
|
||||
if builder.target.platform == 'windows':
|
||||
binary.sources += ['version.rc']
|
||||
binary.compiler.rcdefines += [
|
||||
@ -348,20 +359,20 @@ class MMSConfig(object):
|
||||
'-current_version', self.productVersion
|
||||
]
|
||||
if self.use_auto_versioning():
|
||||
binary.compiler.linkflags += [self.versionlib]
|
||||
binary.compiler.linkflags += [self.versionlib[arch]]
|
||||
binary.compiler.sourcedeps += MMS.generated_headers
|
||||
if builder.options.breakpad_dump:
|
||||
binary.compiler.symbol_files = 'separate'
|
||||
return binary
|
||||
|
||||
def LibraryBuilder(self, compiler, name):
|
||||
def LibraryBuilder(self, compiler, name, arch):
|
||||
binary = compiler.Library(name)
|
||||
self.AddVersioning(binary)
|
||||
self.AddVersioning(binary, arch)
|
||||
return binary
|
||||
|
||||
def ProgramBuilder(self, compiler, name):
|
||||
def ProgramBuilder(self, compiler, name, arch):
|
||||
binary = compiler.Program(name)
|
||||
self.AddVersioning(binary)
|
||||
self.AddVersioning(binary, arch)
|
||||
if '-static-libgcc' in binary.compiler.linkflags:
|
||||
binary.compiler.linkflags.remove('-static-libgcc')
|
||||
if '-lgcc_eh' in binary.compiler.linkflags:
|
||||
@ -370,16 +381,29 @@ class MMSConfig(object):
|
||||
binary.compiler.linkflags += ['-lstdc++']
|
||||
return binary
|
||||
|
||||
def Library(self, context, name):
|
||||
compiler = context.cxx.clone()
|
||||
return self.LibraryBuilder(compiler, name)
|
||||
def StaticLibraryBuilder(self, compiler, name):
|
||||
binary = compiler.StaticLibrary(name)
|
||||
return binary;
|
||||
|
||||
def Program(self, context, name):
|
||||
def Library(self, context, name, arch):
|
||||
compiler = context.cxx.clone()
|
||||
return self.ProgramBuilder(compiler, name)
|
||||
SetArchFlags(compiler, arch, builder.target.platform)
|
||||
return self.LibraryBuilder(compiler, name, arch)
|
||||
|
||||
def HL2Library(self, context, name, sdk):
|
||||
compiler = self.HL2Compiler(context, sdk)
|
||||
def Program(self, context, name, arch):
|
||||
compiler = context.cxx.clone()
|
||||
SetArchFlags(compiler, arch, builder.target.platform)
|
||||
return self.ProgramBuilder(compiler, name, arch)
|
||||
|
||||
def StaticLibrary(self, context, name, arch):
|
||||
compiler = context.cxx.clone()
|
||||
SetArchFlags(compiler, arch, builder.target.platform)
|
||||
return self.StaticLibraryBuilder(compiler, name)
|
||||
|
||||
def HL2Library(self, context, name, sdk, arch):
|
||||
compiler = self.HL2Compiler(context, sdk, arch)
|
||||
|
||||
SetArchFlags(compiler, arch, builder.target.platform)
|
||||
|
||||
if builder.target.platform == 'linux':
|
||||
if sdk.name == 'episode1':
|
||||
@ -391,19 +415,27 @@ class MMSConfig(object):
|
||||
elif builder.target.platform == 'mac':
|
||||
if sdk.name in ['sdk2013', 'bms']:
|
||||
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
|
||||
elif arch == 'x86_64':
|
||||
lib_folder = os.path.join(sdk.path, 'lib', 'osx64')
|
||||
else:
|
||||
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
|
||||
|
||||
if builder.target.platform in ['linux', 'mac']:
|
||||
if sdk.name in ['sdk2013', 'bms']:
|
||||
if sdk.name in ['sdk2013', 'bms'] or arch == 'x86_64':
|
||||
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'tier1.a'))]
|
||||
else:
|
||||
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'tier1_i486.a'))]
|
||||
|
||||
if sdk.name in ['blade', 'insurgency', 'csgo', 'dota']:
|
||||
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))]
|
||||
if arch == 'x86_64':
|
||||
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces.a'))]
|
||||
else:
|
||||
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))]
|
||||
|
||||
binary = self.LibraryBuilder(compiler, name)
|
||||
binary = self.LibraryBuilder(compiler, name, arch)
|
||||
|
||||
if arch == 'x86_64':
|
||||
binary.localFolder = name + ".x64"
|
||||
|
||||
dynamic_libs = []
|
||||
if builder.target.platform == 'linux':
|
||||
@ -422,9 +454,9 @@ class MMSConfig(object):
|
||||
if sdk.name in ['swarm', 'blade', 'insurgency', 'csgo', 'dota']:
|
||||
libs.append('interfaces')
|
||||
for lib in libs:
|
||||
if builder.target.arch == 'x86':
|
||||
if arch == 'x86':
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'public', lib) + '.lib'
|
||||
elif builder.target.arch == 'x86_64':
|
||||
elif arch == 'x86_64':
|
||||
lib_path = os.path.join(sdk.path, 'lib', 'public', 'win64', lib) + '.lib'
|
||||
binary.compiler.linkflags.append(binary.Dep(lib_path))
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# vim: set sts=2 ts=8 sw=2 tw=99 et:
|
||||
import sys
|
||||
try:
|
||||
from ambuild2 import run
|
||||
from ambuild2 import run, util
|
||||
except:
|
||||
try:
|
||||
import ambuild
|
||||
@ -13,7 +13,7 @@ except:
|
||||
sys.exit(1)
|
||||
|
||||
def make_objdir_name(p):
|
||||
return 'obj-linux-' + p.target_arch
|
||||
return 'obj-' + util.Platform() + '-' + p.target_arch
|
||||
|
||||
parser = run.BuildParser(sourcePath=sys.path[0], api='2.1')
|
||||
parser.default_arch = 'x86'
|
||||
|
@ -2,30 +2,34 @@
|
||||
import os
|
||||
|
||||
for sdk_name in MMS.sdks:
|
||||
sdk = MMS.sdks[sdk_name]
|
||||
for arch in MMS.archs:
|
||||
sdk = MMS.sdks[sdk_name]
|
||||
|
||||
name = 'metamod.' + sdk.ext
|
||||
binary = MMS.HL2Library(builder, name, sdk)
|
||||
if not arch in sdk.platformSpec[builder.target.platform]:
|
||||
continue
|
||||
|
||||
binary.sources += [
|
||||
'metamod.cpp',
|
||||
'metamod_console.cpp',
|
||||
'metamod_oslink.cpp',
|
||||
'metamod_plugins.cpp',
|
||||
'metamod_util.cpp',
|
||||
'provider/console.cpp',
|
||||
'provider/provider_ep2.cpp',
|
||||
'sourcehook/sourcehook.cpp',
|
||||
'sourcehook/sourcehook_impl_chookidman.cpp',
|
||||
'sourcehook/sourcehook_impl_chookmaninfo.cpp',
|
||||
'sourcehook/sourcehook_impl_cproto.cpp',
|
||||
'sourcehook/sourcehook_impl_cvfnptr.cpp',
|
||||
'gamedll_bridge.cpp',
|
||||
'vsp_bridge.cpp'
|
||||
]
|
||||
name = 'metamod.' + sdk.ext
|
||||
binary = MMS.HL2Library(builder, name, sdk, arch)
|
||||
|
||||
# Source2 hack. TODO: check this more deterministically, "are we doing an x64 build?"
|
||||
if builder.target.arch == 'x86':
|
||||
binary.sources += ['sourcehook/sourcehook_hookmangen.cpp']
|
||||
nodes = builder.Add(binary)
|
||||
MMS.binaries += [nodes]
|
||||
binary.sources += [
|
||||
'metamod.cpp',
|
||||
'metamod_console.cpp',
|
||||
'metamod_oslink.cpp',
|
||||
'metamod_plugins.cpp',
|
||||
'metamod_util.cpp',
|
||||
'provider/console.cpp',
|
||||
'provider/provider_ep2.cpp',
|
||||
'sourcehook/sourcehook.cpp',
|
||||
'sourcehook/sourcehook_impl_chookidman.cpp',
|
||||
'sourcehook/sourcehook_impl_chookmaninfo.cpp',
|
||||
'sourcehook/sourcehook_impl_cproto.cpp',
|
||||
'sourcehook/sourcehook_impl_cvfnptr.cpp',
|
||||
'gamedll_bridge.cpp',
|
||||
'vsp_bridge.cpp'
|
||||
]
|
||||
|
||||
# Source2 hack. TODO: check this more deterministically, "are we doing an x64 build?"
|
||||
if arch == 'x86':
|
||||
binary.sources += ['sourcehook/sourcehook_hookmangen.cpp']
|
||||
nodes = builder.Add(binary)
|
||||
MMS.binaries += [nodes]
|
||||
|
@ -1,8 +1,9 @@
|
||||
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
|
||||
import os.path
|
||||
|
||||
def configure_library(name, linux_defines):
|
||||
binary = MMS.Library(builder, name)
|
||||
def configure_library(name, linux_defines, arch):
|
||||
libname = name
|
||||
binary = MMS.Library(builder, libname, arch)
|
||||
binary.compiler.cxxincludes += [os.path.join(builder.sourcePath, 'core', 'sourcehook')]
|
||||
binary.sources += [
|
||||
'loader.cpp',
|
||||
@ -10,6 +11,8 @@ def configure_library(name, linux_defines):
|
||||
'serverplugin.cpp',
|
||||
'utility.cpp',
|
||||
]
|
||||
if arch == 'x86_64':
|
||||
binary.localFolder = name + ".x64"
|
||||
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.defines += linux_defines
|
||||
@ -17,11 +20,11 @@ def configure_library(name, linux_defines):
|
||||
nodes = builder.Add(binary)
|
||||
MMS.binaries += [nodes]
|
||||
|
||||
libname = 'server'
|
||||
if builder.target.platform == 'linux' and builder.target.arch == 'x86_64':
|
||||
libname = 'libserver'
|
||||
for arch in MMS.archs:
|
||||
if builder.target.platform == 'linux':
|
||||
if arch == 'x86_64':
|
||||
configure_library('libserver', ['LIB_PREFIX="lib"', 'LIB_SUFFIX=".so"'], arch)
|
||||
elif arch == 'x86':
|
||||
configure_library('server_i486', ['LIB_PREFIX=""', 'LIB_SUFFIX="_i486.so"'], arch)
|
||||
|
||||
configure_library(libname, ['LIB_PREFIX="lib"', 'LIB_SUFFIX=".so"'])
|
||||
|
||||
if builder.target.platform == 'linux' and builder.target.arch == 'x86':
|
||||
configure_library('server_i486', ['LIB_PREFIX=""', 'LIB_SUFFIX="_i486.so"'])
|
||||
configure_library('server', ['LIB_PREFIX="lib"', 'LIB_SUFFIX=".so"'], arch)
|
||||
|
@ -1,13 +1,18 @@
|
||||
# vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
|
||||
lib = builder.cxx.StaticLibrary("version")
|
||||
lib.compiler.defines.remove('MMS_USE_VERSIONLIB')
|
||||
lib.compiler.sourcedeps += MMS.generated_headers
|
||||
lib.sources += [
|
||||
'versionlib.cpp'
|
||||
]
|
||||
rvalue = {}
|
||||
for arch in MMS.archs:
|
||||
libname = 'version'
|
||||
lib = MMS.StaticLibrary(builder, libname, arch)
|
||||
lib.compiler.defines.remove('MMS_USE_VERSIONLIB')
|
||||
lib.compiler.sourcedeps += MMS.generated_headers
|
||||
lib.sources += [
|
||||
'versionlib.cpp'
|
||||
]
|
||||
if arch == 'x86_64':
|
||||
lib.localFolder = libname + '.x64'
|
||||
|
||||
cmd = builder.Add(lib)
|
||||
cmd = builder.Add(lib)
|
||||
|
||||
rvalue = cmd.binary
|
||||
rvalue[arch] = cmd.binary
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user