Skip to content

Commit

Permalink
Initial migration to NDK r19 (Part I - The core) (kivy#1722)
Browse files Browse the repository at this point in the history
* [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?
  • Loading branch information
opacam authored and inclement committed Aug 24, 2019
1 parent c3145cf commit 3887d2b
Show file tree
Hide file tree
Showing 26 changed files with 432 additions and 461 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,12 @@ require to target to a **minimum api level of 21**,
api level below 21, you must use an old version of python-for-android
(<=0.7.1). All this work has been done using android ndk version r17c,
and your build should success with that version...but be aware that the
project is in constant development so...the ndk version will change at
some time.
project is in constant development so, as per time of writing,
``we recommend to use android's NDK r19b`` because the toolchains installed by
default with the NDK may be used *in-place* and the python-for-android project
has been adapted to that feature, so, it's mandatory to use, at least, ndk
version r19 (be aware that more modern versions of the
android's ndk may not work).

Those mentioned changes has been done this way to make easier the transition
between python3 and python2. We will slowly phase out python2 support
Expand Down
2 changes: 1 addition & 1 deletion ci/makefiles/android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ifndef target_os
endif

# Those android NDK/SDK variables can be override when running the file
ANDROID_NDK_VERSION ?= 17c
ANDROID_NDK_VERSION ?= 19b
ANDROID_SDK_TOOLS_VERSION ?= 4333796
ANDROID_SDK_BUILD_TOOLS_VERSION ?= 28.0.2
ANDROID_HOME ?= $(HOME)/.android
Expand Down
4 changes: 2 additions & 2 deletions doc/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ named ``tools``, and you will need to run extra commands to install
the SDK packages needed.

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

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

# Adjust the paths!
export ANDROIDSDK="$HOME/Documents/android-sdk-27"
export ANDROIDNDK="$HOME/Documents/android-ndk-r17c"
export ANDROIDNDK="$HOME/Documents/android-ndk-r19b"
export ANDROIDAPI="27" # Target API version of your application
export NDKAPI="21" # Minimum supported API version of your application
export ANDROIDNDKVER="r10e" # Version of the NDK you installed
Expand Down
Loading

0 comments on commit 3887d2b

Please sign in to comment.