Преглед изворни кода

Build android bullet-native on Travis (#1175)

* 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
MeFisto94 пре 6 година
родитељ
комит
1bde90d1a1

+ 1 - 1
.travis.yml

@@ -30,7 +30,7 @@ matrix:
     before_script:
       - export ANDROID_NDK=$ANDROID_HOME/ndk-bundle
     script:
-      - ./gradlew -PbuildNativeProjects=true jme3-android-native:assemble
+      - ./gradlew -PbuildNativeProjects=true jme3-android-native:assemble jme3-bullet-native-android:assemble
     after_success:
       - '[ "$TRAVIS_PULL_REQUEST" == "false" ] && ./private/upload_native.sh || :'
       - '[ -n "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && ./gradlew bintrayUpload || :'

+ 23 - 58
jme3-bullet-native-android/build.gradle

@@ -1,4 +1,4 @@
-String jmeBulletNativeProjectPath = '../jme3-bullet-native'
+String jmeBulletNativeProjectPath = project(":jme3-bullet-native").projectDir
 
 String localUnzipPath = jmeBulletNativeProjectPath
 String localZipFile = jmeBulletNativeProjectPath + File.separator + bulletZipFile
@@ -24,7 +24,7 @@ dependencies {
     compile project(':jme3-bullet')
 }
 
-// Java source sets for IDE acces and source jar bundling / mavenization
+// Java source sets for IDE access and source jar bundling / mavenization
 sourceSets {
     main {
         java {
@@ -42,70 +42,41 @@ task downloadBullet(type: MyDownload) {
 
 // Unzip bullet if not available
 task unzipBullet(type: Copy) {
-    def zipFile = file(localZipFile)
-    def outputDir = file(localUnzipPath)
-//    println "unzipBullet zipFile = " + zipFile.absolutePath
-//    println "unzipBullet outputDir = " + outputDir.absolutePath
-
-    from zipTree(zipFile)
-    into outputDir
+    from zipTree(localZipFile)
+    into file(localUnzipPath)
 }
 
 unzipBullet.dependsOn {
-    def zipFile = file(localZipFile)
-//    println "zipFile path: " + zipFile.absolutePath
-//    println "zipFile exists: " + zipFile.exists()
-
-    if (!zipFile.exists()) {
+    if (!file(localZipFile).exists()) {
         downloadBullet
     }
 }
 
 // Copy Bullet files to jni directory
 task copyBullet(type: Copy) {
-    def sourceDir = file(bulletSrcPath)
-    def outputDir = new File(jniPath)
-//    println "copyBullet sourceDir = " + sourceDir
-//    println "copyBullet outputDir = " + outputDir
-
-    from sourceDir
-    into outputDir
+    from file(bulletSrcPath)
+    into file(jniPath)
 }
 
 copyBullet.dependsOn {
-    def bulletUnzipDir = file(localZipFolder)
-//    println "bulletUnzipDir: " + bulletUnzipDir.absolutePath
-//    println "bulletUnzipDir exists: " + bulletUnzipDir.exists()
-//    println "bulletUnzipDir isDirectory: " + bulletUnzipDir.isDirectory()
-    if (!bulletUnzipDir.isDirectory()) {
+    if (!file(localZipFolder).isDirectory()) {
         unzipBullet
     }
 }
 
 // Copy jME cpp native files to jni directory
 task copyJmeCpp(type: Copy) {
-    def sourceDir = new File(jmeCppPath)
-    def outputDir = new File(jniPath)
-//    println "copyJmeCpp sourceDir = " + sourceDir
-//    println "copyJmeCpp outputDir = " + outputDir
-
-    from sourceDir
-    into outputDir
+    from file(jmeCppPath)
+    into file(jniPath)
 }
 
 // Copy jME android native files to jni directory
 task copyJmeAndroid(type: Copy) {
-    def sourceDir = new File(jmeAndroidPath)
-    def outputDir = new File(jniPath)
-//    println "copyJmeAndroid sourceDir = " + sourceDir
-//    println "copyJmeAndroid outputDir = " + outputDir
-
-    from sourceDir
-    into outputDir
+    from file(jmeAndroidPath)
+    into file(jniPath)
 }
 
-//dependsOn ':jme3-bullet:generateNativeHeaders'
-task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:generateNativeHeaders', copyJmeCpp, copyBullet]) {
+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
@@ -114,26 +85,20 @@ task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:
     args "-j" + Runtime.runtime.availableProcessors()
 }
 
-//task updatePreCompiledBulletLibs(type: Copy, dependsOn: generateNativeHeaders) {
-task updatePreCompiledBulletLibs(type: Copy, dependsOn: buildBulletNativeLib) {
-    def sourceDir = new File(ndkOutputPath)
-    def outputDir = new File(bulletPreCompiledLibsDir)
-//    println "updatePreCompiledBulletLibs sourceDir: " + sourceDir
-//    println "updatePreCompiledBulletLibs outputDir: " + outputDir
+/* 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
+ */
 
-    from sourceDir
-    into outputDir
+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) {
-    def sourceDir = new File(bulletPreCompiledLibsDir)
-    def outputDir = new File(ndkOutputPath)
-//    println "copyPreCompiledBulletLibs sourceDir: " + sourceDir
-//    println "copyPreCompiledBulletLibs outputDir: " + outputDir
-
-    from sourceDir
-    into outputDir
+    from file(bulletPreCompiledLibsDir)
+    into file(ndkOutputPath)
 }
 
 // ndkExists is a boolean from the build.gradle in the root project
@@ -149,7 +114,7 @@ if (ndkExists && buildNativeProjects == "true") {
 jar.into("lib") { from ndkOutputPath }
 
 
-// Helper class to wrap ant dowload task
+// Helper class to wrap ant download task
 class MyDownload extends DefaultTask {
     @Input
     String sourceUrl

+ 2 - 2
jme3-bullet-native-android/src/native/android/Application.mk

@@ -1,7 +1,7 @@
 APP_OPTIM := release
 APP_ABI := all
-APP_STL := stlport_static
-# gnustl_static or stlport_static
+# Used to be stlport_static, but that has been removed.
+APP_STL := c++_static
 APP_MODULES      := bulletjme
 APP_CFLAGS += -funroll-loops -Ofast
 

+ 1 - 1
jme3-bullet-native/build.gradle

@@ -140,7 +140,7 @@ model {
 
             tasks.all { 
                 dependsOn unzipBulletIfNeeded
-                dependsOn ':jme3-bullet:generateNativeHeaders'
+                dependsOn ':jme3-bullet:compileJava'
             }
 
             // Add output to jar file

+ 6 - 18
jme3-bullet/build.gradle

@@ -1,8 +1,11 @@
+apply plugin: 'java'
+
 if (!hasProperty('mainClass')) {
     ext.mainClass = ''
 }
 
 String classBuildDir = "${buildDir}" + File.separator + 'classes'
+def nativeIncludes = new File(project(":jme3-bullet-native").projectDir, "src/native/cpp")
 
 sourceSets {
     main {
@@ -18,22 +21,7 @@ dependencies {
     compile project(':jme3-terrain')
 }
 
-task generateNativeHeaders(type: Exec, dependsOn: classes) {
-    def files0 = fileTree("src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
-    def files1 = fileTree("src/common/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
-    def files2 = fileTree("../jme3-core/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
-    def files3 = fileTree("../jme3-core/src/plugins/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
-    def files4 = fileTree("../jme3-core/src/tools/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
-    def files5 = fileTree("../jme3-terrain/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
-    def classpath = sourceSets.main.runtimeClasspath.asPath
-    def nativeIncludes = new File(project(":jme3-bullet-native").projectDir, "src/native/cpp")
-	def filesList = "\"" + files0.join("\"\n\"") + "\"\n\"" + files1.join("\"\n\"") + "\"\n\"" + files2.join("\"\n\"") + "\"\n\"" + files3.join("\"\n\"") + "\"\n\"" + files4.join("\"\n\"") + "\"\n\"" + files5.join("\"\n\"") + "\""
-	new File("$projectDir/java_classes.jtxt").text = filesList.replaceAll(java.util.regex.Pattern.quote("\\"), java.util.regex.Matcher.quoteReplacement("/"))
-    executable org.gradle.internal.jvm.Jvm.current().getExecutable('javac')
-    args "-h", nativeIncludes
-    args "@$projectDir/java_classes.jtxt"
-    args '-d', classBuildDir
-    args "-encoding", "UTF-8"
+compileJava {
+    // The Android-Native Project requires the jni headers to be generated, so we do that here
+    options.compilerArgs += ["-h", nativeIncludes]
 }
-
-assemble.dependsOn(generateNativeHeaders)