I want Bob to support building Android apps both for:
- Replacing the ad-hoc collection of shell scripts that serve as a build system for Mist.
- Being able to build an Android app for AQUA, which I can use for cooler GrapeVine demos in the future (camera!).
There are a few things I need to consider for this first though (and may become subissues in their own rights in the future).
Automatically managing SDKs
This is the basis to building an Android app. Everything that's needed to build Android is in here. It would be nice if Bob could automatically use sdkmanager to install the SDK and other necessary things for a given project, such as the NDK (I will only support native projects to start with I think).
I think we should simply have an bob.android import which provides an Android or AndroidSdk class with a bunch of static functions for various things. If and only if one of these static functions is called do we actually install the SDK or that SDK component. See the sections further down for why this would be useful.
Artifacts & packaging
Currently, the only output Bob produces is in the temporary installation prefix or fully installed to the system. I need a way to produce simple artifacts directly in Bob. Something like outputting straight in the working directory. Example uses for this would be creating FreeBSD packages (or other Linux distro packages, like .debs) and APKs of course.
Android uses AAPT2 to create the actual APK file. This could be called straight on the Android object as such:
# Creates a cookie for this APK.
let apk = Android.pkg(
"AndroidManifest.xml", # Path to manifest file.
31, # Android version we're targeting. Is need to get the relevant android.jar to pass to aapt2.
"assets", # Path to assets directory (or 'none' if no assets).
"debug.keystore", # Path to keystore to use to sign the APK.
"123456", # Password to use when accessing the keystore to sign the APK.
)
# TODO Some way to install stuff to this APK, and create an install stage.
# Some kind of install map just for this? That would make some sense I guess.
# Actually build & sign the APK and create an artifact out of it.
# This should support AAPT2 incremental compilation.
artifacts = {
apk.build(): "out.apk",
}
Building C
To build C for Android, we need to use the NDK's toolchain. I would like this to integrate with Bob's Cc class, so it needs to be aware of the fact we're trying to build for Android and be able to change the paths of things and pass any extra include paths or things to link with (if talking about the linker, and mainly thinking of Android's libc++.so and native app glue, which we also need to build in fact but which the Bob build script shouldn't have to concern itself with).
I wonder if to do this we should have a function on Cc objects to set the toolchain path to something else, something like:
let ndk = Android.get_ndk() # Returns a Toolchain object with the necessary information.
let cc = Cc([]).set_toolchain(ndk)
cc.compile(...)
let linker = Linker([]).set_toolchain(ndk)
Other notes
Google does not ship a FreeBSD SDK. Luckily, the Linux SDK works just fine with FreeBSD's Linux binary emulation, so we just have to load linux64. I think if we are on FreeBSD and this is not loaded, we should error out and tell the user to load it.
I want Bob to support building Android apps both for:
There are a few things I need to consider for this first though (and may become subissues in their own rights in the future).
Automatically managing SDKs
This is the basis to building an Android app. Everything that's needed to build Android is in here. It would be nice if Bob could automatically use
sdkmanagerto install the SDK and other necessary things for a given project, such as the NDK (I will only support native projects to start with I think).I think we should simply have an
bob.androidimport which provides anAndroidorAndroidSdkclass with a bunch of static functions for various things. If and only if one of these static functions is called do we actually install the SDK or that SDK component. See the sections further down for why this would be useful.Artifacts & packaging
Currently, the only output Bob produces is in the temporary installation prefix or fully installed to the system. I need a way to produce simple artifacts directly in Bob. Something like outputting straight in the working directory. Example uses for this would be creating FreeBSD packages (or other Linux distro packages, like
.debs) and APKs of course.Android uses AAPT2 to create the actual APK file. This could be called straight on the
Androidobject as such:Building C
To build C for Android, we need to use the NDK's toolchain. I would like this to integrate with Bob's
Ccclass, so it needs to be aware of the fact we're trying to build for Android and be able to change the paths of things and pass any extra include paths or things to link with (if talking about the linker, and mainly thinking of Android'slibc++.soand native app glue, which we also need to build in fact but which the Bob build script shouldn't have to concern itself with).I wonder if to do this we should have a function on
Ccobjects to set the toolchain path to something else, something like:Other notes
Google does not ship a FreeBSD SDK. Luckily, the Linux SDK works just fine with FreeBSD's Linux binary emulation, so we just have to load
linux64. I think if we are on FreeBSD and this is not loaded, we should error out and tell the user to load it.