Setup for android(arm) build
ClosedPublic

Authored by sh-zam on Mar 13 2019, 1:30 PM.

Diff Detail

Repository
R37 Krita
Branch
android-build
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 9525
Build 9543: arc lint + arc unit
sh-zam created this revision.Mar 13 2019, 1:30 PM
Restricted Application added a reviewer: Krita. · View Herald TranscriptMar 13 2019, 1:30 PM
Restricted Application added a project: Krita. · View Herald Transcript
sh-zam requested review of this revision.Mar 13 2019, 1:30 PM
apol added inline comments.Mar 13 2019, 2:44 PM
3rdparty/ext_expat/CMakeLists.txt
4

Maintainability-wise, having the same thing twice isn't very practical. Maybe you can just pass to this one some android extra arguments?

libs/ui/opengl/kis_opengl_canvas2.cpp
419

I think it would make sense to have a HAVE_OPENGL, it reads random not wanting to do that on a specific platform. (for this one and similar cases).

packaging/android/build_kf5.sh
33

Please use the tooling in the Android SDK.
https://community.kde.org/Android/Environment_via_Container

you can build Krita and its dependencies by running:
/opt/helpers/build-generic krita with any cmake paramaters you may need.

rempt added a subscriber: rempt.Mar 13 2019, 3:00 PM

> CMakeLists.txt:4
> if (WIN32)
> ExternalProject_Add( ext_expat
> DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}

Maintainability-wise, having the same thing twice isn't very practical. Maybe you can just pass to this one some android extra arguments?

This is how krita handles its external dependencies mostly, so I'm not to worried about it, we have separate definitions for macOS, Windows and Linux all over the place.

Having the Qt installer, frameworks done with kdesrc-build and the rest with the usual 3rdparty extra cmake projects is a bit weird, and I would prefer to have everything done with the 3rdparty/ext_* things. But first I want to get this patch working. kdesrc-build seems to fail for me...

rempt added a comment.Mar 13 2019, 3:06 PM

Notes:

My setttings:

export BASE=/home/boud/dev/android
export KRITA_ROOT=$BASE/krita
export CMAKE_ANDROID_NDK=$BASE/android-ndk-r19b
export ANDROID_NDK_ROOT=$BASE/android-ndk-r19b
export ANDROID_SDK_ROOT=$BASE/tools
export ANDROID_API_LEVEL=21
export QT_ANDROID=$BASE/Qt/5.12.1/android_armv7/

kdesrc-build builds inside krita's repo -- that's perhaps not ideal.

I do not have a succesful build:

boud@boud-ThinkPad-T470p:~/dev/android$ ./krita/packaging/android/build_kf5.sh
./krita/packaging/android/build_kf5.sh: line 20: cd: ./krita/packaging/android: No such file or directory
Cloning into 'kdesrc-conf-android'...
remote: Counting objects: 42, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 42 (delta 13), reused 33 (delta 10)
Receiving objects: 100% (42/42), 4.83 KiB | 2.42 MiB/s, done.
Resolving deltas: 100% (13/13), done.
Cloning into 'extragear/kdesrc-build'...
remote: Counting objects: 8911, done.
remote: Compressing objects: 100% (3912/3912), done.
remote: Total 8911 (delta 5643), reused 7145 (delta 4527)
Receiving objects: 100% (8911/8911), 3.09 MiB | 6.07 MiB/s, done.
Resolving deltas: 100% (5643/5643), done.
Cloning kde-build-metadata
Cloning sysadmin-repo-metadata

Building extra-cmake-modules from guessed_from_cmdline (1/1)

Cloning extra-cmake-modules
Source update complete for extra-cmake-modules: 519 files affected.
Preparing build system for extra-cmake-modules.
Running cmake...
Compiling... succeeded (after 3 seconds)
Installing.. succeeded (after 0 seconds)

<<< PACKAGES SUCCESSFULLY BUILT >>>
extra-cmake-modules

  • Installing "sample-kde-env-master.sh" would overwrite an existing file:
  • /home/boud/.config/kde-env-master.sh
  • If this is acceptable, please delete the existing file and re-run,
  • or pass --delete-my-settings and re-run.

