rtengine/meson.build
Kevin Trogant 3254af3786 Make progress towards the new builtin asset compiler
Attempts to compile HLSL shaders (with includes)
2024-01-25 09:45:23 +01:00

239 lines
6.8 KiB
Meson

project('voyage', 'c',
default_options: ['buildtype=debug',
'b_sanitize=address',
'c_std=c17',
'warning_level=3',
'werror=true',
'b_vscrt=static_from_buildtype'])
compiler = meson.get_compiler('c')
buildtype = get_option('buildtype')
# Build options
if compiler.get_argument_syntax() == 'gcc'
add_project_arguments(
['-Wconversion', '-Wno-sign-conversion',
'-Wdouble-promotion', '-Wno-unused-function', '-Wno-unused-parameter'],
language : 'c'
)
elif compiler.get_argument_syntax() == 'msvc'
add_project_arguments(
['/wd4146', '/wd4245', '/wd4100', '/D_CRT_SECURE_NO_WARNINGS'],
language: 'c'
)
if buildtype == 'debug'
add_project_arguments(['/RTCsu'], language : 'c')
endif
endif
if get_option('default_library') == 'static'
add_project_arguments(['-DRT_STATIC_LIB'], language : 'c')
endif
if get_option('error_report_debugbreak')
add_project_arguments(['-DRT_ERROR_REPORT_DEBUGBREAK'], language : 'c')
endif
# Debug specific flags
if buildtype == 'debug' or buildtype == 'debugoptimized'
add_project_arguments([ '-DRT_DEBUG'], language : 'c')
endif
# Gather dependencies
common_incdirs = [include_directories(['contrib', 'src'])]
thread_dep = dependency('threads')
m_dep = compiler.find_library('m', required : false)
vk_dep = dependency('vulkan', required : false)
windowing_dep = []
if get_option('use_xlib')
windowing_dep = dependency('x11', required : true)
add_project_arguments(['-DRT_USE_XLIB'], language : 'c')
endif
runtime_incdirs = common_incdirs
runtime_linkargs = []
runtime_additional_sources = []
runtime_cargs = []
runtime_deps = [thread_dep, m_dep, windowing_dep]
if get_option('build_asset_compiler')
runtime_cargs += ['-DRT_BUILD_ASSET_COMPILER']
# Shaderc for shaders
if get_option('enable_vulkan_shader_compiler')
shaderc_include = include_directories('contrib\\shaderc\\libshaderc\\include')
shaderc_libdir = 'NONE'
if host_machine.system() == 'windows'
if buildtype == 'debug' or buildtype == 'debugoptimized'
shaderc_libdir = meson.project_source_root() / 'contrib\\shaderc\\build-win\\libshaderc\\Debug'
else
shaderc_libdir = meson.project_source_root() / 'contrib\\shaderc\\build-win\\libshaderc\\Release'
endif
endif
shaderc_dep = declare_dependency(link_args : ['-L'+shaderc_libdir, '-lshaderc_combined'],
include_directories : shaderc_include)
runtime_deps += shaderc_dep
runtime_additional_sources += [
'src/runtime/vulkan_shader_compiler.c'
]
runtime_cargs += ['-DRT_BUILD_VULKAN_SHADER_COMPILER']
endif
# Asset compiler sources
runtime_additional_sources += [
'src/runtime/asset_compiler.h',
'src/runtime/description_parser.h',
'src/runtime/shader_compiler.h',
'src/runtime/asset_compiler.c',
'src/runtime/description_parser.c',
'src/runtime/pipeline_processor.c',
'src/runtime/shader_compiler.c',
]
endif
runtime_lib = library('rt',
# Project Sources
'src/runtime/aio.h',
'src/runtime/app.h',
'src/runtime/assets.h',
'src/runtime/buffer_manager.h',
'src/runtime/config.h',
'src/runtime/dynamic_libs.h',
'src/runtime/file_tab.h',
'src/runtime/fsutils.h',
'src/runtime/gfx.h',
'src/runtime/handles.h',
'src/runtime/hashing.h',
'src/runtime/jobs.h',
'src/runtime/mem_arena.h',
'src/runtime/packages.h',
'src/runtime/renderer_api.h',
'src/runtime/runtime.h',
'src/runtime/threading.h',
'src/runtime/aio.c',
'src/runtime/app.c',
'src/runtime/asset_manager.c',
'src/runtime/buffer_manager.c',
'src/runtime/config.c',
'src/runtime/dynamic_libs.c',
'src/runtime/error_report.c',
'src/runtime/file_tab.c',
'src/runtime/fsutils.c',
'src/runtime/gfx_main.c',
'src/runtime/hashing.c',
'src/runtime/init.c',
'src/runtime/jobs.c',
'src/runtime/mem_arena.c',
'src/runtime/packages.c',
'src/runtime/text.c',
'src/runtime/threading_cond.c',
'src/runtime/threading_mutex.c',
'src/runtime/threading_rwlock.c',
'src/runtime/threading_thread.c',
# Contrib Sources
'contrib/xxhash/xxhash.c',
'contrib/lz4/lz4.c',
sources : runtime_additional_sources,
dependencies : runtime_deps,
include_directories : runtime_incdirs,
link_args : runtime_linkargs,
c_args : runtime_cargs,
c_pch : 'pch/rt_pch.h')
# Renderer libraries
static_renderer_lib = 'NONE'
if vk_dep.found()
platform_defs = []
if get_option('use_xlib')
platform_defs = ['-DVK_USE_PLATFORM_XLIB_KHR']
elif host_machine.system() == 'windows'
platform_defs = ['-DVK_USE_PLATFORM_WIN32_KHR']
endif
vk_inc_dep = vk_dep.partial_dependency(compile_args : true, includes : true)
vk_renderer_lib = library('rtvk',
# Project Sources
'src/renderer/vk/gpu.h',
'src/renderer/vk/swapchain.h',
'src/renderer/vk/init.c',
'src/renderer/vk/swapchain.c',
'src/renderer/vk/pipelines.c',
# Contrib Sources
'contrib/volk/volk.h',
'contrib/volk/volk.c',
dependencies : [m_dep, vk_inc_dep, windowing_dep],
include_directories : common_incdirs,
link_with : [runtime_lib],
c_pch : 'pch/vk_pch.h',
c_args : platform_defs)
static_renderer_lib = vk_renderer_lib
endif
# Handle linking against both runtime and renderer if we build static libs
engine_link_libs = []
if get_option('default_library') == 'static'
engine_link_libs = [runtime_lib, static_renderer_lib]
else
engine_link_libs = [runtime_lib]
endif
# Asset Compiler Tool
#executable('assetc',
# 'src/tools/assetc/assetmeta.h',
# 'src/tools/assetc/assetsettings.h',
# 'src/tools/assetc/dependency_tracking.h',
# 'src/tools/assetc/description_parser.h',
# 'src/tools/assetc/options.h',
# 'src/tools/assetc/packages.h',
# 'src/tools/assetc/processing.h',
# 'src/tools/assetc/processing_flags.h',
# 'src/tools/assetc/utils.h',
#
# 'src/tools/assetc/assetc.c',
# 'src/tools/assetc/assetmeta.c',
# 'src/tools/assetc/assetsettings.c',
# 'src/tools/assetc/dependency_tracking.c',
# 'src/tools/assetc/description_parser.c',
# 'src/tools/assetc/discovery.c',
# 'src/tools/assetc/packages.c',
# 'src/tools/assetc/pipeline_processor.c',
# 'src/tools/assetc/processor.c',
# 'src/tools/assetc/shader_processor.c',
# 'src/tools/assetc/uidtable.c',
# 'src/tools/assetc/utils.c',
#
# # Contrib sources
# 'contrib/xxhash/xxhash.c',
# 'contrib/lz4/lz4.c',
# include_directories : [incdir, shaderc_include],
# dependencies : [],
# link_with : engine_link_libs,
# link_args : ['-L'+shaderc_libdir, '-lshaderc_combined'],
# win_subsystem : 'console')
# Game
executable('voyage',
'src/game/voyage.c',
include_directories : common_incdirs,
link_with : engine_link_libs,
win_subsystem : 'windows')
# Unit Tests
rttest_exe = executable('rttest',
'src/tests/rttest.c',
link_with : engine_link_libs,
include_directories : common_incdirs,
win_subsystem : 'console')
test('runtime test', rttest_exe)