Improve checking of when to download and unzip the source OpenAL Soft files

git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@10989 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
iwg..ic 11 years ago
parent 5b2a661f56
commit 5453d4f5e9
  1. 32
      jme3-android-native/build.gradle

@ -20,6 +20,7 @@ String openALSoftUrl = 'http://repo.or.cz/w/openal-soft.git/snapshot/be25e6802da
// Typically, the downloaded OpenAL Soft zip file will extract to a directory // Typically, the downloaded OpenAL Soft zip file will extract to a directory
// called "openal-soft" // called "openal-soft"
String openALSoftFolder = 'openal-soft' String openALSoftFolder = 'openal-soft'
String openALSoftZipFile = 'OpenALSoft.zip'
//Working directory for the ndk build. //Working directory for the ndk build.
//Must be the parent directory of the jni directory //Must be the parent directory of the jni directory
@ -61,26 +62,43 @@ dependencies {
// Download bullet if not available // Download bullet if not available
task downloadOpenALSoft(type: MyDownload) { task downloadOpenALSoft(type: MyDownload) {
sourceUrl = openALSoftUrl sourceUrl = openALSoftUrl
target = file('OpenALSoft.zip') target = file(openALSoftZipFile)
} }
// Unzip OpenALSoft // Unzip OpenALSoft
task unzipOpenALSoft(type: Copy, dependsOn:downloadOpenALSoft) { task unzipOpenALSoft(type: Copy) {
def zipFile = file('OpenALSoft.zip') def zipFile = file(openALSoftZipFile)
def outputDir = file(".") def outputDir = file(".")
from zipTree(zipFile) from zipTree(zipFile)
into outputDir into outputDir
} }
unzipOpenALSoft.dependsOn {
def zipFilePath = project.projectDir.absolutePath + File.separator + openALSoftZipFile
def zipFile = new File(zipFilePath)
// println "zipFile path: " + zipFile.absolutePath
// println "zipFile exists: " + zipFile.exists()
if (!zipFile.exists()) {
downloadOpenALSoft
}
}
// Copy OpenALSoft files to jni directory // Copy OpenALSoft files to jni directory
task copyOpenALSoft(type: Copy, dependsOn:unzipOpenALSoft) { task copyOpenALSoft(type: Copy) {
def sourceDir = file(openALSoftFolder) def sourceDir = file(openALSoftFolder)
def outputDir = file(jniPath) def outputDir = file(jniPath)
from sourceDir from sourceDir
into outputDir 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 Android native files to jni directory // Copy jME Android native files to jni directory
task copyJmeOpenALSoft(type: Copy, dependsOn:copyOpenALSoft) { task copyJmeOpenALSoft(type: Copy, dependsOn:copyOpenALSoft) {
@ -98,6 +116,7 @@ task buildNative(type: Exec, dependsOn:copyJmeOpenALSoft) {
ndkBuildFile = "ndk-build.cmd" ndkBuildFile = "ndk-build.cmd"
} }
// ndkPath is defined in the root project gradle.properties file
String ndkBuildPath = ndkPath + File.separator + ndkBuildFile String ndkBuildPath = ndkPath + File.separator + ndkBuildFile
//Use the environment variable for the NDK location if defined //Use the environment variable for the NDK location if defined
if (System.env.ANDROID_NDK != null) { if (System.env.ANDROID_NDK != null) {
@ -113,8 +132,9 @@ task buildNative(type: Exec, dependsOn:copyJmeOpenALSoft) {
jar.into("lib") { from ndkOutputPath } jar.into("lib") { from ndkOutputPath }
compileJava.dependsOn { compileJava.dependsOn {
def ndkFile = new File(ndkPath) // ndkPath is defined in the root project gradle.properties file
if (ndkFile.exists()) { def ndkDir = new File(ndkPath)
if (ndkDir.isDirectory()) {
buildNative buildNative
} }
} }

Loading…
Cancel
Save