X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=cli%2Fcli_resources.cpp;h=a4797e11d414e0b41a35ec2d43c65e74d5714550;hb=0ae84f58eee1c239d5bc2cc148a1d007b328d2e1;hp=255a98b662a700a440750a62e200553c4b193b16;hpb=8e27804d29abfa3a7cd8630aaa3394677c8a3844;p=apitrace diff --git a/cli/cli_resources.cpp b/cli/cli_resources.cpp index 255a98b..a4797e1 100644 --- a/cli/cli_resources.cpp +++ b/cli/cli_resources.cpp @@ -33,8 +33,18 @@ #include "cli_resources.hpp" +static bool +tryPath(const os::String &path, bool verbose) +{ + bool exists = path.exists(); + if (verbose) { + std::cerr << "info: " << (exists ? "found" : "did not find") << " " << path.str() << "\n"; + } + return exists; +} + os::String -findProgram(const char*programFilename) +findProgram(const char *programFilename, bool verbose) { os::String programPath; @@ -43,7 +53,7 @@ findProgram(const char*programFilename) programPath = processDir; programPath.join(programFilename); - if (programPath.exists()) { + if (tryPath(programPath, verbose)) { return programPath; } @@ -51,7 +61,7 @@ findProgram(const char*programFilename) // Try absolute install directory programPath = APITRACE_PROGRAMS_INSTALL_DIR; programPath.join(programFilename); - if (programPath.exists()) { + if (tryPath(programPath, verbose)) { return programPath; } #endif @@ -60,7 +70,7 @@ findProgram(const char*programFilename) } os::String -findWrapper(const char *wrapperFilename) +findWrapper(const char *wrapperFilename, bool verbose) { os::String wrapperPath; @@ -70,9 +80,16 @@ findWrapper(const char *wrapperFilename) // Try relative build directory // XXX: Just make build and install directory layout match wrapperPath = processDir; +#if defined(APITRACE_CONFIGURATION_SUBDIR) + // Go from `Debug\apitrace.exe` to `wrappers\Debug\foo.dll` on MSVC builds. + wrapperPath.join(".."); wrapperPath.join("wrappers"); + wrapperPath.join(APITRACE_CONFIGURATION_SUBDIR); +#else + wrapperPath.join("wrappers"); +#endif wrapperPath.join(wrapperFilename); - if (wrapperPath.exists()) { + if (tryPath(wrapperPath, verbose)) { return wrapperPath; } @@ -86,7 +103,7 @@ findWrapper(const char *wrapperFilename) wrapperPath.join("../lib/apitrace/wrappers"); #endif wrapperPath.join(wrapperFilename); - if (wrapperPath.exists()) { + if (tryPath(wrapperPath, verbose)) { return wrapperPath; } @@ -94,7 +111,7 @@ findWrapper(const char *wrapperFilename) // Try absolute install directory wrapperPath = APITRACE_WRAPPERS_INSTALL_DIR; wrapperPath.join(wrapperFilename); - if (wrapperPath.exists()) { + if (tryPath(wrapperPath, verbose)) { return wrapperPath; } #endif @@ -103,7 +120,7 @@ findWrapper(const char *wrapperFilename) } os::String -findScript(const char *scriptFilename) +findScript(const char *scriptFilename, bool verbose) { os::String scriptPath; @@ -112,12 +129,14 @@ findScript(const char *scriptFilename) // Try relative build directory // XXX: Just make build and install directory layout match - scriptPath = processDir; +#if defined(APITRACE_SOURCE_DIR) + scriptPath = APITRACE_SOURCE_DIR; scriptPath.join("scripts"); scriptPath.join(scriptFilename); - if (scriptPath.exists()) { + if (tryPath(scriptPath, verbose)) { return scriptPath; } +#endif // Try relative install directory scriptPath = processDir; @@ -129,7 +148,7 @@ findScript(const char *scriptFilename) scriptPath.join("../lib/apitrace/scripts"); #endif scriptPath.join(scriptFilename); - if (scriptPath.exists()) { + if (tryPath(scriptPath, verbose)) { return scriptPath; } @@ -137,7 +156,7 @@ findScript(const char *scriptFilename) // Try absolute install directory scriptPath = APITRACE_SCRIPTS_INSTALL_DIR; scriptPath.join(scriptFilename); - if (scriptPath.exists()) { + if (tryPath(scriptPath, verbose)) { return scriptPath; } #endif