Skip to content
This repository has been archived by the owner on Jul 8, 2022. It is now read-only.

Raspberry Pi support #316

Merged
merged 2 commits into from
Jul 24, 2021
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
14 changes: 11 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,12 @@ val doEnableKotlinAndroid get() = enableKotlinAndroid == "true"
val enableKotlinMobile:String by project
val doEnableKotlinMobile get() = enableKotlinMobile == "true"

val KotlinTarget.isLinux get() = this.name == "linuxX64"
val enableKotlinRaspberryPi: String by project
val doEnableKotlinRaspberryPi get() = enableKotlinRaspberryPi == "true"

val KotlinTarget.isLinuxX64 get() = this.name == "linuxX64"
val KotlinTarget.isLinuxArm32Hfp get() = this.name == "linuxArm32Hfp" && doEnableKotlinRaspberryPi
val KotlinTarget.isLinux get() = isLinuxX64 || isLinuxArm32Hfp
val KotlinTarget.isWin get() = this.name == "mingwX64"
val KotlinTarget.isMacosX64 get() = this.name == "macosX64"
val KotlinTarget.isMacosArm64 get() = this.name == "macosArm64"
Expand Down Expand Up @@ -124,10 +129,12 @@ kotlin {
}

fun org.jetbrains.kotlin.gradle.dsl.KotlinTargetContainerWithPresetFunctions.nativeTargets(): List<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
val targetRaspberryPi = if (doEnableKotlinRaspberryPi) listOf(linuxArm32Hfp()) else listOf()

return when {
isWindows -> listOf(mingwX64())
isMacos -> listOf(macosX64(), macosArm64())
else -> listOf(linuxX64(), mingwX64(), macosX64(), macosArm64())
else -> listOf(linuxX64(), mingwX64(), macosX64(), macosArm64()) + targetRaspberryPi
}
}

Expand Down Expand Up @@ -265,7 +272,8 @@ subprojects {
target.compilations.all {
// https://github.com/JetBrains/kotlin/blob/ec6c25ef7ee3e9d89bf9a03c01e4dd91789000f5/kotlin-native/konan/konan.properties#L875
kotlinOptions.freeCompilerArgs = ArrayList<String>().apply {
if (useMimalloc) add("-Xallocator=mimalloc")
// Raspberry Pi doesn't support mimalloc at this time
if (useMimalloc && !target.name.contains("Arm32Hfp")) add("-Xallocator=mimalloc")
add("-Xoverride-konan-properties=clangFlags.mingw_x64=-cc1 -emit-obj -disable-llvm-passes -x ir -target-cpu x86-64")
}
kotlinOptions.suppressWarnings = true
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version=2.0.0.999
#kotlinVersion=1.5.20
kotlinVersion=1.5.30-M1
kotlinSerializationVersion=1.2.1
coroutinesVersion=1.5.0
coroutinesVersion=1.5.1-SNAPSHOT
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just remembered this relies on a custom build of kotlinx.coroutines with Arm32Hfp enabled. Probably can't merge this unless that gets enabled upstream.

Copy link
Member

@soywiz soywiz Jul 24, 2021

Choose a reason for hiding this comment

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

I'm going to merge it and disable it with a flag or something, so the code is already here and we can enable it when this situation changes. you did it already

Did you do something special to compile kotlinx.coroutines & atomicfu on the PI? Maybe we can make a couple of PRs adding support to it. I already did a atomicfu PR here: Kotlin/kotlinx-atomicfu#193 and commented here Kotlin/kotlinx.coroutines#855 not sure if you did something different or I missed something. Maybe we can ping them to see if we can unlock this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For kotlinx.coroutines I needed to disable tests on the arm target: https://gist.github.com/ObsidianX/dcfb862a6f41fad598053eef50679374

Copy link
Member

Choose a reason for hiding this comment

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

Because some of the tests failed, or something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Posted a PR with a better solution: Kotlin/kotlinx.coroutines#2841

androidBuildGradleVersion=4.2.0
proguardVersion=6.2.2
jnaVersion=5.8.0
Expand All @@ -21,7 +21,7 @@ enableKotlinNative=true
enableKotlinNativeLinux=true
enableKotlinMobile=true
enableKotlinAndroid=true

enableKotlinRaspberryPi=false

#org.gradle.jvmargs=-Xmx3600m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.jvmargs=-Xmx5g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.soywiz.klogger

actual object Console : BaseConsole()
4 changes: 2 additions & 2 deletions kmem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ dependencies {
fun org.jetbrains.kotlin.gradle.dsl.KotlinTargetContainerWithPresetFunctions.nativeTargets(): List<org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget> {
return when {
isWindows -> listOf(mingwX64())
isMacos -> listOf(macosX64(), iosArm64(), iosX64())
else -> listOf(linuxX64(), mingwX64(), macosX64(), iosArm64(), iosX64())
isMacos -> listOf(macosX64(), iosArm64(), iosX64())
else -> listOf(linuxX64(), linuxArm32Hfp(), mingwX64(), macosX64(), iosArm64(), iosX64())
}
}

Expand Down
25 changes: 13 additions & 12 deletions korau/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@ fun org.jetbrains.kotlin.gradle.dsl.KotlinTargetContainerWithPresetFunctions.nat
return when {
isWindows -> listOf(mingwX64())
isMacos -> listOf(macosX64(), iosArm64(), iosX64())
else -> listOf(linuxX64(), mingwX64(), macosX64(), iosArm64(), iosX64())
else -> listOf(linuxX64(), linuxArm32Hfp(), mingwX64(), macosX64(), iosArm64(), iosX64())
}
}

if (doEnableKotlinNative) {
kotlin {
for (target in nativeTargets() ) {
target.compilations["main"].cinterops {
kotlin {
for (target in nativeTargets()) {
target.compilations["main"].cinterops {
if (target.name == "mingwX64") maybeCreate("win32_winmm")
if (target.name == "linuxX64") maybeCreate("linux_OpenAL")
maybeCreate("minimp3")
maybeCreate("stb_vorbis")
}
}
if (target.name == "linuxArm32Hfp") maybeCreate("linux_rpi_OpenAL")
maybeCreate("minimp3")
maybeCreate("stb_vorbis")
}
}

}
}
}

dependencies {
add("commonMainApi", project(":korio"))
add("jvmMainApi", "net.java.dev.jna:jna:$jnaVersion")
add("jvmMainApi", "net.java.dev.jna:jna-platform:$jnaVersion")
add("commonMainApi", project(":korio"))
add("jvmMainApi", "net.java.dev.jna:jna:$jnaVersion")
add("jvmMainApi", "net.java.dev.jna:jna-platform:$jnaVersion")
}

/*
Expand Down
Loading