]> git.cworth.org Git - apitrace/blobdiff - common/trace_resource.cpp
dxgi: Support tracng DWM process.
[apitrace] / common / trace_resource.cpp
index 35d2b1a73cc6a9464b3bee03720ee1cd85a4df23..04ac32709dfa09eea11d1d1951dee9948282cf26 100644 (file)
 
 namespace trace {
 
-
 os::String
-findFile(const char *relPath,
-         const char *absPath,
-         bool verbose)
+findProgram(const char*programFilename)
 {
-    os::String complete;
+    os::String programPath;
+
+    os::String processDir = os::getProcessName();
+    processDir.trimFilename();
 
-    /* First look in the same directory from which this process is
-     * running, (to support developers running a compiled program that
-     * has not been installed. */
-    os::String process_dir = os::getProcessName();
-    process_dir.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
 
-    complete = process_dir;
-    complete.join(relPath);
+    return "";
+}
 
-    if (complete.exists())
-        return complete;
+os::String
+findWrapper(const char *wrapperFilename)
+{
+    os::String wrapperPath;
 
-    /* Second, look in the directory for installed wrappers. */
-    complete = absPath;
-    if (complete.exists())
-        return complete;
+    os::String processDir = os::getProcessName();
+    processDir.trimFilename();
 
-    if (verbose) {
-        std::cerr << "error: cannot find " << relPath << " or " << absPath << "\n";
+    // 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)
 {
@@ -101,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;