2021-01-03 02:52:53 +01:00
|
|
|
#! /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')
|
2021-06-07 08:36:37 +02:00
|
|
|
|
|
|
|
grp.add_option('--disable-vulkan', action='store_false', dest='VK', default=True,
|
2021-12-09 23:01:28 +01:00
|
|
|
help = 'disable vulkan [default: %default]')
|
2021-06-07 08:36:37 +02:00
|
|
|
|
2021-12-09 23:01:28 +01:00
|
|
|
grp.add_option('--aftermath', action='store', dest = 'NSIGHT_AFTERMATH_SDK', default = None,
|
|
|
|
help = 'path to Nvidia Nsight Aftermath SDK (optional) [default: %default]')
|
2021-01-03 02:52:53 +01:00
|
|
|
|
|
|
|
def configure(conf):
|
|
|
|
# check for dedicated server build
|
|
|
|
if conf.options.DEDICATED:
|
|
|
|
return
|
|
|
|
|
2021-06-07 08:36:37 +02:00
|
|
|
conf.env.VK = conf.options.VK
|
|
|
|
|
|
|
|
if not conf.env.VK:
|
2021-06-07 08:00:05 +02:00
|
|
|
return
|
|
|
|
|
2021-02-22 08:28:33 +01:00
|
|
|
if conf.env.DEST_OS == 'win32':
|
|
|
|
conf.start_msg('Vulkan SDK available?')
|
|
|
|
if not 'VULKAN_SDK' in conf.environ:
|
2021-06-07 18:55:33 +02:00
|
|
|
conf.error('VULKAN_SDK environment variable is not available, ref_vk will not be built')
|
2021-02-22 08:28:33 +01:00
|
|
|
conf.end_msg('no')
|
|
|
|
conf.env.VULKAN_SDK = conf.environ['VULKAN_SDK']
|
2021-06-07 19:14:04 +02:00
|
|
|
if not os.path.isdir(conf.env.VULKAN_SDK):
|
|
|
|
conf.error(conf.env.VULKAN_SDK + ' is not a valid directory')
|
2021-02-22 08:28:33 +01:00
|
|
|
conf.end_msg('found at ' + conf.env.VULKAN_SDK)
|
|
|
|
|
2021-06-07 18:55:33 +02:00
|
|
|
conf.load('glslc')
|
|
|
|
|
|
|
|
conf.define('REF_DLL', 1)
|
|
|
|
|
2021-05-22 23:01:43 +02:00
|
|
|
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))
|
|
|
|
|
2021-05-26 18:35:36 +02:00
|
|
|
# TODO if debug
|
2021-05-22 23:01:43 +02:00
|
|
|
conf.env.GLSLCFLAGS += ['-g']
|
|
|
|
|
2021-12-10 00:55:26 +01:00
|
|
|
if '-Werror=declaration-after-statement' in conf.env.CFLAGS:
|
|
|
|
conf.env.CFLAGS.remove('-Werror=declaration-after-statement')
|
|
|
|
|
2022-05-14 22:36:33 +02:00
|
|
|
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'))
|
|
|
|
|
2021-01-03 02:52:53 +01:00
|
|
|
def build(bld):
|
2021-06-07 08:36:37 +02:00
|
|
|
if not bld.env.VK:
|
|
|
|
return
|
|
|
|
|
2021-01-03 02:52:53 +01:00
|
|
|
libs = [ 'public', 'M' ]
|
2021-05-22 23:01:43 +02:00
|
|
|
defines = []
|
|
|
|
libpath = []
|
2021-01-03 02:52:53 +01:00
|
|
|
|
|
|
|
source = bld.path.ant_glob(['*.c'])
|
2021-12-09 23:01:28 +01:00
|
|
|
glsl_source = bld.path.ant_glob(['shaders/*.vert', 'shaders/*.frag', 'shaders/*.comp'])
|
|
|
|
rtx_glsl_source = bld.path.ant_glob(['shaders/*.rgen', 'shaders/*.rchit', 'shaders/*.rmiss', 'shaders/*.rahit'])
|
2021-01-03 02:52:53 +01:00
|
|
|
|
|
|
|
includes = ['.',
|
2022-08-08 09:23:38 +02:00
|
|
|
'../filesystem',
|
2021-01-03 02:52:53 +01:00
|
|
|
'../engine',
|
|
|
|
'../engine/common',
|
|
|
|
'../engine/server',
|
|
|
|
'../engine/client',
|
|
|
|
'../public',
|
|
|
|
'../common',
|
|
|
|
'../pm_shared' ]
|
|
|
|
|
2021-02-22 08:28:33 +01:00
|
|
|
if bld.env.DEST_OS == 'win32':
|
|
|
|
includes.append(bld.env.VULKAN_SDK + '\\Include')
|
|
|
|
|
2021-05-22 23:01:43 +02:00
|
|
|
if bld.env.HAVE_AFTERMATH:
|
|
|
|
defines.append('USE_AFTERMATH')
|
|
|
|
libs.append('AFTERMATH')
|
|
|
|
|
2021-07-06 18:41:48 +02:00
|
|
|
if bld.env.COMPILER_CC == 'msvc':
|
|
|
|
bld.env.CFLAGS += ['/WX']
|
2021-05-26 18:35:36 +02:00
|
|
|
|
2021-01-03 02:52:53 +01:00
|
|
|
bld.shlib(
|
|
|
|
source = source,
|
|
|
|
target = 'ref_vk',
|
|
|
|
features = 'c',
|
|
|
|
includes = includes,
|
2021-05-22 23:01:43 +02:00
|
|
|
use = libs,
|
|
|
|
defines = defines,
|
|
|
|
libpath = libpath,
|
2021-01-03 02:52:53 +01:00
|
|
|
install_path = bld.env.LIBDIR,
|
|
|
|
subsystem = bld.env.MSVC_SUBSYSTEM
|
|
|
|
)
|
|
|
|
|
2021-01-18 23:24:05 +01:00
|
|
|
bld(
|
|
|
|
source = glsl_source,
|
|
|
|
features = 'glsl',
|
|
|
|
# includes = 'shaders/', # write your includes here
|
|
|
|
# defines = 'TEST', # write your C preprocessor defines here
|
2021-06-07 08:36:37 +02:00
|
|
|
install_path = bld.env.LIBDIR + '/valve' # FIXME TEMPORARY!!!!
|
2021-01-18 23:24:05 +01:00
|
|
|
)
|
|
|
|
|
2021-12-09 23:01:28 +01:00
|
|
|
bld(
|
|
|
|
source = rtx_glsl_source,
|
|
|
|
features = 'glsl',
|
|
|
|
install_path = bld.env.LIBDIR + '/valve', # FIXME TEMPORARY!!!!
|
|
|
|
glslcflags = '--target-env=vulkan1.2'
|
|
|
|
)
|
|
|
|
|
2022-03-21 20:00:02 +01:00
|
|
|
bld.install_files(bld.env.LIBDIR,
|
|
|
|
bld.path.ant_glob('data/**'),
|
|
|
|
cwd=bld.path.find_dir('data/'),
|
2022-05-14 22:36:33 +02:00
|
|
|
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)
|