]> git.cworth.org Git - apitrace/commitdiff
dump-images: Execute glretrace from source dir when running uninstalled
authorCarl Worth <cworth@cworth.org>
Sun, 12 Aug 2012 23:36:48 +0000 (16:36 -0700)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 18 Nov 2012 14:33:57 +0000 (14:33 +0000)
Previously, we've had code to carefully find wrappers and scripts
relative to an apitrace binary being run from an uninstalled
directory. This is extremely useful while testing an experimental
feature before installing said experimental code.

Similarly, provide a findProgram function to do the same thing for an
executable program and use it within "apitrace dump-images" when
invoking glretrace.

CMakeLists.txt
cli/cli_dump_images.cpp
common/trace_resource.cpp
common/trace_resource.hpp

index 7f75d07f9940b3cfa395633f94a9c6a6316e37f3..3d97b1ea9febc57be520a8fedb189306aef10d5e 100644 (file)
@@ -278,6 +278,7 @@ set (WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
 add_definitions(
     -DAPITRACE_BINARY_DIR="${CMAKE_BINARY_DIR}"
     -DAPITRACE_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}"
+    -DAPITRACE_PROGRAMS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/bin"
     -DAPITRACE_SCRIPTS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${SCRIPTS_INSTALL_DIR}"
     -DAPITRACE_WRAPPERS_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}/${WRAPPER_INSTALL_DIR}"
 )
index d42b3f784a3894bb26653a6c7d04281707920a64..2a856c78b670cfc9c2b3d981ee204d90318fdb13 100644 (file)
@@ -36,6 +36,8 @@
 #include "os_string.hpp"
 #include "os_process.hpp"
 
+#include "trace_resource.hpp"
+
 static const char *synopsis = "Dump frame images obtained from a trace.";
 
 static void
@@ -123,7 +125,9 @@ command(int argc, char *argv[])
      * already been pulled in for the "apitrace retrace" (or "apitrace
      * replay") command. */
     std::vector<const char *> command;
-    command.push_back("glretrace");
+
+    os::String glretracePath = trace::findProgram("glretrace");
+    command.push_back(glretracePath);
     command.push_back("-s");
     command.push_back(output);
     command.push_back("-S");
index 51cd72df253774a301b5e41e95a4cca9d12f2a4f..04ac32709dfa09eea11d1d1951dee9948282cf26 100644 (file)
 
 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)
 {
index 35c8399eff5f9054b4ba4c0e6077d88b5f6b5e98..28c5727c94944acd6215a9314373a82bb979997b 100644 (file)
@@ -36,6 +36,9 @@
 namespace trace {
 
 
+os::String
+findProgram(const char*programFilename);
+
 os::String
 findScript(const char *name);