Skip to content

Commit

Permalink
allow preludes in include folder (shader-slang#3976)
Browse files Browse the repository at this point in the history
Co-authored-by: ArielG-NV <[email protected]>
Co-authored-by: Yong He <[email protected]>
  • Loading branch information
3 people authored Apr 19, 2024
1 parent adbaf8f commit e0aa53f
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions source/core/slang-test-tool-util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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());
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit e0aa53f

Please sign in to comment.