diff --git a/Makefile.am b/Makefile.am index 3dd39101..25fa3289 100644 --- a/Makefile.am +++ b/Makefile.am @@ -44,3 +44,50 @@ libvkd3d.pc: $(srcdir)/libs/vkd3d/libvkd3d.pc.in -e 's![@]libdir[@]!$(libdir)!g' \ -e 's![@]PACKAGE_VERSION[@]!$(PACKAGE_VERSION)!g' \ $< > $@ + +## Cross-compile tests +cross_implibs = crosslibs/d3d12 +CROSS_CPPFLAGS = -I$(srcdir)/include -I$(srcdir)/include/private -I$(builddir)/include + +if HAS_CROSSTARGET32 +CROSS32_CC = @CROSSCC32@ +CROSS32_DLLTOOL = @CROSSTARGET32@-dlltool +CROSS32_IMPLIBS = $(cross_implibs:=.cross32.a) +CROSS32_EXEFILES = $(vkd3d_tests:=.cross32.exe) +CROSS32_FILES = $(CROSS32_IMPLIBS) $(CROSS32_EXEFILES) + +CLEANFILES += $(CROSS32_FILES) +crosstest32: $(widl_headers) $(CROSS32_FILES) + +$(CROSS32_IMPLIBS): %.cross32.a: %.cross32.def + ${MKDIR_P} crosslibs + $(CROSS32_DLLTOOL) -k -m i386 --as-flags=-32 -d $< -l $@ + +$(CROSS32_EXEFILES): %.cross32.exe: %.c $(CROSS32_IMPLIBS) + $(CROSS32_CC) $(CROSS_CPPFLAGS) -o $@ $< $(CROSS32_IMPLIBS) +else +crosstest32: +endif + +if HAS_CROSSTARGET64 +CROSS64_CC = @CROSSCC64@ +CROSS64_DLLTOOL = @CROSSTARGET64@-dlltool +CROSS64_IMPLIBS = $(cross_implibs:=.cross64.a) +CROSS64_EXEFILES = $(vkd3d_tests:=.cross64.exe) +CROSS64_FILES = $(CROSS64_IMPLIBS) $(CROSS64_EXEFILES) + +CLEANFILES += $(CROSS64_FILES) +crosstest64: $(widl_headers) $(CROSS64_FILES) + +$(CROSS64_IMPLIBS): %.cross64.a: %.cross64.def + ${MKDIR_P} crosslibs + $(CROSS64_DLLTOOL) -k -m i386:x86-64 --as-flags=-64 -d $< -l $@ + +$(CROSS64_EXEFILES): %.cross64.exe: %.c $(CROSS64_IMPLIBS) + $(CROSS64_CC) $(CROSS_CPPFLAGS) -o $@ $< $(CROSS64_IMPLIBS) +else +crosstest64: +endif + +.PHONY: crosstest crosstest32 crosstest64 +crosstest: crosstest32 crosstest64 diff --git a/configure.ac b/configure.ac index e9285663..6dd107ed 100644 --- a/configure.ac +++ b/configure.ac @@ -58,6 +58,13 @@ AC_LINK_IFELSE( AC_DEFINE([HAVE_SYNC_SUB_AND_FETCH], [1], [Define to 1 if you have __sync_sub_and_fetch.])], [AC_MSG_RESULT([no])]) +dnl Check for cross compilers +VKD3D_CHECK_MINGW32_PROG(CROSSCC32, CROSSTARGET32, false) +VKD3D_CHECK_MINGW64_PROG(CROSSCC64, CROSSTARGET64, false) + +AM_CONDITIONAL([HAS_CROSSTARGET32], [test "x$CROSSTARGET32" != xfalse]) +AM_CONDITIONAL([HAS_CROSSTARGET64], [test "x$CROSSTARGET64" != xfalse]) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/crosslibs/d3d12.cross32.def b/crosslibs/d3d12.cross32.def new file mode 100644 index 00000000..d3d62b8f --- /dev/null +++ b/crosslibs/d3d12.cross32.def @@ -0,0 +1,7 @@ +LIBRARY D3D12.dll + +EXPORTS + D3D12CreateDevice@16 @101 + D3D12GetDebugInterface@8 @102 + D3D12CreateRootSignatureDeserializer@16 @106 + D3D12SerializeRootSignature@16 @107 diff --git a/crosslibs/d3d12.cross64.def b/crosslibs/d3d12.cross64.def new file mode 100644 index 00000000..c61b3145 --- /dev/null +++ b/crosslibs/d3d12.cross64.def @@ -0,0 +1,7 @@ +LIBRARY D3D12.dll + +EXPORTS + D3D12CreateDevice @101 + D3D12GetDebugInterface @102 + D3D12CreateRootSignatureDeserializer @106 + D3D12SerializeRootSignature @107 diff --git a/include/vkd3d_windows.h b/include/vkd3d_windows.h index 55da7c0f..c1f9c7ff 100644 --- a/include/vkd3d_windows.h +++ b/include/vkd3d_windows.h @@ -182,7 +182,15 @@ typedef struct SECURITY_ATTRIBUTES SECURITY_ATTRIBUTES; # define IsEqualGUID(guid1, guid2) (!memcmp(guid1, guid2, sizeof(GUID))) #endif +#elif !defined(__WIDL__) + +# include + +# ifndef __C89_NAMELESS +# define __C89_NAMELESS +# define __C89_NAMELESSUNIONNAME +# endif /* __C89_NAMELESS */ + #endif /* _WIN32 */ - #endif /* __VKD3D_WINDOWS_H */ diff --git a/m4/check-mingw-prog.m4 b/m4/check-mingw-prog.m4 new file mode 100644 index 00000000..a5f0af26 --- /dev/null +++ b/m4/check-mingw-prog.m4 @@ -0,0 +1,56 @@ +dnl VKD3D_CHECK_MINGW32_PROG(variable, crosstarget-variable, [value-if-not-found], [path]) +AC_DEFUN([VKD3D_CHECK_MINGW32_PROG], +[ +AC_SUBST([$2], [$3])dnl +ac_prefix_list="m4_foreach([ac_vkd3d_prefix], [w64-mingw32, pc-mingw32, mingw32msvc, mingw32], + m4_foreach([ac_vkd3d_cpu], [i686, i586, i486, i386], [ac_vkd3d_cpu-ac_vkd3d_prefix-gcc ])) + mingw32-gcc" +AC_CHECK_PROGS([$1], [$ac_prefix_list], [$3], [$4]) +if test "x[$]$1" != x$3 +then + ac_vkd3d_save_CC="$CC" + CC="[$]$1" + AC_MSG_CHECKING([whether $CC works]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes]) + set x [$]$1 + shift + while test "[$]#" -ge 1 + do + case "[$]1" in + *-gcc) $2=`expr "[$]1" : '\(.*\)-gcc'` ;; + esac + shift + done], + [AC_MSG_RESULT([no])]) + CC="$ac_vkd3d_save_CC" +fi +]) + +dnl VKD3D_CHECK_MINGW64_PROG(variable, crosstarget-variable, [value-if-not-found], [path]) +AC_DEFUN([VKD3D_CHECK_MINGW64_PROG], +[ +AC_SUBST([$2], [$3])dnl +ac_prefix_list="m4_foreach([ac_vkd3d_prefix], [pc-mingw32, w64-mingw32, mingw32msvc], + m4_foreach([ac_vkd3d_cpu], [x86_64, amd64], [ac_vkd3d_cpu-ac_vkd3d_prefix-gcc ]))" +AC_CHECK_PROGS([$1], [$ac_prefix_list], [$3], [$4]) +if test "x[$]$1" != x$3 +then + ac_vkd3d_save_CC="$CC" + CC="[$]$1" + AC_MSG_CHECKING([whether $CC works]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])], + [AC_MSG_RESULT([yes]) + set x [$]$1 + shift + while test "[$]#" -ge 1 + do + case "[$]1" in + *-gcc) $2=`expr "[$]1" : '\(.*\)-gcc'` ;; + esac + shift + done], + [AC_MSG_RESULT([no])]) + CC="$ac_vkd3d_save_CC" +fi +]) diff --git a/tests/d3d12.c b/tests/d3d12.c index 3e00a1ab..14cdc7bd 100644 --- a/tests/d3d12.c +++ b/tests/d3d12.c @@ -20,9 +20,6 @@ * DEALINGS IN THE SOFTWARE. */ -#define INITGUID -#include "vkd3d_test.h" -#include "vkd3d_windows.h" /* Hack for MinGW-w64 headers. * @@ -34,14 +31,21 @@ * specifiers" compiler error. */ #ifdef __MINGW32__ -#include <_mingw.h> +# include <_mingw.h> # ifdef __MINGW64_VERSION_MAJOR # undef __forceinline # define __forceinline __inline__ __attribute__((__always_inline__,__gnu_inline__)) # endif + +# define _HRESULT_DEFINED +typedef int HRESULT; #endif +#define INITGUID #define COBJMACROS +#include "vkd3d_test.h" +#include "vkd3d_windows.h" + #define WIDL_C_INLINE_WRAPPERS #include "d3d12.h" @@ -88,7 +92,7 @@ static void test_create_device(void) check_interface(device, &IID_ID3D12Device, TRUE); refcount = ID3D12Device_Release(device); - ok(!refcount, "ID3D12Device has %u references left.\n", refcount); + ok(!refcount, "ID3D12Device has %u references left.\n", (unsigned int)refcount); hr = D3D12CreateDevice(NULL, D3D_FEATURE_LEVEL_11_0, &IID_ID3D12Device, (void **)&device); ok(hr == S_OK, "D3D12CreateDevice failed, hr %#x.\n", hr);