From e0aa53fb01aa550219c6f71644e6e7a1202b90b3 Mon Sep 17 00:00:00 2001 From: Tomáš Pazdiora Date: Fri, 19 Apr 2024 23:27:48 +0200 Subject: allow preludes in include folder (#3976) Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: Yong He --- source/core/slang-test-tool-util.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'source/core/slang-test-tool-util.cpp') 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; -- cgit v1.2.3