Skip to content

Commit 1bde90d

Browse files
MeFisto94stephengold
authored andcommitted
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
1 parent 194ae88 commit 1bde90d

5 files changed

Lines changed: 33 additions & 80 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ matrix:
3030
before_script:
3131
- export ANDROID_NDK=$ANDROID_HOME/ndk-bundle
3232
script:
33-
- ./gradlew -PbuildNativeProjects=true jme3-android-native:assemble
33+
- ./gradlew -PbuildNativeProjects=true jme3-android-native:assemble jme3-bullet-native-android:assemble
3434
after_success:
3535
- '[ "$TRAVIS_PULL_REQUEST" == "false" ] && ./private/upload_native.sh || :'
3636
- '[ -n "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && ./gradlew bintrayUpload || :'

jme3-bullet-native-android/build.gradle

Lines changed: 23 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
String jmeBulletNativeProjectPath = '../jme3-bullet-native'
1+
String jmeBulletNativeProjectPath = project(":jme3-bullet-native").projectDir
22

33
String localUnzipPath = jmeBulletNativeProjectPath
44
String localZipFile = jmeBulletNativeProjectPath + File.separator + bulletZipFile
@@ -24,7 +24,7 @@ dependencies {
2424
compile project(':jme3-bullet')
2525
}
2626

