diff options
Diffstat (limited to 'source/core/slang-platform.cpp')
| -rw-r--r-- | source/core/slang-platform.cpp | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/source/core/slang-platform.cpp b/source/core/slang-platform.cpp index 5185d5d23..921c85612 100644 --- a/source/core/slang-platform.cpp +++ b/source/core/slang-platform.cpp @@ -43,7 +43,7 @@ namespace Slang Path::combineIntoBuilder(parent.getUnownedSlice(), platformFileNameBuilder.getUnownedSlice(), outPath); } - else + else if (filename.getLength() > 0) { appendPlatformFileName(filename.getUnownedSlice(), outPath); } @@ -107,6 +107,13 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); /* static */SlangResult SharedLibrary::loadWithPlatformPath(char const* platformFileName, SharedLibrary::Handle& handleOut) { handleOut = nullptr; + if (!platformFileName || strlen(platformFileName) == 0) + { + if (!GetModuleHandleExA(0, nullptr, (HMODULE*)&handleOut)) + return SLANG_FAIL; + return SLANG_OK; + } + // https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-loadlibrarya const HMODULE h = LoadLibraryA(platformFileName); if (!h) @@ -170,10 +177,11 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); /* static */SlangResult SharedLibrary::loadWithPlatformPath(char const* platformFileName, Handle& handleOut) { handleOut = nullptr; - - void* h = dlopen(platformFileName, RTLD_NOW | RTLD_GLOBAL); - if(!h) - { + if (strlen(platformFileName) == 0) + platformFileName = nullptr; + void *h = dlopen(platformFileName, RTLD_NOW | RTLD_GLOBAL); + if (!h) + { #if 0 // We can't output the error message here, because it will cause output when testing what code gen is available if(auto msg = dlerror()) @@ -195,7 +203,6 @@ SLANG_COMPILE_TIME_ASSERT(E_OUTOFMEMORY == SLANG_E_OUT_OF_MEMORY); /* static */void* SharedLibrary::findSymbolAddressByName(Handle handle, char const* name) { - SLANG_ASSERT(handle); return dlsym((void*)handle, name); } |
