Generate JNI header file from java source file

This commit is contained in:
2014-11-29 13:26:55 +00:00
parent d8f4fd4634
commit f228bb4d10
3 changed files with 41 additions and 186 deletions

View File

@@ -1,15 +1,28 @@
apply plugin: 'cpp'
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'eclipse'
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
repositories {
maven {
url 'https://github.com/Boukefalos/jlibloader/raw/mvn-repo/'
}
mavenCentral()
}
dependencies {
compile 'java3d:j3d-core:1.3.1'
compile 'com.github.boukefalos:jlibloader:0.2'
}
group = 'com.github.boukefalos'
project.archivesBaseName = 'jlibxinput'
version = '1.0'
task wrapper(type: Wrapper) {
gradleVersion = '1.12'
}
model {
platforms {
windows_i386 {
@@ -45,6 +58,20 @@ model {
}
}
def jniHeadersDir = file("$buildDir/headers")
task jniHeaders(dependsOn: compileJava) {
def outputFile = file("$jniHeadersDir/de_hardcode_jxinput_directinput_DirectInputDriver.h")
inputs.files sourceSets.main.output
outputs.file outputFile
exec {
executable org.gradle.internal.jvm.Jvm.current().getExecutable('javah')
args '-o', outputFile
args '-classpath', sourceSets.main.output.classesDir
args '-classpath', file("$buildDir/../bin")
args 'de.hardcode.jxinput.directinput.DirectInputDriver'
}
}
libraries {
main {
@@ -53,7 +80,8 @@ libraries {
all {
binaries.withType(SharedLibraryBinary) { binary ->
cppCompiler.define 'JXINPUT_EXPORTS'
cppCompiler.args '-Wall'
//cppCompiler.args '-Wall'
cppCompiler.args '-I' + jniHeadersDir
if (targetPlatform.operatingSystem.macOsX) {
cppCompiler.args '-I', "/System/Library/Frameworks/JavaVM.framework/Headers"
linker.args '-framework', "JavaVM"
@@ -64,6 +92,9 @@ libraries {
cppCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
cppCompiler.args "-I${org.gradle.internal.jvm.Jvm.current().javaHome}/include/win32"
}
tasks.withType(CppCompile) { task ->
task.dependsOn jniHeaders
}
lib library: 'dxguid', linkage: 'static'
lib library: 'dinput8', linkage: 'static'
lib library: 'user32', linkage: 'static'