:-)
Your logs are saved in /home/boud/dev/android/krita//kf5/kde/src/log/2019-03-13-01
Updating kde-build-metadata (to branch master)
Updating sysadmin-repo-metadata (to branch master)

Building libintl-lite (1/4)

Cloning libintl-lite
Source update complete for libintl-lite: 9 files affected.
Preparing build system for libintl-lite.
Running cmake...
Unable to configure libintl-lite with CMake!
Unable to configure libintl-lite with KDE

Building ki18n from frameworks-android (2/4)

Cloning ki18n
Source update complete for ki18n: 61 files affected.
Preparing build system for ki18n.
Running cmake...
Unable to configure ki18n with CMake!
Unable to configure ki18n with KDE

Building kcoreaddons from guessed_from_cmdline (3/4)

Cloning kcoreaddons
Source update complete for kcoreaddons: 183 files affected.
Preparing build system for kcoreaddons.
Running cmake...
Unable to configure kcoreaddons with CMake!
Unable to configure kcoreaddons with KDE

Building kcompletion from guessed_from_cmdline (4/4)

Cloning kcompletion
Source update complete for kcompletion: 48 files affected.
Preparing build system for kcompletion.
Running cmake...
Unable to configure kcompletion with CMake!
Unable to configure kcompletion with KDE

<<< PACKAGES FAILED TO BUILD >>>
libintl-lite - ~/dev/android/kritakf5/kde/src/log/2019-03-13-02/libintl-lite/cmake.log
ki18n - ~/dev/android/krita
kf5/kde/src/log/2019-03-13-02/ki18n/cmake.log
kcoreaddons - ~/dev/android/kritakf5/kde/src/log/2019-03-13-02/kcoreaddons/cmake.log
kcompletion - ~/dev/android/krita
kf5/kde/src/log/2019-03-13-02/kcompletion/cmake.log

  • Installing "sample-kde-env-master.sh" would overwrite an existing file:
  • /home/boud/.config/kde-env-master.sh
  • If this is acceptable, please delete the existing file and re-run,
  • or pass --delete-my-settings and re-run.

