Improve dll build

Still not perfect, but more user friendly now.
This commit is contained in:
Kevin Trogant 2024-02-08 16:57:01 +01:00
parent 058c738da9
commit 4f27819fa2
7 changed files with 41 additions and 12 deletions

View File

@ -45,6 +45,8 @@ if buildtype == 'debug' or buildtype == 'debugoptimized'
add_project_arguments([ '-DRT_DEBUG'], language : ['c', 'cpp']) add_project_arguments([ '-DRT_DEBUG'], language : ['c', 'cpp'])
endif endif
fs = import('fs')
# Gather dependencies # Gather dependencies
thread_dep = dependency('threads') thread_dep = dependency('threads')
m_dep = compiler.find_library('m', required : false) m_dep = compiler.find_library('m', required : false)
@ -63,6 +65,10 @@ engine_incdir = include_directories('src')
contrib_dir = meson.project_source_root() / 'contrib' contrib_dir = meson.project_source_root() / 'contrib'
# Targets append to this, to enable us to run shared library builds from IDEs
engine_lib_paths = []
engine_libs = []
subdir('src') subdir('src')
# Handle linking against both runtime and renderer if we build static libs # Handle linking against both runtime and renderer if we build static libs
@ -90,4 +96,12 @@ assetc_dep = declare_dependency(link_with : asset_compiler,
# "inline" game # "inline" game
if get_option('game_as_subdir') if get_option('game_as_subdir')
subdir('src/game') subdir('src/game')
# If we are building shared libraries, copy them to the games output directory.
# This ensures that we can debug with visual studio.
foreach lib_path : engine_lib_paths
run_target('copy'+fs.name(lib_path),
command : [copy_util, lib_path, join_paths(game_build_dir, fs.name(lib_path))],
depends : engine_libs)
endforeach
endif endif

View File

@ -1,5 +1,5 @@
#include "processor.h"
#include "description_parser.h" #include "description_parser.h"
#include "processor.h"
#include "shader_compiler.h" #include "shader_compiler.h"
#include "runtime/buffer_manager.h" #include "runtime/buffer_manager.h"
@ -10,8 +10,8 @@
#include <assert.h> #include <assert.h>
#include <limits.h> #include <limits.h>
#include <string.h>
#include <stdbool.h> #include <stdbool.h>
#include <string.h>
typedef struct { typedef struct {
rt_attribute_binding *uniform_bindings; rt_attribute_binding *uniform_bindings;
@ -39,7 +39,7 @@ enum {
RT_SHADER_NOT_PRESENT = RT_ASSET_PROCESSING_FAILED + 1 RT_SHADER_NOT_PRESENT = RT_ASSET_PROCESSING_FAILED + 1
}; };
extern rt_cvar rt_Renderer; extern RT_DLLIMPORT rt_cvar rt_Renderer;
static bool ParseBindingIndex(rt_text_span span, unsigned int *index) { static bool ParseBindingIndex(rt_text_span span, unsigned int *index) {
if (span.length == 0) if (span.length == 0)
@ -446,8 +446,10 @@ RT_ASSET_PROCESSOR_FN(PipelineProcessor) {
goto out; goto out;
rt_resource_id shader_resources[3] = {0}; rt_resource_id shader_resources[3] = {0};
result = rtCreateResources(pipeline.shader_count, pipeline.shader_names, pipeline.shaders, result = rtCreateResources(pipeline.shader_count,
shader_resources); pipeline.shader_names,
pipeline.shaders,
shader_resources);
if (result != RT_SUCCESS) if (result != RT_SUCCESS)
goto out; goto out;
@ -494,7 +496,7 @@ RT_ASSET_PROCESSOR_FN(PipelineProcessor) {
} }
rt_resource_id pipeline_id; rt_resource_id pipeline_id;
const char *name = rtGetFilePath(file); const char *name = rtGetFilePath(file);
result = rtCreateResources(1, &name, &pipeline_resource, &pipeline_id); result = rtCreateResources(1, &name, &pipeline_resource, &pipeline_id);
if (result == RT_SUCCESS) { if (result == RT_SUCCESS) {
new_resources[0] = pipeline_id; new_resources[0] = pipeline_id;
memcpy(&new_resources[1], shader_resources, sizeof(shader_resources)); memcpy(&new_resources[1], shader_resources, sizeof(shader_resources));

View File

@ -1,10 +1,13 @@
vy_link_libs = engine_link_libs vy_link_libs = engine_link_libs
vy_link_libs += asset_compiler vy_link_libs += asset_compiler
executable('voyage', game = executable('voyage',
'entry.c', 'entry.c',
'main.c', 'main.c',
link_with : vy_link_libs, link_with : vy_link_libs,
include_directories : engine_incdir, include_directories : engine_incdir,
c_pch : 'pch/game_pch.h', c_pch : 'pch/game_pch.h',
win_subsystem : 'windows') win_subsystem : 'windows',
install : true)
game_build_dir = fs.parent(game.full_path())

View File

@ -31,6 +31,10 @@ if vk_dep.found()
c_pch : 'pch/vk_pch.h', c_pch : 'pch/vk_pch.h',
c_args : platform_defs, c_args : platform_defs,
cpp_pch : 'pch/vk_pch.h', cpp_pch : 'pch/vk_pch.h',
cpp_args : platform_defs) cpp_args : platform_defs,
install : true)
engine_libs = vk_renderer_lib
engine_lib_paths += vk_renderer_lib.full_path()
endif endif

View File

@ -18,7 +18,7 @@ rt_renderer_api g_renderer;
static rt_dynlib _renderer_lib; static rt_dynlib _renderer_lib;
static bool _renderer_loaded = false; static bool _renderer_loaded = false;
RT_CVAR_S(rt_Renderer, "Select the render backend. Available options: [vk], Default: vk", "vk"); RT_DLLEXPORT RT_CVAR_S(rt_Renderer, "Select the render backend. Available options: [vk], Default: vk", "vk");
#ifdef RT_STATIC_LIB #ifdef RT_STATIC_LIB
extern void RT_RENDERER_API_FN(RegisterCVars)(void); extern void RT_RENDERER_API_FN(RegisterCVars)(void);

View File

@ -52,4 +52,8 @@ runtime_lib = library('rt',
contrib_dir / 'lz4/lz4.c', contrib_dir / 'lz4/lz4.c',
dependencies : runtime_deps, dependencies : runtime_deps,
include_directories : [engine_incdir, runtime_incdirs], include_directories : [engine_incdir, runtime_incdirs],
c_pch : 'pch/rt_pch.h') c_pch : 'pch/rt_pch.h',
install : true)
engine_libs += runtime_lib
engine_lib_paths += runtime_lib.full_path()

View File

@ -13,8 +13,10 @@ extern "C" {
#if defined(_MSC_VER) && !defined(RT_STATIC_LIB) #if defined(_MSC_VER) && !defined(RT_STATIC_LIB)
#define RT_DLLEXPORT __declspec(dllexport) #define RT_DLLEXPORT __declspec(dllexport)
#define RT_DLLIMPORT __declspec(dllimport)
#else #else
#define RT_DLLEXPORT #define RT_DLLEXPORT
#define RT_DLLIMPORT
#endif #endif
#if defined(_MSC_VER) #if defined(_MSC_VER)