Update libsodium build to latest upstream with tvos modification

This commit is contained in:
Ugljesa Jovanovic 2020-10-18 23:29:21 +02:00
parent 8b3baaba81
commit 065abe1dab
8 changed files with 125 additions and 44 deletions

3
.gitignore vendored
View File

@ -32,3 +32,6 @@ build/
/sodiumWrapper/static-tvos/
/sodiumWrapper/static-watchos/
/kotlin-multiplatform-libsodium-generator/out/
/sodiumWrapper/static-ios-simulators/
/sodiumWrapper/static-tvos-simulators/
/sodiumWrapper/static-watchos-simulators/

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "sodiumWrapper/libsodium"]
path = sodiumWrapper/libsodium
url = https://github.com/ionspin/libsodium.git
url = git@github.com:ionspin/libsodium.git

View File

@ -5,12 +5,11 @@ set -e
#now let's build linux deps
cd sodiumWrapper
./makeMacosX86-64.sh
./makeIos.sh
./makeTvos.sh
./makeWatchos.sh
./makeIosWatchosTvos.sh
#now we can do the delegated build
cd ..
./gradlew multiplatform-crypto-delegated:build
#and finally pure build
#pure build
./gradlew multiplatform-crypto:build
#libsodium bindings
set +e

View File

@ -297,22 +297,28 @@ kotlin {
val macos64Bit = setOf(
"macosX64"
)
val ios64Bit = setOf(
"iosArm64", "iosX64"
val iosArm = setOf(
"iosArm64", "iosArm32"
)
val ios32Bit = setOf(
"iosArm32"
val iosSimulator = setOf(
"iosX64"
)
val mingw64Bit = setOf(
"mingwX64"
)
val tvos64Bit = setOf(
"tvosArm64", "tvosX64"
val tvosArm = setOf(
"tvosArm64"
)
val tvosSimulator = setOf(
"tvosX64"
)
val watchos32Bit = setOf(
"watchosX86", "watchosArm32", "watchosArm64"
val watchosArm = setOf(
"watchosArm32", "watchosArm64"
)
val watchosSimulator = setOf(
"watchosX86"
)
targets.withType<KotlinNativeTarget> {
@ -347,7 +353,7 @@ kotlin {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
}
//All ioses share the same static library
if (ios64Bit.contains(this@withType.name)) {
if (iosArm.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
@ -359,19 +365,19 @@ kotlin {
)
}
if (ios32Bit.contains(this@withType.name)) {
if (iosSimulator.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-ios/include")
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-ios-simulators/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${project.rootDir}/sodiumWrapper/static-ios/lib/libsodium.a"
"-include-binary", "${project.rootDir}/sodiumWrapper/static-ios-simulators/lib/libsodium.a"
)
}
if (tvos64Bit.contains(this@withType.name)) {
if (tvosArm.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
@ -383,7 +389,19 @@ kotlin {
)
}
if (watchos32Bit.contains(this@withType.name)) {
if (tvosSimulator.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-tvos-simulators/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${project.rootDir}/sodiumWrapper/static-tvos-simulators/lib/libsodium.a"
)
}
if (watchosArm.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
@ -395,6 +413,18 @@ kotlin {
)
}
if (watchosSimulator.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-watchos-simulators/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${project.rootDir}/sodiumWrapper/static-watchos-simulators/lib/libsodium.a"
)
}
}

View File

@ -301,22 +301,28 @@ kotlin {
val macos64Bit = setOf(
"macosX64"
)
val ios64Bit = setOf(
"iosArm64", "iosX64"
val iosArm = setOf(
"iosArm64", "iosArm32"
)
val ios32Bit = setOf(
"iosArm32"
val iosSimulator = setOf(
"iosX64"
)
val mingw64Bit = setOf(
"mingwX64"
)
val tvos64Bit = setOf(
"tvosArm64", "tvosX64"
val tvosArm = setOf(
"tvosArm64"
)
val tvosSimulator = setOf(
"tvosX64"
)
val watchos32Bit = setOf(
"watchosX86", "watchosArm32", "watchosArm64"
val watchosArm = setOf(
"watchosArm32", "watchosArm64"
)
val watchosSimulator = setOf(
"watchosX86"
)
targets.withType<KotlinNativeTarget> {
@ -327,12 +333,12 @@ kotlin {
defaultSourceSet.dependsOn(nativeMain)
}
if (linuxArm64Bit.contains(this@withType.name)) {
defaultSourceSet.dependsOn(
createWorkaroundNativeMainSourceSet(
this@withType.name,
nativeDependencies
)
defaultSourceSet.dependsOn(
createWorkaroundNativeMainSourceSet(
this@withType.name,
nativeDependencies
)
)
compilations.getByName("main") {
val libsodiumCinterop by cinterops.creating {
@ -351,7 +357,7 @@ kotlin {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
}
//All ioses share the same static library
if (ios64Bit.contains(this@withType.name)) {
if (iosArm.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
@ -363,19 +369,19 @@ kotlin {
)
}
if (ios32Bit.contains(this@withType.name)) {
if (iosSimulator.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-ios/include")
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-ios-simulators/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${project.rootDir}/sodiumWrapper/static-ios/lib/libsodium.a"
"-include-binary", "${project.rootDir}/sodiumWrapper/static-ios-simulators/lib/libsodium.a"
)
}
if (tvos64Bit.contains(this@withType.name)) {
if (tvosArm.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
@ -387,7 +393,19 @@ kotlin {
)
}
if (watchos32Bit.contains(this@withType.name)) {
if (tvosSimulator.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-tvos-simulators/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${project.rootDir}/sodiumWrapper/static-tvos-simulators/lib/libsodium.a"
)
}
if (watchosArm.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
@ -399,6 +417,18 @@ kotlin {
)
}
if (watchosSimulator.contains(this@withType.name)) {
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
println("Setting ios cinterop for $this")
val libsodiumCinterop by cinterops.creating {
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-watchos-simulators/include")
}
kotlinOptions.freeCompilerArgs = listOf(
"-include-binary", "${project.rootDir}/sodiumWrapper/static-watchos-simulators/lib/libsodium.a"
)
}
}

@ -1 +1 @@
Subproject commit b5402aed53a36dc8bd4b5feb5d954088a85e375a
Subproject commit 1a9ef3db870ba0d98d04a469bdb9b0cd2379a9e3

View File

@ -1,5 +0,0 @@
cd libsodium
./dist-build/ios.sh
mkdir ../static-ios
cp -R ./libsodium-ios/lib ../static-ios/lib
cp -R ./libsodium-ios/include ../static-ios/include

View File

@ -0,0 +1,24 @@
cd libsodium
./dist-build/apple-xcframework.sh
mkdir ../static-ios
mkdir ../static-ios-simulators
mkdir ../static-watchos
mkdir ../static-watchos-simulators
mkdir ../static-tvos
mkdir ../static-tvos-simulators
cp -R ./libsodium-apple/ios/lib ../static-ios/lib
cp -R ./libsodium-apple/ios/include ../static-ios
cp -R ./libsodium-apple/ios-simulators/lib ../static-ios-simulators/lib
cp -R ./libsodium-apple/ios-simulators/include ../static-ios-simulators
cp -R ./libsodium-apple/watchos/lib ../static-watchos/lib
cp -R ./libsodium-apple/watchos/include ../static-watchos
cp -R ./libsodium-apple/watchos-simulators/lib ../static-watchos-simulators/lib
cp -R ./libsodium-apple/watchos-simulators/include ../static-watchos-simulators
cp -R ./libsodium-apple/tvos/lib ../static-tvos/lib
cp -R ./libsodium-apple/tvos/include ../static-tvos
cp -R ./libsodium-apple/tvos-simulators/lib ../static-tvos-simulators/lib
cp -R ./libsodium-apple/tvos-simulators/include ../static-tvos-simulators