From a684451ce345c9d3667921520a4a75e387811ad6 Mon Sep 17 00:00:00 2001 From: Carl Worth Date: Sun, 12 Aug 2012 16:36:48 -0700 Subject: [PATCH 1/1] dump-images: Execute glretrace from source dir when running uninstalled 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 | 1 + cli/cli_dump_images.cpp | 6 +++++- common/trace_resource.cpp | 26 ++++++++++++++++++++++++++ common/trace_resource.hpp | 3 +++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f75d07..3d97b1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}" ) diff --git a/cli/cli_dump_images.cpp b/cli/cli_dump_images.cpp index d42b3f7..2a856c7 100644 --- a/cli/cli_dump_images.cpp +++ b/cli/cli_dump_images.cpp @@ -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 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"); diff --git a/common/trace_resource.cpp b/common/trace_resource.cpp index 51cd72d..04ac327 100644 --- a/common/trace_resource.cpp +++ b/common/trace_resource.cpp @@ -35,6 +35,32 @@ 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) { diff --git a/common/trace_resource.hpp b/common/trace_resource.hpp index 35c8399..28c5727 100644 --- a/common/trace_resource.hpp +++ b/common/trace_resource.hpp @@ -36,6 +36,9 @@ namespace trace { +os::String +findProgram(const char*programFilename); + os::String findScript(const char *name); -- 2.43.0