scripts: waifulib: vgui: add option to disable vgui platform support checks, try to lookup DEST_CPU subdirectories for prebuilt library

This commit is contained in:
Alibek Omarov 2024-07-24 07:04:53 +03:00
parent 2396b2d4db
commit 173aa7333a

View file

@ -19,50 +19,71 @@ def options(opt):
grp.add_option('--vgui', action = 'store', dest = 'VGUI_DEV', default=vgui_dev_path, grp.add_option('--vgui', action = 'store', dest = 'VGUI_DEV', default=vgui_dev_path,
help = 'path to vgui-dev repo [default: %(default)s]') help = 'path to vgui-dev repo [default: %(default)s]')
grp.add_option('--enable-unsupported-vgui', action = 'store_true', dest = 'ENABLE_UNSUPPORTED_VGUI', default=False,
help = 'ignore all checks and allow link against anything [default: %(default)s]')
grp.add_option('--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', default=True, grp.add_option('--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', default=True,
help = 'skip checking VGUI sanity [default: %(default)s]' ) help = 'skip checking VGUI sanity [default: %(default)s]' )
return return
@conf @conf
def check_vgui(conf): def check_vgui(conf):
conf.start_msg('Does this architecture support VGUI?') if conf.env.DEST_CPU == 'x86' or (conf.env.DEST_CPU == 'x86_64' and not conf.options.ALLOW64):
vgui_dest_cpu = 'x86' # link with 32-bit binary when crosscompiling to 32-bit
else: vgui_dest_cpu = conf.env.DEST_CPU
if conf.env.DEST_CPU != 'x86' and not (conf.env.DEST_CPU == 'x86_64' and not conf.options.ALLOW64): if not conf.options.ENABLE_UNSUPPORTED_VGUI:
conf.end_msg('no') conf.start_msg('Does this architecture support VGUI?')
Logs.warn('vgui is not supported on this CPU: ' + str(conf.env.DEST_CPU))
return False
else: conf.end_msg('yes')
conf.start_msg('Does this OS support VGUI?') if vgui_dest_cpu != 'x86':
if conf.env.DEST_OS not in VGUI_SUPPORTED_OS: conf.end_msg('no')
conf.end_msg('no') Logs.warn('vgui is not supported on this CPU: ' + str(vgui_dest_cpu))
Logs.warn('vgui is not supported on this OS: ' + str(conf.env.DEST_OS)) return False
return False else: conf.end_msg('yes')
else: conf.end_msg('yes')
conf.start_msg('Does this toolchain able to link VGUI?') conf.start_msg('Does this OS support VGUI?')
if conf.env.DEST_OS == 'win32' and conf.env.COMPILER_CXX == 'g++': if conf.env.DEST_OS not in VGUI_SUPPORTED_OS:
conf.end_msg('no') conf.end_msg('no')
# we have ABI incompatibility ONLY on MinGW Logs.warn('vgui is not supported on this OS: ' + str(conf.env.DEST_OS))
Logs.warn('vgui can\'t be linked with MinGW') return False
return False else: conf.end_msg('yes')
else: conf.end_msg('yes')
conf.start_msg('Does this toolchain able to link VGUI?')
if conf.env.DEST_OS == 'win32' and conf.env.COMPILER_CXX == 'g++':
conf.end_msg('no')
# we have ABI incompatibility ONLY on MinGW
Logs.warn('vgui can\'t be linked with MinGW')
return False
else: conf.end_msg('yes')
conf.start_msg('Configuring VGUI by provided path') conf.start_msg('Configuring VGUI by provided path')
vgui_dev = conf.options.VGUI_DEV vgui_dev = conf.options.VGUI_DEV
libpath = os.path.abspath(os.path.join(vgui_dev, 'lib'))
if conf.env.DEST_OS == 'win32': if conf.env.DEST_OS == 'win32':
conf.env.LIB_VGUI = ['vgui'] conf.env.LIB_VGUI = ['vgui']
conf.env.LIBPATH_VGUI = [os.path.abspath(os.path.join(vgui_dev, 'lib/win32_vc6/'))] libpath = os.path.join(libpath, 'win32_vc6')
else: if vgui_dest_cpu != 'x86':
libpath = os.path.abspath(os.path.join(vgui_dev, 'lib')) # for 32-bit x86 it's expected to be under win32_vc6
if conf.env.DEST_OS == 'linux': # for others, it's expected to be under win32_vc6 subdirectory matching CPU arch (x86_64 for 64-bit CPUs)
conf.env.LIB_VGUI = [':vgui.so'] libpath = os.path.join(libpath, vgui_dest_cpu)
conf.env.LIBPATH_VGUI = [libpath] conf.env.LIBPATH_VGUI = [libpath]
elif conf.env.DEST_OS == 'darwin': elif conf.env.DEST_OS == 'linux':
conf.env.LDFLAGS_VGUI = [os.path.join(libpath, 'vgui.dylib')] conf.env.LIB_VGUI = [':vgui.so']
if vgui_dest_cpu != 'x86':
libpath = os.path.join(libpath, vgui_dest_cpu)
conf.env.LIBPATH_VGUI = [libpath]
elif conf.env.DEST_OS == 'darwin':
if vgui_dest_cpu != 'x86':
conf.env.LDFLAGS_VGUI = [os.path.join(libpath, vgui_dest_cpu, 'vgui.dylib')]
else: else:
conf.fatal('vgui is not supported on this OS: ' + conf.env.DEST_OS) conf.env.LDFLAGS_VGUI = [os.path.join(libpath, 'vgui.dylib')]
else:
# TODO: figure out what to do here
conf.env.LIB_VGUI = ['vgui']
conf.env.LIBPATH_VGUI = [os.path.join(libpath, conf.env.DEST_OS, vgui_dest_cpu)]
conf.env.INCLUDES_VGUI = [os.path.abspath(os.path.join(vgui_dev, 'include'))] conf.env.INCLUDES_VGUI = [os.path.abspath(os.path.join(vgui_dev, 'include'))]
conf.env.HAVE_VGUI = 1 conf.env.HAVE_VGUI = 1