mirror of
https://github.com/FluxaMedia/fluxa.git
synced 2026-07-26 20:02:14 +00:00
Export bindgen env vars for the Android NDK when building fluxa-core
fluxa-core's plugin-js-engine feature now generates rquickjs FFI bindings via bindgen instead of relying on prebuilt binding files, since rquickjs-sys ships none for any Android target. Export LIBCLANG_PATH (from the NDK's own libclang) and BINDGEN_EXTRA_CLANG_ARGS (NDK sysroot, matching clang resource-dir, and the concrete clang target triple) alongside the existing CC/AR/linker env vars in each buildFluxaCore<Abi> task, so bindgen resolves Android headers instead of falling back to the host's.
This commit is contained in:
parent
fc005ba1df
commit
67c96f86ad
1 changed files with 19 additions and 1 deletions
|
|
@ -194,12 +194,30 @@ val rustTargetTasks = rustAndroidTargets.map { (abi, target, envName) ->
|
|||
if (ndkDir.isBlank() || !file(ndkDir).exists()) {
|
||||
throw GradleException("Android NDK is required to build ../fluxa-core.")
|
||||
}
|
||||
val toolchainBin = file("$ndkDir/toolchains/llvm/prebuilt/$rustHostTag/bin")
|
||||
val toolchainRoot = file("$ndkDir/toolchains/llvm/prebuilt/$rustHostTag")
|
||||
val toolchainBin = toolchainRoot.resolve("bin")
|
||||
val clang = file(toolchainBin.resolve(linkerName)).absolutePath
|
||||
environment("CARGO_TARGET_${envName}_LINKER", clang)
|
||||
environment("CC_$target", clang)
|
||||
environment("CC_${target.replace("-", "_")}", clang)
|
||||
environment("AR_${envName}", file(toolchainBin.resolve("llvm-ar")).absolutePath)
|
||||
|
||||
val clangTargetTriple = linkerName.removeSuffix("-clang")
|
||||
val sysroot = toolchainRoot.resolve("sysroot")
|
||||
val clangVersionDir = toolchainRoot.resolve("lib/clang").listFiles()
|
||||
?.filter { it.isDirectory }
|
||||
?.maxByOrNull { it.name.toIntOrNull() ?: -1 }
|
||||
environment("LIBCLANG_PATH", toolchainRoot.resolve("lib").absolutePath)
|
||||
environment(
|
||||
"BINDGEN_EXTRA_CLANG_ARGS",
|
||||
buildString {
|
||||
append("--target=$clangTargetTriple")
|
||||
append(" --sysroot=${sysroot.absolutePath}")
|
||||
if (clangVersionDir != null) {
|
||||
append(" -resource-dir=${clangVersionDir.absolutePath}")
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
doLast {
|
||||
val builtLibrary = file("$rustCrateDir/target/$target/$rustProfile/libfluxa_core.so")
|
||||
|
|
|
|||
Loading…
Reference in a new issue