forked from FWGS/Paranoia2
169 lines
4.6 KiB
Python
169 lines
4.6 KiB
Python
#! /usr/bin/env python
|
|
# encoding: utf-8
|
|
# a1batross, mittorn, 2018
|
|
|
|
from waflib import Utils
|
|
import os
|
|
|
|
VGUI_SUPPORTED_OS = ['win32', 'darwin', 'linux']
|
|
|
|
def options(opt):
|
|
grp = opt.add_option_group('VGUI options')
|
|
grp.add_option('--vgui', action = 'store', dest = 'VGUI_DEV', default='utils/vgui',
|
|
help = 'path to vgui-dev repo [default: %default]')
|
|
|
|
grp.add_option('--disable-vgui', action = 'store_true', dest = 'NO_VGUI', default = False,
|
|
help = 'disable vgui_support [default: %default]')
|
|
|
|
grp.add_option('--skip-vgui-sanity-check', action = 'store_false', dest = 'VGUI_SANITY_CHECK', default=False,
|
|
help = 'skip checking VGUI sanity [default: %default]' )
|
|
return
|
|
|
|
def configure(conf):
|
|
conf.env.NO_VGUI = conf.options.NO_VGUI
|
|
if conf.options.NO_VGUI:
|
|
return
|
|
|
|
conf.start_msg('Does this architecture support VGUI?')
|
|
|
|
if conf.env.DEST_CPU != 'x86' and not (conf.env.DEST_CPU == 'x86_64' and not conf.options.ALLOW64):
|
|
conf.end_msg('no')
|
|
Logs.warn('vgui is not supported on this CPU: ' + str(conf.env.DEST_CPU))
|
|
conf.env.NO_VGUI = True
|
|
return
|
|
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))
|
|
conf.env.NO_VGUI = True
|
|
return
|
|
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_support can\'t be built with MinGW')
|
|
conf.env.NO_VGUI = True
|
|
return
|
|
else:
|
|
conf.end_msg('yes')
|
|
|
|
if conf.env.NO_VGUI:
|
|
return
|
|
|
|
if conf.options.VGUI_DEV:
|
|
conf.start_msg('Configuring VGUI by provided path')
|
|
conf.env.VGUI_DEV = conf.options.VGUI_DEV
|
|
else:
|
|
conf.start_msg('Configuring VGUI by default path')
|
|
conf.env.VGUI_DEV = 'vgui-dev'
|
|
|
|
if conf.env.DEST_OS == 'win32':
|
|
conf.env.LIB_VGUI = ['vgui']
|
|
conf.env.LIBPATH_VGUI = [os.path.abspath(os.path.join(conf.env.VGUI_DEV, 'lib/win32_vc6/'))]
|
|
else:
|
|
libpath = os.path.abspath(os.path.join(conf.env.VGUI_DEV, 'lib'))
|
|
if conf.env.DEST_OS == 'linux':
|
|
conf.env.LIB_VGUI = [':vgui.so']
|
|
conf.env.LIBPATH_VGUI = [libpath]
|
|
elif conf.env.DEST_OS == 'darwin':
|
|
conf.env.LDFLAGS_VGUI = [os.path.join(libpath, 'vgui.dylib')]
|
|
else:
|
|
conf.fatal('vgui is not supported on this OS: ' + conf.env.DEST_OS)
|
|
conf.env.INCLUDES_VGUI = [os.path.abspath(os.path.join(conf.env.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='''
|
|
#include <VGUI.h>
|
|
int main( int argc, char **argv )
|
|
{
|
|
return 0;
|
|
}''',
|
|
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.")
|
|
|
|
if conf.env.DEST_OS != 'win32':
|
|
conf.check_cc(lib='dl')
|
|
else:
|
|
conf.check_cxx(lib='user32')
|
|
|
|
def build(bld):
|
|
source = bld.path.ant_glob([
|
|
'render/*.cpp',
|
|
'*.cpp'
|
|
])
|
|
source += bld.path.parent.ant_glob([
|
|
'game_shared/bone_setup.cpp',
|
|
'game_shared/common.cpp',
|
|
'game_shared/ikcontext.cpp',
|
|
'game_shared/jigglebones.cpp',
|
|
'game_shared/material.cpp',
|
|
'game_shared/mathlib.cpp',
|
|
'game_shared/matrix.cpp',
|
|
'game_shared/procbones.cpp',
|
|
'game_shared/stringlib.cpp',
|
|
'game_shared/virtualfs.cpp',
|
|
'game_shared/vgui_checkbutton2.cpp',
|
|
'game_shared/vgui_grid.cpp',
|
|
'game_shared/vgui_helpers.cpp',
|
|
'game_shared/vgui_listbox.cpp',
|
|
'game_shared/vgui_loadtga.cpp',
|
|
'game_shared/vgui_scrollbar2.cpp',
|
|
'game_shared/vgui_slider2.cpp',
|
|
'game_shared/voice_banmgr.cpp',
|
|
'game_shared/voice_status.cpp',
|
|
'game_shared/voice_vgui_tweakdlg.cpp',
|
|
'pm_shared/*.cpp'
|
|
])
|
|
|
|
includes = [
|
|
'.',
|
|
'render/',
|
|
'../dlls',
|
|
'../common',
|
|
'../engine',
|
|
'../pm_shared',
|
|
'../game_shared',
|
|
'../public'
|
|
]
|
|
|
|
defines = ['CLIENT_DLL']
|
|
|
|
libs = ['VGUI']
|
|
if bld.env.DEST_OS != 'win32':
|
|
libs += ['DL']
|
|
else:
|
|
libs += ["USER32"]
|
|
|
|
if bld.env.DEST_OS not in ['android', 'dos']:
|
|
install_path = os.path.join(bld.env.GAMEDIR, bld.env.CLIENT_DIR)
|
|
else:
|
|
install_path = bld.env.PREFIX
|
|
|
|
bld.shlib(
|
|
source = source,
|
|
target = 'client' + bld.env.POSTFIX,
|
|
name = 'client',
|
|
features = 'c cxx',
|
|
includes = includes,
|
|
defines = defines,
|
|
use = libs,
|
|
install_path = install_path,
|
|
subsystem = bld.env.MSVC_SUBSYSTEM,
|
|
idx = bld.get_taskgen_count()
|
|
)
|
|
|