174 lines
4.8 KiB
Meson
174 lines
4.8 KiB
Meson
project('voyage', 'c',
|
|
default_options: ['buildtype=debug', 'b_sanitize=address', 'c_std=c17', 'warning_level=3'])
|
|
|
|
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(['-DVY_STATIC_LIB'], language : 'c')
|
|
endif
|
|
|
|
if get_option('error_report_debugbreak')
|
|
add_project_arguments(['-DVY_ERROR_REPORT_DEBUGBREAK'], language : 'c')
|
|
endif
|
|
|
|
# Debug specific flags
|
|
if buildtype == 'debug' or buildtype == 'debugoptimized'
|
|
add_project_arguments([ '-DVY_DEBUG'], language : 'c')
|
|
endif
|
|
|
|
# Gather dependencies
|
|
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(['-DVY_USE_XLIB'], language : 'c')
|
|
endif
|
|
|
|
incdir = include_directories(['contrib', 'src'])
|
|
|
|
runtime_lib = library('vyrt',
|
|
# 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/gfx.h',
|
|
'src/runtime/jobs.h',
|
|
'src/runtime/renderer_api.h',
|
|
'src/runtime/runtime.h',
|
|
'src/runtime/threading.h',
|
|
|
|
'src/runtime/aio.c',
|
|
'src/runtime/app.c',
|
|
'src/runtime/buffer_manager.c',
|
|
'src/runtime/config.c',
|
|
'src/runtime/error_report.c',
|
|
'src/runtime/file_tab.c',
|
|
'src/runtime/gfx_main.c',
|
|
'src/runtime/jobs.c',
|
|
'src/runtime/runtime_cvars.c',
|
|
'src/runtime/text.c',
|
|
'src/runtime/threading_cond.c',
|
|
'src/runtime/threading_mutex.c',
|
|
'src/runtime/threading_thread.c',
|
|
|
|
# Contrib Sources
|
|
'contrib/xxhash/xxhash.c',
|
|
dependencies : [thread_dep, m_dep, windowing_dep],
|
|
include_directories : incdir,
|
|
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('vyvk',
|
|
# 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/gfx_pipelines.c',
|
|
|
|
# Contrib Sources
|
|
'contrib/volk/volk.h',
|
|
'contrib/volk/volk.c',
|
|
dependencies : [m_dep, vk_inc_dep, windowing_dep],
|
|
include_directories : incdir,
|
|
link_with : [runtime_lib],
|
|
c_pch : 'pch/vk_pch.h',
|
|
c_args : platform_defs)
|
|
|
|
static_renderer_lib = vk_renderer_lib
|
|
endif
|
|
|
|
shaderc_include = include_directories('contrib/shaderc/libshaderc/include')
|
|
shaderc_libdir = 'NONE'
|
|
if host_machine.system() == 'windows'
|
|
shaderc_libdir = meson.project_source_root() / 'contrib/shaderc/build-win/libshaderc/Release'
|
|
endif
|
|
|
|
# Asset Compiler Tool
|
|
executable('assetc',
|
|
'src/tools/assetc/assetmeta.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/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',
|
|
include_directories : [incdir, shaderc_include],
|
|
dependencies : [],
|
|
link_with : [runtime_lib],
|
|
link_args : ['-L'+shaderc_libdir, '-lshaderc_combined'],
|
|
win_subsystem : 'console')
|
|
|
|
# Game
|
|
game_link_libs = []
|
|
if get_option('default_library') == 'static'
|
|
game_link_libs = [runtime_lib, static_renderer_lib]
|
|
else
|
|
game_link_libs = [runtime_lib]
|
|
endif
|
|
|
|
executable('voyage',
|
|
'src/game/voyage.c',
|
|
include_directories : incdir,
|
|
link_with : game_link_libs,
|
|
win_subsystem : 'windows')
|
|
|
|
# Unit Tests
|
|
rttest_exe = executable('rttest',
|
|
'src/tests/rttest.c',
|
|
link_with : [runtime_lib],
|
|
include_directories : incdir,
|
|
win_subsystem : 'console')
|
|
test('runtime test', rttest_exe) |