| 27 | #include "strings/string_utils.h" |
| 28 | |
| 29 | rdcstr LocatePluginFile(const rdcstr &path, const rdcstr &fileName) |
| 30 | { |
| 31 | rdcstr ret; |
| 32 | |
| 33 | rdcstr libpath; |
| 34 | FileIO::GetLibraryFilename(libpath); |
| 35 | libpath = get_dirname(libpath); |
| 36 | |
| 37 | rdcarray<rdcstr> paths; |
| 38 | |
| 39 | #if defined(RENDERDOC_PLUGINS_PATH) |
| 40 | string customPath(RENDERDOC_PLUGINS_PATH); |
| 41 | |
| 42 | if(FileIO::IsRelativePath(customPath)) |
| 43 | customPath = libpath + "/" + customPath; |
| 44 | |
| 45 | paths.push_back(customPath); |
| 46 | #endif |
| 47 | |
| 48 | // windows installation |
| 49 | paths.push_back(libpath + "/plugins"); |
| 50 | // linux installation |
| 51 | paths.push_back(libpath + "/../share/renderdoc/plugins"); |
| 52 | // also search the appropriate OS-specific location in the root |
| 53 | #if ENABLED(RDOC_WIN32) && ENABLED(RDOC_X64) |
| 54 | paths.push_back(libpath + "/../../plugins-win64"); |
| 55 | #endif |
| 56 | |
| 57 | #if ENABLED(RDOC_WIN32) && DISABLED(RDOC_X64) |
| 58 | paths.push_back(libpath + "/../../plugins-win32"); |
| 59 | #endif |
| 60 | |
| 61 | #if ENABLED(RDOC_LINUX) |
| 62 | paths.push_back(libpath + "/../../plugins-linux64"); |
| 63 | #endif |
| 64 | |
| 65 | // there is no standard path for local builds as we don't provide these plugins in the repository |
| 66 | // directly. As a courtesy we search the root of the build, from the executable. The user can |
| 67 | // always put the plugins folder relative to the exe where it would be in an installation too. |
| 68 | paths.push_back(libpath + "/../../plugins"); |
| 69 | |
| 70 | // in future maybe we want to search a user-specific plugins folder? Like ~/.renderdoc/ on linux |
| 71 | // or %APPDATA%/renderdoc on windows? |
| 72 | |
| 73 | for(uint32_t i = 0; i < paths.size(); i++) |
| 74 | { |
| 75 | rdcstr check = paths[i] + "/" + path + "/" + fileName; |
| 76 | if(FileIO::exists(check)) |
| 77 | { |
| 78 | ret = check; |
| 79 | break; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | // if we didn't find it anywhere, just try running it directly in case it's in the PATH |
| 84 | if(ret.empty()) |
| 85 | ret = fileName; |
| 86 |
no test coverage detected