Made iwa compile as an S++ library.

This commit is contained in:
Patrick 2024-04-12 21:07:53 +02:00
parent 1d44ecc0ee
commit ddb4f67735
5 changed files with 49 additions and 6 deletions

13
LibConf
View File

@ -33,7 +33,7 @@ lib_argparse = env.Cook('argparse', git_ref = 'refs/tags/v3.0')
lib_yaml_cpp = env.Cook('yaml-cpp', git_ref = 'refs/tags/0.8.0')
# Generated files
env.Jinja('public/iwa/util/vertex_attribute_semantic.gen.hpp')
env.Jinja('include/iwa/util/vertex_attribute_semantic.gen.hpp')
# Iwa
src_files = Split("""
@ -77,16 +77,21 @@ src_files = Split("""
source/util/vkutil.cpp
""")
include_dir = env.Dir('include')
env.Append(JINJA_TEMPLATE_SEARCHPATH = [env.Dir('data/jinja')])
env.Append(JINJA_CONFIG_SEARCHPATH = [env.Dir('data/config')])
lib_iwa = env.UnityStaticLibrary(
target = env['LIB_DIR'] + '/iwa',
source = src_files,
dependencies = [lib_fmt, lib_glslang, lib_glm, lib_magic_enum, lib_mijin, lib_sdl, lib_stb, lib_vulkan_headers,
lib_argparse, lib_yaml_cpp]
lib_argparse, lib_yaml_cpp],
CPPPATH = [include_dir]
)
LIB_CONFIG = {
'CPPPATH': [env.Dir('include')],
'DEPENDENCIES': [lib_iwa]
'CPPPATH': [include_dir],
'DEPENDENCIES': [lib_iwa],
}
Return('LIB_CONFIG')

12
data/config/iwa_enums.yml Normal file
View File

@ -0,0 +1,12 @@
# Data source for enums that are shared between CPP and GLSL
vertex_input_semantic:
cpp_type_name: VertexAttributeSemantic
glsl_prefix: IWA_VAS_
entries:
CUSTOM: 0
POSITION: 1
NORMAL: 2
TANGENT: 3
BITANGENT: 4
TEXCOORDS: 5
COLOR: 6

View File

@ -0,0 +1,26 @@
{%- set enum_config = 'iwa_enums' | load_config -%}
{% macro cpp_enum(name) -%}
enum class {{ enum_config[name].cpp_type_name }}
{
{%- for key, value in enum_config[name].entries.items(): %}
{{ key }} = {{ value }},
{%- endfor %}
};
inline mijin::Optional<{{ enum_config[name].cpp_type_name }}> {{ enum_config[name].cpp_type_name[0] | lower }}{{ enum_config[name].cpp_type_name[1:] }}FromString(std::string_view name)
{
{%- for key in enum_config[name].entries.keys(): %}
if (name == "{{ key | lower }}") {
return {{ enum_config[name].cpp_type_name }}::{{ key }};
}
{%- endfor %}
return mijin::NULL_OPTIONAL;
}
{%- endmacro %}
{% macro glsl_enum(name) -%}
{%- for key, value in enum_config[name].entries.items(): -%}
const int {{ enum_config[name].glsl_prefix }}{{ key }} = {{ value }};
{% endfor -%}
{%- endmacro %}

View File

@ -1,4 +1,4 @@
{% import 'enums.jinja' as enums -%}
{% import 'iwa_enums.jinja' as enums -%}
// auto-generated using Jinja, do not edit!
#pragma once

View File

@ -2,8 +2,8 @@
#include "iwa/util/shader_meta.hpp"
#include "iwa/log.hpp"
#include "kazan/resource/mesh.hpp"
#include "iwa/util/glsl_compiler.hpp"
#include "iwa/util/vertex_layout.hpp"
#include "iwa/util/vkutil.hpp"
namespace