diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2021-01-26 12:15:08 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-01-26 09:15:08 -0800 |
| commit | 798d7731eca286df456bc2ec56c0695ba006b472 (patch) | |
| tree | 37ced2db457a08aa8cfc81f19f18daf9ca26d3f2 /source/core/slang-platform.cpp | |
| parent | 00fad59d49d31538270b811903aeb449c97ca152 (diff) | |
Improved NVRTC location finding (#1674)
* #include an absolute path didn't work - because paths were taken to always be relative.
* WIP more sophisticated mechanism to find NVRTC.
* Improve nvrtc searching to include PATH.
* Make getting an extension able to differentiate between no extension, and just a .
* Add comment.
* Add support for searching instance path.
* Small improvements around scope and finding NVRTC.
* Improve documentation around NVRTC loading.
Diffstat (limited to 'source/core/slang-platform.cpp')
| -rw-r--r-- | source/core/slang-platform.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index 10b9b576b..20dfed5a8 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -66,6 +66,19 @@ SLANG_COMPILE_TIME_ASSERT(E_NOTIMPL == SLANG_E_NOT_IMPLEMENTED); SLANG_COMPILE_TIME_ASSERT(E_INVALIDARG == SLANG_E_INVALID_ARG); SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); +/* static */SlangResult PlatformUtil::getInstancePath(StringBuilder& out) +{ + wchar_t path[_MAX_PATH]; + ::GetModuleFileName(::GetModuleHandle(NULL), path, SLANG_COUNT_OF(path)); + String pathString = String::fromWString(path); + + // We don't want the instance name, just the path to it + out.Clear(); + out.append(Path::getParentDirectory(pathString)); + + return out.getLength() > 0 ? SLANG_OK : SLANG_FAIL; +} + /* static */SlangResult PlatformUtil::appendResult(SlangResult res, StringBuilder& builderOut) { if (SLANG_FAILED(res) && res != SLANG_FAIL) @@ -142,6 +155,13 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); #else // _WIN32 +/* static */SlangResult PlatformUtil::getInstancePath(StringBuilder& out) +{ + // On non Windows it's typically hard to get the instance path, so we'll say not implemented. + // The meaning is also somewhat more ambiguous - is it the exe or the shared library path? + return SLANG_E_NOT_IMPLEMENTED; +} + /* static */SlangResult PlatformUtil::appendResult(SlangResult res, StringBuilder& builderOut) { return SLANG_E_NOT_IMPLEMENTED; @@ -260,4 +280,6 @@ static const PlatformFlags s_familyFlags[int(PlatformFamily::CountOf)] = return s_familyFlags[int(family)]; } + + } |
