* 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. * Bullet Android: Some cosmetic changes (removed commented debug code) and generate bullet-native headers during jme3-bullet compilation. * Fix Bullet Build by using GNU libstdc++ instead of STLPort (discontinued) * Fix Bullet-Native Compilation
131 lines
3.6 KiB
Groovy
131 lines
3.6 KiB
Groovy
String jmeBulletNativeProjectPath = project(":jme3-bullet-native").projectDir
|
|
|
|
String localUnzipPath = jmeBulletNativeProjectPath
|
|
String localZipFile = jmeBulletNativeProjectPath + File.separator + bulletZipFile
|
|
String localZipFolder = jmeBulletNativeProjectPath + File.separator + bulletFolder
|
|
String bulletSrcPath = localZipFolder + File.separator + 'src'
|
|
|
|
String jmeAndroidPath = 'src/native/android'
|
|
String jmeCppPath = jmeBulletNativeProjectPath + '/src/native/cpp'
|
|
|
|
//Working directories for the ndk build.
|
|
String ndkWorkingPath = "${buildDir}" + '/bullet'
|
|
String jniPath = ndkWorkingPath + '/jni'
|
|
String ndkOutputPath = ndkWorkingPath + '/libs'
|
|
|
|
//Pre-compiled libs directory
|
|
String bulletPreCompiledLibsDir = 'libs'
|
|
|
|
if (!hasProperty('mainClass')) {
|
|
ext.mainClass = ''
|
|
}
|
|
|
|
dependencies {
|
|
compile project(':jme3-bullet')
|
|
}
|
|
|
|
// Java source sets for IDE access and source jar bundling / mavenization
|
|
sourceSets {
|
|
main {
|
|
java {
|
|
srcDir jmeCppPath
|
|
srcDir jmeAndroidPath
|
|
}
|
|
}
|
|
}
|
|
|
|
// Download bullet if not available
|
|
task downloadBullet(type: MyDownload) {
|
|
sourceUrl = bulletUrl
|
|
target = file(localZipFile)
|
|
}
|
|
|
|
// Unzip bullet if not available
|
|
task unzipBullet(type: Copy) {
|
|
from zipTree(localZipFile)
|
|
into file(localUnzipPath)
|
|
}
|
|
|
|
unzipBullet.dependsOn {
|
|
if (!file(localZipFile).exists()) {
|
|
downloadBullet
|
|
}
|
|
}
|
|
|
|
// Copy Bullet files to jni directory
|
|
task copyBullet(type: Copy) {
|
|
from file(bulletSrcPath)
|
|
into file(jniPath)
|
|
}
|
|
|
|
copyBullet.dependsOn {
|
|
if (!file(localZipFolder).isDirectory()) {
|
|
unzipBullet
|
|
}
|
|
}
|
|
|
|
// Copy jME cpp native files to jni directory
|
|
task copyJmeCpp(type: Copy) {
|
|
from file(jmeCppPath)
|
|
into file(jniPath)
|
|
}
|
|
|
|
// Copy jME android native files to jni directory
|
|
task copyJmeAndroid(type: Copy) {
|
|
from file(jmeAndroidPath)
|
|
into file(jniPath)
|
|
}
|
|
|
|
task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:compileJava', copyJmeCpp, copyBullet]) {
|
|
// args 'TARGET_PLATFORM=android-9'
|
|
// println "buildBulletNativeLib ndkWorkingPath: " + ndkWorkingPath
|
|
// println "buildBulletNativeLib rootProject.ndkCommandPath: " + rootProject.ndkCommandPath
|
|
workingDir ndkWorkingPath
|
|
executable rootProject.ndkCommandPath
|
|
args "-j" + Runtime.runtime.availableProcessors()
|
|
}
|
|
|
|
/* The following two tasks: We store a prebuilt version in the repository, so nobody has to build
|
|
* natives in order to build the engine. When building these natives however, the prebuilt libraries
|
|
* can be updated (which is what the CI does). That's what the following two tasks do
|
|
*/
|
|
|
|
task updatePreCompiledBulletLibs(type: Copy, dependsOn: buildBulletNativeLib) {
|
|
from file(ndkOutputPath)
|
|
into file(bulletPreCompiledLibsDir)
|
|
}
|
|
|
|
// Copy pre-compiled libs to build directory (when not building new libs)
|
|
task copyPreCompiledBulletLibs(type: Copy) {
|
|
from file(bulletPreCompiledLibsDir)
|
|
into file(ndkOutputPath)
|
|
}
|
|
|
|
// 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 { updatePreCompiledBulletLibs }
|
|
} else {
|
|
// use pre-compiled native libs (not building new ones)
|
|
compileJava.dependsOn { copyPreCompiledBulletLibs }
|
|
}
|
|
|
|
jar.into("lib") { from ndkOutputPath }
|
|
|
|
|
|
// Helper class to wrap ant download task
|
|
class MyDownload extends DefaultTask {
|
|
@Input
|
|
String sourceUrl
|
|
|
|
@OutputFile
|
|
File target
|
|
|
|
@TaskAction
|
|
void download() {
|
|
ant.get(src: sourceUrl, dest: target)
|
|
}
|
|
}
|
|
|