Build DMD for Android
This is a work in progress: Android/x86 is mostly done, going to work on Android/ARM next. Almost all the druntime/phobos unit tests pass on Android/x86 and a sample C/OpenGLES 1.0 purely native app from the NDK has been ported to D.
Prerequisites
- 32-bit linux/x86 host on which to build dmd
- A virtual machine like VirtualBox/VMware will work fine, but you should have at least 512 MB of memory allocated and 1 GB of swap, particularly if building the phobos unit tests, and 10 GB of disk space.
- C++ compiler and toolchain, to build dmd
- dmd/druntime/phobos source
- Get druntime and phobos from git, as they have Android-specific changes that are not in the release branches yet.
- Android native toolchain, the 32-bit NDK and SDK
- The "SDK Tools only" version of the SDK is enough, if you don't plan on using their IDE integration. I will only write about using the command-line tools.
- Android/x86, whether a device or VM
- The SDK comes with an Android/x86 emulator and Intel puts out one of their own. I use the builds put out by the android-x86 project and recommend the deprecated 4.3 build, as it's the least buggy one I've dealt with.
To install Android/x86 in a VM
Download the Android-x86 iso and install as normal: it'll put you through a configuration process, but you can skip every step. Go to Settings->Security and disable the Verify Apps option, or it'll ask you about that every time you install a test app. Alt-F1 will take you to a root shell, which you'll want to do any time you're not using Android/x86 for a couple minutes or the screen will eventually go black and the VM will freeze up. Alt-F7 takes you back to the normal GUI screen.
Build D for Android/x86
Download the patch for DMD, apply it, and build normally:
git apply packed_tls_for_elf.patch
make -f posix.mak -j5
I'll stop writing now, coming back with how to build druntime/phobos and more later.