From ca7283268b6ecc29d371624b908fd85c30024056 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 12 Aug 2012 16:01:09 -0700 Subject: [PATCH] Move trace::findWrapper to trace_resource.cpp It's not actually used outside of trace_tools_trace.cpp, but it is so similar to the existing trace::findScript in trace_resource.cpp that there are benefits to having them defined in the same file. --- common/trace_resource.cpp | 42 +++++++++++++++++++++++++++++++++ common/trace_resource.hpp | 2 ++ common/trace_tools_trace.cpp | 45 +----------------------------------- 3 files changed, 45 insertions(+), 44 deletions(-) diff --git a/common/trace_resource.cpp b/common/trace_resource.cpp index 8a1f56c..51cd72d 100644 --- a/common/trace_resource.cpp +++ b/common/trace_resource.cpp @@ -35,6 +35,48 @@ namespace trace { +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) diff --git a/common/trace_resource.hpp b/common/trace_resource.hpp index 1d0a31b..35c8399 100644 --- a/common/trace_resource.hpp +++ b/common/trace_resource.hpp @@ -39,6 +39,8 @@ namespace trace { os::String findScript(const char *name); +os::String +findWrapper(const char *wrapperFilename); } /* namespace trace */ diff --git a/common/trace_tools_trace.cpp b/common/trace_tools_trace.cpp index 5c88a25..387e2e2 100644 --- a/common/trace_tools_trace.cpp +++ b/common/trace_tools_trace.cpp @@ -33,6 +33,7 @@ #include "os_string.hpp" #include "os_process.hpp" #include "trace_tools.hpp" +#include "trace_resource.hpp" @@ -51,50 +52,6 @@ namespace trace { #endif -static 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 ""; -} - - int traceProgram(API api, char * const *argv, -- 2.43.0