From: José Fonseca <jose.r.fonseca@gmail.com>
Date: Fri, 2 Mar 2012 10:31:19 +0000 (+0000)
Subject: Don't install in per-architecture wrapper directories.
X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=ab6ded73916c5ea5ffee7a44b5c00eab78626b1c;p=apitrace

Don't install in per-architecture wrapper directories.

CMAKE_SYSTEM_PROCESSOR is unreliable and its all a big mess.

Assume for now that people will use an apitrace suited to what they wanna
trace.
---

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0dc805a..39afc05 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -215,22 +215,14 @@ if (WIN32 OR APPLE)
     # On Windows/MacOSX, applications are usually installed on a directory of
     # their own
     set (DOC_INSTALL_DIR doc)
+    set (LIB_INSTALL_DIR lib)
 else ()
     set (DOC_INSTALL_DIR share/doc/${CMAKE_PROJECT_NAME})
-endif ()
-
-set (LIB_INSTALL_DIR lib/apitrace)
-
-if (APPLE)
-    # MacOSX uses fat binaries, so no need to have per-architecture wrapper
-    # directories
-    set (LIB_ARCH_INSTALL_DIR ${LIB_INSTALL_DIR})
-else ()
-    set (LIB_ARCH_INSTALL_DIR ${LIB_INSTALL_DIR}/${CMAKE_SYSTEM_PROCESSOR})
+    set (LIB_INSTALL_DIR lib/${CMAKE_PROJECT_NAME})
 endif ()
 
 set(SCRIPTS_INSTALL_DIR ${LIB_INSTALL_DIR}/scripts)
-set(WRAPPER_INSTALL_DIR ${LIB_ARCH_INSTALL_DIR}/wrappers)
+set(WRAPPER_INSTALL_DIR ${LIB_INSTALL_DIR}/wrappers)
 
 # Expose the binary/install directories to source
 #
diff --git a/TODO.markdown b/TODO.markdown
index e596687..0d6eaa7 100644
--- a/TODO.markdown
+++ b/TODO.markdown
@@ -7,6 +7,9 @@ Things To Do
 Tracing
 -------
 
+* Better multi-arch support on Windows/Linux -- allow one set of binaries to
+  trace both 32/64 bits applications.
+
 * Allow clamping to a GL version or a number of extensions.
 
 * Put (de)compression in a separate thread.
diff --git a/common/trace_resource.cpp b/common/trace_resource.cpp
index 31827b9..35d2b1a 100644
--- a/common/trace_resource.cpp
+++ b/common/trace_resource.cpp
@@ -69,41 +69,46 @@ findFile(const char *relPath,
 
 
 os::String
-findScript(const char *name)
+findScript(const char *scriptFilename)
 {
-    os::String path;
-
-#if defined(APITRACE_SOURCE_DIR)
-    // Try the absolute source  path -- useful for development or quick
-    // experiment.  Relative paths don't quite work here due to out of source
-    // trees.
-    path = APITRACE_SOURCE_DIR "/scripts";
-    path.join(name);
-    if (path.exists()) {
-        return path;
+    os::String scriptPath;
+
+    os::String processDir = os::getProcessName();
+    processDir.trimFilename();
+
+    // Try relative build directory
+    // XXX: Just make build and install directory layout match
+    scriptPath = processDir;
+    scriptPath.join("scripts");
+    scriptPath.join(scriptFilename);
+    if (scriptPath.exists()) {
+        return scriptPath;
     }
-#endif
 
+    // Try relative install directory
+    scriptPath = processDir;
 #if defined(_WIN32)
-    // Windows has no standard installation path, so find it relatively to the
-    // process name, which is assumed to be in a bin subdirectory.
-    path = os::getProcessName();
-    path.trimFilename();
-    path.join("..\\lib\\apitrace\\scripts");
-    path.join(name);
-    if (path.exists()) {
-        return path;
-    }
+    scriptPath.join("..\\lib\\scripts");
+#elif defined(__APPLE__)
+    scriptPath.join("../lib/scripts");
 #else
-    // Assume a predefined installation path on Unices
-    path = APITRACE_INSTALL_PREFIX "/lib/apitrace/scripts";
-    path.join(name);
-    if (path.exists()) {
-        return path;
+    scriptPath.join("../lib/apitrace/scripts");
+#endif
+    scriptPath.join(scriptFilename);
+    if (scriptPath.exists()) {
+        return scriptPath;
+    }
+
+#ifndef _WIN32
+    // Try absolute install directory
+    scriptPath = APITRACE_WRAPPER_INSTALL_DIR;
+    scriptPath.join(scriptFilename);
+    if (scriptPath.exists()) {
+        return scriptPath;
     }
 #endif
 
-    std::cerr << "error: cannot find " << name << " script\n";
+    std::cerr << "error: cannot find " << scriptFilename << " script\n";
 
     return "";
 }
diff --git a/common/trace_tools_trace.cpp b/common/trace_tools_trace.cpp
index fe6b3e2..36fe735 100644
--- a/common/trace_tools_trace.cpp
+++ b/common/trace_tools_trace.cpp
@@ -70,8 +70,10 @@ findWrapper(const char *wrapperFilename)
 
     // Try relative install directory
     wrapperPath = processDir;
-#ifdef _WIN32
-    wrapperPath.join("..\\lib\\apitrace\\wrappers");
+#if defined(_WIN32)
+    wrapperPath.join("..\\lib\\wrappers");
+#elif defined(__APPLE__)
+    wrapperPath.join("../lib/wrappers");
 #else
     wrapperPath.join("../lib/apitrace/wrappers");
 #endif