From 44e48ddc2785b037abd202a8d38b2ef2e8c36600 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 14 Dec 2024 23:15:34 +1100 Subject: initial commit --- sc/includer.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 sc/includer.cpp (limited to 'sc/includer.cpp') diff --git a/sc/includer.cpp b/sc/includer.cpp new file mode 100644 index 0000000..69d9b6a --- /dev/null +++ b/sc/includer.cpp @@ -0,0 +1,43 @@ +#include "includer.hpp" + +#include +#include + +extern "C" { +#include "plat.h" +} + +using IncludeResult = glslang::TShader::Includer::IncludeResult; + +IncludeResult* Includer::includeSystem( + const char* headerName, + const char* includerName, + size_t inclusionDepth +) { + return 0; +} + +extern bool rf(const char* n, char*& buf, size_t& size); + +IncludeResult* Includer::includeLocal( + const char* header_name, + const char* includer_name, + size_t inclusionDepth +) { + char* src; + size_t src_size; + std::filesystem::path inc(includer_name); + inc.remove_filename(); + inc /= header_name; + auto hn = std::filesystem::absolute(inc).string(); + if (!rf(hn.c_str(), src, src_size)) { + print_err("Failed to include %s\n", header_name); + print_err("\tTried %s\n", hn.c_str()); + return 0; + } + return new IncludeResult(hn, src, src_size, 0); +} + +void Includer::releaseInclude(IncludeResult* i) { + delete i; +} -- cgit v1.2.3-54-g00ecf