diff options
-rw-r--r-- | BUILD.gn | 3 | ||||
-rw-r--r-- | src/common/system_utils.h | 2 | ||||
-rw-r--r-- | src/common/system_utils_posix.cpp | 10 | ||||
-rw-r--r-- | src/common/system_utils_win.cpp | 40 | ||||
-rw-r--r-- | src/common/vulkan/vulkan_icd.cpp | 13 | ||||
-rw-r--r-- | src/libANGLE/renderer/cl/CLPlatformCL.cpp | 4 |
6 files changed, 19 insertions, 53 deletions
@@ -107,9 +107,6 @@ config("internal_config") { if (is_win) { defines += [ "ANGLE_IS_WIN" ] - if (angle_is_winuwp) { - defines += [ "ANGLE_IS_WINUWP" ] - } } else if (is_linux || is_chromeos) { defines += [ "ANGLE_IS_LINUX" ] } diff --git a/src/common/system_utils.h b/src/common/system_utils.h index 92100c41b7..efd8a98124 100644 --- a/src/common/system_utils.h +++ b/src/common/system_utils.h @@ -19,7 +19,7 @@ namespace angle std::string GetExecutableName(); std::string GetExecutablePath(); std::string GetExecutableDirectory(); -std::string GetModuleDirectory(); +std::string GetHelperExecutableDir(); const char *GetSharedLibraryExtension(); const char *GetExecutableExtension(); char GetPathSeparator(); diff --git a/src/common/system_utils_posix.cpp b/src/common/system_utils_posix.cpp index 6c704a1c76..323aee6ace 100644 --- a/src/common/system_utils_posix.cpp +++ b/src/common/system_utils_posix.cpp @@ -56,7 +56,7 @@ const char *GetPathSeparatorForEnvironmentVar() return ":"; } -std::string GetModuleDirectory() +std::string GetHelperExecutableDir() { std::string directory; static int placeholderSymbol = 0; @@ -66,12 +66,6 @@ std::string GetModuleDirectory() std::string moduleName = dlInfo.dli_fname; directory = moduleName.substr(0, moduleName.find_last_of('/') + 1); } - // Ensure we return the full path to the module, not the relative path - Optional<std::string> cwd = GetCWD(); - if (!directory.empty() && directory.at(0) != '/' && cwd.valid()) - { - directory = cwd.value() + GetPathSeparator() + directory; - } return directory; } @@ -113,7 +107,7 @@ Library *OpenSharedLibrary(const char *libraryName, SearchType searchType) // On iOS, shared libraries must be loaded from within the app bundle. directory = GetExecutableDirectory() + "/Frameworks/"; #else - directory = GetModuleDirectory(); + directory = GetHelperExecutableDir(); #endif } diff --git a/src/common/system_utils_win.cpp b/src/common/system_utils_win.cpp index 9e03202168..886ca0cce0 100644 --- a/src/common/system_utils_win.cpp +++ b/src/common/system_utils_win.cpp @@ -15,37 +15,21 @@ namespace angle { - -namespace -{ - -std::string GetPath(HMODULE module) +std::string GetExecutablePath() { std::array<char, MAX_PATH> executableFileBuf; - DWORD executablePathLen = GetModuleFileNameA(module, executableFileBuf.data(), + DWORD executablePathLen = GetModuleFileNameA(nullptr, executableFileBuf.data(), static_cast<DWORD>(executableFileBuf.size())); return (executablePathLen > 0 ? std::string(executableFileBuf.data()) : ""); } -std::string GetDirectory(HMODULE module) +std::string GetExecutableDirectory() { - std::string executablePath = GetPath(module); + std::string executablePath = GetExecutablePath(); size_t lastPathSepLoc = executablePath.find_last_of("\\/"); return (lastPathSepLoc != std::string::npos) ? executablePath.substr(0, lastPathSepLoc) : ""; } -} // anonymous namespace - -std::string GetExecutablePath() -{ - return GetPath(nullptr); -} - -std::string GetExecutableDirectory() -{ - return GetDirectory(nullptr); -} - const char *GetSharedLibraryExtension() { return "dll"; @@ -117,20 +101,8 @@ char GetPathSeparator() return '\\'; } -std::string GetModuleDirectory() +std::string GetHelperExecutableDir() { -// GetModuleHandleEx is unavailable on UWP -#if !defined(ANGLE_IS_WINUWP) - static int placeholderSymbol = 0; - HMODULE module = nullptr; - if (GetModuleHandleExA( - GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, - reinterpret_cast<LPCSTR>(&placeholderSymbol), &module)) - { - return GetDirectory(module); - } -#endif - return GetDirectory(nullptr); + return ""; } - } // namespace angle diff --git a/src/common/vulkan/vulkan_icd.cpp b/src/common/vulkan/vulkan_icd.cpp index e915b45f75..807ccb8b22 100644 --- a/src/common/vulkan/vulkan_icd.cpp +++ b/src/common/vulkan/vulkan_icd.cpp @@ -51,9 +51,12 @@ namespace !defined(ANGLE_PLATFORM_GGP) const std::string WrapICDEnvironment(const char *icdEnvironment) { - // The libraries are bundled into the module directory - std::string ret = angle::GetModuleDirectory() + GetPathSeparator() + icdEnvironment; +# if defined(ANGLE_PLATFORM_APPLE) + // On MacOS the libraries are bundled into the application directory + std::string ret = angle::GetHelperExecutableDir() + icdEnvironment; return ret; +# endif // defined(ANGLE_PLATFORM_APPLE) + return icdEnvironment; } constexpr char kLoaderLayersPathEnv[] = "VK_LAYER_PATH"; @@ -143,9 +146,9 @@ ScopedVkLoaderEnvironment::ScopedVkLoaderEnvironment(bool enableValidationLayers } else { - mPreviousCWD = cwd.value(); - std::string moduleDir = angle::GetModuleDirectory(); - mChangedCWD = angle::SetCWD(moduleDir.c_str()); + mPreviousCWD = cwd.value(); + std::string exeDir = angle::GetExecutableDirectory(); + mChangedCWD = angle::SetCWD(exeDir.c_str()); if (!mChangedCWD) { ERR() << "Error setting CWD for Vulkan layers init."; diff --git a/src/libANGLE/renderer/cl/CLPlatformCL.cpp b/src/libANGLE/renderer/cl/CLPlatformCL.cpp index 97c8aa2b2d..1438fcc84b 100644 --- a/src/libANGLE/renderer/cl/CLPlatformCL.cpp +++ b/src/libANGLE/renderer/cl/CLPlatformCL.cpp @@ -393,8 +393,8 @@ void CLPlatformCL::Initialize(const cl_icd_dispatch &dispatch, bool isIcd) } // The absolute path to ANGLE's OpenCL library is needed and it is assumed here that - // it is in the same directory as the shared library which contains this CL back end. - std::string libPath = angle::GetModuleDirectory(); + // it is in the same directory as the executable which contains this CL back end. + std::string libPath = angle::GetExecutableDirectory(); if (!libPath.empty() && libPath.back() != angle::GetPathSeparator()) { libPath += angle::GetPathSeparator(); |