X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=common%2Ftrace_resource.cpp;h=04ac32709dfa09eea11d1d1951dee9948282cf26;hb=77373c35010d89e5ab3f030e4c60f8f6e3fdbe82;hp=206e6da157ae4eea74b50930675584265c071341;hpb=ee659c84695e9f94b1f6a5f8be203dc0012ca685;p=apitrace diff --git a/common/trace_resource.cpp b/common/trace_resource.cpp index 206e6da..04ac327 100644 --- a/common/trace_resource.cpp +++ b/common/trace_resource.cpp @@ -35,6 +35,74 @@ namespace trace { +os::String +findProgram(const char*programFilename) +{ + os::String programPath; + + os::String processDir = os::getProcessName(); + processDir.trimFilename(); + + programPath = processDir; + programPath.join(programFilename); + if (programPath.exists()) { + return programPath; + } + +#ifndef _WIN32 + // Try absolute install directory + programPath = APITRACE_PROGRAMS_INSTALL_DIR; + programPath.join(programFilename); + if (programPath.exists()) { + return programPath; + } +#endif + + return ""; +} + +os::String +findWrapper(const char *wrapperFilename) +{ + os::String wrapperPath; + + os::String processDir = os::getProcessName(); + processDir.trimFilename(); + + // Try relative build directory + // XXX: Just make build and install directory layout match + wrapperPath = processDir; + wrapperPath.join("wrappers"); + wrapperPath.join(wrapperFilename); + if (wrapperPath.exists()) { + return wrapperPath; + } + + // Try relative install directory + wrapperPath = processDir; +#if defined(_WIN32) + wrapperPath.join("..\\lib\\wrappers"); +#elif defined(__APPLE__) + wrapperPath.join("../lib/wrappers"); +#else + wrapperPath.join("../lib/apitrace/wrappers"); +#endif + wrapperPath.join(wrapperFilename); + if (wrapperPath.exists()) { + return wrapperPath; + } + +#ifndef _WIN32 + // Try absolute install directory + wrapperPath = APITRACE_WRAPPERS_INSTALL_DIR; + wrapperPath.join(wrapperFilename); + if (wrapperPath.exists()) { + return wrapperPath; + } +#endif + + return ""; +} os::String findScript(const char *scriptFilename) @@ -69,7 +137,7 @@ findScript(const char *scriptFilename) #ifndef _WIN32 // Try absolute install directory - scriptPath = APITRACE_WRAPPER_INSTALL_DIR; + scriptPath = APITRACE_SCRIPTS_INSTALL_DIR; scriptPath.join(scriptFilename); if (scriptPath.exists()) { return scriptPath;