wscript: add yy-thunks library to help support the holy cow of windows users

This commit is contained in:
Alibek Omarov
2026-06-21 09:41:12 +05:00
parent 57206b3651
commit 3366ad06d0
14 changed files with 76 additions and 10 deletions

View File

@@ -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 }}

59
3rdparty/yy-thunks/wscript vendored Normal file
View File

@@ -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')

View File

@@ -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

View File

@@ -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':

View File

@@ -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

View File

@@ -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' ]

View File

@@ -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
)

View File

@@ -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' ]

View File

@@ -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

View File

@@ -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
)

View File

@@ -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

View File

@@ -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'),