diff options
author | quou <quou@disroot.org> | 2024-12-14 23:15:34 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-12-14 23:19:17 +1100 |
commit | 44e48ddc2785b037abd202a8d38b2ef2e8c36600 (patch) | |
tree | f58887ce48f7fdbf6dcca365b2a1b02a34e1b355 /sc/includer.cpp |
initial commit
Diffstat (limited to 'sc/includer.cpp')
-rw-r--r-- | sc/includer.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
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 <stdio.h> +#include <filesystem> + +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; +} |