Inital xcode support
This commit is contained in:
parent
5527b6dc79
commit
0a7c6a55f3
@ -135,10 +135,10 @@ Currently supported native platforms:
|
|||||||
|
|
||||||
### TODO:
|
### TODO:
|
||||||
- Copy/adapt code documentation, currently only some functions have documentation that is a copy-paste from libsodium website
|
- Copy/adapt code documentation, currently only some functions have documentation that is a copy-paste from libsodium website
|
||||||
- Complete the bindings list
|
- Replace LazySodium with direct JNA calls, and add build scripts for required libraries if missing
|
||||||
- Samples
|
|
||||||
- Android testing
|
- Android testing
|
||||||
- Fix browser testing, both locally and in CI/CD
|
- Fix browser testing, both locally and in CI/CD
|
||||||
|
- LobsodiumUtil `unpad` and `fromBase64` native implementations use a nasty hack to support shared native sourceset. The hack either needs to be removed and replaced with another solution or additional safeguards need to be added.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,14 +17,15 @@
|
|||||||
|
|
||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
|
||||||
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
import org.jetbrains.kotlin.gradle.targets.js.testing.KotlinJsTest
|
||||||
|
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
|
||||||
|
import org.jetbrains.kotlin.gradle.tasks.FatFrameworkTask
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin(PluginsDeps.multiplatform)
|
kotlin(PluginsDeps.multiplatform)
|
||||||
id(PluginsDeps.kapt)
|
id(PluginsDeps.kapt)
|
||||||
// id(PluginsDeps.androidApplication)
|
id(PluginsDeps.androidApplication)
|
||||||
// id(PluginsDeps.kotlinAndroidExtensions)
|
id(PluginsDeps.kotlinAndroidExtensions)
|
||||||
id(PluginsDeps.mavenPublish)
|
id(PluginsDeps.mavenPublish)
|
||||||
id(PluginsDeps.signing)
|
id(PluginsDeps.signing)
|
||||||
kotlin(PluginsDeps.kotlinSerializationPlugin) version Versions.kotlinSerializationPlugin
|
kotlin(PluginsDeps.kotlinSerializationPlugin) version Versions.kotlinSerializationPlugin
|
||||||
@ -35,12 +36,7 @@ org.jetbrains.kotlin.gradle.targets.js.npm.NpmResolverPlugin.apply(project)
|
|||||||
val sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
val sonatypeStaging = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
|
||||||
val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"
|
val sonatypeSnapshots = "https://oss.sonatype.org/content/repositories/snapshots/"
|
||||||
|
|
||||||
val sonatypePassword : String? by project
|
|
||||||
|
|
||||||
val sonatypeUsername : String? by project
|
|
||||||
|
|
||||||
val sonatypePasswordEnv : String? = System.getenv()["SONATYPE_PASSWORD"]
|
|
||||||
val sonatypeUsernameEnv : String? = System.getenv()["SONATYPE_USERNAME"]
|
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -55,6 +51,8 @@ val ideaActive = System.getProperty("idea.active") == "true"
|
|||||||
|
|
||||||
kotlin {
|
kotlin {
|
||||||
val hostOsName = getHostOsName()
|
val hostOsName = getHostOsName()
|
||||||
|
|
||||||
|
android()
|
||||||
runningOnLinuxx86_64 {
|
runningOnLinuxx86_64 {
|
||||||
jvm()
|
jvm()
|
||||||
js {
|
js {
|
||||||
@ -81,7 +79,6 @@ kotlin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// android()
|
|
||||||
|
|
||||||
linuxX64("linux") {
|
linuxX64("linux") {
|
||||||
binaries {
|
binaries {
|
||||||
@ -89,9 +86,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Linux 32 is using target-sysroot-2-raspberrypi which is missing getrandom and explicit_bzero in stdlib
|
|
||||||
// so konanc can't build klib because getrandom missing will cause sodium_misuse()
|
|
||||||
// so 32bit will be only available from non-delegated flavor
|
|
||||||
|
|
||||||
linuxArm64() {
|
linuxArm64() {
|
||||||
binaries {
|
binaries {
|
||||||
@ -103,51 +98,44 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
runningOnMacos {
|
runningOnMacos {
|
||||||
iosX64() {
|
val iosX64Target = iosX64()
|
||||||
binaries {
|
val iosArm64Target = iosArm64()
|
||||||
framework {
|
val iosArm32Target = iosArm32()
|
||||||
|
val macosX64Target = macosX64()
|
||||||
|
val tvosX64Target = tvosX64()
|
||||||
|
val tvosArm64Target = tvosArm64()
|
||||||
|
val watchosArm64Target = watchosArm64()
|
||||||
|
val watchosArm32Target = watchosArm32()
|
||||||
|
val watchosX86Target = watchosX86()
|
||||||
|
|
||||||
|
configure(listOf(
|
||||||
|
iosX64Target, iosArm64Target, iosArm32Target, macosX64Target,
|
||||||
|
tvosX64Target, tvosArm64Target, watchosArm64Target,
|
||||||
|
watchosArm32Target, watchosX86Target)
|
||||||
|
) {
|
||||||
|
binaries.framework {
|
||||||
|
baseName = "sample"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
val mode = System.getenv("CONFIGURATION") ?: "DEBUG"
|
||||||
iosArm64() {
|
// Create a task to build a fat framework.
|
||||||
binaries {
|
tasks.create("packForXcode", FatFrameworkTask::class) {
|
||||||
framework {
|
// The fat framework must have the same base name as the initial frameworks.
|
||||||
|
baseName = "sample"
|
||||||
}
|
// The default destination directory is '<build directory>/fat-framework'.
|
||||||
}
|
destinationDir = File(buildDir, "xcode-frameworks")
|
||||||
}
|
// Specify the frameworks to be merged.
|
||||||
|
from(
|
||||||
iosArm32() {
|
iosX64Target.binaries.getFramework(mode),
|
||||||
binaries {
|
iosArm64Target.binaries.getFramework(mode),
|
||||||
framework {
|
iosArm32Target.binaries.getFramework(mode),
|
||||||
|
macosX64Target.binaries.getFramework(mode),
|
||||||
}
|
tvosX64Target.binaries.getFramework(mode),
|
||||||
}
|
tvosArm64Target.binaries.getFramework(mode),
|
||||||
}
|
watchosArm64Target.binaries.getFramework(mode),
|
||||||
macosX64() {
|
watchosArm32Target.binaries.getFramework(mode),
|
||||||
binaries {
|
watchosX86Target.binaries.getFramework(mode)
|
||||||
executable {
|
)
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// select iOS target platform depending on the Xcode environment variables
|
|
||||||
val iOSTarget: (String, org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget.() -> Unit) -> org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget =
|
|
||||||
if (System.getenv("SDK_NAME")?.startsWith("iphoneos") == true)
|
|
||||||
::iosArm64
|
|
||||||
else
|
|
||||||
::iosX64
|
|
||||||
|
|
||||||
iOSTarget("ios") {
|
|
||||||
binaries {
|
|
||||||
framework {
|
|
||||||
baseName = "LibsodiumBindingsSampleApplication"
|
|
||||||
export(Deps.Common.sharedModule)
|
|
||||||
freeCompilerArgs += ("-Xobjc-generics")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
runningOnWindows {
|
runningOnWindows {
|
||||||
@ -162,6 +150,8 @@ kotlin {
|
|||||||
|
|
||||||
println(targets.names)
|
println(targets.names)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting {
|
val commonMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
@ -179,6 +169,34 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val androidMain by getting {
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}")
|
||||||
|
implementation("androidx.appcompat:appcompat:1.2.0")
|
||||||
|
implementation("androidx.core:core-ktx:1.3.2")
|
||||||
|
implementation("androidx.constraintlayout:constraintlayout:2.0.2")
|
||||||
|
implementation("com.google.android.material:material:1.3.0-alpha03")
|
||||||
|
// implementation("androidx.ui:ui-tooling:$composeDevVersion")
|
||||||
|
// implementation("androidx.ui:ui-layout:$composeDevVersion")
|
||||||
|
// implementation("androidx.ui:ui-material:$composeDevVersion")
|
||||||
|
// implementation("androidx.ui:ui-foundation:$composeDevVersion")
|
||||||
|
// implementation("androidx.ui:ui-framework:$composeDevVersion")
|
||||||
|
implementation(Deps.Android.coroutines)
|
||||||
|
implementation(Deps.Android.timber)
|
||||||
|
// implementation("androidx.compose:compose-runtime:$composeDevVersion")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val androidTest by getting {
|
||||||
|
dependencies {
|
||||||
|
implementation(kotlin(Deps.Jvm.test))
|
||||||
|
implementation(kotlin(Deps.Jvm.testJUnit))
|
||||||
|
implementation(Deps.Jvm.coroutinesTest)
|
||||||
|
implementation(kotlin(Deps.Jvm.reflection))
|
||||||
|
implementation(Deps.Jvm.coroutinesCore)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
val nativeMain by creating {
|
val nativeMain by creating {
|
||||||
@ -232,35 +250,6 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// val androidMain by getting {
|
|
||||||
//
|
|
||||||
// dependencies {
|
|
||||||
// implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin}")
|
|
||||||
// implementation("androidx.appcompat:appcompat:1.2.0")
|
|
||||||
// implementation("androidx.core:core-ktx:1.3.2")
|
|
||||||
// implementation("androidx.constraintlayout:constraintlayout:2.0.2")
|
|
||||||
// implementation("com.google.android.material:material:1.3.0-alpha03")
|
|
||||||
//// implementation("androidx.ui:ui-tooling:$composeDevVersion")
|
|
||||||
//// implementation("androidx.ui:ui-layout:$composeDevVersion")
|
|
||||||
//// implementation("androidx.ui:ui-material:$composeDevVersion")
|
|
||||||
//// implementation("androidx.ui:ui-foundation:$composeDevVersion")
|
|
||||||
//// implementation("androidx.ui:ui-framework:$composeDevVersion")
|
|
||||||
// implementation(Deps.Android.coroutines)
|
|
||||||
// implementation(Deps.Android.timber)
|
|
||||||
//// implementation("androidx.compose:compose-runtime:$composeDevVersion")
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// val androidTest by getting {
|
|
||||||
// dependencies {
|
|
||||||
// implementation(kotlin(Deps.Jvm.test))
|
|
||||||
// implementation(kotlin(Deps.Jvm.testJUnit))
|
|
||||||
// implementation(Deps.Jvm.coroutinesTest)
|
|
||||||
// implementation(kotlin(Deps.Jvm.reflection))
|
|
||||||
// implementation(Deps.Jvm.coroutinesCore)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
val linuxMain by getting {
|
val linuxMain by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
}
|
}
|
||||||
@ -329,81 +318,81 @@ kotlin {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//android {
|
android {
|
||||||
// compileSdkVersion(29)
|
compileSdkVersion(29)
|
||||||
// defaultConfig {
|
defaultConfig {
|
||||||
// applicationId = "com.ionspin.kotlin.crypto.sample"
|
applicationId = "com.ionspin.kotlin.crypto.sample"
|
||||||
// minSdkVersion(21)
|
minSdkVersion(21)
|
||||||
// targetSdkVersion(29)
|
targetSdkVersion(29)
|
||||||
// versionCode = 1
|
versionCode = 1
|
||||||
// versionName = "1.0"
|
versionName = "1.0"
|
||||||
// testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "android.support.test.runner.AndroidJUnitRunner"
|
||||||
|
}
|
||||||
|
buildTypes {
|
||||||
|
getByName("release") {
|
||||||
|
isMinifyEnabled = false
|
||||||
|
proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
val main by getting
|
||||||
|
main.manifest.srcFile("src/androidMain/AndroidManifest.xml")
|
||||||
|
main.java.srcDirs("src/androidMain/kotlin")
|
||||||
|
main.res.srcDirs("src/androidMain/res")
|
||||||
|
}
|
||||||
|
packagingOptions {
|
||||||
|
exclude("META-INF/library_release.kotlin_module")
|
||||||
|
exclude("META-INF/kotlinx-serialization-runtime.kotlin_module")
|
||||||
|
exclude("META-INF/ktor-http.kotlin_module")
|
||||||
|
exclude("META-INF/ktor-utils.kotlin_module")
|
||||||
|
exclude("META-INF/ktor-io.kotlin_module")
|
||||||
|
exclude("META-INF/ktor-*")
|
||||||
|
}
|
||||||
|
compileOptions {
|
||||||
|
setSourceCompatibility(JavaVersion.VERSION_1_8)
|
||||||
|
setTargetCompatibility(JavaVersion.VERSION_1_8)
|
||||||
|
}
|
||||||
|
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
||||||
|
kotlinOptions {
|
||||||
|
jvmTarget = "1.8"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// buildFeatures {
|
||||||
|
// // Enables Jetpack Compose for this module
|
||||||
|
// this.compose = true
|
||||||
// }
|
// }
|
||||||
// buildTypes {
|
|
||||||
// getByName("release") {
|
// composeOptions {
|
||||||
// isMinifyEnabled = false
|
// kotlinCompilerExtensionVersion = "0.1.0-dev05"
|
||||||
// proguardFiles(getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro")
|
// }
|
||||||
|
|
||||||
|
// Magic for compose dev08, but it doesn't work with serialization plugin because of IR. Leave here for future reference.
|
||||||
|
// project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java)
|
||||||
|
// .configureEach {
|
||||||
|
// println("Task: $this")
|
||||||
|
// if (this.name.contains("Android")) {
|
||||||
|
// println("Setting plugins: $this")
|
||||||
|
// this.kotlinOptions.freeCompilerArgs += listOf(
|
||||||
|
// "-P",
|
||||||
|
// "plugin:androidx.compose.plugins.idea:enabled=true"
|
||||||
|
// )
|
||||||
|
// this.kotlinOptions.freeCompilerArgs += "-Xplugin=${project.rootDir}/compose-compiler-0.1.0-dev08.jar"
|
||||||
|
// this.kotlinOptions.freeCompilerArgs += "-Xuse-ir"
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// sourceSets {
|
// project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java)
|
||||||
// val main by getting
|
// .forEach { compile ->
|
||||||
// main.manifest.srcFile("src/androidMain/AndroidManifest.xml")
|
// compile.kotlinOptions.freeCompilerArgs += listOf(
|
||||||
// main.java.srcDirs("src/androidMain/kotlin")
|
// "-P",
|
||||||
// main.res.srcDirs("src/androidMain/res")
|
// "plugin:androidx.compose.plugins.idea:enabled=true"
|
||||||
|
// )
|
||||||
|
// compile.kotlinOptions.freeCompilerArgs += "-Xplugin=${project.rootDir}/compose-compiler-0.1.0-dev08.jar"
|
||||||
|
// compile.kotlinOptions.freeCompilerArgs += "-Xuse-ir"
|
||||||
|
// println("Compile: $compile")
|
||||||
|
// println("Compiler free args ${compile.kotlinOptions.freeCompilerArgs}")
|
||||||
// }
|
// }
|
||||||
// packagingOptions {
|
}
|
||||||
// exclude("META-INF/library_release.kotlin_module")
|
|
||||||
// exclude("META-INF/kotlinx-serialization-runtime.kotlin_module")
|
|
||||||
// exclude("META-INF/ktor-http.kotlin_module")
|
|
||||||
// exclude("META-INF/ktor-utils.kotlin_module")
|
|
||||||
// exclude("META-INF/ktor-io.kotlin_module")
|
|
||||||
// exclude("META-INF/ktor-*")
|
|
||||||
// }
|
|
||||||
// compileOptions {
|
|
||||||
// setSourceCompatibility(JavaVersion.VERSION_1_8)
|
|
||||||
// setTargetCompatibility(JavaVersion.VERSION_1_8)
|
|
||||||
// }
|
|
||||||
// tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
|
|
||||||
// kotlinOptions {
|
|
||||||
// jvmTarget = "1.8"
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// buildFeatures {
|
|
||||||
//// // Enables Jetpack Compose for this module
|
|
||||||
//// this.compose = true
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
//// composeOptions {
|
|
||||||
//// kotlinCompilerExtensionVersion = "0.1.0-dev05"
|
|
||||||
//// }
|
|
||||||
//
|
|
||||||
// // Magic for compose dev08, but it doesn't work with serialization plugin because of IR. Leave here for future reference.
|
|
||||||
//// project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java)
|
|
||||||
//// .configureEach {
|
|
||||||
//// println("Task: $this")
|
|
||||||
//// if (this.name.contains("Android")) {
|
|
||||||
//// println("Setting plugins: $this")
|
|
||||||
//// this.kotlinOptions.freeCompilerArgs += listOf(
|
|
||||||
//// "-P",
|
|
||||||
//// "plugin:androidx.compose.plugins.idea:enabled=true"
|
|
||||||
//// )
|
|
||||||
//// this.kotlinOptions.freeCompilerArgs += "-Xplugin=${project.rootDir}/compose-compiler-0.1.0-dev08.jar"
|
|
||||||
//// this.kotlinOptions.freeCompilerArgs += "-Xuse-ir"
|
|
||||||
//// }
|
|
||||||
//// }
|
|
||||||
//// project.tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class.java)
|
|
||||||
//// .forEach { compile ->
|
|
||||||
//// compile.kotlinOptions.freeCompilerArgs += listOf(
|
|
||||||
//// "-P",
|
|
||||||
//// "plugin:androidx.compose.plugins.idea:enabled=true"
|
|
||||||
//// )
|
|
||||||
//// compile.kotlinOptions.freeCompilerArgs += "-Xplugin=${project.rootDir}/compose-compiler-0.1.0-dev08.jar"
|
|
||||||
//// compile.kotlinOptions.freeCompilerArgs += "-Xuse-ir"
|
|
||||||
//// println("Compile: $compile")
|
|
||||||
//// println("Compiler free args ${compile.kotlinOptions.freeCompilerArgs}")
|
|
||||||
//// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
|
|
||||||
@ -432,20 +421,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// val legacyjsNodeTest by getting(KotlinJsTest::class) {
|
|
||||||
//
|
|
||||||
// testLogging {
|
|
||||||
// events("PASSED", "FAILED", "SKIPPED")
|
|
||||||
// showStandardStreams = true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// val jsIrBrowserTest by getting(KotlinJsTest::class) {
|
|
||||||
// testLogging {
|
|
||||||
// events("PASSED", "FAILED", "SKIPPED")
|
|
||||||
// showStandardStreams = true
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getHostOsName() == "windows") {
|
if (getHostOsName() == "windows") {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user