Skip to content

Commit

Permalink
Merge branch 'kotlin-missing-lib-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
madadam committed Jan 23, 2024
2 parents 51347db + 3d6789c commit 540bdfe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions bindings/kotlin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@
# Ignore Gradle build output directory
build

local.properties
*.hprof
20 changes: 20 additions & 0 deletions bindings/kotlin/lib/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {

android {
compileSdkVersion 33

ndkVersion '25.2.9519653'

namespace 'org.equalitie.ouisync'
Expand Down Expand Up @@ -64,10 +65,29 @@ dependencies {
cargo {
module = "$rootDir/../.."
libname = 'ouisync_ffi'

// Targets can be overriden with "rust.targets" in local.properties.
// Example: "rust.targets=arm64,x86_64".
// More info: https://github.com/mozilla/rust-android-gradle.
targets = ['arm', 'arm64', /* 'x86', */ 'x86_64']

profile = 'release'

extraCargoBuildArguments = ['--package', 'ouisync-ffi']

// HACK: Recent NDK (since r23) no longer links `libgcc`, which breaks some libraries since
// they depended on the symbols from `libclang_rt.builtins-x86_64-android`
// (e.g. `__extenddftf2`, ...). To work around it, we link the library explicitly by setting
// it through the RUSTFLAGS env variable.
// More info: https://github.com/bbqsrc/cargo-ndk/issues/94.
exec { spec, toolchain ->
if (toolchain.target == 'x86_64-linux-android') {
def clangVersion = '14.0.7'
def libDir = "${android.sdkDirectory}/ndk/${android.ndkVersion}/toolchains/llvm/prebuilt/linux-x86_64/lib64/clang/${clangVersion}/lib/linux"

spec.environment('RUSTFLAGS', "-L${libDir} -lstatic=clang_rt.builtins-x86_64-android")
}
}
}

tasks.register('generateBindings', Exec) {
Expand Down

0 comments on commit 540bdfe

Please sign in to comment.