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 #!/usr/bin/env bash
####### Variables you can edit to change build config, or set same environment variables before script execution ####### ####### 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_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" 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. # For M1 Mac use "iosSim" to build for simulator, and ios to build for device.
......
...@@ -271,26 +271,32 @@ fun SkikoProjectContext.createLinkJvmBindings( ...@@ -271,26 +271,32 @@ fun SkikoProjectContext.createLinkJvmBindings(
) )
} }
OS.Linux -> { OS.Linux -> {
osFlags = arrayOf( osFlags = mutableListOf<String>().apply {
"-shared", addAll(
// `libstdc++.so.6.*` binaries are forward-compatible and used from GCC 3.4 to 16+, arrayOf(
// so do not use `-static-libstdc++` to avoid issues with complex setup. "-shared",
"-static-libgcc", // `libstdc++.so.6.*` binaries are forward-compatible and used from GCC 3.4 to 16+,
"-lGL", // so do not use `-static-libstdc++` to avoid issues with complex setup.
"-lX11", "-static-libgcc",
"-lfontconfig", "-lGL",
// Enforce immediate symbol resolution at library load time to prevent "-lX11",
// lazy-binding issues and make GOT read-only afterwards. "-lfontconfig",
"-Wl,-z,relro,-z,now", // Enforce immediate symbol resolution at library load time to prevent
// Hack to fix problem with linker not always finding certain declarations. // lazy-binding issues and make GOT read-only afterwards.
"$skiaBinDir/libsksg.a", "-Wl,-z,relro,-z,now",
"$skiaBinDir/libskia.a", // Hack to fix problem with linker not always finding certain declarations.
"$skiaBinDir/libskunicode_core.a", "$skiaBinDir/libsksg.a",
"$skiaBinDir/libskunicode_icu.a", "$skiaBinDir/libskia.a",
"$skiaBinDir/libskshaper.a", "$skiaBinDir/libskunicode_core.a",
"$skiaBinDir/libjsonreader.a", "$skiaBinDir/libskunicode_icu.a",
"$skiaBinDir/libskshaper.a",
) "$skiaBinDir/libjsonreader.a"
)
)
if (targetArch == Arch.Arm64) {
add("-lEGL")
}
}.toTypedArray()
} }
OS.Windows -> { OS.Windows -> {
libDirs.set(windowsSdkPaths.libDirs) libDirs.set(windowsSdkPaths.libDirs)
......
...@@ -266,6 +266,9 @@ fun SkikoProjectContext.configureNativeTarget(os: OS, arch: Arch, target: Kotlin ...@@ -266,6 +266,9 @@ fun SkikoProjectContext.configureNativeTarget(os: OS, arch: Arch, target: Kotlin
"$skiaBinDir/libskunicode_icu.a", "$skiaBinDir/libskunicode_icu.a",
"$skiaBinDir/libskia.a" "$skiaBinDir/libskia.a"
) )
if (arch == Arch.Arm64) {
options.add("-lEGL")
}
// When cross-compiling for ARM64 from x64, use the ARM toolchain sysroot // When cross-compiling for ARM64 from x64, use the ARM toolchain sysroot
if (arch == Arch.Arm64 && hostArch != Arch.Arm64) { if (arch == Arch.Arm64 && hostArch != Arch.Arm64) {
// ARM GNU toolchain sysroot paths // ARM GNU toolchain sysroot paths
......
...@@ -7,7 +7,7 @@ kotlin.mpp.enableCInteropCommonization=true ...@@ -7,7 +7,7 @@ kotlin.mpp.enableCInteropCommonization=true
deploy.version=0.0.0 deploy.version=0.0.0
# a tag from https://github.com/JetBrains/skia-pack # 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 # a tag from https://github.com/JetBrains/angle-pack
dependencies.angle=ec4d8f8e4d dependencies.angle=ec4d8f8e4d
......
...@@ -8,7 +8,7 @@ class DirectContextNativeTest { ...@@ -8,7 +8,7 @@ class DirectContextNativeTest {
@Test @Test
fun resourceCacheLimitTest() { fun resourceCacheLimitTest() {
if (!TestGlContext.isAvailabale()) return if (!TestGlContext.isAvailable()) return
TestGlContext.run { TestGlContext.run {
DirectContext.makeGL().useContext { context -> DirectContext.makeGL().useContext { context ->
......
...@@ -2,6 +2,12 @@ package org.jetbrains.skia ...@@ -2,6 +2,12 @@ package org.jetbrains.skia
import org.jetbrains.skia.impl.interopScope import org.jetbrains.skia.impl.interopScope
import org.jetbrains.skia.impl.use 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.TestGlContext
import org.jetbrains.skiko.tests.allocateBytesForPixels import org.jetbrains.skiko.tests.allocateBytesForPixels
import org.jetbrains.skiko.tests.runTest import org.jetbrains.skiko.tests.runTest
...@@ -105,8 +111,12 @@ class SurfaceTest { ...@@ -105,8 +111,12 @@ class SurfaceTest {
@Test @Test
fun canMakeRenderTarget() { 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 { val pixels = TestGlContext.run {
DirectContext.makeGL().useContext { ctx -> DirectContext.makeGL().useContext { ctx ->
val imageInfo = ImageInfo.makeN32Premul(16, 16) val imageInfo = ImageInfo.makeN32Premul(16, 16)
......
...@@ -2,10 +2,8 @@ package org.jetbrains.skiko.tests ...@@ -2,10 +2,8 @@ package org.jetbrains.skiko.tests
import org.jetbrains.skia.* import org.jetbrains.skia.*
import org.jetbrains.skia.impl.* import org.jetbrains.skia.impl.*
import org.jetbrains.skiko.Arch
import org.jetbrains.skiko.KotlinBackend import org.jetbrains.skiko.KotlinBackend
import org.jetbrains.skiko.OS import org.jetbrains.skiko.OS
import org.jetbrains.skiko.hostArch
import org.jetbrains.skiko.hostOs import org.jetbrains.skiko.hostOs
import org.jetbrains.skiko.kotlinBackend import org.jetbrains.skiko.kotlinBackend
...@@ -24,20 +22,16 @@ internal class TestGlContext : Managed(TestGlContext_nCreate(), FinalizerHolder. ...@@ -24,20 +22,16 @@ internal class TestGlContext : Managed(TestGlContext_nCreate(), FinalizerHolder.
companion object { companion object {
fun isAvailabale(): Boolean { fun isAvailable(): Boolean {
if (hostOs != OS.Linux || kotlinBackend != KotlinBackend.Native) { if (hostOs != OS.Linux || kotlinBackend != KotlinBackend.Native) {
// TODO implement for other platforms and render targets // TODO implement for other platforms and render targets
return false return false
} }
if (hostArch == Arch.Arm64) {
// TODO implement and test EGL on arm64
return false
}
return true return true
} }
inline fun <T> run(block: TestGlContext.() -> T): T { inline fun <T> run(block: TestGlContext.() -> T): T {
check(isAvailabale()) { "TestGlContext is not available" } check(isAvailable()) { "TestGlContext is not available" }
return TestGlContext().use { return TestGlContext().use {
it.makeCurrent() it.makeCurrent()
val result = it.block() 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