2023-04-17 04:20:22 +02:00
|
|
|
#! /usr/bin/env python
|
|
|
|
# encoding: utf-8
|
|
|
|
# mittorn, 2018
|
|
|
|
|
|
|
|
from waflib.Configure import conf
|
2023-04-17 05:32:37 +02:00
|
|
|
from waflib import Logs
|
2023-04-17 04:20:22 +02:00
|
|
|
import os
|
|
|
|
|
|
|
|
VGUI_SUPPORTED_OS = ['win32', 'darwin', 'linux']
|
|
|
|
|
|
|
|
VGUI_FRAGMENT = '''#include <VGUI.h>
|
|
|
|
int main() { return 0; }'''
|
|
|
|
|
|
|
|
def options(opt):
|
|
|
|
grp = opt.add_option_group('VGUI options')
|
|
|
|
|
|
|
|
vgui_dev_path = os.path.join(opt.path.path_from(opt.root), 'vgui-dev')
|
|
|
|
|
|
|
|
grp.add_option('--vgui', action = 'store', dest = 'VGUI_DEV', default=vgui_dev_path,
|
2024-05-25 03:58:28 +02:00
|
|
|
help = 'path to vgui-dev repo [default: %(default)s]')
|
2023-04-17 04:20:22 +02:00
|
|
|
|
2024-07-24 06:04:53 +02:00
|
|
|
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]')
|
|
|
|
|
2023-04-17 04:20:22 +02:00
|
|
|
grp.add_option('--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', default=True,
|
2024-05-25 03:58:28 +02:00
|
|
|
help = 'skip checking VGUI sanity [default: %(default)s]' )
|
2023-04-17 04:20:22 +02:00
|
|
|
return
|
|
|
|
|
|
|
|
@conf
|
|
|
|
def check_vgui(conf):
|
2024-08-11 17:08:20 +02:00
|
|
|
if conf.env.DEST_CPU == 'x86' or (conf.env.DEST_CPU == 'x86_64' and conf.env.DEST_SIZEOF_VOID_P == 4):
|
2024-07-24 06:04:53 +02:00
|
|
|
vgui_dest_cpu = 'x86' # link with 32-bit binary when crosscompiling to 32-bit
|
|
|
|
else: vgui_dest_cpu = conf.env.DEST_CPU
|
|
|
|
|
|
|
|
if not conf.options.ENABLE_UNSUPPORTED_VGUI:
|
|
|
|
conf.start_msg('Does this architecture support VGUI?')
|
|
|
|
|
|
|
|
if vgui_dest_cpu != 'x86':
|
|
|
|
conf.end_msg('no')
|
|
|
|
Logs.warn('vgui is not supported on this CPU: ' + str(vgui_dest_cpu))
|
|
|
|
return False
|
|
|
|
else: conf.end_msg('yes')
|
|
|
|
|
|
|
|
conf.start_msg('Does this OS support VGUI?')
|
|
|
|
if conf.env.DEST_OS not in VGUI_SUPPORTED_OS:
|
|
|
|
conf.end_msg('no')
|
|
|
|
Logs.warn('vgui is not supported on this OS: ' + str(conf.env.DEST_OS))
|
|
|
|
return False
|
|
|
|
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')
|
2023-04-17 04:20:22 +02:00
|
|
|
|
|
|
|
conf.start_msg('Configuring VGUI by provided path')
|
|
|
|
vgui_dev = conf.options.VGUI_DEV
|
|
|
|
|
2024-07-24 06:04:53 +02:00
|
|
|
libpath = os.path.abspath(os.path.join(vgui_dev, 'lib'))
|
|
|
|
|
2023-04-17 04:20:22 +02:00
|
|
|
if conf.env.DEST_OS == 'win32':
|
|
|
|
conf.env.LIB_VGUI = ['vgui']
|
2024-07-24 06:04:53 +02:00
|
|
|
libpath = os.path.join(libpath, 'win32_vc6')
|
|
|
|
if vgui_dest_cpu != 'x86':
|
|
|
|
# for 32-bit x86 it's expected to be under win32_vc6
|
|
|
|
# for others, it's expected to be under win32_vc6 subdirectory matching CPU arch (x86_64 for 64-bit CPUs)
|
|
|
|
libpath = os.path.join(libpath, vgui_dest_cpu)
|
|
|
|
conf.env.LIBPATH_VGUI = [libpath]
|
|
|
|
elif conf.env.DEST_OS == 'linux':
|
|
|
|
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')]
|
2023-04-17 04:20:22 +02:00
|
|
|
else:
|
2024-07-24 06:04:53 +02:00
|
|
|
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)]
|
|
|
|
|
2023-04-17 04:20:22 +02:00
|
|
|
conf.env.INCLUDES_VGUI = [os.path.abspath(os.path.join(vgui_dev, 'include'))]
|
|
|
|
|
|
|
|
conf.env.HAVE_VGUI = 1
|
|
|
|
conf.end_msg('yes: {0}, {1}, {2}'.format(conf.env.LIB_VGUI, conf.env.LIBPATH_VGUI, conf.env.INCLUDES_VGUI))
|
|
|
|
|
|
|
|
if conf.env.HAVE_VGUI and conf.options.VGUI_SANITY_CHECK:
|
|
|
|
try:
|
|
|
|
conf.check_cxx(fragment=VGUI_FRAGMENT,
|
|
|
|
msg = 'Checking for library VGUI sanity',
|
|
|
|
use = 'VGUI',
|
|
|
|
execute = False)
|
|
|
|
except conf.errors.ConfigurationError:
|
|
|
|
conf.fatal("Can't compile simple program. Check your path to vgui-dev repository.")
|
|
|
|
|
|
|
|
return True
|