mirror of
https://github.com/w23/xash3d-fwgs
synced 2024-12-15 13:41:33 +01:00
165 lines
4.5 KiB
Python
165 lines
4.5 KiB
Python
#! /usr/bin/env python
|
|
# encoding: utf-8
|
|
# mittorn, 2018
|
|
|
|
from waflib import Logs
|
|
import os
|
|
|
|
top = '.'
|
|
|
|
def options(opt):
|
|
grp = opt.add_option_group('ref_vk options')
|
|
|
|
grp.add_option('--disable-vulkan', action='store_false', dest='VK', default=True,
|
|
help = 'disable vulkan [default: %default]')
|
|
|
|
grp.add_option('--aftermath', action='store', dest = 'NSIGHT_AFTERMATH_SDK', default = None,
|
|
help = 'path to Nvidia Nsight Aftermath SDK (optional) [default: %default]')
|
|
|
|
def configure(conf):
|
|
# check for dedicated server build
|
|
if conf.options.DEDICATED:
|
|
return
|
|
|
|
conf.env.VK = conf.options.VK
|
|
|
|
if not conf.env.VK:
|
|
return
|
|
|
|
if conf.env.DEST_OS == 'win32':
|
|
conf.start_msg('Vulkan SDK available?')
|
|
if not 'VULKAN_SDK' in conf.environ:
|
|
conf.error('VULKAN_SDK environment variable is not available, ref_vk will not be built')
|
|
conf.end_msg('no')
|
|
conf.env.VULKAN_SDK = conf.environ['VULKAN_SDK']
|
|
if not os.path.isdir(conf.env.VULKAN_SDK):
|
|
conf.error(conf.env.VULKAN_SDK + ' is not a valid directory')
|
|
conf.end_msg('found at ' + conf.env.VULKAN_SDK)
|
|
|
|
conf.load('glslc')
|
|
conf.load('sebastian')
|
|
|
|
conf.define('REF_DLL', 1)
|
|
|
|
if conf.options.NSIGHT_AFTERMATH_SDK:
|
|
conf.start_msg('Nvidia Nsight Aftermath SDK')
|
|
conf.env.HAVE_AFTERMATH = 1
|
|
path = conf.options.NSIGHT_AFTERMATH_SDK
|
|
conf.env.INCLUDES_AFTERMATH = [os.path.abspath(os.path.join(path, 'include'))]
|
|
libdir = 'lib'
|
|
lib = 'GFSDK_Aftermath_Lib'
|
|
if conf.env.COMPILER_CC == 'msvc':
|
|
if conf.env.DEST_CPU == 'x86_64':
|
|
libdir = 'lib/x64'
|
|
lib += '.x64'
|
|
else:
|
|
libdir = 'lib/' + conf.env.DEST_CPU
|
|
lib += conf.env.DEST_CPU
|
|
libdir = os.path.abspath(os.path.join(path, libdir))
|
|
conf.env.LIBPATH_AFTERMATH = [libdir]
|
|
conf.env.LIB_AFTERMATH = [lib]
|
|
conf.end_msg('SDK: {0}, includes: {1}, libpath: {2}, lib: {3}'.format(path, conf.env.INCLUDES_AFTERMATH, conf.env.LIBPATH_AFTERMATH, conf.env.LIB_AFTERMATH))
|
|
|
|
# TODO if debug
|
|
conf.env.GLSLCFLAGS += ['-g', '-O']
|
|
|
|
if '-Werror=declaration-after-statement' in conf.env.CFLAGS:
|
|
conf.env.CFLAGS.remove('-Werror=declaration-after-statement')
|
|
|
|
def printTestSummary(bld):
|
|
results = getattr(bld, 'utest_results', [])
|
|
for (f, code, out, err) in results:
|
|
if code == 0:
|
|
Logs.pprint('GREEN', '%s: ok' % f)
|
|
continue
|
|
|
|
Logs.pprint('RED', '%s: test failed' % f)
|
|
Logs.pprint('CYAN', out.decode('utf-8'))
|
|
Logs.pprint('CYAN', err.decode('utf-8'))
|
|
|
|
def build(bld):
|
|
if not bld.env.VK:
|
|
return
|
|
|
|
libs = [ 'engine_includes', 'public', 'M' ]
|
|
defines = []
|
|
libpath = []
|
|
|
|
source = bld.path.ant_glob(['*.c'])
|
|
glsl_source = bld.path.ant_glob(['shaders/*.vert', 'shaders/*.frag'])
|
|
rtx_glsl_source = bld.path.ant_glob(['shaders/*.rgen', 'shaders/*.rchit', 'shaders/*.rmiss', 'shaders/*.rahit', 'shaders/*.comp'])
|
|
|
|
meatpipes = bld.path.ant_glob(['shaders/*.json'])
|
|
|
|
includes = ['.',
|
|
'../filesystem',
|
|
'../engine',
|
|
'../engine/common',
|
|
'../engine/server',
|
|
'../engine/client',
|
|
'../public',
|
|
'../common',
|
|
'../pm_shared' ]
|
|
|
|
if bld.env.DEST_OS == 'win32':
|
|
includes.append(bld.env.VULKAN_SDK + '\\Include')
|
|
includes.append(bld.env.VULKAN_SDK + '\\Source\SPIRV-Reflect\include') # for spirv.h
|
|
|
|
if bld.env.HAVE_AFTERMATH:
|
|
defines.append('USE_AFTERMATH')
|
|
libs.append('AFTERMATH')
|
|
for file in ['GFSDK_Aftermath_Lib.x64.dll', 'llvm_7_0_1.dll']:
|
|
bld.install_files(
|
|
bld.env.LIBDIR,
|
|
bld.root.find_dir(bld.env.LIBPATH_AFTERMATH[0]).find_node(file))
|
|
|
|
if bld.env.COMPILER_CC == 'msvc':
|
|
bld.env.CFLAGS += ['/WX']
|
|
else:
|
|
bld.env.CFLAGS += ['-Werror'] # TODO , '-Wall']
|
|
|
|
bld.shlib(
|
|
source = source,
|
|
target = 'ref_vk',
|
|
features = 'c',
|
|
includes = includes,
|
|
use = libs,
|
|
defines = defines,
|
|
libpath = libpath,
|
|
install_path = bld.env.LIBDIR,
|
|
subsystem = bld.env.MSVC_SUBSYSTEM
|
|
)
|
|
|
|
bld(
|
|
source = glsl_source,
|
|
features = 'glsl',
|
|
# includes = 'shaders/', # write your includes here
|
|
# defines = 'TEST', # write your C preprocessor defines here
|
|
install_path = bld.env.LIBDIR + '/valve' # FIXME TEMPORARY!!!!
|
|
)
|
|
|
|
bld(
|
|
source = rtx_glsl_source,
|
|
features = 'glsl',
|
|
glslcflags = '--target-env=vulkan1.2'
|
|
)
|
|
|
|
bld(
|
|
source = meatpipes,
|
|
features = 'sebastian',
|
|
install_path = bld.env.LIBDIR + '/valve'
|
|
)
|
|
#print(things.tasks())
|
|
#bld.install_files(bld.env.LIBDIR + '/valve', things)
|
|
|
|
bld.install_files(bld.env.LIBDIR,
|
|
bld.path.ant_glob('data/**'),
|
|
cwd=bld.path.find_dir('data/'),
|
|
relative_trick=True)
|
|
|
|
#bld.program(features='test', defines=['ALOLCATOR_TEST'],source='alolcator.c', target='alolcator')
|
|
bld.add_post_fun(printTestSummary)
|
|
|
|
#from waflib.Tools import waf_unit_test
|
|
#bld.add_post_fun(waf_unit_test.summary)
|