Cross Compile to PinePhone Part Three
Click Here for Part one
Click Here for Part two
On last part, we managed to generate package by hand. While it works, having a script to do everything for us is even better. So I’ve wrote a small python script to automate the process.
ppbuild
ppbuild: https://invent.kde.org/hanyoung/ppbuild
ppbuild is a small script for cross compile common Plasma Mobile apps. It expects you’ve already set up the binfmt. If you haven’t, refer to part one.
The usage is simple, you feed it sysroot
rootfs
and source directory. By default, it creates a temporary directory and do all the work there, and it purge the temporary directory afterwards. However for large projects, you may want to re-use the compile result. In that case, you can pass build directory to ppbuild via -B
.
The configuration file is in ~/.config/ppbuildrc
, I recommand you to set sysroot and rootfs path in configuration file. On first run, ppbuild will create the default configuration file for you, everything that isn’t in the default configuration won’t be read by ppbuild. Command line arguments will always override configuration.
ppbuild -h
will show you all the supported flags.
SDK
In previous chapters, we manually extract the rootfs from image. It would make the life easier for us if we can just download the rootfs from internet. I’ve talked with Manjaro developers to see if they can build minimal rootfs as part of daily dev builds. But turns out include only the files we want is bit hard to do in CI. They’d have to build the full image and use a script to delete the unwanted files. So I might write a script to do this locally instead, this script can later be corporated into ppbuild. Meanwhile, you can track the progress of SDK on this Plasma Mobile issue
Things left to do
Apart from the SDK issue mentioned above, we still need to write proper tutorials on https://develop.kde.org/ about cross compile. I’m happy with the overall result, to be able to cross compile to target platform is essention to mobile development. The major difference between Plasma Mobile and Android/iOS is apps on Plasma Mobile are neither self-contained or static linked. Together with the updating of system libraries it’s impossible to ship a static SDK, you’ll need to have all the dynamic linked libraries on rootfs. For iOS and Android, the only dynamic linked libraries is system ones, and they don’t change throughout one major version. You can have Android 10 SDK for Android 10, 11 SDK for 11… But for Plasma Mobile Manjaro, it’s a rolling distribution, you’ll also need a rolling SDK.
I hope the ablity to cross compiling to PinePhone can improve everyone’s productivity on Plasma Mobile development, however it’s just a small step towards what Android and iOS have. We still lack phone emulator, remote debugging and UI debugging tools.
You can help too
Though I’m writing all these blogs and scripts for PinePhone, the same practice and even script can also apply to any Arch to Arch cross compiling. Cross compiling is crucial to debugging efficiency, but debug is just part of the application development cycle. We also need people to test our apps can report bugs to us, then we can debug it :). So if you’re not a programmer, you can also help with using Plasma Mobile. If you find any bugs feel free to open a issue on https://invent.kde.org/plasma-mobile or on the app’s repository.