@@ -77,31 +77,29 @@ static tcpp::TInputStreamUniquePtr getInputStreamInclude(
77
77
std::vector<std::pair<uint32_t , std::string>>& includeStack
78
78
)
79
79
{
80
- std::filesystem::path relDir ;
80
+ std::filesystem::path requestingSourceDir ;
81
81
#ifdef NBL_EMBED_BUILTIN_RESOURCES
82
82
const bool reqFromBuiltin = nbl::builtin::hasPathPrefix (requestingSource) || spirv::builtin::hasPathPrefix (requestingSource);
83
83
const bool reqBuiltin = nbl::builtin::hasPathPrefix (requestedSource) || spirv::builtin::hasPathPrefix (requestedSource);
84
+ // While #includ'ing a builtin, one must specify its full path (starting with "nbl/builtin" or "/nbl/builtin").
85
+ // This rule applies also while a builtin is #includ`ing another builtin.
86
+ // While including a filesystem file it must be either absolute path (or relative to any search dir added to asset::iIncludeHandler; <>-type),
87
+ // or path relative to executable's working directory (""-type).
84
88
if (!reqFromBuiltin && !reqBuiltin)
85
- {
86
- // While #includ'ing a builtin, one must specify its full path (starting with "nbl/builtin" or "/nbl/builtin").
87
- // This rule applies also while a builtin is #includ`ing another builtin.
88
- // While including a filesystem file it must be either absolute path (or relative to any search dir added to asset::iIncludeHandler; <>-type),
89
- // or path relative to executable's working directory (""-type).
90
- relDir = std::filesystem::path (requestingSource).parent_path ();
91
- }
92
89
#else
93
90
const bool reqBuiltin = false ;
94
91
#endif // NBL_EMBED_BUILTIN_RESOURCES
95
- std::filesystem::path name = isRelative ? (relDir / requestedSource) : (requestedSource );
92
+ requestingSourceDir = system::path (requestingSource). parent_path ( );
96
93
94
+ system::path name = isRelative ? (requestingSourceDir / requestedSource) : (requestedSource);
97
95
if (std::filesystem::exists (name) && !reqBuiltin)
98
96
name = std::filesystem::absolute (name);
99
97
100
98
std::optional<std::string> result;
101
99
if (isRelative)
102
- result = inclFinder->getIncludeRelative (relDir , requestedSource);
100
+ result = inclFinder->getIncludeRelative (requestingSourceDir , requestedSource);
103
101
else // shaderc_include_type_standard
104
- result = inclFinder->getIncludeStandard (relDir , requestedSource);
102
+ result = inclFinder->getIncludeStandard (requestingSourceDir , requestedSource);
105
103
106
104
if (!result)
107
105
{
0 commit comments