update native android libs build to use pre-compiled versions of the libs from the repo if not building native libs
This commit is contained in:
parent
384e19f281
commit
df2e38798d
@ -11,10 +11,13 @@ String openALSoftZipFile = 'OpenALSoft.zip'
|
|||||||
// called "openal-soft"
|
// called "openal-soft"
|
||||||
String openALSoftFolder = 'openal-soft'
|
String openALSoftFolder = 'openal-soft'
|
||||||
|
|
||||||
//Working directory for the ndk build.
|
//Working directories for the ndk build.
|
||||||
//Must be the parent directory of the jni directory
|
|
||||||
//Libs directory (output of ndk) will be created in this directory as well
|
|
||||||
String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft'
|
String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft'
|
||||||
|
String openalsoftBuildJniDir = openalsoftBuildDir + File.separator + 'jni'
|
||||||
|
String openalsoftBuildLibsDir = openalsoftBuildDir + File.separator + 'libs'
|
||||||
|
|
||||||
|
//Pre-compiled libs directory
|
||||||
|
String openalsoftPreCompiledLibsDir = 'libs' + File.separator + 'openalsoft'
|
||||||
|
|
||||||
// jME Android Native source files path
|
// jME Android Native source files path
|
||||||
String openalsoftJmeAndroidPath = 'src/native/jme_openalsoft'
|
String openalsoftJmeAndroidPath = 'src/native/jme_openalsoft'
|
||||||
@ -46,7 +49,7 @@ unzipOpenALSoft.dependsOn {
|
|||||||
// Copy external source files to jni directory
|
// Copy external source files to jni directory
|
||||||
task copyOpenALSoft(type: Copy) {
|
task copyOpenALSoft(type: Copy) {
|
||||||
def sourceDir = file(openALSoftFolder)
|
def sourceDir = file(openALSoftFolder)
|
||||||
def outputDir = file(openalsoftBuildDir + File.separator + 'jni')
|
def outputDir = file(openalsoftBuildJniDir)
|
||||||
// println "copyOpenALSoft sourceDir: " + sourceDir
|
// println "copyOpenALSoft sourceDir: " + sourceDir
|
||||||
// println "copyOpenALSoft outputDir: " + outputDir
|
// println "copyOpenALSoft outputDir: " + outputDir
|
||||||
|
|
||||||
@ -65,19 +68,15 @@ copyOpenALSoft.dependsOn {
|
|||||||
// 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) {
|
||||||
def sourceDir = file(openalsoftJmeAndroidPath)
|
def sourceDir = file(openalsoftJmeAndroidPath)
|
||||||
def outputDir = file(openalsoftBuildDir + File.separator + 'jni')
|
def outputDir = file(openalsoftBuildJniDir)
|
||||||
// println "copyJmeOpenALSoft sourceDir: " + sourceDir
|
// println "copyJmeOpenALSoft sourceDir: " + sourceDir
|
||||||
// println "copyJmeOpenALSoft outputDir: " + outputDir
|
// println "copyJmeOpenALSoft outputDir: " + outputDir
|
||||||
|
|
||||||
from sourceDir
|
from sourceDir
|
||||||
into outputDir
|
into outputDir
|
||||||
}
|
}
|
||||||
|
copyJmeOpenALSoft.doLast {
|
||||||
jar.into("lib") { from openalsoftBuildDir + File.separator + 'libs' }
|
String destDirPath = openalsoftBuildJniDir
|
||||||
|
|
||||||
task generateOpenAlSoftHeaders(dependsOn:copyJmeOpenALSoft) {
|
|
||||||
String destDir = openalsoftBuildDir + File.separator + 'jni'
|
|
||||||
|
|
||||||
String classes = ""
|
String classes = ""
|
||||||
.concat("com.jme3.audio.android.AndroidOpenALSoftAudioRenderer, ")
|
.concat("com.jme3.audio.android.AndroidOpenALSoftAudioRenderer, ")
|
||||||
// println "openalsoft classes = " + classes
|
// println "openalsoft classes = " + classes
|
||||||
@ -86,13 +85,12 @@ task generateOpenAlSoftHeaders(dependsOn:copyJmeOpenALSoft) {
|
|||||||
|
|
||||||
ant.javah(
|
ant.javah(
|
||||||
classpath: project.projectClassPath,
|
classpath: project.projectClassPath,
|
||||||
destdir: destDir,
|
destdir: destDirPath,
|
||||||
class: classes
|
class: classes
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task buildOpenAlSoftNativeLib(type: Exec, dependsOn: generateOpenAlSoftHeaders) {
|
task buildOpenAlSoftNativeLib(type: Exec, dependsOn: copyJmeOpenALSoft) {
|
||||||
// println "openalsoft build dir: " + openalsoftBuildDir
|
// println "openalsoft build dir: " + openalsoftBuildDir
|
||||||
// println "ndkCommandPath: " + project.ndkCommandPath
|
// println "ndkCommandPath: " + project.ndkCommandPath
|
||||||
args 'TARGET_PLATFORM=android-9'
|
args 'TARGET_PLATFORM=android-9'
|
||||||
@ -100,13 +98,25 @@ task buildOpenAlSoftNativeLib(type: Exec, dependsOn: generateOpenAlSoftHeaders)
|
|||||||
executable project.ndkCommandPath
|
executable project.ndkCommandPath
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.dependsOn {
|
// Copy pre-compiled libs to build directory (when not building new libs)
|
||||||
// ndkPath is defined in the root project gradle.properties file
|
task copyPreCompiledOpenAlSoftLibs(type: Copy) {
|
||||||
if (ndkCommandPath != null && new File(ndkCommandPath).exists()) {
|
def sourceDir = file(openalsoftPreCompiledLibsDir)
|
||||||
buildOpenAlSoftNativeLib
|
def outputDir = file(openalsoftBuildLibsDir)
|
||||||
}
|
// println "copyStbiJmeFiles sourceDir: " + sourceDir
|
||||||
|
// println "copyStbiJmeFiles outputDir: " + outputDir
|
||||||
|
|
||||||
|
from sourceDir
|
||||||
|
into outputDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ndkExists()) {
|
||||||
|
compileJava.dependsOn { buildOpenAlSoftNativeLib }
|
||||||
|
} else {
|
||||||
|
compileJava.dependsOn { copyPreCompiledOpenAlSoftLibs }
|
||||||
|
}
|
||||||
|
|
||||||
|
jar.into("lib") { from openalsoftBuildLibsDir }
|
||||||
|
|
||||||
// Helper class to wrap ant dowload task
|
// Helper class to wrap ant dowload task
|
||||||
class MyDownload extends DefaultTask {
|
class MyDownload extends DefaultTask {
|
||||||
@Input
|
@Input
|
||||||
|
@ -5,10 +5,13 @@ 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'
|
||||||
|
|
||||||
//Working directory for the ndk build.
|
//Working directories for the ndk build.
|
||||||
//Must be the parent directory of the jni directory
|
|
||||||
//Libs directory (output of ndk) will be created in this directory as well
|
|
||||||
String stbiBuildDir = "${buildDir}" + File.separator + 'stb_image'
|
String stbiBuildDir = "${buildDir}" + File.separator + 'stb_image'
|
||||||
|
String stbiBuildJniDir = stbiBuildDir + File.separator + 'jni'
|
||||||
|
String stbiBuildLibsDir = stbiBuildDir + File.separator + 'libs'
|
||||||
|
|
||||||
|
//Pre-compiled libs directory
|
||||||
|
String stbiPreCompiledLibsDir = 'libs' + 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'
|
||||||
@ -22,7 +25,7 @@ task downloadStbImage(type: MyDownload) {
|
|||||||
// 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)
|
||||||
def outputDir = file(stbiBuildDir + File.separator + 'jni')
|
def outputDir = file(stbiBuildJniDir)
|
||||||
// println "copyStbiFiles sourceDir: " + sourceDir
|
// println "copyStbiFiles sourceDir: " + sourceDir
|
||||||
// println "copyStbiFiles outputDir: " + outputDir
|
// println "copyStbiFiles outputDir: " + outputDir
|
||||||
|
|
||||||
@ -43,18 +46,15 @@ copyStbiFiles.dependsOn {
|
|||||||
// 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) {
|
||||||
def sourceDir = file(stbiJmeAndroidPath)
|
def sourceDir = file(stbiJmeAndroidPath)
|
||||||
def outputDir = file(stbiBuildDir + File.separator + 'jni')
|
def outputDir = file(stbiBuildJniDir)
|
||||||
// println "copyStbiJmeFiles sourceDir: " + sourceDir
|
// println "copyStbiJmeFiles sourceDir: " + sourceDir
|
||||||
// println "copyStbiJmeFiles outputDir: " + outputDir
|
// println "copyStbiJmeFiles outputDir: " + outputDir
|
||||||
|
|
||||||
from sourceDir
|
from sourceDir
|
||||||
into outputDir
|
into outputDir
|
||||||
}
|
}
|
||||||
|
copyStbiJmeFiles.doLast {
|
||||||
jar.into("lib") { from stbiBuildDir + File.separator + 'libs' }
|
String destDirPath = stbiBuildJniDir
|
||||||
|
|
||||||
task generateStbiHeaders(dependsOn:copyStbiJmeFiles) {
|
|
||||||
String destDir = stbiBuildDir + File.separator + 'jni'
|
|
||||||
String classes = ""
|
String classes = ""
|
||||||
.concat("com.jme3.texture.plugins.AndroidNativeImageLoader, ")
|
.concat("com.jme3.texture.plugins.AndroidNativeImageLoader, ")
|
||||||
|
|
||||||
@ -64,13 +64,13 @@ task generateStbiHeaders(dependsOn:copyStbiJmeFiles) {
|
|||||||
|
|
||||||
ant.javah(
|
ant.javah(
|
||||||
classpath: project.projectClassPath,
|
classpath: project.projectClassPath,
|
||||||
destdir: destDir,
|
destdir: destDirPath,
|
||||||
class: classes
|
class: classes
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
task buildStbiNativeLib(type: Exec, dependsOn: generateStbiHeaders) {
|
task buildStbiNativeLib(type: Exec, dependsOn: copyStbiJmeFiles) {
|
||||||
// println "stb_image build dir: " + buildLibDir
|
// println "stb_image build dir: " + buildLibDir
|
||||||
// println "ndkCommandPath: " + project.ndkCommandPath
|
// println "ndkCommandPath: " + project.ndkCommandPath
|
||||||
args 'TARGET_PLATFORM=android-9'
|
args 'TARGET_PLATFORM=android-9'
|
||||||
@ -78,13 +78,24 @@ task buildStbiNativeLib(type: Exec, dependsOn: generateStbiHeaders) {
|
|||||||
executable project.ndkCommandPath
|
executable project.ndkCommandPath
|
||||||
}
|
}
|
||||||
|
|
||||||
compileJava.dependsOn {
|
// Copy pre-compiled libs to build directory (when not building new libs)
|
||||||
// ndkPath is defined in the root project gradle.properties file
|
task copyPreCompiledStbiLibs(type: Copy) {
|
||||||
if (ndkCommandPath != null && new File(ndkCommandPath).exists()) {
|
def sourceDir = file(stbiPreCompiledLibsDir)
|
||||||
buildStbiNativeLib
|
def outputDir = file(stbiBuildLibsDir)
|
||||||
}
|
// println "copyStbiJmeFiles sourceDir: " + sourceDir
|
||||||
|
// println "copyStbiJmeFiles outputDir: " + outputDir
|
||||||
|
|
||||||
|
from sourceDir
|
||||||
|
into outputDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ndkExists()) {
|
||||||
|
compileJava.dependsOn { buildStbiNativeLib }
|
||||||
|
} else {
|
||||||
|
compileJava.dependsOn { copyPreCompiledStbiLibs }
|
||||||
|
}
|
||||||
|
|
||||||
|
jar.into("lib") { from stbiBuildLibsDir }
|
||||||
|
|
||||||
// Helper class to wrap ant dowload task
|
// Helper class to wrap ant dowload task
|
||||||
class MyDownload extends DefaultTask {
|
class MyDownload extends DefaultTask {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user