* First attempt at building android-natives. * Use OpenJDK because native build is broken without * Try OpenJDK 10 * Try openJDK 9 * Try openJDK11 again but "enable" the EE Module * OpenJDK 11 has no Java EE Module anymore. * Try to fix Android Header Generation * Fix invalid flag error with javac by removing empty quotes * Try to fix build of decode. * Remove jni generated headers from the repository. * Adjust .gitignore as those header files won't appear at that location anymore * Fix Android Build: Fill the jme3-android-native headers during the build of jme3-android. This works because jme3-android-native already depends on jme3-android. Due to technical reasons, the headers share the same location and thus the include directives have been adjusted slightly. * Copy jni headers to the jni directory. * Adjust the path slightly * Try to silence android sdk's license print out * Also fix openAL * Solve task name conflict * Really silence license now * Tasks seem shared but Strings are not... * Only build Android-Native * Trying to reduce the amount of dependencies needed. * Remove even more dependencies * Even more removal * Prepare Deployment * Fix Deployment * Cleanup: Remove feature branch from branches for travis. * Revert a few unnecessary things * Removed NDK Comments.
111 lines
3.3 KiB
Groovy
111 lines
3.3 KiB
Groovy
String tremorZipFile = "TremorAndroid.zip"
|
|
String stbiUrl = 'https://raw.githubusercontent.com/nothings/stb/master/stb_image.h'
|
|
|
|
// Working directories for the ndk build.
|
|
String decodeBuildDir = "${buildDir}" + File.separator + 'decode'
|
|
String decodeClassesBuildDir = "${buildDir}" + File.separator + 'decode_classes'
|
|
String decodeBuildJniDir = decodeBuildDir + File.separator + 'jni'
|
|
String decodeBuildLibsDir = decodeBuildDir + File.separator + 'libs'
|
|
|
|
// Pre-compiled libs directory
|
|
String decodePreCompiledLibsDir = 'libs' + File.separator + 'decode'
|
|
|
|
// jME Android Native source files path
|
|
String decodeSourceDir = 'src/native/jme_decode'
|
|
String jmeHeaders = 'src/native/headers'
|
|
|
|
task downloadStbImage(type: MyDownload) {
|
|
sourceUrl = stbiUrl
|
|
target = file(decodeBuildDir + File.separator + 'stb_image.h')
|
|
}
|
|
|
|
// Copy stb_image.h to the jni directory.
|
|
task copyStbiFiles(type: Copy) {
|
|
def sourceDir = file(decodeBuildDir + File.separator + 'stb_image.h')
|
|
def outputDir = file(decodeBuildJniDir + File.separator + "STBI")
|
|
from sourceDir
|
|
into outputDir
|
|
}
|
|
copyStbiFiles.dependsOn {
|
|
def stbiFile = file(decodeBuildDir + File.separator + 'stb_image.h')
|
|
if (!stbiFile.exists()) {
|
|
downloadStbImage
|
|
}
|
|
}
|
|
|
|
// Copy libtremor source to the jni directory.
|
|
task copyTremorFiles(type: Copy) {
|
|
def zipFile = file(tremorZipFile)
|
|
def outputDir = file(decodeBuildJniDir + File.separator + "Tremor")
|
|
|
|
from (zipTree(zipFile)) {
|
|
include '*.c'
|
|
include '*.h'
|
|
}
|
|
|
|
into outputDir
|
|
}
|
|
|
|
task copyJmeHeadersDecode(type: Copy) {
|
|
from file(jmeHeaders)
|
|
into file(decodeBuildJniDir + File.separator + "headers")
|
|
}
|
|
|
|
// Copy jME Android native files to jni directory
|
|
task copySourceToBuild(type: Copy, dependsOn:[copyTremorFiles, copyStbiFiles, copyJmeHeadersDecode]) {
|
|
def sourceDir = file(decodeSourceDir)
|
|
def outputDir = file(decodeBuildJniDir)
|
|
|
|
from sourceDir
|
|
into outputDir
|
|
}
|
|
|
|
task buildNativeLib(type: Exec, dependsOn: copySourceToBuild) {
|
|
workingDir decodeBuildDir
|
|
executable rootProject.ndkCommandPath
|
|
args "-j" + Runtime.runtime.availableProcessors()
|
|
}
|
|
|
|
task updatePreCompiledLibs(type: Copy, dependsOn: buildNativeLib) {
|
|
def sourceDir = new File(decodeBuildLibsDir)
|
|
def outputDir = new File(decodePreCompiledLibsDir)
|
|
|
|
from sourceDir
|
|
into outputDir
|
|
}
|
|
|
|
// Copy pre-compiled libs to build directory (when not building new libs)
|
|
task copyPreCompiledLibs(type: Copy) {
|
|
def sourceDir = file(decodePreCompiledLibsDir)
|
|
def outputDir = file(decodeBuildLibsDir)
|
|
|
|
from sourceDir
|
|
into outputDir
|
|
}
|
|
|
|
// ndkExists is a boolean from the build.gradle in the root project
|
|
// buildNativeProjects is a string set to "true"
|
|
if (ndkExists && buildNativeProjects == "true") {
|
|
// build native libs and update stored pre-compiled libs to commit
|
|
compileJava.dependsOn { updatePreCompiledLibs }
|
|
} else {
|
|
// use pre-compiled native libs (not building new ones)
|
|
compileJava.dependsOn { copyPreCompiledLibs }
|
|
}
|
|
|
|
jar.into("lib") { from decodeBuildLibsDir }
|
|
|
|
// Helper class to wrap ant dowload task
|
|
class MyDownload extends DefaultTask {
|
|
@Input
|
|
String sourceUrl
|
|
|
|
@OutputFile
|
|
File target
|
|
|
|
@TaskAction
|
|
void download() {
|
|
ant.get(src: sourceUrl, dest: target)
|
|
}
|
|
}
|