Since I was on a roll with the TCC Bootstrap and the Windows Builds on GitHub Actions, I decided to take a crack at bringing the Android builds back.
It would be underwhelming if I didn't bring things somewhat up-to-date in the process. Android NDK versions are numbered by [r]evisions, and we had been on "r13" from October 2016. Five years ago is basically eternity in cell phone time...and the revisions have counted up steadily since then, currently at "r21" (!)
So I dug in and suffered for another long continuous day-and-night to make it happen.
Big Change: Toolchain Switch to Clang
The Android toolset was originally based on GCC. But they wound up switching to Clang...starting by making it available in revision r16, and then removing the GCC support altogether in r18.
This may seem like a minor change for us (and it probably would have been easier if I knew more about the NDK to start with). But cross compilation is never "simple", and Android is a particularly crazy combinatoric monster. When the .zipped file for installing the SDK is 500MB--with executables for only one of the cross-compiling platforms--you can bet there's a lot in there to trip up.
I'll spare you the details, but you can read config/android-common.r if you want to see comments I wrote to document the process.
Still Supporting The Older NDKs!
The Google Play store will only accept apps that are built with very recent API Levels!
But I think it's interesting to be in the position that we can still build against older NDKs, perhaps for older hardware. It's a distinguishing feature.
Anyway, I made the script detect the version and react accordingly. Maybe there will be a time when it's not worth it to support the older NDKs, but for now it doesn't cost much...and it helps keep a check on making sure that if we use any "newfangled" APIs that only exist on certain modern devices, we do so consciously.
Next Steps... CI Testing!
So I said that I wanted anything we thought was important to be rigged up with automated testing. I did some research into Android emulators that could run "headlessly" with no screen...let you install apps on a virtual phone, and run tests. Such things do exist, and we could run them on GitHub Actions!
They say it only runs on Mac hosts. So that incentivizes hammering on the cross-compile script until it's able to use platforms other than Linux to build for Android. It may not actually be all that hard to do (will have to find out...) Of course we could build on Linux and then just send that product to a mac to run the emulator.
Getting that ability to run a simulator that can test the built Android executable is a priority.
Revive Building the APK
So we definitely want to have the process from @giuliolunati's conference demo be automated and tested. That means building the .APK file which bundles together both the native interpreter (as a backdoor to phone services) along with a WASM interpreter (to live in a webpage and be able to communicate with the native interpreter).
Maybe Giulio can speak to how far we are from having that work again... or if he's busy, I guess I can just go through the video... that's what it's for!
Bring Back TCC Extension
I resurrected the TCC bootstrapping because I think it is an impressive demo, and it speaks to an important spiritual point about the project.
It's pretty easy to get the ball rolling for TCC on Linux. But a bit more work when you're cross-compiling it, or making it for Windows.
I never tried it, but it seemed like we had TCC working on Android. It would probably be worth doing it again, and interesting if we could see the TCC bootstrap demo work on a phone too (!) We'll have to consult the old Travis build script to see how the ARM configuration was done.
Revisiting This Gives Me More Motivation
Slogging through the nightmare of the Android NDK reminds me that we are really doing something that almost no one does anymore. They just sign away their lives to something like Android Studio and are so far away from the actual mechanical levels that they don't know what the dependencies are. Most people probably wouldn't know how to do any different...and among those who know, it's simply too frustrating to work through the details.
When you add up all the platforms and parts that we have, this is probably a more compelling story than I give it credit for. So we should definitely not take for granted what we've got...and get the great demos like the AndroidNative+WASM packaging back up and running!