WIP: Add support to build the Native Bullet for Android (only building, not packaging into jar file yet)
git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@10991 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
a8a664b76b
commit
766ebef96d
@ -2,6 +2,15 @@ apply plugin: 'cpp'
|
|||||||
|
|
||||||
String bulletUrl = 'http://bullet.googlecode.com/files/bullet-2.82-r2704.zip'
|
String bulletUrl = 'http://bullet.googlecode.com/files/bullet-2.82-r2704.zip'
|
||||||
String bulletFolder = 'bullet-2.82-r2704'
|
String bulletFolder = 'bullet-2.82-r2704'
|
||||||
|
String bulletSrcPath = bulletFolder + '/src'
|
||||||
|
String bulletZipFile = 'bullet.zip'
|
||||||
|
|
||||||
|
//Directories for the android ndk build.
|
||||||
|
String ndkWorkingPath = 'src/native'
|
||||||
|
String jmeAndroidPath = ndkWorkingPath + '/android'
|
||||||
|
String jmeCppPath = ndkWorkingPath + '/cpp'
|
||||||
|
String jniPath = ndkWorkingPath + '/jni'
|
||||||
|
String ndkOutputPath = ndkWorkingPath + '/libs'
|
||||||
|
|
||||||
if (!hasProperty('mainClass')) {
|
if (!hasProperty('mainClass')) {
|
||||||
ext.mainClass = ''
|
ext.mainClass = ''
|
||||||
@ -17,13 +26,13 @@ sources {
|
|||||||
cpp {
|
cpp {
|
||||||
source {
|
source {
|
||||||
srcDir 'src/native/cpp'
|
srcDir 'src/native/cpp'
|
||||||
srcDir "${bulletFolder}/src"
|
srcDir bulletSrcPath
|
||||||
exclude 'BulletMultiThreaded/GpuSoftBodySolvers/**'
|
exclude 'BulletMultiThreaded/GpuSoftBodySolvers/**'
|
||||||
include '**/*.cpp'
|
include '**/*.cpp'
|
||||||
}
|
}
|
||||||
exportedHeaders {
|
exportedHeaders {
|
||||||
srcDir 'src/native/cpp'
|
srcDir 'src/native/cpp'
|
||||||
srcDir "${bulletFolder}/src"
|
srcDir bulletSrcPath
|
||||||
include '**/*.h'
|
include '**/*.h'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -100,19 +109,35 @@ libraries {
|
|||||||
// Download bullet if not available
|
// Download bullet if not available
|
||||||
task downloadBullet(type: MyDownload) {
|
task downloadBullet(type: MyDownload) {
|
||||||
sourceUrl = bulletUrl
|
sourceUrl = bulletUrl
|
||||||
target = file('bullet.zip')
|
target = file(bulletZipFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unzip bullet if not available
|
// Unzip bullet if not available
|
||||||
task unzipBullet(type: Copy, dependsOn:downloadBullet) {
|
task unzipBullet(type: Copy) {
|
||||||
def zipFile = file('bullet.zip')
|
def zipFile = file(bulletZipFile)
|
||||||
def outputDir = file(".")
|
def outputDir = file(".")
|
||||||
|
|
||||||
from zipTree(zipFile)
|
from zipTree(zipFile)
|
||||||
into outputDir
|
into outputDir
|
||||||
}
|
}
|
||||||
|
unzipBullet.dependsOn {
|
||||||
|
def zipFilePath = project.projectDir.absolutePath + File.separator + bulletZipFile
|
||||||
|
def zipFile = new File(zipFilePath)
|
||||||
|
// println "zipFile path: " + zipFile.absolutePath
|
||||||
|
// println "zipFile exists: " + zipFile.exists()
|
||||||
|
if (!zipFile.exists()) {
|
||||||
|
downloadBullet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
compileJava.dependsOn unzipBullet
|
compileJava.dependsOn {
|
||||||
|
def bulletUnzipDir = new File(project.projectDir.absolutePath + File.separator + bulletFolder)
|
||||||
|
// println "bulletUnzipDir path: " + bulletUnzipDir.absolutePath
|
||||||
|
// println "bulletUnzipDir exists: " + bulletUnzipDir.isDirectory()
|
||||||
|
if (!bulletUnzipDir.isDirectory()) {
|
||||||
|
unzipBullet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//task buildAllExecutables {
|
//task buildAllExecutables {
|
||||||
// dependsOn binaries.withType(SharedLibraryBinary).matching {
|
// dependsOn binaries.withType(SharedLibraryBinary).matching {
|
||||||
@ -147,3 +172,68 @@ class MyDownload extends DefaultTask {
|
|||||||
ant.get(src: sourceUrl, dest: target)
|
ant.get(src: sourceUrl, dest: target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ANDROID NDK BUILD
|
||||||
|
|
||||||
|
// Copy Bullet files to jni directory
|
||||||
|
task copyBullet(type: Copy) {
|
||||||
|
def sourceDir = file(bulletSrcPath)
|
||||||
|
def outputDir = file(jniPath)
|
||||||
|
|
||||||
|
from sourceDir
|
||||||
|
into outputDir
|
||||||
|
}
|
||||||
|
copyBullet.dependsOn {
|
||||||
|
def bulletUnzipDir = new File(project.projectDir.absolutePath + File.separator + bulletFolder)
|
||||||
|
if (!bulletUnzipDir.isDirectory()) {
|
||||||
|
unzipBullet
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy jME cpp native files to jni directory
|
||||||
|
task copyJmeCpp(type: Copy, dependsOn:copyBullet) {
|
||||||
|
def sourceDir = file(jmeCppPath)
|
||||||
|
def outputDir = file(jniPath)
|
||||||
|
|
||||||
|
from sourceDir
|
||||||
|
into outputDir
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy jME android native files to jni directory
|
||||||
|
task copyJmeAndroid(type: Copy, dependsOn:copyJmeCpp) {
|
||||||
|
def sourceDir = file(jmeAndroidPath)
|
||||||
|
def outputDir = file(jniPath)
|
||||||
|
|
||||||
|
from sourceDir
|
||||||
|
into outputDir
|
||||||
|
}
|
||||||
|
|
||||||
|
task buildNative(type: Exec, dependsOn:copyJmeAndroid) {
|
||||||
|
String ndkBuildFile = "ndk-build"
|
||||||
|
// if windows, use ndk-build.cmd instead
|
||||||
|
if (System.properties['os.name'].toLowerCase().contains('windows')) {
|
||||||
|
ndkBuildFile = "ndk-build.cmd"
|
||||||
|
}
|
||||||
|
|
||||||
|
String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
|
||||||
|
//Use the environment variable for the NDK location if defined
|
||||||
|
if (System.env.ANDROID_NDK != null) {
|
||||||
|
ndkBuildPath = System.env.ANDROID_NDK + File.separator + ndkBuildFile
|
||||||
|
}
|
||||||
|
|
||||||
|
// need to target android-9 so the ndk can pull in the opensl library
|
||||||
|
args 'TARGET_PLATFORM=android-9'
|
||||||
|
workingDir ndkWorkingPath
|
||||||
|
executable ndkBuildPath
|
||||||
|
}
|
||||||
|
|
||||||
|
jar.dependsOn {
|
||||||
|
def ndkDir = new File(ndkPath)
|
||||||
|
if (ndkDir.isDirectory()) {
|
||||||
|
buildNative
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//jar.into("lib") { from ndkOutputPath }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user