Merge pull request #427 from alliedmodders/refactor-amb
Refactor and cleanup the AMBuildScript a bit.
This commit is contained in:
commit
195a836999
103
AMBuildScript
103
AMBuildScript
@ -121,7 +121,6 @@ class SMConfig(object):
|
|||||||
if len(self.sdks) < 1:
|
if len(self.sdks) < 1:
|
||||||
raise Exception('At least one SDK must be available.')
|
raise Exception('At least one SDK must be available.')
|
||||||
|
|
||||||
|
|
||||||
if builder.options.mms_path:
|
if builder.options.mms_path:
|
||||||
self.mms_root = builder.options.mms_path
|
self.mms_root = builder.options.mms_path
|
||||||
else:
|
else:
|
||||||
@ -153,6 +152,42 @@ class SMConfig(object):
|
|||||||
cxx = builder.DetectCompilers()
|
cxx = builder.DetectCompilers()
|
||||||
|
|
||||||
if cxx.like('gcc'):
|
if cxx.like('gcc'):
|
||||||
|
self.configure_gcc(cxx)
|
||||||
|
elif cxx.vendor == 'msvc':
|
||||||
|
self.configure_msvc(cxx)
|
||||||
|
|
||||||
|
# Optimizaiton
|
||||||
|
if builder.options.opt == '1':
|
||||||
|
cxx.defines += ['NDEBUG']
|
||||||
|
|
||||||
|
# Debugging
|
||||||
|
if builder.options.debug == '1':
|
||||||
|
cxx.defines += ['DEBUG', '_DEBUG']
|
||||||
|
|
||||||
|
# Platform-specifics
|
||||||
|
if builder.target_platform == 'linux':
|
||||||
|
self.configure_linux(cxx)
|
||||||
|
elif builder.target_platform == 'mac':
|
||||||
|
self.configure_mac(cxx)
|
||||||
|
elif builder.target_platform == 'windows':
|
||||||
|
self.configure_windows(cxx)
|
||||||
|
|
||||||
|
# Finish up.
|
||||||
|
cxx.defines += [
|
||||||
|
'SOURCEMOD_BUILD',
|
||||||
|
'SM_USE_VERSIONLIB',
|
||||||
|
]
|
||||||
|
cxx.includes += [
|
||||||
|
os.path.join(builder.sourcePath, 'public'),
|
||||||
|
]
|
||||||
|
if self.use_auto_versioning():
|
||||||
|
cxx.defines += ['SM_GENERATED_BUILD']
|
||||||
|
cxx.includes += [
|
||||||
|
os.path.join(builder.buildPath, 'includes'),
|
||||||
|
os.path.join(builder.sourcePath, 'versionlib'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def configure_gcc(self, cxx):
|
||||||
cxx.defines += [
|
cxx.defines += [
|
||||||
'stricmp=strcasecmp',
|
'stricmp=strcasecmp',
|
||||||
'_stricmp=strcasecmp',
|
'_stricmp=strcasecmp',
|
||||||
@ -171,24 +206,29 @@ class SMConfig(object):
|
|||||||
'-Wno-array-bounds',
|
'-Wno-array-bounds',
|
||||||
'-msse',
|
'-msse',
|
||||||
'-m32',
|
'-m32',
|
||||||
|
'-fvisibility=hidden',
|
||||||
]
|
]
|
||||||
cxx.cxxflags += [
|
cxx.cxxflags += [
|
||||||
'-std=c++11',
|
'-std=c++11',
|
||||||
|
'-fno-exceptions',
|
||||||
|
'-fno-threadsafe-statics',
|
||||||
|
'-Wno-non-virtual-dtor',
|
||||||
|
'-Wno-overloaded-virtual',
|
||||||
|
'-fvisibility-inlines-hidden',
|
||||||
]
|
]
|
||||||
|
cxx.linkflags += ['-m32']
|
||||||
|
|
||||||
have_gcc = cxx.vendor == 'gcc'
|
have_gcc = cxx.vendor == 'gcc'
|
||||||
have_clang = cxx.vendor == 'clang'
|
have_clang = cxx.vendor == 'clang'
|
||||||
if have_clang or (have_gcc and cxx.version >= '4'):
|
if cxx.version >= 'clang-3.6':
|
||||||
cxx.cflags += ['-fvisibility=hidden']
|
|
||||||
cxx.cxxflags += ['-fvisibility-inlines-hidden']
|
|
||||||
if have_clang and cxx.version >= 'clang-3.6':
|
|
||||||
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
|
cxx.cxxflags += ['-Wno-inconsistent-missing-override']
|
||||||
if have_clang or (have_gcc and cxx.version >= '4.6'):
|
if have_clang or (cxx.version >= 'gcc-4.6'):
|
||||||
cxx.cflags += ['-Wno-narrowing']
|
cxx.cflags += ['-Wno-narrowing']
|
||||||
if (have_gcc and cxx.version >= '4.7') or (have_clang and cxx.version >= '3'):
|
if have_clang or (cxx.version >= 'gcc-4.7'):
|
||||||
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
cxx.cxxflags += ['-Wno-delete-non-virtual-dtor']
|
||||||
if have_gcc and cxx.version >= '4.8':
|
if cxx.version >= 'gcc-4.8':
|
||||||
cxx.cflags += ['-Wno-unused-result']
|
cxx.cflags += ['-Wno-unused-result']
|
||||||
|
|
||||||
if have_clang:
|
if have_clang:
|
||||||
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
cxx.cxxflags += ['-Wno-implicit-exception-spec-mismatch']
|
||||||
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
if cxx.version >= 'apple-clang-5.1' or cxx.version >= 'clang-3.4':
|
||||||
@ -197,17 +237,13 @@ class SMConfig(object):
|
|||||||
cxx.cxxflags += ['-Wno-deprecated']
|
cxx.cxxflags += ['-Wno-deprecated']
|
||||||
cxx.cflags += ['-Wno-sometimes-uninitialized']
|
cxx.cflags += ['-Wno-sometimes-uninitialized']
|
||||||
|
|
||||||
cxx.linkflags += ['-m32']
|
|
||||||
cxx.cxxflags += [
|
|
||||||
'-fno-exceptions',
|
|
||||||
'-fno-threadsafe-statics',
|
|
||||||
'-Wno-non-virtual-dtor',
|
|
||||||
'-Wno-overloaded-virtual',
|
|
||||||
]
|
|
||||||
|
|
||||||
if have_gcc:
|
if have_gcc:
|
||||||
cxx.cflags += ['-mfpmath=sse']
|
cxx.cflags += ['-mfpmath=sse']
|
||||||
elif cxx.vendor == 'msvc':
|
|
||||||
|
if builder.options.opt == '1':
|
||||||
|
cxx.cflags += ['-O3']
|
||||||
|
|
||||||
|
def configure_msvc(self, cxx):
|
||||||
if builder.options.debug == '1':
|
if builder.options.debug == '1':
|
||||||
cxx.cflags += ['/MTd']
|
cxx.cflags += ['/MTd']
|
||||||
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
cxx.linkflags += ['/NODEFAULTLIB:libcmt']
|
||||||
@ -243,35 +279,26 @@ class SMConfig(object):
|
|||||||
'odbccp32.lib',
|
'odbccp32.lib',
|
||||||
]
|
]
|
||||||
|
|
||||||
# Optimization
|
|
||||||
if builder.options.opt == '1':
|
if builder.options.opt == '1':
|
||||||
cxx.defines += ['NDEBUG']
|
|
||||||
if cxx.like('gcc'):
|
|
||||||
cxx.cflags += ['-O3']
|
|
||||||
elif cxx.like('msvc'):
|
|
||||||
cxx.cflags += ['/Ox', '/Zo']
|
cxx.cflags += ['/Ox', '/Zo']
|
||||||
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
|
cxx.linkflags += ['/OPT:ICF', '/OPT:REF']
|
||||||
|
|
||||||
# Debugging
|
|
||||||
if builder.options.debug == '1':
|
if builder.options.debug == '1':
|
||||||
cxx.defines += ['DEBUG', '_DEBUG']
|
|
||||||
if cxx.like('msvc'):
|
|
||||||
cxx.cflags += ['/Od', '/RTC1']
|
cxx.cflags += ['/Od', '/RTC1']
|
||||||
|
|
||||||
# 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.vendor == 'msvc':
|
|
||||||
# Don't omit the frame pointer.
|
# Don't omit the frame pointer.
|
||||||
cxx.cflags += ['/Oy-']
|
cxx.cflags += ['/Oy-']
|
||||||
|
|
||||||
# Platform-specifics
|
def configure_linux(self, cxx):
|
||||||
if builder.target_platform == 'linux':
|
|
||||||
cxx.defines += ['_LINUX', 'POSIX']
|
cxx.defines += ['_LINUX', 'POSIX']
|
||||||
cxx.linkflags += ['-lm']
|
cxx.linkflags += ['-lm']
|
||||||
if cxx.vendor == 'gcc':
|
if cxx.vendor == 'gcc':
|
||||||
cxx.linkflags += ['-static-libgcc']
|
cxx.linkflags += ['-static-libgcc']
|
||||||
elif cxx.vendor == 'clang':
|
elif cxx.vendor == 'clang':
|
||||||
cxx.linkflags += ['-lgcc_eh']
|
cxx.linkflags += ['-lgcc_eh']
|
||||||
elif builder.target_platform == 'mac':
|
|
||||||
|
def configure_mac(self, cxx):
|
||||||
cxx.defines += ['OSX', '_OSX', 'POSIX']
|
cxx.defines += ['OSX', '_OSX', 'POSIX']
|
||||||
cxx.cflags += ['-mmacosx-version-min=10.5']
|
cxx.cflags += ['-mmacosx-version-min=10.5']
|
||||||
cxx.linkflags += [
|
cxx.linkflags += [
|
||||||
@ -281,23 +308,9 @@ class SMConfig(object):
|
|||||||
'-stdlib=libstdc++',
|
'-stdlib=libstdc++',
|
||||||
]
|
]
|
||||||
cxx.cxxflags += ['-stdlib=libstdc++']
|
cxx.cxxflags += ['-stdlib=libstdc++']
|
||||||
elif builder.target_platform == 'windows':
|
|
||||||
cxx.defines += ['WIN32', '_WINDOWS']
|
|
||||||
|
|
||||||
# Finish up.
|
def configure_windows(self, cxx):
|
||||||
cxx.defines += [
|
cxx.defines += ['WIN32', '_WINDOWS']
|
||||||
'SOURCEMOD_BUILD',
|
|
||||||
'SM_USE_VERSIONLIB',
|
|
||||||
]
|
|
||||||
cxx.includes += [
|
|
||||||
os.path.join(builder.sourcePath, 'public'),
|
|
||||||
]
|
|
||||||
if self.use_auto_versioning():
|
|
||||||
cxx.defines += ['SM_GENERATED_BUILD']
|
|
||||||
cxx.includes += [
|
|
||||||
os.path.join(builder.buildPath, 'includes'),
|
|
||||||
os.path.join(builder.sourcePath, 'versionlib'),
|
|
||||||
]
|
|
||||||
|
|
||||||
def AddVersioning(self, binary):
|
def AddVersioning(self, binary):
|
||||||
if builder.target_platform == 'windows':
|
if builder.target_platform == 'windows':
|
||||||
|
@ -109,7 +109,7 @@ IThreadHandle *PosixThreader::MakeThread(IThread *pThread, const ThreadParams *p
|
|||||||
|
|
||||||
ke::AutoPtr<ThreadHandle> pHandle(new ThreadHandle(this, pThread, params));
|
ke::AutoPtr<ThreadHandle> pHandle(new ThreadHandle(this, pThread, params));
|
||||||
|
|
||||||
pHandle->m_thread = new ke::Thread(pHandle, "SourceMod");
|
pHandle->m_thread = new ke::Thread(pHandle.get(), "SourceMod");
|
||||||
if (!pHandle->m_thread->Succeeded())
|
if (!pHandle->m_thread->Succeeded())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ IThreadHandle *WinThreader::MakeThread(IThread *pThread, const ThreadParams *par
|
|||||||
|
|
||||||
ke::AutoPtr<ThreadHandle> pHandle(new ThreadHandle(this, pThread, params));
|
ke::AutoPtr<ThreadHandle> pHandle(new ThreadHandle(this, pThread, params));
|
||||||
|
|
||||||
pHandle->m_thread = new ke::Thread(pHandle, "SourceMod");
|
pHandle->m_thread = new ke::Thread(pHandle.get(), "SourceMod");
|
||||||
if (!pHandle->m_thread->Succeeded())
|
if (!pHandle->m_thread->Succeeded())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 298217cbbfac16851bb58574bc6744f58b260b15
|
Subproject commit c35532ced5e7e4f882106857bfae8f3db0fbacf0
|
Loading…
Reference in New Issue
Block a user