]> git.cworth.org Git - apitrace/commitdiff
cli: Allow to use `apitrace trace` from MSVC build directories.
authorJosé Fonseca <jfonseca@vmware.com>
Thu, 30 May 2013 16:15:32 +0000 (17:15 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Thu, 30 May 2013 16:15:32 +0000 (17:15 +0100)
Also add a bit more verbose output when searching for wrappers.

cli/CMakeLists.txt
cli/cli_resources.cpp
cli/cli_resources.hpp
cli/cli_trace.cpp

index 689374dc5333ade934d45ea2a398e57d7182cec5..713222fcfbb5e52670a7173102e74b32fc77119d 100644 (file)
@@ -40,4 +40,16 @@ if (NOT CMAKE_CROSSCOMPILING)
     )
 endif ()
 
+if (MSVC)
+    # On MSVC builds tell which subdirectory the binaries with be (for each
+    # configuration)
+    set_target_properties (apitrace PROPERTIES
+        COMPILE_DEFINITIONS_DEBUG APITRACE_CONFIGURATION_SUBDIR="Debug"
+        COMPILE_DEFINITIONS_RELEASE APITRACE_CONFIGURATION_SUBDIR="Release"
+        COMPILE_DEFINITIONS_MINSIZEREL APITRACE_CONFIGURATION_SUBDIR="MinSizeRel"
+        COMPILE_DEFINITIONS_RELWITHDEBINFO APITRACE_CONFIGURATION_SUBDIR="RelWithDebInfo"
+    )
+endif ()
+
+
 install (TARGETS apitrace RUNTIME DESTINATION bin)
index a533b01e0300910b42e0bc27347fd80838e58be5..a4797e11d414e0b41a35ec2d43c65e74d5714550 100644 (file)
 #include "cli_resources.hpp"
 
 
+static bool
+tryPath(const os::String &path, bool verbose)
+{
+    bool exists = path.exists();
+    if (verbose) {
+        std::cerr << "info: " << (exists ? "found" : "did not find") << " " << path.str() << "\n";
+    }
+    return exists;
+}
+
 os::String
-findProgram(const char*programFilename)
+findProgram(const char *programFilename, bool verbose)
 {
     os::String programPath;
 
@@ -43,7 +53,7 @@ findProgram(const char*programFilename)
 
     programPath = processDir;
     programPath.join(programFilename);
-    if (programPath.exists()) {
+    if (tryPath(programPath, verbose)) {
         return programPath;
     }
 
@@ -51,7 +61,7 @@ findProgram(const char*programFilename)
     // Try absolute install directory
     programPath = APITRACE_PROGRAMS_INSTALL_DIR;
     programPath.join(programFilename);
-    if (programPath.exists()) {
+    if (tryPath(programPath, verbose)) {
         return programPath;
     }
 #endif
@@ -60,7 +70,7 @@ findProgram(const char*programFilename)
 }
 
 os::String
-findWrapper(const char *wrapperFilename)
+findWrapper(const char *wrapperFilename, bool verbose)
 {
     os::String wrapperPath;
 
@@ -70,9 +80,16 @@ findWrapper(const char *wrapperFilename)
     // Try relative build directory
     // XXX: Just make build and install directory layout match
     wrapperPath = processDir;
+#if defined(APITRACE_CONFIGURATION_SUBDIR)
+    // Go from `Debug\apitrace.exe` to `wrappers\Debug\foo.dll` on MSVC builds.
+    wrapperPath.join("..");
     wrapperPath.join("wrappers");
+    wrapperPath.join(APITRACE_CONFIGURATION_SUBDIR);
+#else
+    wrapperPath.join("wrappers");
+#endif
     wrapperPath.join(wrapperFilename);
-    if (wrapperPath.exists()) {
+    if (tryPath(wrapperPath, verbose)) {
         return wrapperPath;
     }
 
@@ -86,7 +103,7 @@ findWrapper(const char *wrapperFilename)
     wrapperPath.join("../lib/apitrace/wrappers");
 #endif
     wrapperPath.join(wrapperFilename);
-    if (wrapperPath.exists()) {
+    if (tryPath(wrapperPath, verbose)) {
         return wrapperPath;
     }
 
@@ -94,7 +111,7 @@ findWrapper(const char *wrapperFilename)
     // Try absolute install directory
     wrapperPath = APITRACE_WRAPPERS_INSTALL_DIR;
     wrapperPath.join(wrapperFilename);
-    if (wrapperPath.exists()) {
+    if (tryPath(wrapperPath, verbose)) {
         return wrapperPath;
     }
 #endif
@@ -103,7 +120,7 @@ findWrapper(const char *wrapperFilename)
 }
 
 os::String
-findScript(const char *scriptFilename)
+findScript(const char *scriptFilename, bool verbose)
 {
     os::String scriptPath;
 
@@ -116,7 +133,7 @@ findScript(const char *scriptFilename)
     scriptPath = APITRACE_SOURCE_DIR;
     scriptPath.join("scripts");
     scriptPath.join(scriptFilename);
-    if (scriptPath.exists()) {
+    if (tryPath(scriptPath, verbose)) {
         return scriptPath;
     }
 #endif
@@ -131,7 +148,7 @@ findScript(const char *scriptFilename)
     scriptPath.join("../lib/apitrace/scripts");
 #endif
     scriptPath.join(scriptFilename);
-    if (scriptPath.exists()) {
+    if (tryPath(scriptPath, verbose)) {
         return scriptPath;
     }
 
@@ -139,7 +156,7 @@ findScript(const char *scriptFilename)
     // Try absolute install directory
     scriptPath = APITRACE_SCRIPTS_INSTALL_DIR;
     scriptPath.join(scriptFilename);
-    if (scriptPath.exists()) {
+    if (tryPath(scriptPath, verbose)) {
         return scriptPath;
     }
 #endif
index dde86dd58971f6833e105e3203bb7854495595a3..ee3882be51c1757fef64e383287807695f1b007b 100644 (file)
 
 
 os::String
-findProgram(const char*programFilename);
+findProgram(const char *programFilename, bool verbose = false);
 
 os::String
-findScript(const char *name);
+findScript(const char *name, bool verbose = false);
 
 os::String
-findWrapper(const char *wrapperFilename);
+findWrapper(const char *wrapperFilename, bool verbose = false);
 
 
 #endif /* _CLI_RESOURCES_HPP_ */
index 8c7f5b125dfda176841bbc9ab0468e4d3d466fd7..52843c70703564af811410553a3cfc95dd278fb5 100644 (file)
@@ -126,9 +126,9 @@ traceProgram(trace::API api,
         return 1;
     }
 
-    os::String wrapperPath = findWrapper(wrapperFilename);
+    os::String wrapperPath = findWrapper(wrapperFilename, verbose);
     if (!wrapperPath.length()) {
-        std::cerr << "error: failed to find " << wrapperFilename << "\n";
+        std::cerr << "error: failed to find " << wrapperFilename << " wrapper\n";
         goto exit;
     }