MeFisto94 90d3b69bd1 Build Android Natives (OpenAL, Vorbis, TextureLoading) on Travis (#1171)
* 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.
2019-09-14 11:26:18 -07:00

138 lines
4.9 KiB
Groovy

// OpenAL Soft r1.16
String openALSoftUrl = 'http://repo.or.cz/w/openal-soft.git/snapshot/e5016f814a265ed592a88acea95cf912c4bfdf12.zip'
String openALSoftZipFile = 'OpenALSoft.zip'
// OpenAL Soft directory the download is extracted into
// Typically, the downloaded OpenAL Soft zip file will extract to a directory
// called "openal-soft"
String openALSoftFolder = 'openal-soft-e5016f8'
//Working directories for the ndk build.
String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft'
String openalsoftClassesBuildDir = "${buildDir}" + File.separator + 'openalsoft_classes'
String openalsoftBuildJniDir = openalsoftBuildDir + File.separator + 'jni'
String openalsoftBuildLibsDir = openalsoftBuildDir + File.separator + 'libs'
//Pre-compiled libs directory
String openalsoftPreCompiledLibsDir = 'libs' + File.separator + 'openalsoft'
// jME Android Native source files path
String openalsoftJmeAndroidPath = 'src/native/jme_openalsoft'
String jmeHeaders = 'src/native/headers'
// Download external source files if not available
task downloadOpenALSoft(type: MyDownload) {
sourceUrl = openALSoftUrl
target = file(openalsoftBuildDir + File.separator + openALSoftZipFile)
}
// Unzip external source files
task unzipOpenALSoft(type: Copy) {
def zipFile = file(openalsoftBuildDir + File.separator + openALSoftZipFile)
def outputDir = file(openalsoftBuildDir)
from zipTree(zipFile)
into outputDir
}
unzipOpenALSoft.dependsOn {
def zipFilePath = openalsoftBuildDir + File.separator + openALSoftZipFile
def zipFile = new File(zipFilePath)
// println "zipFile path: " + zipFile.absolutePath
// println "zipFile exists: " + zipFile.exists()
if (!zipFile.exists()) {
downloadOpenALSoft
}
}
// Copy external source files to jni directory
task copyOpenALSoft(type: Copy) {
def sourceDir = file(openalsoftBuildDir + File.separator + openALSoftFolder)
def outputDir = file(openalsoftBuildJniDir)
// println "copyOpenALSoft sourceDir: " + sourceDir
// println "copyOpenALSoft outputDir: " + outputDir
from sourceDir
into outputDir
}
copyOpenALSoft.dependsOn {
def openALSoftUnzipDir = new File(project.projectDir.absolutePath + File.separator + openALSoftFolder)
// println "openALSoftUnzipDir path: " + openALSoftUnzipDir.absolutePath
// println "openALSoftUnzipDir exists: " + openALSoftUnzipDir.isDirectory()
if (!openALSoftUnzipDir.isDirectory()) {
unzipOpenALSoft
}
}
// Copy JME Headers to jni directory
task copyJmeHeadersOpenAL(type: Copy) {
from file(jmeHeaders)
into file(openalsoftBuildJniDir + File.separator + "headers")
}
// Copy jME Android native files to jni directory
task copyJmeOpenALSoft(type: Copy, dependsOn: [copyOpenALSoft, copyJmeHeadersOpenAL]) {
def sourceDir = file(openalsoftJmeAndroidPath)
def outputDir = file(openalsoftBuildJniDir)
// println "copyJmeOpenALSoft sourceDir: " + sourceDir
// println "copyJmeOpenALSoft outputDir: " + outputDir
from sourceDir
into outputDir
}
task buildOpenAlSoftNativeLib(type: Exec, dependsOn: copyJmeOpenALSoft) {
// println "openalsoft build dir: " + openalsoftBuildDir
// println "ndkCommandPath: " + project.ndkCommandPath
workingDir openalsoftBuildDir
executable rootProject.ndkCommandPath
args "-j" + Runtime.runtime.availableProcessors()
}
task updatePreCompiledOpenAlSoftLibs(type: Copy, dependsOn: buildOpenAlSoftNativeLib) {
def sourceDir = new File(openalsoftBuildLibsDir)
def outputDir = new File(openalsoftPreCompiledLibsDir)
// println "updatePreCompiledOpenAlSoftLibs sourceDir: " + sourceDir
// println "updatePreCompiledOpenAlSoftLibs outputDir: " + outputDir
from sourceDir
into outputDir
}
// Copy pre-compiled libs to build directory (when not building new libs)
task copyPreCompiledOpenAlSoftLibs(type: Copy) {
def sourceDir = file(openalsoftPreCompiledLibsDir)
def outputDir = file(openalsoftBuildLibsDir)
// println "copyStbiJmeFiles sourceDir: " + sourceDir
// println "copyStbiJmeFiles outputDir: " + outputDir
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 { updatePreCompiledOpenAlSoftLibs }
} else {
// use pre-compiled native libs (not building new ones)
compileJava.dependsOn { copyPreCompiledOpenAlSoftLibs }
}
jar.into("lib") { from openalsoftBuildLibsDir }
// 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)
}
}