Forgot to add files
This commit is contained in:
parent
293fd37bad
commit
8a4eb512c4
@ -87,3 +87,13 @@ fun NamedDomainObjectContainer<KotlinSourceSet>.createWorkaroundNativeMainSource
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun NamedDomainObjectContainer<KotlinSourceSet>.createWorkaround32bitNativeMainSourceSet(name : String, nativeDeps : KotlinDependencyHandler.() -> Unit) : KotlinSourceSet {
|
||||||
|
return create("${name}Workaround") {
|
||||||
|
kotlin.srcDir("src/native32Main/kotlin")
|
||||||
|
dependencies {
|
||||||
|
nativeDeps.invoke(this)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -76,7 +76,7 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
linuxX64("linux") {
|
linuxX64() {
|
||||||
binaries {
|
binaries {
|
||||||
staticLib {
|
staticLib {
|
||||||
}
|
}
|
||||||
@ -171,6 +171,15 @@ kotlin {
|
|||||||
optimized = true
|
optimized = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
compilations.getByName("main") {
|
||||||
|
val libsodiumCinterop by cinterops.creating {
|
||||||
|
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||||
|
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-macos-x86-64/include/")
|
||||||
|
}
|
||||||
|
kotlinOptions.freeCompilerArgs = listOf(
|
||||||
|
"-include-binary", "${project.rootDir}/sodiumWrapper/static-macos-x86-64/lib/libsodium.a"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tvosX64() {
|
tvosX64() {
|
||||||
binaries {
|
binaries {
|
||||||
@ -220,6 +229,15 @@ kotlin {
|
|||||||
optimized = true
|
optimized = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
compilations.getByName("main") {
|
||||||
|
val libsodiumCinterop by cinterops.creating {
|
||||||
|
defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
||||||
|
compilerOpts.add("-I${project.rootDir}/sodiumWrapper/static-mingw-x86-64/include/")
|
||||||
|
}
|
||||||
|
kotlinOptions.freeCompilerArgs = listOf(
|
||||||
|
"-include-binary", "${project.rootDir}/sodiumWrapper/static-mingw-x86-64/lib/libsodium.a"
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -275,34 +293,42 @@ kotlin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Set up shared source sets
|
||||||
|
//linux, linuxArm32Hfp, linuxArm64
|
||||||
|
val linux64Bit = setOf(
|
||||||
|
"linuxX64", "linuxArm64"
|
||||||
|
)
|
||||||
|
val linux32Bit = setOf(
|
||||||
|
"linuxArm32Hfp"
|
||||||
|
)
|
||||||
|
//iosArm32, iosArm64, iosX64, macosX64, metadata, tvosArm64, tvosX64, watchosArm32, watchosArm64, watchosX86
|
||||||
|
val macos64Bit = setOf(
|
||||||
|
"macosX64"
|
||||||
|
)
|
||||||
|
val ios64Bit = setOf(
|
||||||
|
"iosArm64", "iosX64", "tvosArm64", "tvosX64", "watchosArm64"
|
||||||
|
)
|
||||||
|
val ios32Bit = setOf(
|
||||||
|
"iosArm32", "watchosX86"
|
||||||
|
)
|
||||||
|
val mingw64Bit = setOf(
|
||||||
|
"mingwX64"
|
||||||
|
)
|
||||||
targets.withType<KotlinNativeTarget> {
|
targets.withType<KotlinNativeTarget> {
|
||||||
println("Target $name")
|
println("Target $name")
|
||||||
compilations.getByName("main") {
|
|
||||||
when(this@withType.name) {
|
|
||||||
|
|
||||||
}
|
compilations.getByName("main") {
|
||||||
if ((this@withType.name.contains("ios") || this@withType.name.contains("tvos") || this@withType.name.contains("watchos")).not()) {
|
if (linux64Bit.contains(this@withType.name)) {
|
||||||
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
||||||
// println("Setting cinterop for $this")
|
|
||||||
// if (this@withType.name.contains("arm64")) {
|
|
||||||
// val libsodiumCinterop by cinterops.creating {
|
|
||||||
// defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
|
||||||
// compilerOpts.add("-I${project.rootDir}/sodiumWrapper/libsodium-arm64/include/")
|
|
||||||
// }
|
|
||||||
// kotlinOptions.freeCompilerArgs = listOf(
|
|
||||||
// "-include-binary", "${project.rootDir}/sodiumWrapper/libsodium-arm64/lib/libsodium.a"
|
|
||||||
// )
|
|
||||||
// } else {
|
|
||||||
// val libsodiumCinterop by cinterops.creating {
|
|
||||||
// defFile(project.file("src/nativeInterop/cinterop/libsodium.def"))
|
|
||||||
// compilerOpts.add("-I${project.rootDir}/sodiumWrapper/include/")
|
|
||||||
// }
|
|
||||||
// kotlinOptions.freeCompilerArgs = listOf(
|
|
||||||
// "-include-binary", "${project.rootDir}/sodiumWrapper/lib/libsodium.a"
|
|
||||||
// )
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
if (this@withType.name.contains("ios") || this@withType.name.contains("tvos") || this@withType.name.contains("watchos")) {
|
if (linux32Bit.contains(this@withType.name)) {
|
||||||
|
defaultSourceSet.dependsOn(createWorkaround32bitNativeMainSourceSet(this@withType.name, nativeDependencies))
|
||||||
|
}
|
||||||
|
if (macos64Bit.contains(this@withType.name)) {
|
||||||
|
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
||||||
|
}
|
||||||
|
//All ioses share the same static library
|
||||||
|
if (ios64Bit.contains(this@withType.name)) {
|
||||||
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
defaultSourceSet.dependsOn(createWorkaroundNativeMainSourceSet(this@withType.name, nativeDependencies))
|
||||||
println("Setting ios cinterop for $this")
|
println("Setting ios cinterop for $this")
|
||||||
val libsodiumCinterop by cinterops.creating {
|
val libsodiumCinterop by cinterops.creating {
|
||||||
@ -314,11 +340,28 @@ kotlin {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ios32Bit.contains(this@withType.name)) {
|
||||||
|
defaultSourceSet.dependsOn(createWorkaround32bitNativeMainSourceSet(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/")
|
||||||
|
}
|
||||||
|
kotlinOptions.freeCompilerArgs = listOf(
|
||||||
|
"-include-binary", "${project.rootDir}/sodiumWrapper/static-ios/libsodium.a"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
compilations.getByName("test") {
|
compilations.getByName("test") {
|
||||||
println("Setting native test dep for $this@withType.name")
|
println("Setting native test dep for $this@withType.name")
|
||||||
|
if (linux64Bit.contains(this@withType.name) ||
|
||||||
|
macos64Bit.contains(this@withType.name) ||
|
||||||
|
mingw64Bit.contains(this@withType.name)) {
|
||||||
defaultSourceSet.dependsOn(nativeTest)
|
defaultSourceSet.dependsOn(nativeTest)
|
||||||
|
} else {
|
||||||
|
defaultSourceSet.dependsOn(native32Test)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -360,18 +403,31 @@ kotlin {
|
|||||||
implementation(npm(Deps.Js.Npm.libsodium.first, Deps.Js.Npm.libsodium.second))
|
implementation(npm(Deps.Js.Npm.libsodium.first, Deps.Js.Npm.libsodium.second))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val linuxMain by getting {
|
val linuxX64Main by getting {
|
||||||
dependsOn(nativeMain)
|
dependsOn(nativeMain)
|
||||||
isRunningInIdea {
|
isRunningInIdea {
|
||||||
kotlin.srcDir("src/nativeMain/kotlin")
|
kotlin.srcDir("src/nativeMain/kotlin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val linuxTest by getting {
|
val linuxX64Test by getting {
|
||||||
dependsOn(nativeTest)
|
dependsOn(nativeTest)
|
||||||
isRunningInIdea {
|
isRunningInIdea {
|
||||||
kotlin.srcDir("src/nativeTest/kotlin")
|
kotlin.srcDir("src/nativeTest/kotlin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val linuxArm32HfpMain by getting {
|
||||||
|
dependsOn(native32Main)
|
||||||
|
isRunningInIdea {
|
||||||
|
kotlin.srcDir("src/native32Main/kotlin")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val linuxArm32HfpTest by getting {
|
||||||
|
dependsOn(native32Test)
|
||||||
|
isRunningInIdea {
|
||||||
|
kotlin.srcDir("src/native32Test/kotlin")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
runningOnMacos {
|
runningOnMacos {
|
||||||
@ -478,7 +534,7 @@ tasks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val linuxTest by getting(KotlinNativeTest::class) {
|
val linuxX64Test by getting(KotlinNativeTest::class) {
|
||||||
|
|
||||||
testLogging {
|
testLogging {
|
||||||
events("PASSED", "FAILED", "SKIPPED")
|
events("PASSED", "FAILED", "SKIPPED")
|
||||||
|
@ -31,7 +31,7 @@ actual object SRNG {
|
|||||||
actual fun getRandomBytes(amount: Int): UByteArray {
|
actual fun getRandomBytes(amount: Int): UByteArray {
|
||||||
memScoped {
|
memScoped {
|
||||||
val array = allocArray<UByteVar>(amount)
|
val array = allocArray<UByteVar>(amount)
|
||||||
randombytes_buf(array, amount.toULong())
|
randombytes_buf(array, amount.toUInt())
|
||||||
return UByteArray(amount) {
|
return UByteArray(amount) {
|
||||||
array[it]
|
array[it]
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@ actual object Blake2bStateless : Blake2bStatelessInterface {
|
|||||||
val hashResultPinned = hashResult.pin()
|
val hashResultPinned = hashResult.pin()
|
||||||
crypto_generichash(
|
crypto_generichash(
|
||||||
hashResultPinned.addressOf(0),
|
hashResultPinned.addressOf(0),
|
||||||
hashLength.toULong(),
|
hashLength.toUInt(),
|
||||||
inputString.encodeToByteArray().toUByteArray().toCValues(),
|
inputString.encodeToByteArray().toUByteArray().toCValues(),
|
||||||
inputString.length.toULong(),
|
inputString.length.toULong(),
|
||||||
key?.run { this.encodeToByteArray().toUByteArray().toCValues() },
|
key?.run { this.encodeToByteArray().toUByteArray().toCValues() },
|
||||||
key?.length?.toULong() ?: 0UL
|
key?.length?.toUInt() ?: 0U
|
||||||
)
|
)
|
||||||
println("HashPointer: ${hashResult.toHexString()}")
|
println("HashPointer: ${hashResult.toHexString()}")
|
||||||
println(hashResult.toHexString())
|
println(hashResult.toHexString())
|
||||||
@ -54,11 +54,11 @@ actual object Blake2bStateless : Blake2bStatelessInterface {
|
|||||||
|
|
||||||
crypto_generichash(
|
crypto_generichash(
|
||||||
StableRef.create(hashResult).asCPointer().reinterpret(),
|
StableRef.create(hashResult).asCPointer().reinterpret(),
|
||||||
hashLength.toULong(),
|
hashLength.toUInt(),
|
||||||
inputMessage.toCValues(),
|
inputMessage.toCValues(),
|
||||||
inputMessage.size.toULong(),
|
inputMessage.size.toULong(),
|
||||||
key.toCValues(),
|
key.toCValues(),
|
||||||
key.size.toULong() ?: 0UL
|
key.size.toUInt() ?: 0U
|
||||||
)
|
)
|
||||||
println("HashPointer: ${hashResult.toHexString()}")
|
println("HashPointer: ${hashResult.toHexString()}")
|
||||||
println(hashResult.toHexString())
|
println(hashResult.toHexString())
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
export PREFIX="$(pwd)/static-arm64"
|
export PREFIX="$(pwd)/static-arm64"
|
||||||
export CC=/usr/bin/aarch64-linux-gnu-gcc
|
export CC=/usr/bin/aarch64-linux-gnu-gcc
|
||||||
export TARGET_ARCH=armv8-a
|
export CFLAGS="-O3"
|
||||||
export CFLAGS="-Os -march=${TARGET_ARCH}"
|
export SYSROOT=$HOME/.konan/dependencies/target-sysroot-1-linux-glibc-arm64/
|
||||||
export SYSROOT="$HOME/.konan/dependencies/target-sysroot-1-linux-glibc-arm64/"
|
|
||||||
cd libsodium
|
cd libsodium
|
||||||
./configure --prefix=$PREFIX --host=aarch64-linux-gnu-gcc --with-sysroot=$SYSROOT "$@"
|
./configure --prefix=$PREFIX --host=aarch64-linux-gnu-gcc --with-sysroot=$SYSROOT "$@"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user