Merge: android: update compiler to use the "new" toolchain
authorJean Privat <jean@pryen.org>
Mon, 27 Nov 2017 15:02:55 +0000 (10:02 -0500)
committerJean Privat <jean@pryen.org>
Mon, 27 Nov 2017 15:02:55 +0000 (10:02 -0500)
Update the Android support in the compiler to use of the new official Android toolchain based on gradle and CMake, it replaces the old toolchain based on ndk-build and Android.mk files. The use of the new toolchain makes it easier to connect with libraries, it follow the current examples, it is a bit faster to compile, it automatically downloads the SDK files for the target platforms and it has a decent quiet compilation mode!

The new toolchain brings the following changes to the generate Android projects:
* It adds a new project layer above the app layer, this results in moving most of the generated code down in the `app/src/main` folder.
* It moves some settings (API levels, etc.) out of AndroidManifest.xml to a `build.gradle`.
* It replaces the makefiles Android.mk by CMakeLists.txt.

I took advantage of these changes to bring back the GC support for Nit on Android. The new toolchain executes the standard libgc/bdwgc CMakeLists.txt with only small modifications (based on the Unity fork) and the GC works as expected on Android (with thread support). Having a working GC required tweaking some existing Nit code that did not take into account a functioning GC in order to correctly pin references to Nit objects from Java.

I've also updated the full Docker image to support the new toolchain.

Note that the new Android toolchain supports only 64 bits host platforms with Java 8 JDK.

Future work:
* Support more ABIs, incl. arm64 and x86_64, they should be activated only when targetting their minimum supported platform.
* Compile libunwind with its CMakeLists.txt.
* Support adding extra lines to the gradle files, or accept full gradle files from clients.

Pull-Request: #2575
Reviewed-by: Jean Privat <jean@pryen.org>


Trivial merge