summaryrefslogtreecommitdiffstats
path: root/source/core/slang-test-tool-util.cpp
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-10-26 03:22:01 +0800
committerGitHub <noreply@github.com>2023-10-25 12:22:01 -0700
commit1a8216b7cd6f272253e7381bc520c65b7dd38b24 (patch)
tree9865d2dcf28d7a56a13c665563f8adc0fa96de04 /source/core/slang-test-tool-util.cpp
parente04abb54bc69d90a503852d60a89e8bac7b60ec8 (diff)
Fix warnings for gcc 12.3 (#3286)
* Silence a few gcc out of bounds warnings * Search upwards from executable for prelude directory instead of assuming depth * comment wording * Check return values of read and write * Correct path to vulkan headers in gfx * Correct diagnostic on missing file in slang-embed * Do not use absolute path to libraries in test-context.cpp --------- Co-authored-by: Yong He <yonghe@outlook.com>
Diffstat (limited to 'source/core/slang-test-tool-util.cpp')
-rw-r--r--source/core/slang-test-tool-util.cpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/source/core/slang-test-tool-util.cpp b/source/core/slang-test-tool-util.cpp
index 68673a29f..487ea89ac 100644
--- a/source/core/slang-test-tool-util.cpp
+++ b/source/core/slang-test-tool-util.cpp
@@ -103,12 +103,21 @@ static SlangResult _addCUDAPrelude(const String& rootPath, slang::IGlobalSession
String parentPath;
SLANG_RETURN_ON_FAIL(getExeDirectoryPath(inExePath, parentPath));
- // From directory to the root is ../../..
- // Work out the relative path to the root
- String rootRelPath = Path::combine(parentPath, "../../../");
+ // Work out the relative path to the root, we will search upwards until we
+ // find a directory containing 'prelude/slang-cpp-prelude.h'
+ String rootRelPath;
+ SLANG_RETURN_ON_FAIL(Path::getCanonical(parentPath, rootRelPath));
+ do
+ {
+ if(File::exists(Path::combine(rootRelPath, "prelude/slang-cpp-prelude.h")))
+ break;
+
+ rootRelPath = Path::getParentDirectory(rootRelPath);
+ if(rootRelPath == "")
+ return SLANG_E_NOT_AVAILABLE;
+ } while(1);
- // We want the absolute path to the root
- SLANG_RETURN_ON_FAIL(Path::getCanonical(rootRelPath, outExePath));
+ outExePath = std::move(rootRelPath);
return SLANG_OK;
}