:-(
Your logs are saved in /home/boud/dev/android/kritakf5/kde/src/log/2019-03-13-02
sed: can't read /home/boud/dev/android/krita
kf5/kde/src/frameworks/kitemmodels/CMakeLists.txt: No such file or directory
sed: can't read /home/boud/dev/android/krita//kf5/kde/src/frameworks/kitemmodels/CMakeLists.txt: No such file or directory
Updating kde-build-metadata (to branch master)
Updating sysadmin-repo-metadata (to branch master)

Building kcoreaddons from guessed_from_cmdline (1/9)

No source update, but the last configure failed
Updating kcoreaddons (to branch master)
Local changes detected, stashing them away...
Module updated, reapplying your local changes.
Source update complete for kcoreaddons: no files affected
Preparing build system for kcoreaddons.
Removing files in build directory for kcoreaddons
Old build system cleaned, starting new build system.
Running cmake...
Unable to configure kcoreaddons with CMake!
Unable to configure kcoreaddons with KDE

Building kconfig from frameworks-android (2/9)

Cloning kconfig
Source update complete for kconfig: 231 files affected.
Preparing build system for kconfig.
Running cmake...
Unable to configure kconfig with CMake!
Unable to configure kconfig with KDE

Building ki18n from frameworks-android (3/9)

No source update, but the last configure failed
Updating ki18n (to branch master)
Local changes detected, stashing them away...
Module updated, reapplying your local changes.
Source update complete for ki18n: no files affected
Preparing build system for ki18n.
Removing files in build directory for ki18n
Old build system cleaned, starting new build system.
Running cmake...
Unable to configure ki18n with CMake!
Unable to configure ki18n with KDE

Building kwidgetsaddons from guessed_from_cmdline (4/9)

Cloning kwidgetsaddons
Source update complete for kwidgetsaddons: 296 files affected.
Preparing build system for kwidgetsaddons.
Running cmake...
Unable to configure kwidgetsaddons with CMake!
Unable to configure kwidgetsaddons with KDE

Building kcompletion from guessed_from_cmdline (5/9)

No source update, but the last configure failed
Updating kcompletion (to branch master)
Local changes detected, stashing them away...
Module updated, reapplying your local changes.
Source update complete for kcompletion: no files affected
Preparing build system for kcompletion.
Removing files in build directory for kcompletion
Old build system cleaned, starting new build system.
Running cmake...
Unable to configure kcompletion with CMake!
Unable to configure kcompletion with KDE

Building kguiaddons from guessed_from_cmdline (6/9)

Cloning kguiaddons
Source update complete for kguiaddons: 47 files affected.
Preparing build system for kguiaddons.
Running cmake...
Unable to configure kguiaddons with CMake!
Unable to configure kguiaddons with KDE

Building kitemmodels from guessed_from_cmdline (7/9)

Cloning kitemmodels
Source update complete for kitemmodels: 151 files affected.
Preparing build system for kitemmodels.
Running cmake...
Unable to configure kitemmodels with CMake!
Unable to configure kitemmodels with KDE

Building kitemviews from guessed_from_cmdline (8/9)

Cloning kitemviews
Source update complete for kitemviews: 40 files affected.
Preparing build system for kitemviews.
Running cmake...
Unable to configure kitemviews with CMake!
Unable to configure kitemviews with KDE

Building kwindowsystem from guessed_from_cmdline (9/9)

Cloning kwindowsystem
Source update complete for kwindowsystem: 110 files affected.
Preparing build system for kwindowsystem.
Running cmake...
Unable to configure kwindowsystem with CMake!
Unable to configure kwindowsystem with KDE

<<< PACKAGES FAILED TO BUILD >>>
kcoreaddons - ~/dev/android/kritakf5/kde/src/log/2019-03-13-03/kcoreaddons/cmake.log
kconfig - ~/dev/android/krita
kf5/kde/src/log/2019-03-13-03/kconfig/cmake.log
ki18n - ~/dev/android/kritakf5/kde/src/log/2019-03-13-03/ki18n/cmake.log
kwidgetsaddons - ~/dev/android/krita
kf5/kde/src/log/2019-03-13-03/kwidgetsaddons/cmake.log
kcompletion - ~/dev/android/kritakf5/kde/src/log/2019-03-13-03/kcompletion/cmake.log
kguiaddons - ~/dev/android/krita
kf5/kde/src/log/2019-03-13-03/kguiaddons/cmake.log
kitemmodels - ~/dev/android/kritakf5/kde/src/log/2019-03-13-03/kitemmodels/cmake.log
kitemviews - ~/dev/android/krita
kf5/kde/src/log/2019-03-13-03/kitemviews/cmake.log
kwindowsystem - ~/dev/android/krita//kf5/kde/src/log/2019-03-13-03/kwindowsystem/cmake.log

  • Installing "sample-kde-env-master.sh" would overwrite an existing file:
  • /home/boud/.config/kde-env-master.sh
  • If this is acceptable, please delete the existing file and re-run,
  • or pass --delete-my-settings and re-run.

:-(
Your logs are saved in /home/boud/dev/android/krita//kf5/kde/src/log/2019-03-13-03
sed: can't read kde/install/lib/cmake/KF5I18n/KF5I18nMacros.cmake: No such file or directory
cp: cannot stat '/usr/lib/x86_64-linux-gnu/libexec/kf5/kconfig_compiler_kf5': No such file or directory

Could you paste the log file ~/dev/android/kritakf5/kde/src/log/2019-03-13-03/kcoreaddons/cmake.log and ~/dev/android/kritakf5/kde/src/log/2019-03-13-03/kwidgetsaddons/cmake.log so I can get a general idea, why it is failing?

vkrause added inline comments.Mar 13 2019, 6:11 PM
CMakeLists.txt
255

Apparently there is, as no other application on binary factory seems to need this ;-)
Setting CMAKE_PREFIX_PATH to the corresponding install prefixes should take care of this usually.

packaging/android/build_kf5.sh
33

Yep, that would make setting up nightly builds on binary factory straightforward for this.

59

These patches are somewhat surprising, as both the CI and binary factory manage to build this just fine without needing any of this.
If there are actual issues (like the one you found resulting in D19734), let's fix them in KF5 directly, that will benefit everyone and it will make this considerably easier to maintain.

sh-zam added inline comments.Mar 13 2019, 6:34 PM
CMakeLists.txt
255

I tried using it and other variables, but couldn't get cmake to find the packages.

related: https://stackoverflow.com/questions/40054495/set-cmake-prefix-path-not-working-with-android-toolchain

packaging/android/build_kf5.sh
33

I did see the docker image. I couldn't pull the image because of some authorization issues.
So, had to do this the hard way.
Currently the patch has been built only on my PC, if it builds fine for others. I will move to the docker route.

59

Yes!

sh-zam updated this revision to Diff 53828.Mar 13 2019, 7:49 PM
  • Minor bug fix

Sorry, missed your IRC message: Referring to the kcompletion linker error (https://paste.ubuntu.com/p/xr5MDGvf6h/): this again looks like an issue with the API level define not being propagated correctly. At API 23 stdout/stderr etc changed from a define to an actual symbol. If you don't see -DANDROID_API=xx in the compiler command lines something is probably still fundamentally wrong.

In CMakeCache.txt it is given out ANDROID_API_LEVEL:STRING=21. When I change it to 23, only then it builds fine.

However, in CI API 21 is being used.

I agree you should make a separate define for use with OpenGL-ES-only environments. OpenGL ES is not limited to Android after all.

Aside from the suggestion to use a more specific define, I see that you put #ifdef blocks inside the conditional blocks for the condition !KisOpenGL::hasOpenGLES(). This isn't great because:

  • If you expect KisOpenGL::hasOpenGLES() to always return true, then there would be a pointless run-time conditional check.
  • If there is a bug elsewhere (or missing checks) that causes KisOpenGL::hasOpenGLES() to return false, it ends up silently skipping some code instead of outputting an error or crashing immediately (though it will probably still crash eventually).

May I suggest you to either exclude the conditional checks with #ifdef or add asserts in the else blocks?


In hindsight, it might've been better to have put four classifications at compile time:

  • Desktop OpenGL only (Linux and macOS)
  • Desktop OpenGL or OpenGL ES (Windows with Qt ANGLE switching)
  • OpenGL ES only (mobile, which wasn't supported before this change)
  • No OpenGL (only software-rendered canvas, though I don't think Krita currently provides this option at compile time)

Btw it is actually possible to use OpenGL ES on some desktop OpenGL environments without using ANGLE,. It's just that Krita doesn't try to use them.

But if you're targeting an OpenGL ES environment, you would exclude everything that targets desktop OpenGL because they wouldn't even compile.

libs/ui/opengl/kis_opengl_canvas2.cpp
419

I would suggest to use something like HAVE_OPENGL_ES_NO_DESKTOP_OPENGL, maybe in some alternative wording. It should deliver the meaning that OpenGL ES library is available but full desktop OpenGL is not.

rempt added a comment.Mar 14 2019, 9:57 AM
sh-zam updated this revision to Diff 53909.Mar 14 2019, 6:53 PM
  • Changed Q_OS_ANDROID to HAS_ONLY_OPENGL_ES
sh-zam marked 2 inline comments as done.Mar 14 2019, 6:54 PM
sh-zam updated this revision to Diff 54043.Mar 16 2019, 9:00 PM
  • Patches removed by including the API flag in build_kf5.sh
sh-zam marked 2 inline comments as done.Mar 16 2019, 9:03 PM
sh-zam added inline comments.
packaging/android/build_kf5.sh
59

You were right, it was an issue with ANDROID_API.

But oddly enough, __ANDROID_API__ was being added to c_flags but not to cxx_flags in CMakeCache.txt

sh-zam marked an inline comment as done.Mar 16 2019, 9:04 PM
sh-zam updated this revision to Diff 55043.Mar 29 2019, 6:31 PM
  • Fix change which broke desktop builds
sh-zam updated this revision to Diff 55380.Apr 3 2019, 9:44 PM
  • [Android]: Changes to access default resources and plugins
This revision was not accepted when it landed; it landed in state Needs Review.Apr 11 2019, 11:47 AM
This revision was automatically updated to reflect the committed changes.