diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index fc37bc37..267e2eb8 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -70,6 +70,7 @@ jobs: env: SDL_VERSION: 2.32.10 FFMPEG_VERSION: 8.1 + YY_THUNKS_VERSION: v1.2.1 GH_CPU_ARCH: ${{ matrix.targetarch }} GH_CPU_OS: ${{ matrix.targetos }} GH_CROSSCOMPILING: ${{ matrix.cross }} diff --git a/3rdparty/mainui b/3rdparty/mainui index a0c8b85c..493b08fb 160000 --- a/3rdparty/mainui +++ b/3rdparty/mainui @@ -1 +1 @@ -Subproject commit a0c8b85cb4f1fd661513666ccc707b4d56043ab7 +Subproject commit 493b08fb4917ec407e2333309058800a3ac76ade diff --git a/3rdparty/vgui_support b/3rdparty/vgui_support index e021fb5e..d2aaec10 160000 --- a/3rdparty/vgui_support +++ b/3rdparty/vgui_support @@ -1 +1 @@ -Subproject commit e021fb5e7f08535005d2e38e29510e153db73bd2 +Subproject commit d2aaec107d70ffb45a167cfb33ecf849310aa330 diff --git a/3rdparty/yy-thunks/wscript b/3rdparty/yy-thunks/wscript new file mode 100644 index 00000000..55c04675 --- /dev/null +++ b/3rdparty/yy-thunks/wscript @@ -0,0 +1,59 @@ +#! /usr/bin/env python +# encoding: utf-8 + +import hashlib +from waflib import Task, TaskGen, Logs + +OBJ_NAME = 'YY_Thunks_for_WinXP.obj' +OBJ_SHA256 = '51a13c4b667c82181d357e274a50308a273be63f5f85ae958465774857721573' +DLL_LINKFLAGS = ['-ENTRY:DllMainCRTStartupForYY_Thunks', '-alternatename:_YY_ThunksOriginalDllMainCRTStartup@12=__DllMainCRTStartup@12'] + +class copy_yy_thunks(Task.Task): + color = 'CYAN' + def run(self): + return self.outputs[0].write(self.inputs[0].read('rb'), 'wb') + +@TaskGen.feature('yy_thunks') +def add_yy_thunks_obj(self): + src = self.path.find_node(OBJ_NAME) + out = self.path.find_or_declare(OBJ_NAME) + self.compiled_tasks = [self.create_task('copy_yy_thunks', src, out)] + +@TaskGen.feature('cshlib', 'cxxshlib') +@TaskGen.after_method('process_use') +def apply_yy_thunks_dll(self): + if 'yy_thunks' not in self.to_list(getattr(self, 'use', [])): + return + + try: + self.bld.get_tgen_by_name('yy_thunks') + except Exception: + return + self.env.append_value('LINKFLAGS', DLL_LINKFLAGS) + +def options(opt): + pass + +def configure(conf): + if conf.env.DEST_OS != 'win32' or conf.env.COMPILER_CC != 'msvc': + return + + if conf.env.MSVC_TARGETS[0] not in ['amd64_x86', 'x86']: + return + + obj = conf.path.find_node(OBJ_NAME) + if not obj: + Logs.warn('YY-Thunks: %s not found, XP compatibility disabled' % OBJ_NAME) + return + + with open(obj.abspath(), 'rb') as f: + digest = hashlib.sha256(f.read()).hexdigest() + + if digest != OBJ_SHA256: + conf.fatal('%s checksum mismatch: expected %s, got %s' % (OBJ_NAME, OBJ_SHA256, digest)) + + conf.env.YY_THUNKS = True + +def build(bld): + if bld.env.YY_THUNKS: + bld(name='yy_thunks', features='yy_thunks') diff --git a/engine/wscript b/engine/wscript index 7b3ee70b..12322c35 100644 --- a/engine/wscript +++ b/engine/wscript @@ -161,7 +161,7 @@ def build(bld): # public includes for renderers and utils use bld(name = 'engine_includes', export_includes = '. common common/imagelib', use = 'filesystem_includes') - libs = ['engine_includes', 'public', 'werror', 'backtrace_custom', 'library_suffix', 'build_vcs', 'mbedtls'] + libs = ['engine_includes', 'public', 'werror', 'backtrace_custom', 'library_suffix', 'build_vcs', 'mbedtls', 'yy_thunks'] includes = ['server', 'client', 'client/vgui', 'common/soundlib', 'platform'] # basic build: dedicated only diff --git a/filesystem/wscript b/filesystem/wscript index 8d34abfe..9c4b79b7 100644 --- a/filesystem/wscript +++ b/filesystem/wscript @@ -33,7 +33,7 @@ def configure(conf): def build(bld): bld(name = 'filesystem_includes', export_includes = '.') - libs = [ 'filesystem_includes', 'sdk_includes', 'werror' ] + libs = [ 'filesystem_includes', 'sdk_includes', 'werror', 'yy_thunks' ] # on PSVita do not link any libraries that are already in the main executable, but add the includes target if bld.env.DEST_OS != 'psvita': diff --git a/game_launch/wscript b/game_launch/wscript index 1247e46b..2e2fff68 100644 --- a/game_launch/wscript +++ b/game_launch/wscript @@ -32,7 +32,7 @@ def build(bld): bld.program(source = source, target = 'xash3d', # hl.exe - use = 'sdk_includes DL USER32 SHELL32 werror', + use = 'sdk_includes DL USER32 SHELL32 werror yy_thunks', rpath = bld.env.DEFAULT_RPATH, install_path = bld.env.BINDIR, subsystem = bld.env.MSVC_SUBSYSTEM diff --git a/ref/gl/wscript b/ref/gl/wscript index f085da6d..c566c01b 100644 --- a/ref/gl/wscript +++ b/ref/gl/wscript @@ -25,7 +25,7 @@ def configure(conf): conf.check_cc(lib='log') def build(bld): - libs = [ 'ref_common', 'engine_includes', 'werror' ] + libs = [ 'ref_common', 'engine_includes', 'werror', 'yy_thunks' ] # on PSVita do not link any libraries that are already in the main executable, but add the includes target if bld.env.DEST_OS == 'psvita': libs += [ 'sdk_includes', 'vgl_shim' ] diff --git a/ref/null/wscript b/ref/null/wscript index 8de44e99..606645e8 100644 --- a/ref/null/wscript +++ b/ref/null/wscript @@ -13,6 +13,6 @@ def build(bld): source = 'r_context.c', target = 'ref_null', defines = 'REF_DLL', - use = 'engine_includes sdk_includes werror', + use = 'engine_includes sdk_includes werror yy_thunks', install_path = bld.env.LIBDIR ) diff --git a/ref/soft/wscript b/ref/soft/wscript index 4ed21aad..990c12f2 100644 --- a/ref/soft/wscript +++ b/ref/soft/wscript @@ -14,7 +14,7 @@ def configure(conf): return def build(bld): - libs = [ 'ref_common', 'engine_includes', 'werror' ] + libs = [ 'ref_common', 'engine_includes', 'werror', 'yy_thunks' ] # on PSVita do not link any libraries that are already in the main executable, but add the includes target if bld.env.DEST_OS == 'psvita': libs += [ 'sdk_includes' ] diff --git a/scripts/gha/deps_win32.sh b/scripts/gha/deps_win32.sh index 26a55248..d960c6df 100755 --- a/scripts/gha/deps_win32.sh +++ b/scripts/gha/deps_win32.sh @@ -8,6 +8,11 @@ mv "SDL2-$SDL_VERSION" SDL2_VC if [ "$GH_CPU_ARCH" = "i386" ]; then rustup target add i686-pc-windows-msvc + + # YY-Thunks obj for Windows XP support + curl -L "https://github.com/Chuyu-Team/YY-Thunks/releases/download/$YY_THUNKS_VERSION/YY-Thunks-Objs.zip" -o yy-thunks.zip + unzip -q -j -o yy-thunks.zip 'objs/x86/YY_Thunks_for_WinXP.obj' -d 3rdparty/yy-thunks + rm yy-thunks.zip fi curl -L https://github.com/FWGS/potential-meme/releases/download/prebuilts/mingw-w64-x86_64-pkgconf-1.2.3.0-1-any.pkg.tar.zst -o pkgconf.tar.zst diff --git a/utils/mdldec/wscript b/utils/mdldec/wscript index 790cc61a..07d2d900 100644 --- a/utils/mdldec/wscript +++ b/utils/mdldec/wscript @@ -19,7 +19,7 @@ def build(bld): bld.program(source = bld.path.ant_glob('*.c'), target = 'mdldec', includes = '.', - use = 'engine_includes public M werror', + use = 'engine_includes public M werror yy_thunks', install_path = bld.env.BINDIR, subsystem = bld.env.CONSOLE_SUBSYSTEM ) diff --git a/utils/xar/wscript b/utils/xar/wscript index f1c7a1dc..9634148e 100644 --- a/utils/xar/wscript +++ b/utils/xar/wscript @@ -12,7 +12,7 @@ def build(bld): bld.program(source = bld.path.ant_glob('*.c'), target = 'xar', includes = '.', - use = 'public filesystem_includes werror', + use = 'public filesystem_includes werror yy_thunks', rpath = bld.env.DEFAULT_RPATH, install_path = bld.env.BINDIR, subsystem = bld.env.CONSOLE_SUBSYSTEM diff --git a/wscript b/wscript index e042f1f2..5ea70995 100644 --- a/wscript +++ b/wscript @@ -85,6 +85,7 @@ SUBDIRS = [ Subproject('stub/server'), Subproject('3rdparty/libbacktrace'), Subproject('3rdparty/library_suffix'), + Subproject('3rdparty/yy-thunks'), # disable only by engine feature, makes no sense to even parse subprojects in dedicated mode Subproject('3rdparty/extras', lambda x: x.env.CLIENT and x.env.DEST_OS != 'android'),