diff options
| author | Tomáš Pazdiora <tomas.pazdiora@gmail.com> | 2024-04-19 23:27:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-19 14:27:48 -0700 |
| commit | e0aa53fb01aa550219c6f71644e6e7a1202b90b3 (patch) | |
| tree | dd98aaf72b2747ea34635c75db3d316457c3a269 /source/core | |
| parent | adbaf8f23d7ef8c8e7786e8be706a47adce3f2ef (diff) | |
allow preludes in include folder (#3976)
Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com>
Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/slang-test-tool-util.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp index 487ea89ac..74802e233 100644 --- a/source/core/slang-test-tool-util.cpp +++ b/source/core/slang-test-tool-util.cpp @@ -71,7 +71,12 @@ namespace Slang static SlangResult _addCPPPrelude(const String& rootPath, slang::IGlobalSession* session) { String includePath; - SLANG_RETURN_ON_FAIL(TestToolUtil::getIncludePath(rootPath, "prelude/slang-cpp-prelude.h", includePath)); + SlangResult res = SLANG_FAIL; + if (SLANG_FAILED(res)) + res = TestToolUtil::getIncludePath(Path::combine(rootPath, "include"), "slang-cpp-prelude.h", includePath); + if (SLANG_FAILED(res)) + res = TestToolUtil::getIncludePath(rootPath, "prelude/slang-cpp-prelude.h", includePath); + SLANG_RETURN_ON_FAIL(res); StringBuilder prelude; prelude << "#include \"" << includePath << "\"\n\n"; session->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_CPP, prelude.getBuffer()); @@ -81,7 +86,12 @@ static SlangResult _addCPPPrelude(const String& rootPath, slang::IGlobalSession* static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession* session) { String includePath; - SLANG_RETURN_ON_FAIL(TestToolUtil::getIncludePath(rootPath, "prelude/slang-cuda-prelude.h", includePath)); + SlangResult res = SLANG_FAIL; + if (SLANG_FAILED(res)) + res = TestToolUtil::getIncludePath(Path::combine(rootPath, "include"), "slang-cuda-prelude.h", includePath); + if (SLANG_FAILED(res)) + res = TestToolUtil::getIncludePath(rootPath, "prelude/slang-cuda-prelude.h", includePath); + SLANG_RETURN_ON_FAIL(res); StringBuilder prelude; prelude << "#include \"" << includePath << "\"\n\n"; session->setLanguagePrelude(SLANG_SOURCE_LANGUAGE_CUDA, prelude.getBuffer()); @@ -109,6 +119,8 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession SLANG_RETURN_ON_FAIL(Path::getCanonical(parentPath, rootRelPath)); do { + if(File::exists(Path::combine(rootRelPath, "include/slang-cpp-prelude.h"))) + break; if(File::exists(Path::combine(rootRelPath, "prelude/slang-cpp-prelude.h"))) break; |
