Change stb_image to be auto downloaded during build

experimental
iwgeric 11 years ago
parent d1033005ae
commit 5cfd1c812b
  1. 35
      jme3-android-native/stb_image.gradle
  2. 4673
      jme3-android-native/stb_image/stb_image.c

@ -1,3 +1,7 @@
// stb_image url for download
String stbiUrl = 'http://www.nothings.org/stb_image.c'
String stbiDownloadTarget = 'stb_image.c'
// stb_image is not downloaded. The single source file is included in the repo // stb_image is not downloaded. The single source file is included in the repo
String stbiFolder = 'stb_image' String stbiFolder = 'stb_image'
@ -9,6 +13,12 @@ String stbiBuildDir = "${buildDir}" + File.separator + 'stb_image'
// jME Android Native source files path // jME Android Native source files path
String stbiJmeAndroidPath = 'src/native/jme_stbi' String stbiJmeAndroidPath = 'src/native/jme_stbi'
// Download external source files if not available
task downloadStbImage(type: MyDownload) {
sourceUrl = stbiUrl
target = file(stbiFolder + File.separator + stbiDownloadTarget)
}
// Copy stb_image files to jni directory // Copy stb_image files to jni directory
task copyStbiFiles(type: Copy) { task copyStbiFiles(type: Copy) {
def sourceDir = file(stbiFolder) def sourceDir = file(stbiFolder)
@ -19,6 +29,16 @@ task copyStbiFiles(type: Copy) {
from sourceDir from sourceDir
into outputDir into outputDir
} }
copyStbiFiles.dependsOn {
def stbiFilePath = project.projectDir.absolutePath + stbiFolder + File.separator + stbiDownloadTarget
def stbiFile = new File(stbiFilePath)
// println "zipFile path: " + zipFile.absolutePath
// println "zipFile exists: " + zipFile.exists()
if (!stbiFile.exists()) {
downloadStbImage
}
}
// Copy jME Android native files to jni directory // Copy jME Android native files to jni directory
task copyStbiJmeFiles(type: Copy, dependsOn:copyStbiFiles) { task copyStbiJmeFiles(type: Copy, dependsOn:copyStbiFiles) {
@ -64,3 +84,18 @@ compileJava.dependsOn {
buildStbiNativeLib buildStbiNativeLib
} }
} }
// 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)
}
}

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save