- Compile 64 and 32 bit variants on Linux.
- Give each variant of the native library a unique name.
This commit is contained in:
45
build.gradle
45
build.gradle
@@ -1,6 +1,6 @@
|
|||||||
apply plugin: 'java'
|
apply plugin: 'java'
|
||||||
apply plugin: 'groovy'
|
apply plugin: 'groovy'
|
||||||
apply plugin: 'cpp-lib'
|
apply plugin: 'cpp'
|
||||||
apply plugin: 'idea'
|
apply plugin: 'idea'
|
||||||
apply plugin: 'application'
|
apply plugin: 'application'
|
||||||
|
|
||||||
@@ -20,27 +20,55 @@ targetCompatibility = 1.5
|
|||||||
|
|
||||||
configurations.compile.extendsFrom = []
|
configurations.compile.extendsFrom = []
|
||||||
|
|
||||||
|
cpp {
|
||||||
|
sourceSets {
|
||||||
|
main
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
libraries {
|
libraries {
|
||||||
main {
|
|
||||||
spec {
|
|
||||||
includes([nativeHeadersDir])
|
|
||||||
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
|
if (org.gradle.internal.os.OperatingSystem.current().macOsX) {
|
||||||
|
universal.spec {
|
||||||
|
baseName = 'native-osx-universal'
|
||||||
includes(['/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/'])
|
includes(['/System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/'])
|
||||||
args("-lcurses", "-arch", "x86_64", "-arch", "i386", "-o", outputFile)
|
args("-lcurses", "-arch", "x86_64", "-arch", "i386", "-o", outputFile)
|
||||||
|
}
|
||||||
} else if (org.gradle.internal.os.OperatingSystem.current().windows) {
|
} 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"])
|
||||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"])
|
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"])
|
||||||
args("/DWIN32")
|
args("/DWIN32")
|
||||||
|
}
|
||||||
} else if (org.gradle.internal.os.OperatingSystem.current().linux) {
|
} 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"])
|
||||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"])
|
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"])
|
||||||
args("-lcurses")
|
args("-lcurses")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
i386.spec {
|
||||||
|
baseName = 'native-linux-i386'
|
||||||
|
args("-m32")
|
||||||
|
}
|
||||||
|
amd64.spec {
|
||||||
|
baseName = 'native-linux-amd64'
|
||||||
|
args("-m64")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
baseName = "native-solaris"
|
||||||
|
main.spec {
|
||||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include"])
|
||||||
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/solaris"])
|
includes(["${org.gradle.internal.jvm.Jvm.current().javaHome}/include/solaris"])
|
||||||
args("-DSOLARIS", "-lcurses")
|
args("-DSOLARIS", "-lcurses")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
all {
|
||||||
|
spec {
|
||||||
|
includes([nativeHeadersDir])
|
||||||
|
}
|
||||||
|
sourceSets << cpp.sourceSets.main
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +94,7 @@ task nativeHeaders {
|
|||||||
}
|
}
|
||||||
|
|
||||||
task nativeJar(type: Jar) {
|
task nativeJar(type: Jar) {
|
||||||
from compileMain
|
from libraries.collect { it.spec.task }
|
||||||
archiveName = 'native-platform-jni.jar'
|
archiveName = 'native-platform-jni.jar'
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,6 +103,7 @@ applicationDistribution.from(nativeJar) {
|
|||||||
into 'lib'
|
into 'lib'
|
||||||
}
|
}
|
||||||
|
|
||||||
compileMain.dependsOn nativeHeaders
|
libraries.all {
|
||||||
test.dependsOn compileMain
|
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.
|
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
|
### 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.
|
* Use fully decomposed form for unicode file names on hfs+ filesystems.
|
||||||
* Handle string encoding for file system details
|
* Handle string encoding for file system details
|
||||||
* Handle string encoding for system info
|
* 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
|
@Override
|
||||||
public String getLibraryName() {
|
public String getLibraryName() {
|
||||||
return "native-platform.dll";
|
return "native-win32.dll";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -91,11 +91,7 @@ public abstract class Platform {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Unix extends Posix {
|
private abstract static class Unix extends Posix {
|
||||||
@Override
|
|
||||||
public String getLibraryName() {
|
|
||||||
return "libnative-platform.so";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class Linux extends Unix {
|
private static class Linux extends Unix {
|
||||||
@@ -106,9 +102,21 @@ public abstract class Platform {
|
|||||||
}
|
}
|
||||||
return super.get(type);
|
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 {
|
private static class Solaris extends Unix {
|
||||||
|
@Override
|
||||||
|
public String getLibraryName() {
|
||||||
|
return "libnative-solaris.so";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class OsX extends Posix {
|
private static class OsX extends Posix {
|
||||||
@@ -122,7 +130,7 @@ public abstract class Platform {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getLibraryName() {
|
public String getLibraryName() {
|
||||||
return "libnative-platform.dylib";
|
return "libnative-osx-universal.dylib";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user