Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add macos targets #123

Merged
merged 4 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ plugins {
val currentOs = org.gradle.internal.os.OperatingSystem.current()

group = "fr.acinq.bitcoin"
version = "0.18.0"
version = "0.19.0-SNAPSHOT"

repositories {
google()
Expand All @@ -32,6 +32,10 @@ kotlin {

linuxX64()

macosX64()

macosArm64()

iosX64 {
compilations["main"].cinterops.create("CoreCrypto")
}
Expand All @@ -45,7 +49,7 @@ kotlin {
}

sourceSets {
val secp256k1KmpVersion = "0.14.0"
val secp256k1KmpVersion = "0.15.0"

val commonMain by getting {
dependencies {
Expand Down
73 changes: 44 additions & 29 deletions publishing/bitcoin-kmp-snapshot-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,51 @@ mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/conte
-Djavadoc=$ARTIFACT_ID_BASE-$VERSION-javadoc.jar
popd
pushd .
for i in iosarm64 iossimulatorarm64 iosx64 jvm linuxx64; do
for i in iosarm64 iossimulatorarm64 iosx64 macosarm64 macosx64 jvm linuxx64; do
cd fr/acinq/bitcoin/bitcoin-kmp-$i/$VERSION
if [ $i == iosarm64 ] || [ $i == iossimulatorarm64 ] || [ $i == iosx64 ]; then
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION-metadata.jar,$ARTIFACT_ID_BASE-$i-$VERSION.module,$ARTIFACT_ID_BASE-$i-$VERSION-cinterop-CoreCrypto.klib \
-Dtypes=jar,module,klib \
-Dclassifiers=metadata,,cinterop-CoreCrypto \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
elif [ $i == linuxx64 ]; then
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
-Dtypes=module \
-Dclassifiers= \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
else
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.jar \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
-Dtypes=module \
-Dclassifiers= \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
fi

case $i in
iosarm64 |iossimulatorarm64 | iosx64)
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION-metadata.jar,$ARTIFACT_ID_BASE-$i-$VERSION.module,$ARTIFACT_ID_BASE-$i-$VERSION-cinterop-CoreCrypto.klib \
-Dtypes=jar,module,klib \
-Dclassifiers=metadata,,cinterop-CoreCrypto \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
;;
macosarm64 | macosx64)
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION-metadata.jar,$ARTIFACT_ID_BASE-$i-$VERSION.module \
-Dtypes=jar,module \
-Dclassifiers=metadata, \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
;;
linuxx64)
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.klib \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
-Dtypes=module \
-Dclassifiers= \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
;;
*)
mvn deploy:deploy-file -DrepositoryId=ossrh -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
-DpomFile=$ARTIFACT_ID_BASE-$i-$VERSION.pom \
-Dfile=$ARTIFACT_ID_BASE-$i-$VERSION.jar \
-Dfiles=$ARTIFACT_ID_BASE-$i-$VERSION.module \
-Dtypes=module \
-Dclassifiers= \
-Dsources=$ARTIFACT_ID_BASE-$i-$VERSION-sources.jar \
-Djavadoc=$ARTIFACT_ID_BASE-$i-$VERSION-javadoc.jar
;;
esac
popd
pushd .
done
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import kotlinx.cinterop.memScoped
import kotlinx.cinterop.refTo
import platform.KCoreCrypto.KCCKeyDerivationPBKDF
import platform.CoreCrypto.kCCPBKDF2
import platform.CoreCrypto.kCCPRFHmacAlgSHA256
import platform.CoreCrypto.kCCPRFHmacAlgSHA512


Expand Down
6 changes: 6 additions & 0 deletions src/linuxMain/kotlin/fr/acinq/bitcoin/crypto/Digest.linux.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fr.acinq.bitcoin.crypto


internal actual fun Sha1(): Digest = Sha1Native()
internal actual fun Sha256(): Digest = Sha256Native()
internal actual fun Sha512(): Digest = Sha512Native()
6 changes: 0 additions & 6 deletions src/linuxMain/kotlin/fr/acinq/bitcoin/crypto/DigestLinux.kt

This file was deleted.

6 changes: 6 additions & 0 deletions src/linuxMain/kotlin/fr/acinq/bitcoin/crypto/pbkdf2.linux.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fr.acinq.bitcoin.crypto

public actual object Pbkdf2 {
public actual fun withHmacSha512(password: ByteArray, salt: ByteArray, count: Int, dkLen: Int): ByteArray =
Pbkdf2Native.withHmacSha512(password, salt, count, dkLen)
}
7 changes: 7 additions & 0 deletions src/macosMain/kotlin/fr/acinq/bitcoin/crypto/Digest.macos.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fr.acinq.bitcoin.crypto

internal actual fun Sha1(): Digest = Sha1Native()

internal actual fun Sha256(): Digest = Sha256Native()

internal actual fun Sha512(): Digest = Sha512Native()
6 changes: 6 additions & 0 deletions src/macosMain/kotlin/fr/acinq/bitcoin/crypto/Pbkdf2.macos.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package fr.acinq.bitcoin.crypto

public actual object Pbkdf2 {
public actual fun withHmacSha512(password: ByteArray, salt: ByteArray, count: Int, dkLen: Int): ByteArray =
Pbkdf2Native.withHmacSha512(password, salt, count, dkLen)
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.acinq.bitcoin.crypto

internal class Sha1Linux : Digest {
internal class Sha1Native : Digest {
private var H1 = 0
private var H2 = 0
private var H3 = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package fr.acinq.bitcoin.crypto

public class Sha256Linux : Digest {
public class Sha256Native : Digest {
private val xBuf = ByteArray(4)
private var xBufOff = 0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package fr.acinq.bitcoin.crypto

public class Sha512Linux : Digest {
public class Sha512Native : Digest {

private val DIGEST_LENGTH = 64

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package fr.acinq.bitcoin.crypto

import kotlin.experimental.xor


public actual object Pbkdf2 {
public object Pbkdf2Native {

private interface Prf {
fun outputLen(): Int
Expand Down Expand Up @@ -47,6 +46,6 @@ public actual object Pbkdf2 {
return t
}

public actual fun withHmacSha512(password: ByteArray, salt: ByteArray, count: Int, dkLen: Int): ByteArray =
public fun withHmacSha512(password: ByteArray, salt: ByteArray, count: Int, dkLen: Int): ByteArray =
generate(salt, count, dkLen, Hmac512(password))
}
Loading