mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-01-31 20:52:18 +01:00
Update configure.py and buildscripts to AMBuild API v2.1.
This commit is contained in:
parent
314e116927
commit
0eaf14f9ec
146
AMBuildScript
146
AMBuildScript
@ -8,9 +8,14 @@ class SDK(object):
|
||||
self.ext = ext
|
||||
self.code = aDef
|
||||
self.define = name
|
||||
self.platform = platform
|
||||
self.name = dir
|
||||
self.path = None # Actual path
|
||||
self.platformSpec = platform
|
||||
|
||||
def shouldBuild(self, target):
|
||||
if target.platform not in self.platformSpec:
|
||||
return False
|
||||
return True
|
||||
|
||||
WinOnly = ['windows']
|
||||
WinLinux = ['windows', 'linux']
|
||||
@ -92,7 +97,7 @@ class MMSConfig(object):
|
||||
|
||||
for sdk_name in PossibleSDKs:
|
||||
sdk = PossibleSDKs[sdk_name]
|
||||
if builder.target_platform in sdk.platform:
|
||||
if sdk.shouldBuild(builder.target):
|
||||
if builder.options.hl2sdk_root:
|
||||
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
|
||||
else:
|
||||
@ -111,11 +116,10 @@ class MMSConfig(object):
|
||||
def configure(self):
|
||||
builder.AddConfigureFile('pushbuild.txt')
|
||||
|
||||
cfg = builder.DetectCompilers()
|
||||
cxx = cfg.cxx
|
||||
cxx = builder.DetectCxx()
|
||||
|
||||
if cxx.behavior == 'gcc':
|
||||
cfg.defines += [
|
||||
cxx.defines += [
|
||||
'stricmp=strcasecmp',
|
||||
'_stricmp=strcasecmp',
|
||||
'_snprintf=snprintf',
|
||||
@ -123,7 +127,7 @@ class MMSConfig(object):
|
||||
'HAVE_STDINT_H',
|
||||
'GNUC',
|
||||
]
|
||||
cfg.cflags += [
|
||||
cxx.cflags += [
|
||||
'-pipe',
|
||||
'-fno-strict-aliasing',
|
||||
'-Wall',
|
||||
@ -134,47 +138,49 @@ class MMSConfig(object):
|
||||
'-msse',
|
||||
'-m32',
|
||||
]
|
||||
cfg.cxxflags += [ '-std=c++11' ]
|
||||
if (cxx.name == 'gcc' and cxx.majorVersion >= 4) or cxx.name == 'clang':
|
||||
cfg.cflags += ['-fvisibility=hidden']
|
||||
cfg.cxxflags += ['-fvisibility-inlines-hidden']
|
||||
cfg.linkflags += ['-m32']
|
||||
cfg.cxxflags += [
|
||||
cxx.cxxflags += [ '-std=c++11' ]
|
||||
if (cxx.version >= 'gcc-4.0') or cxx.family == 'clang':
|
||||
cxx.cflags += ['-fvisibility=hidden']
|
||||
cxx.cxxflags += ['-fvisibility-inlines-hidden']
|
||||
cxx.linkflags += ['-m32']
|
||||
cxx.cxxflags += [
|
||||
'-fno-exceptions',
|
||||
'-fno-rtti',
|
||||
'-fno-threadsafe-statics',
|
||||
'-Wno-non-virtual-dtor',
|
||||
'-Wno-overloaded-virtual',
|
||||
]
|
||||
if (cxx.name == 'gcc' and cxx.majorVersion >= 4 and cxx.minorVersion >= 7) or \
|
||||
(cxx.name == 'clang' and cxx.majorVersion >= 3):
|
||||
cfg.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
||||
if cxx.name == 'gcc':
|
||||
cfg.cflags += ['-mfpmath=sse']
|
||||
if cxx.name == 'clang':
|
||||
cfg.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
||||
if cfg.version >= 'apple-clang-5.1' or cfg.version >= 'clang-3.4':
|
||||
cfg.cxxflags += ['-Wno-deprecated-register']
|
||||
if (cxx.version >= 'gcc-4.7' or cxx.version >= 'clang-3.0'):
|
||||
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
||||
if cxx.family == 'gcc':
|
||||
cxx.cflags += ['-mfpmath=sse']
|
||||
if cxx.family == 'clang':
|
||||
cxx.cxxflags += [
|
||||
'-Wno-implicit-exception-spec-mismatch',
|
||||
'-Wno-inconsistent-missing-override',
|
||||
]
|
||||
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
||||
cxx.cxxflags += ['-Wno-deprecated-register']
|
||||
else:
|
||||
cfg.cxxflags += ['-Wno-deprecated']
|
||||
cxx.cxxflags += ['-Wno-deprecated']
|
||||
|
||||
elif cxx.name == 'msvc':
|
||||
if builder.options.debug == '1':
|
||||
cfg.cflags += ['/MTd']
|
||||
cfg.linkflags += ['/NODEFAULTLIB:libcmt']
|
||||
cxx.cflags += ['/MTd']
|
||||
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
||||
else:
|
||||
cfg.cflags += ['/MT']
|
||||
cfg.defines += [
|
||||
cxx.cflags += ['/MT']
|
||||
cxx.defines += [
|
||||
'_CRT_SECURE_NO_DEPRECATE',
|
||||
'_CRT_SECURE_NO_WARNINGS',
|
||||
'_CRT_NONSTDC_NO_DEPRECATE',
|
||||
]
|
||||
cfg.cflags += [
|
||||
cxx.cflags += [
|
||||
'/W3',
|
||||
'/Zi',
|
||||
]
|
||||
cfg.cxxflags += ['/TP']
|
||||
cfg.linkflags += [
|
||||
cxx.cxxflags += ['/TP']
|
||||
cxx.linkflags += [
|
||||
'/MACHINE:X86',
|
||||
'/SUBSYSTEM:WINDOWS',
|
||||
'kernel32.lib',
|
||||
@ -193,58 +199,58 @@ class MMSConfig(object):
|
||||
|
||||
# Optimization
|
||||
if builder.options.opt == '1':
|
||||
cfg.defines += ['NDEBUG']
|
||||
cxx.defines += ['NDEBUG']
|
||||
if cxx.behavior == 'gcc':
|
||||
cfg.cflags += ['-O3']
|
||||
cxx.cflags += ['-O3']
|
||||
elif cxx.behavior == 'msvc':
|
||||
cfg.cflags += ['/Ox', '/Zo']
|
||||
cfg.linkflags += ['/OPT:ICF', '/OPT:REF']
|
||||
cxx.cflags += ['/Ox', '/Zo']
|
||||
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
|
||||
|
||||
# Debugging
|
||||
if builder.options.debug == '1':
|
||||
cfg.defines += ['DEBUG', '_DEBUG']
|
||||
cxx.defines += ['DEBUG', '_DEBUG']
|
||||
if cxx.behavior == 'gcc':
|
||||
cfg.cflags += ['-g3']
|
||||
cxx.cflags += ['-g3']
|
||||
elif cxx.behavior == 'msvc':
|
||||
cfg.cflags += ['/Od', '/RTC1']
|
||||
cxx.cflags += ['/Od', '/RTC1']
|
||||
|
||||
# This needs to be after our optimization flags which could otherwise disable it.
|
||||
if cxx.name == 'msvc':
|
||||
if cxx.family == 'msvc':
|
||||
# Don't omit the frame pointer.
|
||||
cfg.cflags += ['/Oy-']
|
||||
cxx.cflags += ['/Oy-']
|
||||
|
||||
# Platform-specifics
|
||||
if builder.target_platform == 'linux':
|
||||
cfg.defines += ['_LINUX', 'POSIX']
|
||||
if cxx.name == 'gcc':
|
||||
cfg.linkflags += ['-static-libgcc']
|
||||
elif cxx.name == 'clang':
|
||||
cfg.linkflags += ['-lgcc_eh']
|
||||
if builder.target.platform == 'linux':
|
||||
cxx.defines += ['_LINUX', 'POSIX']
|
||||
if cxx.family == 'gcc':
|
||||
cxx.linkflags += ['-static-libgcc']
|
||||
elif cxx.family == 'clang':
|
||||
cxx.linkflags += ['-lgcc_eh']
|
||||
elif builder.target_platform == 'mac':
|
||||
cfg.defines += ['OSX', '_OSX', 'POSIX']
|
||||
cfg.cflags += ['-mmacosx-version-min=10.5']
|
||||
cfg.linkflags += [
|
||||
cxx.defines += ['OSX', '_OSX', 'POSIX']
|
||||
cxx.cflags += ['-mmacosx-version-min=10.5']
|
||||
cxx.linkflags += [
|
||||
'-mmacosx-version-min=10.5',
|
||||
'-arch', 'i386',
|
||||
'-lstdc++',
|
||||
]
|
||||
elif builder.target_platform == 'windows':
|
||||
cfg.defines += ['WIN32', '_WINDOWS']
|
||||
cxx.defines += ['WIN32', '_WINDOWS']
|
||||
|
||||
# Finish up.
|
||||
cfg.defines += [ 'MMS_USE_VERSIONLIB' ]
|
||||
cfg.includes += [
|
||||
cxx.defines += [ 'MMS_USE_VERSIONLIB' ]
|
||||
cxx.includes += [
|
||||
os.path.join(builder.sourcePath, 'public'),
|
||||
]
|
||||
if self.use_auto_versioning():
|
||||
cfg.defines += ['MMS_GENERATED_BUILD']
|
||||
cfg.includes += [
|
||||
cxx.defines += ['MMS_GENERATED_BUILD']
|
||||
cxx.includes += [
|
||||
os.path.join(builder.buildPath, 'includes'),
|
||||
os.path.join(builder.sourcePath, 'versionlib'),
|
||||
]
|
||||
|
||||
def HL2Compiler(self, context, sdk):
|
||||
compiler = context.compiler.clone()
|
||||
compiler = context.cxx.clone()
|
||||
compiler.cxxincludes += [
|
||||
os.path.join(context.currentSourcePath),
|
||||
os.path.join(context.currentSourcePath, 'sourcehook'),
|
||||
@ -268,19 +274,19 @@ class MMSConfig(object):
|
||||
|
||||
compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
|
||||
|
||||
if sdk.name in ['sdk2013', 'bms'] and compiler.cxx.behavior == 'gcc':
|
||||
if sdk.name in ['sdk2013', 'bms'] and compiler.like('gcc'):
|
||||
# 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')
|
||||
|
||||
if compiler.cc.behavior == 'msvc':
|
||||
if compiler.family == 'msvc':
|
||||
compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32']
|
||||
else:
|
||||
compiler.defines += ['COMPILER_GCC']
|
||||
|
||||
if sdk.name == 'dota' and builder.target_platform in ['linux', 'mac']:
|
||||
if sdk.name == 'dota' and builder.target.platform in ['linux', 'mac']:
|
||||
compiler.defines += ['X64BITS', 'PLATFORM_64BITS']
|
||||
compiler.cflags.remove('-m32')
|
||||
compiler.cflags += ['-m64', '-fPIC']
|
||||
@ -288,10 +294,10 @@ class MMSConfig(object):
|
||||
compiler.linkflags += ['-m64']
|
||||
|
||||
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2', 'dota']:
|
||||
if builder.target_platform in ['linux', 'mac']:
|
||||
if builder.target.platform in ['linux', 'mac']:
|
||||
compiler.defines += ['NO_HOOK_MALLOC', 'NO_MALLOC_OVERRIDE']
|
||||
|
||||
if sdk.name == 'csgo' and builder.target_platform == 'linux':
|
||||
if sdk.name == 'csgo' and builder.target.platform == 'linux':
|
||||
compiler.linkflags += ['-lstdc++']
|
||||
|
||||
|
||||
@ -301,13 +307,13 @@ class MMSConfig(object):
|
||||
return compiler
|
||||
|
||||
def AddVersioning(self, binary):
|
||||
if builder.target_platform == 'windows':
|
||||
if builder.target.platform == 'windows':
|
||||
binary.sources += ['version.rc']
|
||||
binary.compiler.rcdefines += [
|
||||
'BINARY_NAME="{0}"'.format(binary.outputFile),
|
||||
'RC_COMPILE'
|
||||
]
|
||||
elif builder.target_platform == 'mac':
|
||||
elif builder.target.platform == 'mac':
|
||||
binary.compiler.postlink += [
|
||||
'-compatibility_version', '1.0.0',
|
||||
'-current_version', self.productVersion
|
||||
@ -334,17 +340,17 @@ class MMSConfig(object):
|
||||
return binary
|
||||
|
||||
def Library(self, context, name):
|
||||
compiler = context.compiler.clone()
|
||||
compiler = context.cxx.clone()
|
||||
return self.LibraryBuilder(compiler, name)
|
||||
|
||||
def Program(self, context, name):
|
||||
compiler = context.compiler.clone()
|
||||
compiler = context.cxx.clone()
|
||||
return self.ProgramBuilder(compiler, name)
|
||||
|
||||
def HL2Library(self, context, name, sdk):
|
||||
compiler = self.HL2Compiler(context, sdk)
|
||||
|
||||
if builder.target_platform == 'linux':
|
||||
if builder.target.platform == 'linux':
|
||||
if sdk.name == 'episode1':
|
||||
lib_folder = os.path.join(sdk.path, 'linux_sdk')
|
||||
elif sdk.name in ['sdk2013', 'bms']:
|
||||
@ -357,7 +363,7 @@ class MMSConfig(object):
|
||||
else:
|
||||
lib_folder = os.path.join(sdk.path, 'lib', 'mac')
|
||||
|
||||
if builder.target_platform in ['linux', 'mac']:
|
||||
if builder.target.platform in ['linux', 'mac']:
|
||||
if sdk.name in ['sdk2013', 'bms']:
|
||||
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'tier1.a'))]
|
||||
else:
|
||||
@ -369,7 +375,7 @@ class MMSConfig(object):
|
||||
binary = self.LibraryBuilder(compiler, name)
|
||||
|
||||
dynamic_libs = []
|
||||
if builder.target_platform == 'linux':
|
||||
if builder.target.platform == 'linux':
|
||||
compiler.linkflags[0:0] = ['-lm']
|
||||
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency']:
|
||||
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
|
||||
@ -377,10 +383,10 @@ class MMSConfig(object):
|
||||
dynamic_libs = ['libtier0.so', 'libvstdlib.so']
|
||||
else:
|
||||
dynamic_libs = ['tier0_i486.so', 'vstdlib_i486.so']
|
||||
elif builder.target_platform == 'mac':
|
||||
elif builder.target.platform == 'mac':
|
||||
binary.compiler.linkflags.append('-liconv')
|
||||
dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
|
||||
elif builder.target_platform == 'windows':
|
||||
elif builder.target.platform == 'windows':
|
||||
libs = ['tier0', 'tier1', 'vstdlib']
|
||||
if sdk.name in ['swarm', 'blade', 'insurgency', 'csgo', 'dota']:
|
||||
libs.append('interfaces')
|
||||
@ -409,11 +415,11 @@ MMS.detectSDKs()
|
||||
MMS.configure()
|
||||
|
||||
if MMS.use_auto_versioning():
|
||||
MMS.generated_headers = builder.RunScript(
|
||||
MMS.generated_headers = builder.Build(
|
||||
'support/buildbot/Versioning',
|
||||
{ 'MMS': MMS }
|
||||
)
|
||||
MMS.versionlib = builder.RunScript(
|
||||
MMS.versionlib = builder.Build(
|
||||
'versionlib/AMBuildScript',
|
||||
{ 'MMS': MMS }
|
||||
)
|
||||
@ -434,5 +440,5 @@ if builder.backend == 'amb2':
|
||||
'support/buildbot/PackageScript',
|
||||
]
|
||||
|
||||
builder.RunBuildScripts(BuildScripts, { 'MMS': MMS })
|
||||
builder.Build(BuildScripts, { 'MMS': MMS })
|
||||
|
||||
|
16
configure.py
16
configure.py
@ -12,17 +12,17 @@ except:
|
||||
sys.stderr.write('http://www.alliedmods.net/ambuild\n')
|
||||
sys.exit(1)
|
||||
|
||||
run = run.PrepareBuild(sourcePath=sys.path[0])
|
||||
run.default_build_folder = 'obj-' + run.target_platform
|
||||
run.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
|
||||
parser = run.BuildParser(sourcePath=sys.path[0], api='2.1')
|
||||
parser.default_build_folder = 'obj-' + parser.host.platform
|
||||
parser.options.add_option('--hl2sdk-root', type=str, dest='hl2sdk_root', default=None,
|
||||
help='Root search folder for HL2SDKs')
|
||||
run.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
|
||||
parser.options.add_option('--enable-debug', action='store_const', const='1', dest='debug',
|
||||
help='Enable debugging symbols')
|
||||
run.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||
parser.options.add_option('--enable-optimize', action='store_const', const='1', dest='opt',
|
||||
help='Enable optimization')
|
||||
run.options.add_option('-s', '--sdks', default='all', dest='sdks',
|
||||
parser.options.add_option('-s', '--sdks', default='all', dest='sdks',
|
||||
help='Build against specified SDKs; valid args are "all", "present", or '
|
||||
'comma-delimited list of engine names (default: %default)')
|
||||
run.options.add_option('--enable-tests', default=False, dest='enable_tests', action='store_true',
|
||||
parser.options.add_option('--enable-tests', default=False, dest='enable_tests', action='store_true',
|
||||
help='Build tests.')
|
||||
run.Configure()
|
||||
parser.Configure()
|
||||
|
@ -27,7 +27,7 @@ for sdk_name in MMS.sdks:
|
||||
]
|
||||
|
||||
# Source2 hack. TODO: check this more deterministically, "are we doing an x64 build?"
|
||||
if sdk.name != 'dota' or builder.target_platform == 'windows':
|
||||
if sdk.name != 'dota' or builder.target.platform == 'windows':
|
||||
binary.sources += ['sourcehook/sourcehook_hookmangen.cpp']
|
||||
nodes = builder.Add(binary)
|
||||
MMS.binaries += [nodes]
|
||||
|
@ -11,7 +11,7 @@ def configure_library(name, linux_defines):
|
||||
'utility.cpp',
|
||||
]
|
||||
|
||||
if builder.target_platform == 'linux':
|
||||
if builder.target.platform == 'linux':
|
||||
binary.compiler.defines += linux_defines
|
||||
# Temporary Source2 hack. Always build linux with -m64
|
||||
binary.compiler.cflags.remove('-m32')
|
||||
@ -23,5 +23,5 @@ def configure_library(name, linux_defines):
|
||||
MMS.binaries += [nodes]
|
||||
|
||||
configure_library('server', ['LIB_PREFIX="lib"', 'LIB_SUFFIX=".so"'])
|
||||
if builder.target_platform == 'linux':
|
||||
if builder.target.platform == 'linux':
|
||||
configure_library('server_i486', ['LIB_PREFIX=""', 'LIB_SUFFIX="_i486.so"'])
|
||||
|
@ -1,6 +1,6 @@
|
||||
# vim: sts=2 ts=8 sw=2 tw=99 et ft=python:
|
||||
|
||||
lib = builder.compiler.StaticLibrary("version")
|
||||
lib = builder.cxx.StaticLibrary("version")
|
||||
lib.compiler.defines.remove('MMS_USE_VERSIONLIB')
|
||||
lib.compiler.sourcedeps += MMS.generated_headers
|
||||
lib.sources += [
|
||||
@ -8,7 +8,7 @@ lib.sources += [
|
||||
]
|
||||
|
||||
# Temporary Source2 hack. Always build linux with -m64
|
||||
if builder.target_platform == 'linux':
|
||||
if builder.target.platform == 'linux':
|
||||
lib.compiler.cflags.remove('-m32')
|
||||
lib.compiler.cflags += ['-m64', '-fPIC']
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user