Build x86 and x64 variants of windows dlls.

This commit is contained in:
Adam Murdoch
2012-09-16 09:33:47 +10:00
parent b44e037b05
commit d5404493cf
2 changed files with 29 additions and 5 deletions

View File

@@ -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'
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 {

View File

@@ -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()));
}