https://kotlinlang.org logo
Title
a

Aru

01/12/2021, 11:19 PM
Hi. JB-Compose is pretty cool. I want to use it for an embedded linux project. Is there going to be a ARM 64-bit packaging target ?
j

jim

01/12/2021, 11:37 PM
When you say ARM-64, are you referring to a raspberry pi or something else?
a

Aru

01/13/2021, 1:53 AM
It's yocto Linux for one of these boards. But I think that shouldn't make a difference, right? If we have the proper graphics driver with open GL ES Implementation. https://www.variscite.com/product/system-on-module-som/cortex-a53-krait/var-som-mx8m-mini-nxp-i-mx8m-mini/
j

jim

01/13/2021, 3:15 AM
Thanks for the info, it's helpful as we do planning. Knowing the exact platforms people want is often helpful because in theory it wouldn't make a difference, but... in theory there is no difference between theory and practice, but in practice there is. We've gotten a few requests for Raspberry Pi, and hopefully that would work here too. As @suresh mentioned, there is no official support for arm64 yet, but everything is open source, so a motivated individual could do a build on that platform. No concrete plans to support yet, but it seems likely to happen eventually given that there have been several requests at this point.
o

olonho

01/13/2021, 7:54 AM
Generally Compose for Desktop is pure JVM code, all native code (i.e. Skia bindings) is collected in https://github.com/JetBrains/skiko so someone will provide port of that library - adding support to Compose is pretty straightforward
j

jim

01/13/2021, 9:22 AM
Yeah, to be clear for those following along at home, @Aru's use case would continue to use the JVM bindings (not require new native bindings) but would need a build of Skia for arm64.
a

Aru

01/13/2021, 12:26 PM
So, I build Skia for arm64, build
skiko
with bindings for arm64 Skia and Compose for Desktop should work. And Skia should compile with ease for arm64 given that it's being used in Fuchsia.
j

jim

01/13/2021, 12:37 PM
Yes, that's all correct. In addition to Fuchsia, both Flutter and Android build Skia on arm64, so it should be entirely supported/possible. Although having said that, I've never seen anyone describe Skia as compiling (regardless of platform) with "ease". 🤣 . But yes, there is no reason to assume it wouldn't more or less "just work" if you're brave/motivated enough to compile Skia.
😃 2
o

olonho

01/13/2021, 3:35 PM
well, we have set of scripts to simplify Skia compilation: https://github.com/JetBrains/skia-build
a

Aru

01/13/2021, 4:36 PM
Sweet.
So, I've compiled skia for arm64. Do I need to compile
skija
separately and then compile
skiko
or just building skiko is enough? Also, do I need
Skia-linux-Release-arm64.zip
in the target system or will skiko build-output will have it packaged ?
o

olonho

01/15/2021, 6:33 AM
Guess best approach would be to send PR with linux-arm64 build script to skia-build and then adjust Skiko. No need to do anything in Skija. Target system doesn’t need to have .zip archive, as Skiko build takes care about packaging Skia into JNI library.
Also did you do cross-build on use Raspberry for Skia builds?
In https://github.com/JetBrains/skiko/pull/43 I did some improvements for cross-compilation.
a

Aru

01/15/2021, 3:52 PM
Hey thanks for this PR. I didn't do cross-build for Raspberry PI. It is for a System-on-Module based on NXP i.MX processor (link on top of this thread). I was fitting the build inside a Yocto Recipe but cross compilation was smooth by passing
cxx=\"$CXX\"         cc=\"$CC\"
in the args. Similarly I'll have to pass in the native toolchain with a sysroot for cross compilation for Skiko as well.
o

olonho

01/18/2021, 9:29 AM
Generally, if you’ll provide Skia build scripts and build instructions we could reproduce - we could build Skiko for linux-arm64 targets as well
a

Aru

01/19/2021, 5:40 PM
Alright. I'll create a PR for
skia-build
to cross-compile to linux-arm64.
I looked into adjusting the gradle build script for skiko to use a cross-compiler like
aarch64-linux-gcc
instead of
gcc
toolchain. It's not straight forward and gradle itself does not support configuring a custom toolchain yet.
Posting here for continuity. I've looked at the gradle file for skiko and wrote a CMakeFiles.txt that would generate
libskiko-linux.so
in a similar way and packaged that into
skiko-linux-arm64-0.0.0-SNAPSHOT.jar
. With a big satisfaction, I wanted to test the "Hello world" code in the embedded device and copied the jars over and ran it. I got
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Library file libskija.so not found in /
        at org.jetbrains.skija.impl.Library._extract(Library.java:85)
        at org.jetbrains.skija.impl.Library.load(Library.java:50)
        at org.jetbrains.skija.impl.Library.staticLoad(Library.java:32)
        at org.jetbrains.skija.PictureRecorder.<clinit>(PictureRecorder.java:8)
        ... 18 more
Caused by: java.lang.IllegalArgumentException: Library file libskija.so not found in /
        at org.jetbrains.skija.impl.Library._extract(Library.java:68)
        ... 21 more
I thought skija is not needed if skiko is compiled? Is that not the case ?
j

jim

02/25/2021, 12:35 AM
Skiko is a Kotlin MPP binding around Skija (for JVM), and doesn't (yet) provide any other native skia bindings. In the future, Skiko may also provide bindings through KotlinNative that bind directly to Skia, but that is not yet implemented.
So to answer your question: You do still need Skija because Skija is a dependency of Skiko. And you need Skia because Skia is a dependency of Skija.
a

Aru

02/25/2021, 1:05 AM
I am running it on a JVM only. So, I need something like below:
.
├── compose-example.jar
├── skiko-jvm-0.1.18.jar
├── skiko-jvm-runtime-linux-arm64-0.1.18.jar
│   ├── libskiko.so  <-- This has SKIKO & SKIJA objects along with SKIA bindings
│   ├── libskiko.so.sha256
│   ├── org.jetbrains.skija
│   └── org.jetbrains.skiko
└── libskija.so
obviously with other jars for kotlin runtime and androidx