Update the build script to the latest AMBuild API.
This commit is contained in:
parent
891ebe4480
commit
4f7b0ff487
107
AMBuildScript
107
AMBuildScript
@ -141,11 +141,10 @@ class SMConfig(object):
|
|||||||
def configure(self):
|
def configure(self):
|
||||||
builder.AddConfigureFile('pushbuild.txt')
|
builder.AddConfigureFile('pushbuild.txt')
|
||||||
|
|
||||||
cfg = builder.DetectCompilers()
|
cxx = builder.DetectCompilers()
|
||||||
cxx = cfg.cxx
|
|
||||||
|
|
||||||
if cxx.behavior == 'gcc':
|
if cxx.like('gcc'):
|
||||||
cfg.defines += [
|
cxx.defines += [
|
||||||
'stricmp=strcasecmp',
|
'stricmp=strcasecmp',
|
||||||
'_stricmp=strcasecmp',
|
'_stricmp=strcasecmp',
|
||||||
'_snprintf=snprintf',
|
'_snprintf=snprintf',
|
||||||
@ -153,7 +152,7 @@ class SMConfig(object):
|
|||||||
'HAVE_STDINT_H',
|
'HAVE_STDINT_H',
|
||||||
'GNUC',
|
'GNUC',
|
||||||
]
|
]
|
||||||
cfg.cflags += [
|
cxx.cflags += [
|
||||||
'-pipe',
|
'-pipe',
|
||||||
'-fno-strict-aliasing',
|
'-fno-strict-aliasing',
|
||||||
'-Wall',
|
'-Wall',
|
||||||
@ -167,18 +166,18 @@ class SMConfig(object):
|
|||||||
'-m32',
|
'-m32',
|
||||||
]
|
]
|
||||||
|
|
||||||
have_gcc = cxx.name == 'gcc'
|
have_gcc = cxx.vendor == 'gcc'
|
||||||
have_clang = cxx.name == 'clang'
|
have_clang = cxx.vendor == 'clang'
|
||||||
if have_clang or (have_gcc and cxx.majorVersion >= 4):
|
if have_clang or (have_gcc and cxx.version >= '4'):
|
||||||
cfg.cflags += ['-fvisibility=hidden']
|
cxx.cflags += ['-fvisibility=hidden']
|
||||||
cfg.cxxflags += ['-fvisibility-inlines-hidden']
|
cxx.cxxflags += ['-fvisibility-inlines-hidden']
|
||||||
if have_clang or (have_gcc and cxx.minorVersion >= 6):
|
if have_clang or (have_gcc and cxx.version >= '4.6'):
|
||||||
cfg.cflags += ['-Wno-narrowing']
|
cxx.cflags += ['-Wno-narrowing']
|
||||||
if (have_gcc and cxx.minorVersion >= 7) or (have_clang and cxx.majorVersion >= 3):
|
if (have_gcc and cxx.version >= '4.7') or (have_clang and cxx.version >= '3'):
|
||||||
cfg.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
||||||
|
|
||||||
cfg.linkflags += ['-m32']
|
cxx.linkflags += ['-m32']
|
||||||
cfg.cxxflags += [
|
cxx.cxxflags += [
|
||||||
'-fno-exceptions',
|
'-fno-exceptions',
|
||||||
'-fno-threadsafe-statics',
|
'-fno-threadsafe-statics',
|
||||||
'-Wno-non-virtual-dtor',
|
'-Wno-non-virtual-dtor',
|
||||||
@ -186,28 +185,28 @@ class SMConfig(object):
|
|||||||
]
|
]
|
||||||
|
|
||||||
if have_gcc:
|
if have_gcc:
|
||||||
cfg.cflags += ['-mfpmath=sse']
|
cxx.cflags += ['-mfpmath=sse']
|
||||||
elif cxx.name == 'msvc':
|
elif cxx.vendor == 'msvc':
|
||||||
if builder.options.debug == '1':
|
if builder.options.debug == '1':
|
||||||
cfg.cflags += ['/MTd']
|
cxx.cflags += ['/MTd']
|
||||||
cfg.linkflags += ['/NODEFAULTLIB:libcmt']
|
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
||||||
else:
|
else:
|
||||||
cfg.cflags += ['/MT']
|
cxx.cflags += ['/MT']
|
||||||
cfg.defines += [
|
cxx.defines += [
|
||||||
'_CRT_SECURE_NO_DEPRECATE',
|
'_CRT_SECURE_NO_DEPRECATE',
|
||||||
'_CRT_SECURE_NO_WARNINGS',
|
'_CRT_SECURE_NO_WARNINGS',
|
||||||
'_CRT_NONSTDC_NO_DEPRECATE',
|
'_CRT_NONSTDC_NO_DEPRECATE',
|
||||||
'_ITERATOR_DEBUG_LEVEL=0',
|
'_ITERATOR_DEBUG_LEVEL=0',
|
||||||
]
|
]
|
||||||
cfg.cflags += [
|
cxx.cflags += [
|
||||||
'/W3',
|
'/W3',
|
||||||
]
|
]
|
||||||
cfg.cxxflags += [
|
cxx.cxxflags += [
|
||||||
'/EHsc',
|
'/EHsc',
|
||||||
'/GR-',
|
'/GR-',
|
||||||
'/TP',
|
'/TP',
|
||||||
]
|
]
|
||||||
cfg.linkflags += [
|
cxx.linkflags += [
|
||||||
'/MACHINE:X86',
|
'/MACHINE:X86',
|
||||||
'/SUBSYSTEM:WINDOWS',
|
'/SUBSYSTEM:WINDOWS',
|
||||||
'kernel32.lib',
|
'kernel32.lib',
|
||||||
@ -226,55 +225,55 @@ class SMConfig(object):
|
|||||||
|
|
||||||
# Optimization
|
# Optimization
|
||||||
if builder.options.opt == '1':
|
if builder.options.opt == '1':
|
||||||
cfg.defines += ['NDEBUG']
|
cxx.defines += ['NDEBUG']
|
||||||
if cxx.behavior == 'gcc':
|
if cxx.like('gcc'):
|
||||||
cfg.cflags += ['-O3']
|
cxx.cflags += ['-O3']
|
||||||
elif cxx.behavior == 'msvc':
|
elif cxx.like('msvc'):
|
||||||
cfg.cflags += ['/Ox']
|
cxx.cflags += ['/Ox']
|
||||||
cfg.linkflags += ['/OPT:ICF', '/OPT:REF']
|
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
|
||||||
|
|
||||||
# Debugging
|
# Debugging
|
||||||
if builder.options.debug == '1':
|
if builder.options.debug == '1':
|
||||||
cfg.defines += ['DEBUG', '_DEBUG']
|
cxx.defines += ['DEBUG', '_DEBUG']
|
||||||
if cxx.behavior == 'msvc':
|
if cxx.like('msvc'):
|
||||||
cfg.cflags += ['/Od', '/RTC1']
|
cxx.cflags += ['/Od', '/RTC1']
|
||||||
if int(cxx.version) >= 1600:
|
if cxx.version >= 1600:
|
||||||
cfg.cflags += ['/d2Zi+']
|
cxx.cflags += ['/d2Zi+']
|
||||||
|
|
||||||
# This needs to be after our optimization flags which could otherwise disable it.
|
# 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.
|
# Don't omit the frame pointer.
|
||||||
cfg.cflags += ['/Oy-']
|
cxx.cflags += ['/Oy-']
|
||||||
|
|
||||||
# Platform-specifics
|
# Platform-specifics
|
||||||
if builder.target_platform == 'linux':
|
if builder.target_platform == 'linux':
|
||||||
cfg.defines += ['_LINUX', 'POSIX']
|
cxx.defines += ['_LINUX', 'POSIX']
|
||||||
if cxx.name == 'gcc':
|
if cxx.vendor == 'gcc':
|
||||||
cfg.linkflags += ['-static-libgcc']
|
cxx.linkflags += ['-static-libgcc']
|
||||||
elif cxx.name == 'clang':
|
elif cxx.vendor == 'clang':
|
||||||
cfg.linkflags += ['-lgcc_eh']
|
cxx.linkflags += ['-lgcc_eh']
|
||||||
elif builder.target_platform == 'mac':
|
elif builder.target_platform == 'mac':
|
||||||
cfg.defines += ['OSX', '_OSX', 'POSIX']
|
cxx.defines += ['OSX', '_OSX', 'POSIX']
|
||||||
cfg.cflags += ['-mmacosx-version-min=10.5']
|
cxx.cflags += ['-mmacosx-version-min=10.5']
|
||||||
cfg.linkflags += [
|
cxx.linkflags += [
|
||||||
'-mmacosx-version-min=10.5',
|
'-mmacosx-version-min=10.5',
|
||||||
'-arch', 'i386',
|
'-arch', 'i386',
|
||||||
'-lstdc++',
|
'-lstdc++',
|
||||||
'-stdlib=libstdc++',
|
'-stdlib=libstdc++',
|
||||||
]
|
]
|
||||||
cfg.cxxflags += ['-stdlib=libstdc++']
|
cxx.cxxflags += ['-stdlib=libstdc++']
|
||||||
elif builder.target_platform == 'windows':
|
elif builder.target_platform == 'windows':
|
||||||
cfg.defines += ['WIN32', '_WINDOWS']
|
cxx.defines += ['WIN32', '_WINDOWS']
|
||||||
|
|
||||||
# Finish up.
|
# Finish up.
|
||||||
cfg.defines += [
|
cxx.defines += [
|
||||||
'SOURCEMOD_BUILD',
|
'SOURCEMOD_BUILD',
|
||||||
'SM_USE_VERSIONLIB',
|
'SM_USE_VERSIONLIB',
|
||||||
]
|
]
|
||||||
if self.use_auto_versioning():
|
if self.use_auto_versioning():
|
||||||
cfg.defines += ['SM_GENERATED_BUILD']
|
cxx.defines += ['SM_GENERATED_BUILD']
|
||||||
cfg.includes += [os.path.join(builder.buildPath, 'includes')]
|
cxx.includes += [os.path.join(builder.buildPath, 'includes')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'versionlib')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'versionlib')]
|
||||||
|
|
||||||
def LibraryBuilder(self, compiler, name):
|
def LibraryBuilder(self, compiler, name):
|
||||||
binary = compiler.Library(name)
|
binary = compiler.Library(name)
|
||||||
@ -365,14 +364,14 @@ class SMConfig(object):
|
|||||||
|
|
||||||
compiler.defines += ['SOURCE_ENGINE=' + sdk.code]
|
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
|
# The 2013 SDK already has these in public/tier0/basetypes.h
|
||||||
compiler.defines.remove('stricmp=strcasecmp')
|
compiler.defines.remove('stricmp=strcasecmp')
|
||||||
compiler.defines.remove('_stricmp=strcasecmp')
|
compiler.defines.remove('_stricmp=strcasecmp')
|
||||||
compiler.defines.remove('_snprintf=snprintf')
|
compiler.defines.remove('_snprintf=snprintf')
|
||||||
compiler.defines.remove('_vsnprintf=vsnprintf')
|
compiler.defines.remove('_vsnprintf=vsnprintf')
|
||||||
|
|
||||||
if compiler.cc.behavior == 'msvc':
|
if compiler.like('msvc'):
|
||||||
compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32']
|
compiler.defines += ['COMPILER_MSVC', 'COMPILER_MSVC32']
|
||||||
else:
|
else:
|
||||||
compiler.defines += ['COMPILER_GCC']
|
compiler.defines += ['COMPILER_GCC']
|
||||||
|
Loading…
Reference in New Issue
Block a user