Update the build script to the latest AMBuild API.

This commit is contained in:
David Anderson 2014-05-30 22:50:35 -07:00
parent 891ebe4480
commit 4f7b0ff487

View File

@ -141,11 +141,10 @@ class SMConfig(object):
def configure(self):
builder.AddConfigureFile('pushbuild.txt')
cfg = builder.DetectCompilers()
cxx = cfg.cxx
cxx = builder.DetectCompilers()
if cxx.behavior == 'gcc':
cfg.defines += [
if cxx.like('gcc'):
cxx.defines += [
'stricmp=strcasecmp',
'_stricmp=strcasecmp',
'_snprintf=snprintf',
@ -153,7 +152,7 @@ class SMConfig(object):
'HAVE_STDINT_H',
'GNUC',
]
cfg.cflags += [
cxx.cflags += [
'-pipe',
'-fno-strict-aliasing',
'-Wall',
@ -167,18 +166,18 @@ class SMConfig(object):
'-m32',
]
have_gcc = cxx.name == 'gcc'
have_clang = cxx.name == 'clang'
if have_clang or (have_gcc and cxx.majorVersion >= 4):
cfg.cflags += ['-fvisibility=hidden']
cfg.cxxflags += ['-fvisibility-inlines-hidden']
if have_clang or (have_gcc and cxx.minorVersion >= 6):
cfg.cflags += ['-Wno-narrowing']
if (have_gcc and cxx.minorVersion >= 7) or (have_clang and cxx.majorVersion >= 3):
cfg.cxxflags += ['-Wno-delete-non-virtual-dtor']
have_gcc = cxx.vendor == 'gcc'
have_clang = cxx.vendor == 'clang'
if have_clang or (have_gcc and cxx.version >= '4'):
cxx.cflags += ['-fvisibility=hidden']
cxx.cxxflags += ['-fvisibility-inlines-hidden']
if have_clang or (have_gcc and cxx.version >= '4.6'):
cxx.cflags += ['-Wno-narrowing']
if (have_gcc and cxx.version >= '4.7') or (have_clang and cxx.version >= '3'):
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
cfg.linkflags += ['-m32']
cfg.cxxflags += [
cxx.linkflags += ['-m32']
cxx.cxxflags += [
'-fno-exceptions',
'-fno-threadsafe-statics',
'-Wno-non-virtual-dtor',
@ -186,28 +185,28 @@ class SMConfig(object):
]
if have_gcc:
cfg.cflags += ['-mfpmath=sse']
elif cxx.name == 'msvc':
cxx.cflags += ['-mfpmath=sse']
elif cxx.vendor == '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',
'_ITERATOR_DEBUG_LEVEL=0',
]
cfg.cflags += [
cxx.cflags += [
'/W3',
]
cfg.cxxflags += [
cxx.cxxflags += [
'/EHsc',
'/GR-',
'/TP',
]
cfg.linkflags += [
cxx.linkflags += [
'/MACHINE:X86',
'/SUBSYSTEM:WINDOWS',
'kernel32.lib',
@ -226,55 +225,55 @@ class SMConfig(object):
# Optimization
if builder.options.opt == '1':
cfg.defines += ['NDEBUG']
if cxx.behavior == 'gcc':
cfg.cflags += ['-O3']
elif cxx.behavior == 'msvc':
cfg.cflags += ['/Ox']
cfg.linkflags += ['/OPT:ICF', '/OPT:REF']
cxx.defines += ['NDEBUG']
if cxx.like('gcc'):
cxx.cflags += ['-O3']
elif cxx.like('msvc'):
cxx.cflags += ['/Ox']
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
# Debugging
if builder.options.debug == '1':
cfg.defines += ['DEBUG', '_DEBUG']
if cxx.behavior == 'msvc':
cfg.cflags += ['/Od', '/RTC1']
if int(cxx.version) >= 1600:
cfg.cflags += ['/d2Zi+']
cxx.defines += ['DEBUG', '_DEBUG']
if cxx.like('msvc'):
cxx.cflags += ['/Od', '/RTC1']
if cxx.version >= 1600:
cxx.cflags += ['/d2Zi+']
# This needs to be after our optimization flags which could otherwise disable it.
if cxx.name == 'msvc':
if cxx.vendor == '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']
cxx.defines += ['_LINUX', 'POSIX']
if cxx.vendor == 'gcc':
cxx.linkflags += ['-static-libgcc']
elif cxx.vendor == '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++',
'-stdlib=libstdc++',
]
cfg.cxxflags += ['-stdlib=libstdc++']
cxx.cxxflags += ['-stdlib=libstdc++']
elif builder.target_platform == 'windows':
cfg.defines += ['WIN32', '_WINDOWS']
cxx.defines += ['WIN32', '_WINDOWS']
# Finish up.
cfg.defines += [
cxx.defines += [
'SOURCEMOD_BUILD',
'SM_USE_VERSIONLIB',
]
if self.use_auto_versioning():
cfg.defines += ['SM_GENERATED_BUILD']
cfg.includes += [os.path.join(builder.buildPath, 'includes')]
cfg.includes += [os.path.join(builder.sourcePath, 'versionlib')]
cxx.defines += ['SM_GENERATED_BUILD']
cxx.includes += [os.path.join(builder.buildPath, 'includes')]
cxx.includes += [os.path.join(builder.sourcePath, 'versionlib')]
def LibraryBuilder(self, compiler, name):
binary = compiler.Library(name)
@ -365,14 +364,14 @@ class SMConfig(object):
compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
if sdk.name == 'sdk2013' and compiler.cxx.behavior == 'gcc':
if sdk.name == 'sdk2013' 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.like('msvc'):
compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32']
else:
compiler.defines += ['COMPILER_GCC']