From 19baf8b0487bdc6c95c9b906c960c28021d07677 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 13 Nov 2023 14:27:51 -0500 Subject: [PATCH] include recursive --- include/blt/std/loader.h | 2 +- src/blt/std/loader.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/blt/std/loader.h b/include/blt/std/loader.h index f0d288e..037c34b 100755 --- a/include/blt/std/loader.h +++ b/include/blt/std/loader.h @@ -18,7 +18,7 @@ namespace blt::fs { std::vector getLinesFromFile(const std::string& path); - std::vector recursiveShaderInclude(const std::string& path); + std::vector recursiveShaderInclude(const std::string& path, const std::string& include_header = "#include"); static inline std::string loadShaderFile(const std::string& path) { std::stringstream stringStream; diff --git a/src/blt/std/loader.cpp b/src/blt/std/loader.cpp index 099e32d..322a209 100755 --- a/src/blt/std/loader.cpp +++ b/src/blt/std/loader.cpp @@ -32,7 +32,7 @@ std::vector blt::fs::getLinesFromFile(const std::string& path) { return string::split(shaderSource, "\n"); } -std::vector blt::fs::recursiveShaderInclude(const std::string& path) { +std::vector blt::fs::recursiveShaderInclude(const std::string& path, const std::string& include_header) { std::string pathOnly = path.substr(0, path.find_last_of('/')); auto mainLines = getLinesFromFile(path); @@ -41,7 +41,7 @@ std::vector blt::fs::recursiveShaderInclude(const std::string& path for (unsigned int i = 0; i < mainLines.size(); i++) { auto& line = mainLines[i]; // if the line is an include statement then we want to add lines recursively. - if (string::starts_with(line, "#include")) { + if (string::starts_with(line, include_header)) { std::vector include_statement = string::split(line, "<"); if (include_statement.size() <= 1) @@ -61,7 +61,7 @@ std::vector blt::fs::recursiveShaderInclude(const std::string& path BLT_TRACE("Recusing into %s/%s\n", pathOnly.c_str(), file.c_str()); - includes.insert({i, recursiveShaderInclude((pathOnly + "/" + file))}); + includes.insert({i, recursiveShaderInclude(pathOnly + "/" + file, include_header)}); } catch (std::exception& e) { BLT_FATAL("Shader file contains an invalid #include statement. (Missing < or \")\n"); BLT_FATAL("Exception: %s", e.what());