From 0b744a0e2460c1796acf46e283dfe5ac6120d6c4 Mon Sep 17 00:00:00 2001 From: Accelerator Date: Tue, 28 May 2024 08:30:43 +0300 Subject: [PATCH] Update ambuild scripts --- AMBuildScript | 45 ++++++++++++++++++++++++++++++++++++--------- AMBuilder | 15 +-------------- 2 files changed, 37 insertions(+), 23 deletions(-) diff --git a/AMBuildScript b/AMBuildScript index a56a7b0..e42e9cf 100644 --- a/AMBuildScript +++ b/AMBuildScript @@ -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: @@ -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: @@ -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.') @@ -233,7 +233,6 @@ class ExtensionConfig(object): '_snprintf=snprintf', '_vsnprintf=vsnprintf', 'HAVE_STDINT_H', - 'HAVE_STRING_H', 'GNUC', ] cxx.cflags += [ @@ -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', @@ -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', @@ -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'] @@ -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: @@ -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) diff --git a/AMBuilder b/AMBuilder index 58f5aab..336a4d0 100644 --- a/AMBuilder +++ b/AMBuilder @@ -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] @@ -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)