Refactor and cleanup the AMBuildScript a bit
This commit is contained in:
parent
07f87990ef
commit
23080b7455
286
AMBuildScript
286
AMBuildScript
|
@ -120,144 +120,31 @@ class AMXXConfig(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.like('gcc'):
|
if cxx.like('gcc'):
|
||||||
cfg.cflags += [
|
self.configure_gcc(cxx)
|
||||||
'-pipe',
|
elif cxx.like('msvc'):
|
||||||
'-fno-strict-aliasing',
|
self.configure_msvc(cxx)
|
||||||
'-Wall',
|
|
||||||
'-Werror',
|
|
||||||
'-Wno-uninitialized',
|
|
||||||
'-Wno-unused',
|
|
||||||
'-Wno-switch',
|
|
||||||
'-Wno-format',
|
|
||||||
'-Wno-format-security',
|
|
||||||
'-m32',
|
|
||||||
]
|
|
||||||
cfg.cxxflags += [
|
|
||||||
'-Wno-invalid-offsetof',
|
|
||||||
'-std=c++11',
|
|
||||||
]
|
|
||||||
|
|
||||||
cfg.linkflags += ['-m32']
|
|
||||||
|
|
||||||
have_gcc = cxx.name == 'gcc'
|
|
||||||
have_clang = cxx.name == 'clang'
|
|
||||||
|
|
||||||
if have_clang or (have_gcc and cxx.version >= '4'):
|
|
||||||
cfg.cflags += ['-fvisibility=hidden']
|
|
||||||
cfg.cxxflags += ['-fvisibility-inlines-hidden']
|
|
||||||
if have_clang or (have_gcc and cxx.version >= '4.6'):
|
|
||||||
cfg.cflags += ['-Wno-narrowing']
|
|
||||||
if (have_gcc and cxx.version >= '4.7') or (have_clang and cxx.version >= '3'):
|
|
||||||
cfg.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
|
||||||
if have_gcc and cxx.version >= '4.8':
|
|
||||||
cfg.cflags += ['-Wno-unused-result', '-Wno-error=sign-compare']
|
|
||||||
if have_clang:
|
|
||||||
cfg.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
|
||||||
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
|
||||||
cfg.cxxflags += ['-Wno-deprecated-register']
|
|
||||||
else:
|
|
||||||
cfg.cxxflags += ['-Wno-deprecated']
|
|
||||||
cfg.cflags += ['-Wno-sometimes-uninitialized']
|
|
||||||
if builder.target_platform == 'linux' and cxx.version >= '3.6':
|
|
||||||
cfg.cxxflags += ['-Wno-inconsistent-missing-override']
|
|
||||||
|
|
||||||
if have_gcc:
|
|
||||||
cfg.cflags += ['-Wno-parentheses']
|
|
||||||
cfg.c_only_flags += ['-std=c99']
|
|
||||||
elif have_clang:
|
|
||||||
cfg.cflags += ['-Wno-logical-op-parentheses']
|
|
||||||
|
|
||||||
cfg.cxxflags += [
|
|
||||||
'-fno-exceptions',
|
|
||||||
'-fno-rtti',
|
|
||||||
]
|
|
||||||
elif cxx.name == 'msvc':
|
|
||||||
if builder.options.debug == '1':
|
|
||||||
cfg.cflags += ['/MTd']
|
|
||||||
cfg.linkflags += ['/NODEFAULTLIB:libcmt']
|
|
||||||
else:
|
|
||||||
cfg.cflags += ['/MT']
|
|
||||||
cfg.defines += [
|
|
||||||
'_CRT_SECURE_NO_DEPRECATE',
|
|
||||||
'_CRT_SECURE_NO_WARNINGS',
|
|
||||||
'_CRT_NONSTDC_NO_DEPRECATE',
|
|
||||||
'_ITERATOR_DEBUG_LEVEL=0',
|
|
||||||
]
|
|
||||||
cfg.cflags += [
|
|
||||||
'/W3',
|
|
||||||
]
|
|
||||||
cfg.cxxflags += [
|
|
||||||
'/EHsc',
|
|
||||||
'/GR-',
|
|
||||||
'/TP',
|
|
||||||
]
|
|
||||||
cfg.linkflags += [
|
|
||||||
'/MACHINE:X86',
|
|
||||||
'/SUBSYSTEM:WINDOWS',
|
|
||||||
'kernel32.lib',
|
|
||||||
'user32.lib',
|
|
||||||
'gdi32.lib',
|
|
||||||
'winspool.lib',
|
|
||||||
'comdlg32.lib',
|
|
||||||
'advapi32.lib',
|
|
||||||
'shell32.lib',
|
|
||||||
'ole32.lib',
|
|
||||||
'oleaut32.lib',
|
|
||||||
'uuid.lib',
|
|
||||||
'odbc32.lib',
|
|
||||||
'odbccp32.lib',
|
|
||||||
]
|
|
||||||
|
|
||||||
# Optimization
|
# Optimization
|
||||||
if builder.options.opt == '1':
|
if builder.options.opt == '1':
|
||||||
cfg.defines += ['NDEBUG']
|
cxx.defines += ['NDEBUG']
|
||||||
if cxx.like('gcc'):
|
|
||||||
cfg.cflags += ['-O2']
|
|
||||||
elif cxx.like('msvc'):
|
|
||||||
cfg.cflags += ['/Ox']
|
|
||||||
cfg.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.like('msvc'):
|
|
||||||
cfg.cflags += ['/Od', '/RTC1']
|
|
||||||
|
|
||||||
# This needs to be after our optimization flags which could otherwise disable it.
|
|
||||||
if cxx.name == 'msvc':
|
|
||||||
# Don't omit the frame pointer.
|
|
||||||
cfg.cflags += ['/Oy-']
|
|
||||||
|
|
||||||
# Platform-specifics
|
# Platform-specifics
|
||||||
if builder.target_platform == 'linux':
|
if builder.target_platform == 'linux':
|
||||||
cfg.defines += ['_LINUX', 'POSIX', 'LINUX']
|
self.configure_linux(cxx)
|
||||||
cfg.postlink += ['-ldl', '-lm']
|
|
||||||
if cxx.name == 'gcc':
|
|
||||||
cfg.postlink += ['-static-libgcc']
|
|
||||||
elif cxx.name == 'clang':
|
|
||||||
cfg.postlink += ['-lgcc_eh']
|
|
||||||
if cxx.like('gcc'):
|
|
||||||
self.stdcxx_path = self.invokeCompiler(['-m32', '-print-file-name=' + 'libstdc++.a'])[0]
|
|
||||||
elif builder.target_platform == 'mac':
|
elif builder.target_platform == 'mac':
|
||||||
cfg.defines += ['OSX', '_OSX', 'POSIX']
|
self.configure_mac(cxx)
|
||||||
cfg.cflags += ['-mmacosx-version-min=10.5']
|
|
||||||
cfg.postlink += [
|
|
||||||
'-mmacosx-version-min=10.5',
|
|
||||||
'-arch', 'i386',
|
|
||||||
'-lstdc++',
|
|
||||||
'-stdlib=libstdc++',
|
|
||||||
'-framework', 'CoreServices',
|
|
||||||
]
|
|
||||||
cfg.cxxflags += ['-stdlib=libstdc++']
|
|
||||||
elif builder.target_platform == 'windows':
|
elif builder.target_platform == 'windows':
|
||||||
cfg.defines += ['WIN32', '_WINDOWS']
|
self.configure_windows(cxx)
|
||||||
|
|
||||||
# Finish up.
|
# Finish up.
|
||||||
cfg.defines += [
|
cxx.defines += [
|
||||||
'AMX_NOPROPLIST',
|
'AMX_NOPROPLIST',
|
||||||
'PAWN_CELL_SIZE=32',
|
'PAWN_CELL_SIZE=32',
|
||||||
'AMXMODX_BUILD',
|
'AMXMODX_BUILD',
|
||||||
|
@ -265,19 +152,148 @@ class AMXXConfig(object):
|
||||||
]
|
]
|
||||||
|
|
||||||
if self.use_auto_versioning():
|
if self.use_auto_versioning():
|
||||||
cfg.defines += ['AMXX_GENERATED_BUILD']
|
cxx.defines += ['AMXX_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, 'support', 'versionlib')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'support', 'versionlib')]
|
||||||
|
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'public')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'public')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'sdk')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'public', 'sdk')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'amtl')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'public', 'amtl')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'amtl', 'amtl')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'public', 'amtl', 'amtl')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'public', 'memtools')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'public', 'memtools')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'third_party')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'third_party')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'third_party', 'hashing')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'third_party', 'hashing')]
|
||||||
cfg.includes += [os.path.join(builder.sourcePath, 'third_party', 'zlib')]
|
cxx.includes += [os.path.join(builder.sourcePath, 'third_party', 'zlib')]
|
||||||
return
|
|
||||||
|
def configure_gcc(self, cxx):
|
||||||
|
cxx.cflags += [
|
||||||
|
'-pipe',
|
||||||
|
'-fno-strict-aliasing',
|
||||||
|
'-Wall',
|
||||||
|
'-Werror',
|
||||||
|
'-Wno-uninitialized',
|
||||||
|
'-Wno-unused',
|
||||||
|
'-Wno-switch',
|
||||||
|
'-Wno-format',
|
||||||
|
'-Wno-format-security',
|
||||||
|
'-m32',
|
||||||
|
]
|
||||||
|
cxx.cxxflags += [
|
||||||
|
'-Wno-invalid-offsetof',
|
||||||
|
'-std=c++11',
|
||||||
|
]
|
||||||
|
|
||||||
|
cxx.linkflags += ['-m32']
|
||||||
|
|
||||||
|
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']
|
||||||
|
if have_gcc and cxx.version >= '4.8':
|
||||||
|
cxx.cflags += ['-Wno-unused-result', '-Wno-error=sign-compare']
|
||||||
|
if have_clang:
|
||||||
|
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
||||||
|
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
||||||
|
cxx.cxxflags += ['-Wno-deprecated-register']
|
||||||
|
else:
|
||||||
|
cxx.cxxflags += ['-Wno-deprecated']
|
||||||
|
cxx.cflags += ['-Wno-sometimes-uninitialized']
|
||||||
|
if builder.target_platform == 'linux' and cxx.version >= '3.6':
|
||||||
|
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
|
||||||
|
|
||||||
|
if have_gcc:
|
||||||
|
cxx.cflags += ['-Wno-parentheses']
|
||||||
|
cxx.c_only_flags += ['-std=c99']
|
||||||
|
elif have_clang:
|
||||||
|
cxx.cflags += ['-Wno-logical-op-parentheses']
|
||||||
|
|
||||||
|
cxx.cxxflags += [
|
||||||
|
'-fno-exceptions',
|
||||||
|
'-fno-rtti',
|
||||||
|
]
|
||||||
|
|
||||||
|
if builder.options.opt == '1':
|
||||||
|
cxx.cflags += ['-O2']
|
||||||
|
|
||||||
|
def configure_msvc(self, cxx):
|
||||||
|
if builder.options.debug == '1':
|
||||||
|
cxx.cflags += ['/MTd']
|
||||||
|
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
||||||
|
else:
|
||||||
|
cxx.cflags += ['/MT']
|
||||||
|
|
||||||
|
cxx.defines += [
|
||||||
|
'_CRT_SECURE_NO_DEPRECATE',
|
||||||
|
'_CRT_SECURE_NO_WARNINGS',
|
||||||
|
'_CRT_NONSTDC_NO_DEPRECATE',
|
||||||
|
'_ITERATOR_DEBUG_LEVEL=0',
|
||||||
|
]
|
||||||
|
cxx.cflags += [
|
||||||
|
'/W3',
|
||||||
|
]
|
||||||
|
cxx.cxxflags += [
|
||||||
|
'/EHsc',
|
||||||
|
'/GR-',
|
||||||
|
'/TP',
|
||||||
|
]
|
||||||
|
cxx.linkflags += [
|
||||||
|
'/MACHINE:X86',
|
||||||
|
'/SUBSYSTEM:WINDOWS',
|
||||||
|
'kernel32.lib',
|
||||||
|
'user32.lib',
|
||||||
|
'gdi32.lib',
|
||||||
|
'winspool.lib',
|
||||||
|
'comdlg32.lib',
|
||||||
|
'advapi32.lib',
|
||||||
|
'shell32.lib',
|
||||||
|
'ole32.lib',
|
||||||
|
'oleaut32.lib',
|
||||||
|
'uuid.lib',
|
||||||
|
'odbc32.lib',
|
||||||
|
'odbccp32.lib',
|
||||||
|
]
|
||||||
|
|
||||||
|
if builder.options.opt == '1':
|
||||||
|
cxx.cflags += ['/Ox']
|
||||||
|
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
|
||||||
|
|
||||||
|
if builder.options.debug == '1':
|
||||||
|
cxx.cflags += ['/Od', '/RTC1']
|
||||||
|
|
||||||
|
# This needs to be after our optimization flags which could otherwise disable it.
|
||||||
|
# Don't omit the frame pointer.
|
||||||
|
cxx.cflags += ['/Oy-']
|
||||||
|
|
||||||
|
def configure_linux(self, cxx):
|
||||||
|
cxx.defines += ['_LINUX', 'POSIX', 'LINUX']
|
||||||
|
cxx.linkflags += ['-ldl', '-lm']
|
||||||
|
if cxx.vendor == 'gcc':
|
||||||
|
cxx.linkflags += ['-static-libgcc']
|
||||||
|
elif cxx.vendor == 'clang':
|
||||||
|
cxx.linkflags += ['-lgcc_eh']
|
||||||
|
if cxx.like('gcc'):
|
||||||
|
self.stdcxx_path = self.invokeCompiler(['-m32', '-print-file-name=' + 'libstdc++.a'])[0]
|
||||||
|
|
||||||
|
def configure_mac(self, cxx):
|
||||||
|
cxx.defines += ['OSX', '_OSX', 'POSIX']
|
||||||
|
cxx.cflags += ['-mmacosx-version-min=10.5']
|
||||||
|
cxx.linkflags += [
|
||||||
|
'-mmacosx-version-min=10.5',
|
||||||
|
'-arch', 'i386',
|
||||||
|
'-lstdc++',
|
||||||
|
'-stdlib=libstdc++',
|
||||||
|
'-framework', 'CoreServices',
|
||||||
|
]
|
||||||
|
cxx.cxxflags += ['-stdlib=libstdc++']
|
||||||
|
|
||||||
|
def configure_windows(self, cxx):
|
||||||
|
cxx.defines += ['WIN32', '_WINDOWS']
|
||||||
|
|
||||||
#
|
#
|
||||||
# Low-level compiler and binary construction.
|
# Low-level compiler and binary construction.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user