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

Support Kotlin/Native #855

Open
wants to merge 93 commits into
base: main
Choose a base branch
from
Open

Support Kotlin/Native #855

wants to merge 93 commits into from

Conversation

DRSchlaubi
Copy link
Member

@DRSchlaubi DRSchlaubi commented Aug 5, 2023

This PR aims at implementing Kotlin/Native for the following platforms:

  • linuxX64
  • linuxArm64
  • mingwX64
  • macosArm64
  • macosX64
  • iosArm64
  • iosX64
  • iosSimulatorArm64
  • watchosX64
  • watchosArm64
  • watchosSimulatorArm64
  • tvosX64
  • tvosArm64
  • tvosSimulatorArm64

Experimental Snapshot

There currently is an experimental snapshot on OSSRH under the feature-native-SNAPSHOT for you to try

An example implementation can be found here

Please note that you need to configure our custom repository:

Gradle Configuration
repositories {
    // Required for custom Ktor build
    maven("https://europe-west3-maven.pkg.dev/mik-music/kord")
    maven("https://oss.sonatype.org/content/repositories/snapshots/")
    mavenCentral()
}

kotlin {
  sourceSets {
    commonMain {
      dependencies {
        implementation("dev.kord:kord-core:feature-native-SNAPSHOT")
      }
    }
  }
}
  

Current limitations

Checklist

Blocked by

@lukellmann
Copy link
Member

can't wait to run my bot on an apple watch

@lukellmann
Copy link
Member

what's this commit? seems to be related to #836 but that is already on main.

@DRSchlaubi
Copy link
Member Author

When I compiled these files were generated

@DRSchlaubi
Copy link
Member Author

can't wait to run my bot on an apple watch

Need to buy one again for this, or ask @melike2d

@viztea
Copy link
Contributor

viztea commented Aug 6, 2023

can't wait to run my bot on an apple watch

Need to buy one again for this, or ask @melike2d

can't believe you think i have enough money for that

@lukellmann
Copy link
Member

When I compiled these files were generated

the one in the build dir, sure, but the other ones?

@DRSchlaubi DRSchlaubi linked an issue Aug 6, 2023 that may be closed by this pull request
8 tasks
lukellmann added a commit that referenced this pull request Sep 3, 2023
The use of value classes for the Reset class has already caused issues
implementing #855. However, it was isolated to native platforms.
Unfortunately, this behavior will become a compiler error soon, so we
need to change it. This can be achieved by simply using the backing
Instant instead of Reset with AtomicRef.

Related Issues:
#855
#69
Kotlin/kotlinx-atomicfu#291
https://youtrack.jetbrains.com/issue/KT-61584

Co-authored-by: lukellmann <[email protected]>
@DRSchlaubi DRSchlaubi marked this pull request as ready for review January 30, 2024 18:55
@DRSchlaubi DRSchlaubi changed the title Add support for Kotlin/Native Support Kotlin/Native Jan 30, 2024
This was referenced Feb 6, 2024
@DRSchlaubi
Copy link
Member Author

A workaround for the blocking teamcity bug has been implemented, snapshots are now published to feature-native-SNAPSHOT

lukellmann and others added 9 commits April 22, 2024 20:46
I spent way too much time reading documentation...
# Conflicts:
#	.github/workflows/gradle-wrapper-validation.yml
#	buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
#	core/api/core.api
#	core/api/core.klib.api
#	core/live-tests/build.gradle.kts
#	core/src/commonMain/kotlin/Kord.kt
#	gateway/api/gateway.api
#	gateway/api/gateway.klib.api
#	gateway/src/commonMain/kotlin/Gateway.kt
#	gateway/src/commonMain/kotlin/Inflater.kt
#	gateway/src/commonMain/kotlin/Utils.kt
#	gradle/libs.versions.toml
#	voice/api/voice.api
#	voice/src/commonMain/kotlin/gateway/VoiceGateway.kt
@@ -63,6 +64,8 @@ class KordEventDropTest {
)

@Test
// This test seems to timeout sometimes on native
@IgnoreOnNative
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we increase/remove the timeout as with js? #926

DRSchlaubi and others added 8 commits July 18, 2024 18:23
# Conflicts:
#	gradle/libs.versions.toml
# Conflicts:
#	.github/workflows/deployment-ci.yml
#	.github/workflows/docs-ci.yml
#	buildSrc/src/main/kotlin/kord-internal-multiplatform-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-multiplatform-module.gradle.kts
#	buildSrc/src/main/kotlin/kord-publishing.gradle.kts
#	core/src/commonMain/kotlin/Kord.kt
#	gateway/src/commonMain/kotlin/Gateway.kt
#	gateway/src/commonMain/kotlin/Utils.kt
#	gradle/libs.versions.toml
#	ksp-annotations/build.gradle.kts
#	voice/src/commonMain/kotlin/gateway/VoiceGateway.kt
Comment on lines 8 to 12
internal actual fun formatIntegerFromLittleEndianLongArray(data: LongArray): String {
val buffer = Buffer()
data.reversedArray().forEach(buffer::writeLong)
return BigInteger.fromByteArray(buffer.readByteArray(), Sign.POSITIVE).toString()
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just in case, an alternative implementation:

internal actual fun formatIntegerFromLittleEndianLongArray(data: LongArray): String {
    // need to convert from little-endian data to big-endian expected by BigInteger
    val bytes = ByteArray(size = data.size * Long.SIZE_BYTES)
    val lastIndex = data.lastIndex
    for (i in 0..lastIndex) {
        val long = data[i]
        val offset = (lastIndex - i) * Long.SIZE_BYTES
        bytes[offset + 0] = long.ushr(56).toByte()
        bytes[offset + 1] = long.ushr(48).toByte()
        bytes[offset + 2] = long.ushr(40).toByte()
        bytes[offset + 3] = long.ushr(32).toByte()
        bytes[offset + 4] = long.ushr(24).toByte()
        bytes[offset + 5] = long.ushr(16).toByte()
        bytes[offset + 6] = long.ushr(8).toByte()
        bytes[offset + 7] = long.ushr(0).toByte()
    }
    return BigInteger.fromByteArray(bytes, Sign.POSITIVE).toString()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support kord-voice on Kotlin/JS and Windows
3 participants