121 lines
3.3 KiB
Groovy
121 lines
3.3 KiB
Groovy
apply plugin: 'cpp'
|
|
apply plugin: 'java'
|
|
apply plugin: 'maven'
|
|
apply plugin: 'eclipse'
|
|
|
|
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 {
|
|
architecture 'i386'
|
|
operatingSystem 'windows'
|
|
}
|
|
windows_amd64 {
|
|
architecture 'amd64'
|
|
operatingSystem 'windows'
|
|
}
|
|
}
|
|
toolChains {
|
|
visualCpp(VisualCpp)
|
|
}
|
|
repositories {
|
|
libs(PrebuiltLibraries) {
|
|
dxguid {
|
|
binaries.withType(StaticLibraryBinary) {
|
|
staticLibraryFile = file("lib/${targetPlatform.name}/dxguid.lib")
|
|
}
|
|
}
|
|
dinput8 {
|
|
binaries.withType(StaticLibraryBinary) {
|
|
staticLibraryFile = file("lib/${targetPlatform.name}/dinput8.lib")
|
|
}
|
|
}
|
|
user32 {
|
|
binaries.withType(StaticLibraryBinary) {
|
|
staticLibraryFile = file("lib/${targetPlatform.name}/user32.lib")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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 {
|
|
baseName project.archivesBaseName
|
|
}
|
|
all {
|
|
binaries.withType(SharedLibraryBinary) { binary ->
|
|
cppCompiler.define 'JXINPUT_EXPORTS'
|
|
//cppCompiler.args '-Wall'
|
|
cppCompiler.args '-I' + jniHeadersDir
|
|
if (targetPlatform.operatingSystem.macOsX) {
|
|
cppCompiler.args '-I', "/System/Library/Frameworks/JavaVM.framework/Headers"
|
|
linker.args '-framework', "JavaVM"
|
|
} else if (targetPlatform.operatingSystem.linux) {
|
|
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include"
|
|
cppCompiler.args '-I', "${org.gradle.internal.jvm.Jvm.current().javaHome}/include/linux"
|
|
} else if (targetPlatform.operatingSystem.windows) {
|
|
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'
|
|
}
|
|
}
|
|
}
|
|
binaries.withType(SharedLibraryBinary) { binary ->
|
|
if (buildable) {
|
|
def builderTask = binary.tasks.builder
|
|
jar.into("native/${targetPlatform.operatingSystem.name}/${targetPlatform.architecture.name}") {
|
|
from builderTask.outputFile
|
|
}
|
|
jar.dependsOn builderTask
|
|
}
|
|
}
|
|
|
|
task sourcesJar(type: Jar, dependsOn: classes) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.java.srcDirs
|
|
}
|
|
|
|
artifacts {
|
|
archives sourcesJar
|
|
} |