diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dde1d4b06..9328e0161 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,13 +15,13 @@ jobs: name: [android, linux, windows] include: - name: android - os: ubuntu-latest + os: ubuntu-24.04 cargo-command: cross cargo-dir: ~/.cargo target: aarch64-linux-android - name: linux - os: ubuntu-latest + os: ubuntu-24.04 cargo-command: cargo cargo-dir: ~/.cargo @@ -86,7 +86,7 @@ jobs: check_kotlin_bindings: name: check kotlin bindings - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 @@ -147,11 +147,11 @@ jobs: - name: Build the example app working-directory: bindings/kotlin - run: ./gradlew example:assembleDebug + run: ./gradlew --stacktrace example:assembleDebug check_dart_bindings: name: check dart bindings - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 diff --git a/bindings/dart/android/build.gradle b/bindings/dart/android/build.gradle index a30031f52..1d3ba0751 100644 --- a/bindings/dart/android/build.gradle +++ b/bindings/dart/android/build.gradle @@ -1,146 +1,119 @@ -group = "org.equalitie.ouisync.lib" -version = "1.0-SNAPSHOT" - -buildscript { - ext.kotlin_version = "2.0.20" - repositories { - google() - mavenCentral() - - maven { - url "https://plugins.gradle.org/m2/" - } - } - - dependencies { - classpath("com.android.tools.build:gradle:8.5.2") - classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") - classpath("org.mozilla.rust-android-gradle:plugin:0.9.4") - } -} - -allprojects { - repositories { - google() - mavenCentral() - } -} - -apply plugin: "com.android.library" -apply plugin: "kotlin-android" -apply plugin: "org.mozilla.rust-android-gradle.rust-android" - -android { - if (project.android.hasProperty("namespace")) { - namespace = "org.equalitie.ouisync.lib" - } - - compileSdk = 34 - // TODO: The default NDK version should be the lowest possible. - ndkVersion = System.getenv("OUISYNC_ANDROID_NDK_VERSION") ?: "27.0.12077973" - - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - kotlinOptions { - jvmTarget = JavaVersion.VERSION_17 - } - - sourceSets { - main.java.srcDirs += "src/main/kotlin" - test.java.srcDirs += "src/test/kotlin" - } - - defaultConfig { - minSdk = 21 - targetSdkVersion = 35 - } - - buildTypes { - debug { - android.packagingOptions.doNotStrip '**.so' - } - profile { - } - } - - dependencies { - testImplementation("org.jetbrains.kotlin:kotlin-test") - testImplementation("org.mockito:mockito-core:5.10.0") - } - - testOptions { - unitTests.all { - useJUnitPlatform() - - testLogging { - events "passed", "skipped", "failed", "standardOut", "standardError" - outputs.upToDateWhen {false} - showStandardStreams = true - } - } - } -} - -def abiTargets = { - if (project.hasProperty("target-platform")) { - // https://github.com/flutter/flutter/blob/37dbe030feb47cdf15f3d4c1921857dbbac8aedf/packages/flutter_tools/gradle/flutter.gradle#L78-L82 - return project.property("target-platform").split(',').collect{ - if (it == "android-arm") { - return "arm" - } else if (it == "android-arm64") { - return "arm64" - } else if (it == "android-x86") { - return "x86" - } else if (it == "android-x64") { - return "x86_64" - } else { - println("Unknown target platform: " + it) - System.exit(1) - } - } - } - else { - // NOTE: x86 is not added by default when invoking `flutter build aar` - // so we don't include it here neither. - return ["arm", "arm64", /* "x86", */ "x86_64"] - } -}() - -cargo { - // MacOS no longer has `python` (only has `python3`) and `python3` is present on all other - // systems. - pythonCommand = "python3" - module = "../../.." - libname = "ouisync_ffi" - targets = abiTargets - profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release" - - extraCargoBuildArguments = ['-p', '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 os_toolchain - if (System.properties['os.name'].toLowerCase().contains('windows')) { - os_toolchain = 'windows-x86_64' - } else { - os_toolchain = 'linux-x86_64' - } - - - def clangVersion = '18' - def libDir = "${android.sdkDirectory}/ndk/${android.ndkVersion}/toolchains/llvm/prebuilt/${os_toolchain}/lib/clang/${clangVersion}/lib/linux" - - spec.environment('RUSTFLAGS', "-L${libDir} -lstatic=clang_rt.builtins-x86_64-android") - } - } -} - -preBuild.dependsOn 'cargoBuild' +buildscript { + ext.kotlin_version = "2.0.20" + repositories { + google() + mavenCentral() + + maven { + url "https://plugins.gradle.org/m2/" + } + } + + dependencies { + classpath("com.android.tools.build:gradle:8.7.2") + classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version") + } +} + +plugins { + id "com.android.library" + id "kotlin-android" + id "org.mozilla.rust-android-gradle.rust-android" version '0.9.4' +} + +allprojects { + repositories { + google() + mavenCentral() + } +} + +group = "org.equalitie.ouisync.lib" +version = "1.0-SNAPSHOT" + +android { + if (project.android.hasProperty("namespace")) { + namespace = "org.equalitie.ouisync.lib" + } + + compileSdk = 34 + ndkVersion = '27.2.12479018' + + sourceSets { + main.java.srcDirs += "src/main/kotlin" + test.java.srcDirs += "src/test/kotlin" + } + + defaultConfig { + minSdk = 21 + targetSdkVersion = 34 + } + + kotlin { + jvmToolchain(17) + } + + buildTypes { + debug { + android.packagingOptions.doNotStrip '**.so' + } + profile { + } + } + + dependencies { + testImplementation("org.jetbrains.kotlin:kotlin-test") + testImplementation("org.mockito:mockito-core:5.10.0") + } + + testOptions { + unitTests.all { + useJUnitPlatform() + + testLogging { + events "passed", "skipped", "failed", "standardOut", "standardError" + outputs.upToDateWhen {false} + showStandardStreams = true + } + } + } +} + +def abiTargets = { + if (project.hasProperty("target-platform")) { + // https://github.com/flutter/flutter/blob/37dbe030feb47cdf15f3d4c1921857dbbac8aedf/packages/flutter_tools/gradle/flutter.gradle#L78-L82 + return project.property("target-platform").split(',').collect{ + if (it == "android-arm") { + return "arm" + } else if (it == "android-arm64") { + return "arm64" + } else if (it == "android-x86") { + return "x86" + } else if (it == "android-x64") { + return "x86_64" + } else { + println("Unknown target platform: " + it) + System.exit(1) + } + } + } + else { + // NOTE: x86 is not added by default when invoking `flutter build aar` + // so we don't include it here neither. + return ["arm", "arm64", /* "x86", */ "x86_64"] + } +}() + +cargo { + // MacOS no longer has `python` (only has `python3`) and `python3` is present on all other + // systems. + pythonCommand = "python3" + module = "../../.." + libname = "ouisync_ffi" + targets = abiTargets + profile = gradle.startParameter.taskNames.any{it.toLowerCase().contains("debug")} ? "debug" : "release" + + extraCargoBuildArguments = ['-p', 'ouisync-ffi'] +} + +preBuild.dependsOn 'cargoBuild' diff --git a/bindings/dart/android/gradle/wrapper/gradle-wrapper.properties b/bindings/dart/android/gradle/wrapper/gradle-wrapper.properties index b82aa23a4..9355b4155 100644 --- a/bindings/dart/android/gradle/wrapper/gradle-wrapper.properties +++ b/bindings/dart/android/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/bindings/kotlin/build.gradle b/bindings/kotlin/build.gradle index 4160749fd..189732be7 100644 --- a/bindings/kotlin/build.gradle +++ b/bindings/kotlin/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:8.7.0' + classpath 'com.android.tools.build:gradle:8.7.2' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } diff --git a/bindings/kotlin/gradle/wrapper/gradle-wrapper.properties b/bindings/kotlin/gradle/wrapper/gradle-wrapper.properties index 09523c0e5..9355b4155 100644 --- a/bindings/kotlin/gradle/wrapper/gradle-wrapper.properties +++ b/bindings/kotlin/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/bindings/kotlin/lib/build.gradle b/bindings/kotlin/lib/build.gradle index 342ead6c4..e01df6bb1 100644 --- a/bindings/kotlin/lib/build.gradle +++ b/bindings/kotlin/lib/build.gradle @@ -21,13 +21,11 @@ version = rootProject.version group = rootProject.group android { - compileSdkVersion 34 - - // TODO: The default NDK version should be the lowest possible. - ndkVersion = System.getenv("OUISYNC_ANDROID_NDK_VERSION") ?: '26.3.11579264' - namespace 'org.equalitie.ouisync.lib' + compileSdk = 34 + ndkVersion = '27.2.12479018' + sourceSets { main { kotlin { @@ -44,13 +42,8 @@ android { versionName version } - compileOptions { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 - } - - kotlinOptions { - jvmTarget = '17' + kotlin { + jvmToolchain(17) } testOptions { @@ -103,27 +96,6 @@ cargo { absTargetDir = "$projectDir/$relTargetDir" } } - - exec { spec, toolchain -> - // HACK: rust.cargoTargetDir local property is not passed to cargo for some reason - // (https://github.com/mozilla/rust-android-gradle?tab=readme-ov-file#targetdirectory). - // Force it: - if (absTargetDir != null) { - spec.environment('CARGO_TARGET_DIR', absTargetDir) - } - - // 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. - if (toolchain.target == 'x86_64-linux-android') { - def clangVersion = '17' - def libDir = "${android.sdkDirectory}/ndk/${android.ndkVersion}/toolchains/llvm/prebuilt/linux-x86_64/lib/clang/${clangVersion}/lib/linux" - - spec.environment('RUSTFLAGS', "-L${libDir} -lstatic=clang_rt.builtins-x86_64-android") - } - } } tasks.register('generateBindings', Exec) {