-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
132 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters