- Compile 64 and 32 bit variants on Linux.
- Give each variant of the native library a unique name.
This commit is contained in:
69
build.gradle
69
build.gradle
@@ -1,6 +1,6 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'cpp-lib'
|
||||
apply plugin: 'cpp'
|
||||
apply plugin: 'idea'
|
||||
apply plugin: 'application'
|
||||
|
||||
@@ -20,27 +20,55 @@ targetCompatibility = 1.5
|
||||
|
||||
configurations.compile.extendsFrom = []
|
||||
|
||||
cpp {
|
||||
sourceSets {
|
||||
main
|
||||
}
|
||||
}
|
||||
|
||||
libraries {
|
||||
main {
|
||||
spec {
|
||||
includes([nativeHeadersDir])
|
||||
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
|
||||
includes(['/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/'])
|
||||
args("-lcurses", "-arch", "x86_64", "-arch", "i386", "-o", outputFile)
|
||||
} else if (org.gradle.internal.os.OperatingSystem.current().windows) {
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"])
|
||||
args("/DWIN32")
|
||||
} else if (org.gradle.internal.os.OperatingSystem.current().linux) {
|
||||
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
|
||||
universal.spec {
|
||||
baseName = 'native-osx-universal'
|
||||
includes(['/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/'])
|
||||
args("-lcurses", "-arch", "x86_64", "-arch", "i386", "-o", outputFile)
|
||||
}
|
||||
} else if (org.gradle.internal.os.OperatingSystem.current().windows) {
|
||||
main.spec {
|
||||
baseName = 'native-win32'
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"])
|
||||
args("/DWIN32")
|
||||
}
|
||||
} else if (org.gradle.internal.os.OperatingSystem.current().linux) {
|
||||
all {
|
||||
spec {
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"])
|
||||
args("-lcurses")
|
||||
} else {
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/solaris"])
|
||||
args("-DSOLARIS", "-lcurses")
|
||||
}
|
||||
}
|
||||
i386.spec {
|
||||
baseName = 'native-linux-i386'
|
||||
args("-m32")
|
||||
}
|
||||
amd64.spec {
|
||||
baseName = 'native-linux-amd64'
|
||||
args("-m64")
|
||||
}
|
||||
} else {
|
||||
baseName = "native-solaris"
|
||||
main.spec {
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/solaris"])
|
||||
args("-DSOLARIS", "-lcurses")
|
||||
}
|
||||
}
|
||||
all {
|
||||
spec {
|
||||
includes([nativeHeadersDir])
|
||||
}
|
||||
sourceSets << cpp.sourceSets.main
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +94,7 @@ task nativeHeaders {
|
||||
}
|
||||
|
||||
task nativeJar(type: Jar) {
|
||||
from compileMain
|
||||
from libraries.collect { it.spec.task }
|
||||
archiveName = 'native-platform-jni.jar'
|
||||
}
|
||||
|
||||
@@ -75,6 +103,7 @@ applicationDistribution.from(nativeJar) {
|
||||
into 'lib'
|
||||
}
|
||||
|
||||
compileMain.dependsOn nativeHeaders
|
||||
test.dependsOn compileMain
|
||||
|
||||
libraries.all {
|
||||
it.spec.task.dependsOn nativeHeaders
|
||||
}
|
||||
test.dependsOn libraries.collect { it.spec.task }
|
||||
|
||||
@@ -68,7 +68,9 @@ You will need a very recent snapshot of [Gradle](http://www.gradle.org/).
|
||||
|
||||
The g++ compiler is required to build the native library. You will need to `g++` package for this. Generally this is already installed.
|
||||
|
||||
You need to install the `libncurses5-dev` package to pick up the ncurses header files. Also worth installing the `ncurses-doc` package too.
|
||||
You need to install the `gcc-multilib` and `g++-multilib` packages to pick up i386 support.
|
||||
|
||||
You need to install the `libncurses5-dev` and `lib32ncurses5-dev` package to pick up the ncurses header files and i386 version. Also worth installing the `ncurses-doc` package too.
|
||||
|
||||
### Windows
|
||||
|
||||
@@ -116,5 +118,7 @@ You can run `$INSTALL_DIR/bin/native-platform` to run the test application.
|
||||
* Use fully decomposed form for unicode file names on hfs+ filesystems.
|
||||
* Handle string encoding for file system details
|
||||
* Handle string encoding for system info
|
||||
* Expose platform-specific HTTP proxy configuration. Query registry on windows to determine IE settings.
|
||||
|
||||
### Ideas
|
||||
|
||||
* Expose platform-specific HTTP proxy configuration. Query registry on windows to determine IE settings.
|
||||
|
||||
@@ -50,7 +50,7 @@ public abstract class Platform {
|
||||
|
||||
@Override
|
||||
public String getLibraryName() {
|
||||
return "native-platform.dll";
|
||||
return "native-win32.dll";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -91,11 +91,7 @@ public abstract class Platform {
|
||||
}
|
||||
}
|
||||
|
||||
private static class Unix extends Posix {
|
||||
@Override
|
||||
public String getLibraryName() {
|
||||
return "libnative-platform.so";
|
||||
}
|
||||
private abstract static class Unix extends Posix {
|
||||
}
|
||||
|
||||
private static class Linux extends Unix {
|
||||
@@ -106,9 +102,21 @@ public abstract class Platform {
|
||||
}
|
||||
return super.get(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLibraryName() {
|
||||
if (System.getProperty("os.arch").equals("amd64")) {
|
||||
return "libnative-linux-amd64.so";
|
||||
}
|
||||
return "libnative-linux-i386.so";
|
||||
}
|
||||
}
|
||||
|
||||
private static class Solaris extends Unix {
|
||||
@Override
|
||||
public String getLibraryName() {
|
||||
return "libnative-solaris.so";
|
||||
}
|
||||
}
|
||||
|
||||
private static class OsX extends Posix {
|
||||
@@ -122,7 +130,7 @@ public abstract class Platform {
|
||||
|
||||
@Override
|
||||
public String getLibraryName() {
|
||||
return "libnative-platform.dylib";
|
||||
return "libnative-osx-universal.dylib";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user