Skip to content

Commit 3887d2b

Browse files
opacaminclement
authored andcommitted
Initial migration to NDK r19 (Part I - The core) (kivy#1722)
* [ndk19] Rework of the arch environment to work with ndk r19+ Things done here: - Modifies target so we can use the toolchains `in-place` (as if we were using a standalone toolchain) - Removes some cflags that we don't need anymore - Move `macros` and `includes` from `CFLAGS` to `CPPFLAGS` (because this is the way it's supposed to be) - Move libraries from `LDFLAGS` to `LDLIBS` (again, the same as above) - Refactor `Arch`'s variables into class attributes, to make `get_env` smaller and to be more readable/maintainable: + class attributes for flags: * common_cflags * common_cppflags * common_ldflags * common_ldlibs * common_ldshared * arch_cflags + class attributes for compiler: * clang_path * clang_exe * clang_exe_cxx - Remove hardcoded cpu count in `MAKE` - Remove `gcc` of environment (because it has been partially removed in ndk r18) - Shorten long line to be pep8 friendly (line where we define env['BUILDLIB_PATH']) - Commented lines for `ArchAarch_64` that it seems tha we don't need anymore (not removed because I'm not sure if we need them) Note: This will force us to use a minimal ndk version of 19 See also: https://developer.android.com/ndk/guides/other_build_systems * [ndk19] Update `test_archs` to ndk's r19+ build system Also add some more tests. Now we check if some of the functions we mock, `glob` and `find_executable`, are called with the expected arguments * [ndk19] Update `test_bootstrap` to ndk's r19+ build system Because `clang` is the new default compiler and the affected tests were made thinking in `gcc` compiler * [ndk19] Remove `clang` of `get_recipe_env` Because as per ndk r19 the default compiler is clang and gcc has been partially removed * [ndk19] Adapt python recipes to ndk's r19+ build system We move python recipe to use a minimal ndk version of 19 because it will simplify the python's cross compilation (this way we can remove some environment variables that we don't need anymore). The only side effect detected is that the python's `zlib` module isn't built anymore. This is caused because python3 and python2 build systems contains libz's hardcoded version, which does not match the version used in ndk 19 (may be this the cause of some `zip/unzip` errors reported in python-for-android's issues?). We will take care later of this zlib problem, or we will get a runtime crash...so it seems that zlib is an `essential module` to successfully run a python-for-android app * [ndk19] Update libffi to version post `v3.3RC0` and adapt it to be ndk r19+ compatible * [ndk19] Fix build of python's zlib module Because python has a hardcoded zlib version which does not match android's ndk r19, and that prevents the build of zlib's module Note: it seems that we have to point to the right lib and headers, otherwise we won't succeed in building python's zlib module * [ndk19] Fix build of python2's _ctypes module for ndk r19+ * [ndk19] Fix numpy for ndk r19+ Note: because of the new build system recently introduced, we can safely remove some of the patches that we needed because it seems that it builds and runs fine without them * [ndk19] Update docs with the new ndk requirements * [ndk19] Set min/max/recommended android's NDK * [ndk19] Make CI tests with android's NDK `r19b` Because it's our minimum supported android NDK * [ndk19] Fix png recipe for NDK r19+ We remove `get_recipe_env` because we don't need anymore to specify the flags set in there. Note: As per new NDK r19+ build system implemented in p4a, the removed `flags` should be automatically set by the android's NDK * [ndk19] Add `-fPIC` to `armeabi-v7a`'s arch cflags... ...force `Position-Independent Code` To solve the kivy's build error detected in travis `OSX` test (https://travis-ci.org/kivy/python-for-android/jobs/576204088#L1105). But also detected the same error in my local tests (linux os in this case) for `freetype` and `harfbuzz` recipes...so I have the feeling that this is better to set as global 🤞..is it?
1 parent c3145cf commit 3887d2b

26 files changed

+432
-461
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,12 @@ require to target to a **minimum api level of 21**,
108108
api level below 21, you must use an old version of python-for-android
109109
(<=0.7.1). All this work has been done using android ndk version r17c,
110110
and your build should success with that version...but be aware that the
111-
project is in constant development so...the ndk version will change at
112-
some time.
111+
project is in constant development so, as per time of writing,
112+
``we recommend to use android's NDK r19b`` because the toolchains installed by
113+
default with the NDK may be used *in-place* and the python-for-android project
114+
has been adapted to that feature, so, it's mandatory to use, at least, ndk
115+
version r19 (be aware that more modern versions of the
116+
android's ndk may not work).
113117

114118
Those mentioned changes has been done this way to make easier the transition
115119
between python3 and python2. We will slowly phase out python2 support

ci/makefiles/android.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ifndef target_os
66
endif
77

88
# Those android NDK/SDK variables can be override when running the file
9-
ANDROID_NDK_VERSION ?= 17c
9+
ANDROID_NDK_VERSION ?= 19b
1010
ANDROID_SDK_TOOLS_VERSION ?= 4333796
1111
ANDROID_SDK_BUILD_TOOLS_VERSION ?= 28.0.2
1212
ANDROID_HOME ?= $(HOME)/.android

doc/source/quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ named ``tools``, and you will need to run extra commands to install
110110
the SDK packages needed.
111111

112112
For Android NDK, note that modern releases will only work on a 64-bit
113-
operating system. **The minimal, and recommended, NDK version to use is r17c:**
113+
operating system. **The minimal, and recommended, NDK version to use is r19b:**
114114

115115
- `Go to ndk downloads page <https://developer.android.com/ndk/downloads/>`_
116116
- Windows users should create a virtual machine with an GNU Linux os
@@ -144,7 +144,7 @@ variables necessary for building on android::
144144

145145
# Adjust the paths!
146146
export ANDROIDSDK="$HOME/Documents/android-sdk-27"
147-
export ANDROIDNDK="$HOME/Documents/android-ndk-r17c"
147+
export ANDROIDNDK="$HOME/Documents/android-ndk-r19b"
148148
export ANDROIDAPI="27" # Target API version of your application
149149
export NDKAPI="21" # Minimum supported API version of your application
150150
export ANDROIDNDKVER="r10e" # Version of the NDK you installed

0 commit comments

Comments
 (0)