Unverified Commit cad4b53c authored by Thomas Vos's avatar Thomas Vos Committed by GitHub

Add support for EGL on Linux Arm64 (#1052)

Requires skia-pack version update before merging:
https://github.com/JetBrains/skia-pack/pull/68

Required for my linuxArm64 device which only support EGL.

https://youtrack.jetbrains.com/issue/SKIKO-918
parent 3af0752f
#!/usr/bin/env bash
####### Variables you can edit to change build config, or set same environment variables before script execution #######
SKIA_VERSION="${SKIA_VERSION:="m138-80d088a-1"}" # Version of Skia m###-commit-sha-#. This commit sha will be cloned from repository https://github.com/JetBrains/skia
SKIA_VERSION="${SKIA_VERSION:="m138-80d088a-2"}" # Version of Skia m###-commit-sha-#. This commit sha will be cloned from repository https://github.com/JetBrains/skia
SKIA_DEBUG_MODE="${SKIA_DEBUG_MODE:="false"}" # in debug mode Skiko will be published with postix "+debug", for example "0.0.0-SNAPSHOT+debug"
SKIA_TARGET="${SKIA_TARGET:="iosSim"}" # possible values: "ios", "iosSim", "macos", "windows", "linux", "wasm", "android", "tvos", "tvosSim"
# For M1 Mac use "iosSim" to build for simulator, and ios to build for device.
......
......@@ -271,7 +271,9 @@ fun SkikoProjectContext.createLinkJvmBindings(
)
}
OS.Linux -> {
osFlags = arrayOf(
osFlags = mutableListOf<String>().apply {
addAll(
arrayOf(
"-shared",
// `libstdc++.so.6.*` binaries are forward-compatible and used from GCC 3.4 to 16+,
// so do not use `-static-libstdc++` to avoid issues with complex setup.
......@@ -288,9 +290,13 @@ fun SkikoProjectContext.createLinkJvmBindings(
"$skiaBinDir/libskunicode_core.a",
"$skiaBinDir/libskunicode_icu.a",
"$skiaBinDir/libskshaper.a",
"$skiaBinDir/libjsonreader.a",
"$skiaBinDir/libjsonreader.a"
)
)
if (targetArch == Arch.Arm64) {
add("-lEGL")
}
}.toTypedArray()
}
OS.Windows -> {
libDirs.set(windowsSdkPaths.libDirs)
......
......@@ -266,6 +266,9 @@ fun SkikoProjectContext.configureNativeTarget(os: OS, arch: Arch, target: Kotlin
"$skiaBinDir/libskunicode_icu.a",
"$skiaBinDir/libskia.a"
)
if (arch == Arch.Arm64) {
options.add("-lEGL")
}
// When cross-compiling for ARM64 from x64, use the ARM toolchain sysroot
if (arch == Arch.Arm64 && hostArch != Arch.Arm64) {
// ARM GNU toolchain sysroot paths
......
......@@ -7,7 +7,7 @@ kotlin.mpp.enableCInteropCommonization=true
deploy.version=0.0.0
# a tag from https://github.com/JetBrains/skia-pack
dependencies.skia=m138-80d088a-1
dependencies.skia=m138-80d088a-2
# a tag from https://github.com/JetBrains/angle-pack
dependencies.angle=ec4d8f8e4d
......
......@@ -8,7 +8,7 @@ class DirectContextNativeTest {
@Test
fun resourceCacheLimitTest() {
if (!TestGlContext.isAvailabale()) return
if (!TestGlContext.isAvailable()) return
TestGlContext.run {
DirectContext.makeGL().useContext { context ->
......
......@@ -2,6 +2,12 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.interopScope
import org.jetbrains.skia.impl.use
import org.jetbrains.skiko.Arch
import org.jetbrains.skiko.KotlinBackend
import org.jetbrains.skiko.OS
import org.jetbrains.skiko.hostArch
import org.jetbrains.skiko.hostOs
import org.jetbrains.skiko.kotlinBackend
import org.jetbrains.skiko.tests.TestGlContext
import org.jetbrains.skiko.tests.allocateBytesForPixels
import org.jetbrains.skiko.tests.runTest
......@@ -105,8 +111,12 @@ class SurfaceTest {
@Test
fun canMakeRenderTarget() {
if (!TestGlContext.isAvailabale()) return
if (!TestGlContext.isAvailable()) return
if (hostOs == OS.Linux && kotlinBackend == KotlinBackend.Native && hostArch == Arch.Arm64) {
// TODO: fix test on Linux arm64 using EGL
return
}
val pixels = TestGlContext.run {
DirectContext.makeGL().useContext { ctx ->
val imageInfo = ImageInfo.makeN32Premul(16, 16)
......
......@@ -2,10 +2,8 @@ package org.jetbrains.skiko.tests
import org.jetbrains.skia.*
import org.jetbrains.skia.impl.*
import org.jetbrains.skiko.Arch
import org.jetbrains.skiko.KotlinBackend
import org.jetbrains.skiko.OS
import org.jetbrains.skiko.hostArch
import org.jetbrains.skiko.hostOs
import org.jetbrains.skiko.kotlinBackend
......@@ -24,20 +22,16 @@ internal class TestGlContext : Managed(TestGlContext_nCreate(), FinalizerHolder.
companion object {
fun isAvailabale(): Boolean {
fun isAvailable(): Boolean {
if (hostOs != OS.Linux || kotlinBackend != KotlinBackend.Native) {
// TODO implement for other platforms and render targets
return false
}
if (hostArch == Arch.Arm64) {
// TODO implement and test EGL on arm64
return false
}
return true
}
inline fun <T> run(block: TestGlContext.() -> T): T {
check(isAvailabale()) { "TestGlContext is not available" }
check(isAvailable()) { "TestGlContext is not available" }
return TestGlContext().use {
it.makeCurrent()
val result = it.block()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment