Skip to content

Commit

Permalink
Update ambuild scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
accelerator74 committed May 28, 2024
1 parent fec645e commit 0b744a0
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 23 deletions.
45 changes: 36 additions & 9 deletions AMBuildScript
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class ExtensionConfig(object):
if builder.options.sm_path:
self.sm_root = builder.options.sm_path
else:
self.sm_root = ResolveEnvPath('SOURCEMOD110', 'sourcemod-1.10')
self.sm_root = ResolveEnvPath('SOURCEMOD112', 'sourcemod-1.12')
if not self.sm_root:
self.sm_root = ResolveEnvPath('SOURCEMOD', 'sourcemod')
if not self.sm_root:
Expand All @@ -172,7 +172,7 @@ class ExtensionConfig(object):
if builder.options.mms_path:
self.mms_root = builder.options.mms_path
else:
self.mms_root = ResolveEnvPath('MMSOURCE110', 'mmsource-1.10')
self.mms_root = ResolveEnvPath('MMSOURCE112', 'mmsource-1.12')
if not self.mms_root:
self.mms_root = ResolveEnvPath('MMSOURCE_DEV', 'metamod-source')
if not self.mms_root:
Expand All @@ -191,8 +191,8 @@ class ExtensionConfig(object):

def configure_cxx(self, cxx):
if cxx.family == 'msvc':
if cxx.version < 1914:
raise Exception('Only MSVC 2017 15.7 and later are supported, full C++17 support is required.')
if cxx.version < 1914 and builder.options.generator != 'vs':
raise Exception(f'Only MSVC 2017 15.7 and later are supported, full C++17 support is required. ({str(cxx.version)} < 1914)')
elif cxx.family == 'gcc':
if cxx.version < 'gcc-9':
raise Exception('Only GCC versions 9 or later are supported, full C++17 support is required.')
Expand Down Expand Up @@ -233,7 +233,6 @@ class ExtensionConfig(object):
'_snprintf=snprintf',
'_vsnprintf=vsnprintf',
'HAVE_STDINT_H',
'HAVE_STRING_H',
'GNUC',
]
cxx.cflags += [
Expand All @@ -244,9 +243,10 @@ class ExtensionConfig(object):
'-Wno-unused',
'-Wno-switch',
'-Wno-array-bounds',
'-msse',
'-fvisibility=hidden',
]
if cxx.target.arch in ['x86', 'x86_64']:
cxx.cflags += ['-msse']

cxx.cxxflags += [
'-std=c++17',
Expand Down Expand Up @@ -284,7 +284,7 @@ class ExtensionConfig(object):
cxx.cflags += ['-Wno-sometimes-uninitialized']

# Work around SDK warnings.
if cxx.version >= 'clang-10.0':
if cxx.version >= 'clang-10.0' or cxx.version >= 'apple-clang-12.0':
cxx.cflags += [
'-Wno-implicit-int-float-conversion',
'-Wno-tautological-overlap-compare',
Expand Down Expand Up @@ -354,7 +354,6 @@ class ExtensionConfig(object):
cxx.linkflags += ['-static-libgcc']
elif cxx.family == 'clang':
cxx.linkflags += ['-lgcc_eh']
#cxx.linkflags += ['-static-libstdc++']

def configure_mac(self, cxx):
cxx.defines += ['OSX', '_OSX', 'POSIX', 'KE_ABSOLUTELY_NO_STL']
Expand Down Expand Up @@ -484,7 +483,6 @@ class ExtensionConfig(object):

if compiler.target.platform == 'linux':
if sdk.name in ['csgo', 'blade']:
#compiler.linkflags.remove('-static-libstdc++')
compiler.defines += ['_GLIBCXX_USE_CXX11_ABI=0']

for path in paths:
Expand Down Expand Up @@ -562,6 +560,35 @@ class ExtensionConfig(object):

return binary

def AddCDetour(self, binary):
sm_public_path = os.path.join(self.sm_root, 'public')

if os.path.exists(os.path.join(sm_public_path, 'safetyhook', 'safetyhook.cpp')):
binary.sources += [
os.path.join(sm_public_path, 'CDetour', 'detours.cpp'),
os.path.join(sm_public_path, 'safetyhook', 'safetyhook.cpp'),
os.path.join(sm_public_path, 'safetyhook', 'Zydis.c')
]
binary.compiler.cxxincludes += [ os.path.join(sm_public_path, 'safetyhook') ]
binary.compiler.includes += [ os.path.join(sm_public_path, 'safetyhook') ]
else:
binary.sources += [
os.path.join(sm_public_path, 'CDetour', 'detours.cpp'),
os.path.join(sm_public_path, 'asm', 'asm.c'),
]
# sm1.10+
libudis_folder = os.path.join(sm_public_path, 'libudis86')
if os.path.isdir(libudis_folder):
binary.compiler.defines += ['HAVE_STRING_H']
binary.sources += [
os.path.join(libudis_folder, 'decode.c'),
os.path.join(libudis_folder, 'itab.c'),
os.path.join(libudis_folder, 'syn-att.c'),
os.path.join(libudis_folder, 'syn-intel.c'),
os.path.join(libudis_folder, 'syn.c'),
os.path.join(libudis_folder, 'udis86.c'),
]

def HL2Library(self, context, compiler, name, sdk):
binary = self.Library(context, compiler, name)
self.ConfigureForExtension(context, binary.compiler)
Expand Down
15 changes: 1 addition & 14 deletions AMBuilder
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,8 @@ project = builder.LibraryProject('cleaner')
project.sources += [
'extension.cpp',
os.path.join(Extension.sm_root, 'public', 'smsdk_ext.cpp'),
os.path.join(Extension.sm_root, 'public', 'CDetour', 'detours.cpp'),
os.path.join(Extension.sm_root, 'public', 'asm', 'asm.c'),
]

# sm1.10+
libudis_folder = os.path.join(Extension.sm_root, 'public', 'libudis86')
if os.path.isdir(libudis_folder):
project.sources += [
os.path.join(libudis_folder, 'decode.c'),
os.path.join(libudis_folder, 'itab.c'),
os.path.join(libudis_folder, 'syn-att.c'),
os.path.join(libudis_folder, 'syn-intel.c'),
os.path.join(libudis_folder, 'syn.c'),
os.path.join(libudis_folder, 'udis86.c'),
]

for sdk_name in Extension.sdks:
sdk = Extension.sdks[sdk_name]

Expand All @@ -29,5 +15,6 @@ for sdk_name in Extension.sdks:
continue

binary = Extension.HL2ExtConfig(project, builder, cxx, 'cleaner.ext.' + sdk.ext, sdk)
Extension.AddCDetour(binary)

Extension.extensions += builder.Add(project)

0 comments on commit 0b744a0

Please sign in to comment.