Switch to AMBuild 2.1 API. (#694)

This commit is contained in:
Scott Ehlert
2017-10-02 07:18:57 -05:00
committed by GitHub
parent f67e4ce610
commit bbdecceb4b
20 changed files with 137 additions and 110 deletions
+68 -45
View File
@@ -104,7 +104,7 @@ class SMConfig(object):
for sdk_name in PossibleSDKs:
sdk = PossibleSDKs[sdk_name]
if builder.target_platform in sdk.platform:
if builder.target.platform in sdk.platform:
if builder.options.hl2sdk_root:
sdk_path = os.path.join(builder.options.hl2sdk_root, sdk.folder)
else:
@@ -148,11 +148,11 @@ class SMConfig(object):
def configure(self):
builder.AddConfigureFile('pushbuild.txt')
cxx = builder.DetectCompilers()
cxx = builder.DetectCxx()
if cxx.like('gcc'):
self.configure_gcc(cxx)
elif cxx.vendor == 'msvc':
elif cxx.family == 'msvc':
self.configure_msvc(cxx)
# Optimizaiton
@@ -164,11 +164,11 @@ class SMConfig(object):
cxx.defines += ['DEBUG', '_DEBUG']
# Platform-specifics
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
self.configure_linux(cxx)
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
self.configure_mac(cxx)
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
self.configure_windows(cxx)
# Finish up.
@@ -217,10 +217,12 @@ class SMConfig(object):
]
cxx.linkflags += ['-m32']
have_gcc = cxx.vendor == 'gcc'
have_clang = cxx.vendor == 'clang'
if cxx.version >= 'clang-3.6':
have_gcc = cxx.family == 'gcc'
have_clang = cxx.family == 'clang'
if cxx.version >= 'clang-3.6' or cxx.version >= 'apple-clang-7.0':
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
if cxx.version >= 'clang-2.9' or cxx.version >= 'apple-clang-3.0':
cxx.cxxflags += ['-Wno-null-dereference']
if have_clang or (cxx.version >= 'gcc-4.6'):
cxx.cflags += ['-Wno-narrowing']
if have_clang or (cxx.version >= 'gcc-4.7'):
@@ -292,9 +294,9 @@ class SMConfig(object):
def configure_linux(self, cxx):
cxx.defines += ['_LINUX', 'POSIX', '_FILE_OFFSET_BITS=64']
cxx.linkflags += ['-Wl,--exclude-libs,ALL', '-lm']
if cxx.vendor == 'gcc':
if cxx.family == 'gcc':
cxx.linkflags += ['-static-libgcc']
elif cxx.vendor == 'clang':
elif cxx.family == 'clang':
cxx.linkflags += ['-lgcc_eh']
def configure_mac(self, cxx):
@@ -312,7 +314,7 @@ class SMConfig(object):
cxx.defines += ['WIN32', '_WINDOWS']
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),
@@ -320,7 +322,7 @@ class SMConfig(object):
]
if self.use_auto_versioning():
binary.compiler.rcdefines += ['SM_GENERATED_BUILD']
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
if binary.type == 'library':
binary.compiler.postlink += [
'-compatibility_version', '1.0.0',
@@ -330,18 +332,42 @@ class SMConfig(object):
binary.compiler.linkflags += [self.versionlib]
binary.compiler.sourcedeps += SM.generated_headers
return binary
def Library(self, context, name):
binary = context.compiler.Library(name)
def LibraryBuilder(self, compiler, name):
binary = compiler.Library(name)
self.AddVersioning(binary)
if binary.compiler.like('msvc'):
binary.compiler.linkflags += ['/SUBSYSTEM:WINDOWS']
return self.AddVersioning(binary)
return binary
def Program(self, context, name):
binary = context.compiler.Program(name)
def ProgramBuilder(self, compiler, name):
binary = compiler.Program(name)
self.AddVersioning(binary)
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'):
binary.compiler.linkflags += ['-lstdc++']
if binary.compiler.like('msvc'):
binary.compiler.linkflags += ['/SUBSYSTEM:CONSOLE']
return self.AddVersioning(binary)
return binary
def StaticLibraryBuilder(self, compiler, name):
binary = compiler.StaticLibrary(name)
return binary;
def Library(self, context, name):
compiler = context.cxx.clone()
return self.LibraryBuilder(compiler, name)
def Program(self, context, name):
compiler = context.cxx.clone()
return self.ProgramBuilder(compiler, name)
def StaticLibrary(self, context, name):
compiler = context.cxx.clone()
return self.StaticLibraryBuilder(compiler, name)
def ConfigureForExtension(self, context, compiler):
compiler.cxxincludes += [
@@ -355,9 +381,9 @@ class SMConfig(object):
return compiler
def ExtLibrary(self, context, name):
binary = context.compiler.Library(name)
binary = self.Library(context, name)
self.ConfigureForExtension(context, binary.compiler)
return self.AddVersioning(binary)
return binary
def ConfigureForHL2(self, binary, sdk):
compiler = binary.compiler
@@ -409,29 +435,29 @@ class SMConfig(object):
compiler.defines += ['NETWORK_VARS_ENABLED']
if sdk.name in ['css', 'hl2dm', 'dods', 'sdk2013', 'bms', 'tf2', 'l4d', 'nucleardawn', 'l4d2']:
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++']
for path in paths:
compiler.cxxincludes += [os.path.join(sdk.path, *path)]
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']:
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'linux32')
else:
lib_folder = os.path.join(sdk.path, 'lib', 'linux')
elif builder.target_platform == 'mac':
elif builder.target.platform == 'mac':
if sdk.name in ['sdk2013', 'bms']:
lib_folder = os.path.join(sdk.path, 'lib', 'public', 'osx32')
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')),
@@ -446,20 +472,18 @@ class SMConfig(object):
if sdk.name in ['blade', 'insurgency', 'csgo']:
compiler.postlink += [compiler.Dep(os.path.join(lib_folder, 'interfaces_i486.a'))]
self.AddVersioning(binary)
dynamic_libs = []
if builder.target_platform == 'linux':
if builder.target.platform == 'linux':
if sdk.name in ['css', 'hl2dm', 'dods', 'tf2', 'sdk2013', 'bms', 'nucleardawn', 'l4d2', 'insurgency']:
dynamic_libs = ['libtier0_srv.so', 'libvstdlib_srv.so']
elif sdk.name in ['l4d', 'blade', 'insurgency', 'csgo']:
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':
compiler.linkflags.append('-liconv')
dynamic_libs = ['libtier0.dylib', 'libvstdlib.dylib']
elif builder.target_platform == 'windows':
elif builder.target.platform == 'windows':
libs = ['tier0', 'tier1', 'vstdlib', 'mathlib']
if sdk.name in ['swarm', 'blade', 'insurgency', 'csgo']:
libs.append('interfaces')
@@ -483,17 +507,18 @@ class SMConfig(object):
return binary
def HL2Library(self, context, name, sdk):
binary = context.compiler.Library(name)
binary = self.Library(context, name)
self.ConfigureForExtension(context, binary.compiler)
return self.ConfigureForHL2(binary, sdk)
def HL2Project(self, context, name):
project = context.compiler.LibraryProject(name)
project = context.cxx.LibraryProject(name)
self.ConfigureForExtension(context, project.compiler)
return project
def HL2Config(self, project, name, sdk):
binary = project.Configure(name, '{0} - {1}'.format(self.tag, sdk.name))
self.AddVersioning(binary)
return self.ConfigureForHL2(binary, sdk)
SM = SMConfig()
@@ -502,23 +527,21 @@ SM.detectSDKs()
SM.configure()
if SM.use_auto_versioning():
SM.generated_headers = builder.RunScript(
SM.generated_headers = builder.Build(
'tools/buildbot/Versioning',
{ 'SM': SM }
)
SM.versionlib = builder.RunScript(
SM.versionlib = builder.Build(
'versionlib/AMBuilder',
{ 'SM': SM }
)
# Build SourcePawn externally.
SourcePawn = builder.RunScript('sourcepawn/AMBuildScript', {})
SP = SourcePawn(
root = SM,
amtl = os.path.join(builder.sourcePath, 'public', 'amtl'),
)
SP.BuildSpcomp()
SP.BuildVM()
SP = builder.Build('sourcepawn/AMBuildScript', {
'external_root': SM,
'external_amtl': os.path.join(builder.sourcePath, 'public', 'amtl'),
'external_build': ['core'],
})
SM.spcomp = SP.spcomp
SM.binaries += [
SP.libsourcepawn
@@ -549,7 +572,7 @@ if builder.backend == 'amb2':
'tools/buildbot/PackageScript',
]
builder.RunBuildScripts(BuildScripts, { 'SM': SM })
builder.Build(BuildScripts, { 'SM': SM })
if builder.options.breakpad_dump:
builder.RunScript('tools/buildbot/BreakpadSymbols', { 'SM': SM })
builder.Build('tools/buildbot/BreakpadSymbols', { 'SM': SM })