is there currently any solution/approach to bundle...
# kotlin-native
n
is there currently any solution/approach to bundle files/binary data into kotlin-native executables so i can avoid having to distribute them in a zip file or such ?
👀 1
b
Only via ReadOnlyByteArray I'm affraid. This basically means you have to convert your resource files to bytes and store them in a kt file as ByteArray. For kmm there's moko-resources gradle plugin to help with that
n
sadly it seems to not target
linuxX64
or
mingwX64
b
As I said, moko-resources is for KMM only. For wider KMP you'll need to do ByteArray generation yourself
n
that is not really a scalable solution if you want to bundle a few kilobytes of data
b
It's definitely not, but that's the only way for now. You can automate it with gradle, though.
n
what i mean is that the compiler cannot handle too long
ubyteArrayOf
statements
b
Ah, I see. Then zip + fs might be the only option for you. Maybe you can make zip executable on unix systems by prepending bash script to it to unzip and run itself.
That way at least you only have a single file to ship
n
Really need the feature for a C library that is being used (LVGL - https://lvgl.io/ ) with cases where large image data is being handled, and can't be put into a Kotlin source file. Putting a large amount of Byte data into a Kotlin source file will cause the IntelliJ Kotlin plugin to go haywire with syntax checking of Kotlin source files. Often locking up the IntelliJ UI for about 30 sec per pause ☹️.
e
how about embedding resources into C then using cinterop to bring it into K/N?
🤔 1
n
if someone got a an idea/ proof of concept / link to article of how to embed things into C code or compiling into
.so
or
.a
, that would be useful the
cinterop
part should be relatively simple
e
I linked to https://www.devever.net/~hl/incbin in the other conversation
also there's tools like https://git.sr.ht/~sircmpwn/koio that are like extended versions of the bin2h approach, giving you some fs-like structure
n
this kinda worked
bin2c -d build/ressources/include/resources.h -o resources.c *.jpg
gcc -o obj -c ressources.c
ar -rcs build/resources.lib/resources.a obj
this this def
Copy code
headers = resources.h

staticLibraries = resources.a
libraryPaths = build/resources/lib

compilerOpts = -Ibuild/resources/include