27-
// Java source sets for IDE acces and source jar bundling / mavenization
27+
// Java source sets for IDE access and source jar bundling / mavenization
2828
sourceSets {
2929
main {
3030
java {
@@ -42,70 +42,41 @@ task downloadBullet(type: MyDownload) {
4242

4343
// Unzip bullet if not available
4444
task unzipBullet(type: Copy) {
45-
def zipFile = file(localZipFile)
46-
def outputDir = file(localUnzipPath)
47-
// println "unzipBullet zipFile = " + zipFile.absolutePath
48-
// println "unzipBullet outputDir = " + outputDir.absolutePath
49-
50-
from zipTree(zipFile)
51-
into outputDir
45+
from zipTree(localZipFile)
46+
into file(localUnzipPath)
5247
}
5348

5449
unzipBullet.dependsOn {
55-
def zipFile = file(localZipFile)
56-
// println "zipFile path: " + zipFile.absolutePath
57-
// println "zipFile exists: " + zipFile.exists()
58-
59-
if (!zipFile.exists()) {
50+
if (!file(localZipFile).exists()) {
6051
downloadBullet
6152
}
6253
}
6354

6455
// Copy Bullet files to jni directory
6556
task copyBullet(type: Copy) {
66-
def sourceDir = file(bulletSrcPath)
67-
def outputDir = new File(jniPath)
68-
// println "copyBullet sourceDir = " + sourceDir
69-
// println "copyBullet outputDir = " + outputDir
70-
71-
from sourceDir
72-
into outputDir
57+
from file(bulletSrcPath)
58+
into file(jniPath)
7359
}
7460

7561
copyBullet.dependsOn {
76-
def bulletUnzipDir = file(localZipFolder)
77-
// println "bulletUnzipDir: " + bulletUnzipDir.absolutePath
78-
// println "bulletUnzipDir exists: " + bulletUnzipDir.exists()
79-
// println "bulletUnzipDir isDirectory: " + bulletUnzipDir.isDirectory()
80-
if (!bulletUnzipDir.isDirectory()) {
62+
if (!file(localZipFolder).isDirectory()) {
8163
unzipBullet
8264
}
8365
}
8466

8567
// Copy jME cpp native files to jni directory
8668
task copyJmeCpp(type: Copy) {
87-
def sourceDir = new File(jmeCppPath)
88-
def outputDir = new File(jniPath)
89-
// println "copyJmeCpp sourceDir = " + sourceDir
90-
// println "copyJmeCpp outputDir = " + outputDir
91-
92-
from sourceDir
93-
into outputDir
69+
from file(jmeCppPath)
70+
into file(jniPath)
9471
}
9572

9673
// Copy jME android native files to jni directory
9774
task copyJmeAndroid(type: Copy) {
98-
def sourceDir = new File(jmeAndroidPath)
99-
def outputDir = new File(jniPath)
100-
// println "copyJmeAndroid sourceDir = " + sourceDir
101-
// println "copyJmeAndroid outputDir = " + outputDir
102-
103-
from sourceDir
104-
into outputDir
75+
from file(jmeAndroidPath)
76+
into file(jniPath)
10577
}
10678

107-
//dependsOn ':jme3-bullet:generateNativeHeaders'
108-
task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:generateNativeHeaders', copyJmeCpp, copyBullet]) {
79+
task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:compileJava', copyJmeCpp, copyBullet]) {
10980
// args 'TARGET_PLATFORM=android-9'
11081
// println "buildBulletNativeLib ndkWorkingPath: " + ndkWorkingPath
11182
// println "buildBulletNativeLib rootProject.ndkCommandPath: " + rootProject.ndkCommandPath
@@ -114,26 +85,20 @@ task buildBulletNativeLib(type: Exec, dependsOn: [copyJmeAndroid, ':jme3-bullet:
11485
args "-j" + Runtime.runtime.availableProcessors()
11586
}
11687

117-
//task updatePreCompiledBulletLibs(type: Copy, dependsOn: generateNativeHeaders) {
118-
task updatePreCompiledBulletLibs(type: Copy, dependsOn: buildBulletNativeLib) {
119-
def sourceDir = new File(ndkOutputPath)
120-
def outputDir = new File(bulletPreCompiledLibsDir)
121-
// println "updatePreCompiledBulletLibs sourceDir: " + sourceDir
122-
// println "updatePreCompiledBulletLibs outputDir: " + outputDir
88+
/* The following two tasks: We store a prebuilt version in the repository, so nobody has to build
89+
* natives in order to build the engine. When building these natives however, the prebuilt libraries
90+
* can be updated (which is what the CI does). That's what the following two tasks do
91+
*/
12392

124-
from sourceDir
125-
into outputDir
93+
task updatePreCompiledBulletLibs(type: Copy, dependsOn: buildBulletNativeLib) {
94+
from file(ndkOutputPath)
95+
into file(bulletPreCompiledLibsDir)
12696
}
12797

12898
// Copy pre-compiled libs to build directory (when not building new libs)
12999
task copyPreCompiledBulletLibs(type: Copy) {
130-
def sourceDir = new File(bulletPreCompiledLibsDir)
131-
def outputDir = new File(ndkOutputPath)
132-
// println "copyPreCompiledBulletLibs sourceDir: " + sourceDir
133-
// println "copyPreCompiledBulletLibs outputDir: " + outputDir
134-
135-
from sourceDir
136-
into outputDir
100+
from file(bulletPreCompiledLibsDir)
101+
into file(ndkOutputPath)
137102
}
138103

139104
// ndkExists is a boolean from the build.gradle in the root project
@@ -149,7 +114,7 @@ if (ndkExists && buildNativeProjects == "true") {
149114
jar.into("lib") { from ndkOutputPath }
150115

151116

152-
// Helper class to wrap ant dowload task
117+
// Helper class to wrap ant download task
153118
class MyDownload extends DefaultTask {
154119
@Input
155120
String sourceUrl
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
APP_OPTIM := release
22
APP_ABI := all
3-
APP_STL := stlport_static
4-
# gnustl_static or stlport_static
3+
# Used to be stlport_static, but that has been removed.
4+
APP_STL := c++_static
55
APP_MODULES := bulletjme
66
APP_CFLAGS += -funroll-loops -Ofast
77

jme3-bullet-native/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ model {
140140

141141
tasks.all {
142142
dependsOn unzipBulletIfNeeded
143-
dependsOn ':jme3-bullet:generateNativeHeaders'
143+
dependsOn ':jme3-bullet:compileJava'
144144
}
145145

146146
// Add output to jar file

jme3-bullet/build.gradle

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
apply plugin: 'java'
2+
13
if (!hasProperty('mainClass')) {
24
ext.mainClass = ''
35
}
46

57
String classBuildDir = "${buildDir}" + File.separator + 'classes'
8+
def nativeIncludes = new File(project(":jme3-bullet-native").projectDir, "src/native/cpp")
69

710
sourceSets {
811
main {
@@ -18,22 +21,7 @@ dependencies {
1821
compile project(':jme3-terrain')
1922
}
2023

21-
task generateNativeHeaders(type: Exec, dependsOn: classes) {
22-
def files0 = fileTree("src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
23-
def files1 = fileTree("src/common/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
24-
def files2 = fileTree("../jme3-core/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
25-
def files3 = fileTree("../jme3-core/src/plugins/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
26-
def files4 = fileTree("../jme3-core/src/tools/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
27-
def files5 = fileTree("../jme3-terrain/src/main/java/").filter { it.isFile() && it.getName().endsWith(".java") }.files
28-
def classpath = sourceSets.main.runtimeClasspath.asPath
29-
def nativeIncludes = new File(project(":jme3-bullet-native").projectDir, "src/native/cpp")
30-
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\"") + "\""
31-
new File("$projectDir/java_classes.jtxt").text = filesList.replaceAll(java.util.regex.Pattern.quote("\\"), java.util.regex.Matcher.quoteReplacement("/"))
32-
executable org.gradle.internal.jvm.Jvm.current().getExecutable('javac')
33-
args "-h", nativeIncludes
34-
args "@$projectDir/java_classes.jtxt"
35-
args '-d', classBuildDir
36-
args "-encoding", "UTF-8"
24+
compileJava {
25+
// The Android-Native Project requires the jni headers to be generated, so we do that here
26+
options.compilerArgs += ["-h", nativeIncludes]
3727
}
38-
39-
assemble.dependsOn(generateNativeHeaders)

0 commit comments

Comments
 (0)