From d5404493cfdcc337cef19d19a22796858a9dd5f4 Mon Sep 17 00:00:00 2001 From: Adam Murdoch Date: Sun, 16 Sep 2012 09:33:47 +1000 Subject: [PATCH] Build x86 and x64 variants of windows dlls. --- build.gradle | 31 ++++++++++++++++--- .../platform/internal/Platform.java | 3 ++ 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/build.gradle b/build.gradle index c3b48ad..5f09f43 100755 --- a/build.gradle +++ b/build.gradle @@ -51,12 +51,33 @@ libraries { args("-lcurses", "-arch", "x86_64", "-arch", "i386", "-o", outputFile) } } else if (org.gradle.internal.os.OperatingSystem.current().windows) { - i386.spec { - baseName = 'native-platform-windows-i386' - includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"]) - includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"]) - args("/DWIN32") + all { + spec { + includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"]) + includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"]) + args("/DWIN32") + } } + + def out = new ByteArrayOutputStream() + exec { + commandLine "cl.exe", "/?" + errorOutput = out + standardOutput = new ByteArrayOutputStream() + } + def header = out.toString().readLines().head() + if (header.endsWith("for 80x86") || header.endsWith("for x86")) { + i386.spec { + baseName = 'native-platform-windows-i386' + } + } else if (header.endsWith("for x64")) { + amd64.spec { + baseName = 'native-platform-windows-amd64' + } + } else { + throw new RuntimeException("Cannot determine compiler's target architecture") + } + } else if (org.gradle.internal.os.OperatingSystem.current().linux) { all { spec { diff --git a/src/main/java/net/rubygrapefruit/platform/internal/Platform.java b/src/main/java/net/rubygrapefruit/platform/internal/Platform.java index 31fc76d..79b6341 100755 --- a/src/main/java/net/rubygrapefruit/platform/internal/Platform.java +++ b/src/main/java/net/rubygrapefruit/platform/internal/Platform.java @@ -49,6 +49,9 @@ public abstract class Platform { if (getArchitecture().equals("x86")) { return "native-platform-windows-i386.dll"; } + if (getArchitecture().equals("amd64")) { + return "native-platform-windows-amd64.dll"; + } throw new NativeIntegrationUnavailableException(String.format( "Native integration is not available for this architecture (%s) on Windows.", getArchitecture())); }