]> git.cworth.org Git - apitrace/commitdiff
Don't link against d3d9 in runtime.
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 14 Apr 2012 16:24:14 +0000 (17:24 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sat, 14 Apr 2012 16:24:14 +0000 (17:24 +0100)
retrace/CMakeLists.txt
retrace/d3dretrace.py
retrace/dllretrace.py [new file with mode: 0644]

index c45b33fd679e06ad2179cfe86d23ed793b92f8b7..358361e14e515973db393f23ccb74b0367ef4cb3 100644 (file)
@@ -115,7 +115,7 @@ if (ENABLE_EGL AND X11_FOUND AND NOT WIN32 AND NOT APPLE)
     install (TARGETS eglretrace RUNTIME DESTINATION bin) 
 endif ()
 
-if (WIN32 AND DirectX_D3DX9_FOUND)
+if (WIN32 AND DirectX_D3DX9_INCLUDE_DIR)
     add_custom_command (
         OUTPUT d3dretrace_d3d9.cpp
         COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/d3dretrace.py > ${CMAKE_CURRENT_BINARY_DIR}/d3dretrace_d3d9.cpp
@@ -140,7 +140,6 @@ if (WIN32 AND DirectX_D3DX9_FOUND)
         common
         ${ZLIB_LIBRARIES}
         ${SNAPPY_LIBRARIES}
-        ${DirectX_D3D9_LIBRARY}
     )
 endif ()
 
index f472a0aa54ba63c328ad9b67fb5d2e556f53dd00..ca936f2556ce0f38d4f5cd537957b05ae9662a00 100644 (file)
@@ -27,7 +27,7 @@
 """GL retracer generator."""
 
 
-from retrace import Retracer
+from dllretrace import DllRetracer as Retracer
 import specs.stdapi as stdapi
 from specs.d3d9 import d3d9
 
diff --git a/retrace/dllretrace.py b/retrace/dllretrace.py
new file mode 100644 (file)
index 0000000..51e2c68
--- /dev/null
@@ -0,0 +1,64 @@
+##########################################################################
+#
+# Copyright 2008-2010 VMware, Inc.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+#
+##########################################################################/
+
+
+from retrace import Retracer
+from dispatch import Dispatcher
+
+
+class DllRetracer(Retracer):
+
+    def retraceApi(self, api):
+        print '''
+static HINSTANCE g_hDll = NULL;
+
+static PROC
+__getPublicProcAddress(LPCSTR lpProcName)
+{
+    if (!g_hDll) {
+        char szDll[MAX_PATH] = {0};
+        
+        if (!GetSystemDirectoryA(szDll, MAX_PATH)) {
+            return NULL;
+        }
+        
+        strcat(szDll, "\\\\%s");
+        
+        g_hDll = LoadLibraryA(szDll);
+        if (!g_hDll) {
+            return NULL;
+        }
+    }
+        
+    return GetProcAddress(g_hDll, lpProcName);
+}
+
+''' % api.name
+
+        dispatcher = Dispatcher()
+        dispatcher.dispatch_api(api)
+
+        Retracer.retraceApi(self, api)
+