|
1 | 1 | // OpenAL Soft r1.21.1 |
2 | 2 | // TODO: update URL to jMonkeyEngine fork once it's updated with latest kcat's changes |
3 | | -String openALSoftUrl = 'https://github.com/kcat/openal-soft/archive/1.21.1.zip' |
| 3 | +String openALSoftUrl = 'https://github.com/kcat/openal-soft/archive/1.24.3.zip' |
4 | 4 | String openALSoftZipFile = 'OpenALSoft.zip' |
5 | 5 |
|
6 | 6 | // OpenAL Soft directory the download is extracted into |
7 | 7 | // Typically, the downloaded OpenAL Soft zip file will extract to a directory |
8 | 8 | // called "openal-soft" |
9 | | -String openALSoftFolder = 'openal-soft-1.21.1' |
| 9 | +String openALSoftFolder = 'openal-soft-1.24.3' |
10 | 10 |
|
11 | 11 | //Working directories for the ndk build. |
12 | 12 | String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft' |
@@ -81,13 +81,103 @@ task copyJmeOpenALSoft(type: Copy, dependsOn: [copyOpenALSoft, copyJmeHeadersOpe |
81 | 81 | from sourceDir |
82 | 82 | into outputDir |
83 | 83 | } |
| 84 | +// rootProject.ndkCommandPath must be set to your ndk-build wrapper or full ndk path |
| 85 | +def ndkPath = new File(rootProject.ndkCommandPath).getParent() |
| 86 | +def cmakeToolchain = "${ndkPath}/build/cmake/android.toolchain.cmake" |
| 87 | + |
| 88 | +// 1) list your ABIs here |
| 89 | +def openalAbis = [ |
| 90 | + "armeabi-v7a", |
| 91 | + "arm64-v8a", |
| 92 | + "x86", |
| 93 | + "x86_64" |
| 94 | +] |
| 95 | + |
| 96 | +// 2) for each ABI, register a configure/build pair |
| 97 | +openalAbis.each { abi -> |
| 98 | + |
| 99 | + // configure task |
| 100 | + tasks.register("configureOpenAlSoft_${abi}", Exec) { |
| 101 | + group = "external-native" |
| 102 | + description = "Generate CMake build files for OpenAL-Soft [$abi]" |
| 103 | + |
| 104 | + workingDir file("$openalsoftBuildDir/$openALSoftFolder") |
| 105 | + commandLine = [ |
| 106 | + "cmake", |
| 107 | + "-S", ".", |
| 108 | + "-B", "cmake-build-${abi}", |
| 109 | + "-G", "Unix Makefiles", // or Ninja |
| 110 | + "-DCMAKE_TOOLCHAIN_FILE=${cmakeToolchain}", |
| 111 | + "-DANDROID_PLATFORM=android-21", |
| 112 | + "-DANDROID_ABI=${abi}", |
| 113 | + "-DCMAKE_BUILD_TYPE=Release", |
| 114 | + "-DALSOFT_UTILS=OFF", |
| 115 | + "-DALSOFT_EXAMPLES=OFF", |
| 116 | + "-DALSOFT_TESTS=OFF", |
| 117 | + "-DALSOFT_BACKEND_OPENSL=ON", |
| 118 | + '-DALSOFT_SHARED=OFF', |
| 119 | + '-DBUILD_SHARED_LIBS=OFF', |
| 120 | + '-DALSOFT_STATIC=ON', |
| 121 | + '-DLIBTYPE=STATIC', |
| 122 | + '-DCMAKE_CXX_FLAGS=-stdlib=libc++' |
| 123 | + ] |
| 124 | + |
| 125 | + dependsOn copyOpenALSoft |
| 126 | + } |
| 127 | + |
| 128 | + // build task |
| 129 | + tasks.register("buildOpenAlSoft_${abi}", Exec) { |
| 130 | + group = "external-native" |
| 131 | + description = "Compile OpenAL-Soft into libopenalsoft.a for [$abi]" |
| 132 | + |
| 133 | + dependsOn "configureOpenAlSoft_${abi}" |
| 134 | + workingDir file("$openalsoftBuildDir/$openALSoftFolder") |
| 135 | + commandLine = [ |
| 136 | + "cmake", |
| 137 | + "--build", "cmake-build-${abi}", |
| 138 | + "--config", "Release" |
| 139 | + ] |
| 140 | + } |
| 141 | +} |
| 142 | + |
| 143 | +// 3) optional: aggregate tasks |
| 144 | +tasks.register("configureOpenAlSoftAll") { |
| 145 | + group = "external-native" |
| 146 | + description = "Configure OpenAL-Soft for all ABIs" |
| 147 | + dependsOn openalAbis.collect { "configureOpenAlSoft_${it}" } |
| 148 | +} |
| 149 | + |
| 150 | +tasks.register("buildOpenAlSoftAll") { |
| 151 | + group = "external-native" |
| 152 | + description = "Build OpenAL-Soft for all ABIs" |
| 153 | + dependsOn openalAbis.collect { "buildOpenAlSoft_${it}" } |
| 154 | +} |
84 | 155 |
|
85 | | -task buildOpenAlSoftNativeLib(type: Exec, dependsOn: copyJmeOpenALSoft) { |
86 | | -// println "openalsoft build dir: " + openalsoftBuildDir |
87 | | -// println "ndkCommandPath: " + project.ndkCommandPath |
| 156 | +task buildOpenAlSoftNativeLib(type: Exec) { |
| 157 | + group = "external-native" |
| 158 | + description = "Runs ndk-build on your JNI code, linking in the prebuilt OpenAL-Soft .a files" |
| 159 | + |
| 160 | + dependsOn copyJmeOpenALSoft, buildOpenAlSoftAll |
| 161 | + |
| 162 | + // where your Android.mk lives |
88 | 163 | workingDir openalsoftBuildDir |
| 164 | + |
| 165 | + // call the NDK build script |
89 | 166 | executable rootProject.ndkCommandPath |
90 | | - args "-j" + Runtime.runtime.availableProcessors() |
| 167 | + |
| 168 | + // pass in all ABIs (so ndk-build will rebuild your shared .so for each one), |
| 169 | + // and pass in a custom var OPENALSOFT_BUILD_DIR so your Android.mk can find |
| 170 | + // the cmake-build-<ABI> folders. |
| 171 | + args( |
| 172 | + // let ndk-build know which ABIs to build for |
| 173 | + "APP_ABI=armeabi-v7a,arm64-v8a,x86,x86_64", |
| 174 | + |
| 175 | + // pass in the path to the CMake output root |
| 176 | + "OPENALSOFT_BUILD_ROOT=${openalsoftBuildDir}/${openALSoftFolder}", |
| 177 | + |
| 178 | + // parallel jobs |
| 179 | + "-j${Runtime.runtime.availableProcessors()}" |
| 180 | + ) |
91 | 181 | } |
92 | 182 |
|
93 | 183 | task updatePreCompiledOpenAlSoftLibs(type: Copy, dependsOn: buildOpenAlSoftNativeLib) { |
@@ -140,3 +230,4 @@ class MyDownload extends DefaultTask { |
140 | 230 | ant.get(src: sourceUrl, dest: target) |
141 | 231 | } |
142 | 232 | } |
| 233 | + |
0 commit comments