[graphics/krita] /: Scaffold in OCIO compatibility for Android
L. E. Segovia
null at kde.org
Thu Jan 6 14:12:33 GMT 2022
Git commit 06e7ca5be44374080992fd739deb44f9fc45bd9a by L. E. Segovia.
Committed on 06/01/2022 at 14:10.
Pushed by lsegovia into branch 'master'.
Scaffold in OCIO compatibility for Android
This commit makes the following changes to our Android build:
- Removal of the ECM hack for DSO linking. This is incompatible with
static libraries on x86 because of "relocation R_386_GOTOFF against
preemptible symbol". I've made a local build without issues.
- Use a consistent Android STL across Krita and its dependencies. This
prevents the infamous abort on unwind when handling OCIO exceptions [1].
- Patch OCIO so that Android toolchain specs are propagated to its static
dependencies. This fixes linking issues on x86, because the static
libraries were built for armv7a by default. This patch will be
upstreamed separately.
Please notice that OCIO is still *not* shipped with Krita, because it
is unable to read configuration files natively due to the Scoped
Storage "feature" of Android [2]. A prospective dev or tester
can uncomment the ext_ocio line on androidbuild.sh.
[1]: https://github.com/android/ndk/issues/1441
[2]: https://developer.android.com/about/versions/11/privacy/storage#scoped-storage
CCMAIL: kimageshop at kde.org
M +2 -4 3rdparty/CMakeLists.txt
A +154 -0 3rdparty/ext_ocio/0001-Propagate-Android-CMake-configuration-to-external-pr.patch
M +2 -0 3rdparty/ext_ocio/CMakeLists.txt
M +3 -0 CMakeLists.txt
M +3 -0 packaging/android/androidbuild.sh
M +2 -3 plugins/dockers/lut/lutdocker_dock.cpp
https://invent.kde.org/graphics/krita/commit/06e7ca5be44374080992fd739deb44f9fc45bd9a
diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index 0d167a26b8..17e90bbffa 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -193,20 +193,18 @@ if (APPLE)
endif ()
if (ANDROID)
- # HACK: copied from ECM, this makes sure that we don't build an executable (kf5s do that), but a DSO.
- set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
-
# Increase the stack size to match MinGW's. Prevents crashes with GMic.
set(SECURITY_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,stack-size=4194304")
set(SECURITY_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,stack-size=4194304")
set(SECURITY_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-z,stack-size=4194304")
+ # stl must be consistent:
set (GLOBAL_PROFILE ${GLOBAL_PROFILE}
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_ABI=${ANDROID_ABI}
+ -DANDROID_STL=${ANDROID_STL}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
- -DCMAKE_CXX_LINK_EXECUTABLE=${CMAKE_CXX_LINK_EXECUTABLE}
-DCMAKE_EXE_LINKER_FLAGS=${SECURITY_EXE_LINKER_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS=${SECURITY_SHARED_LINKER_FLAGS}
-DCMAKE_MODULE_LINKER_FLAGS=${SECURITY_MODULE_LINKER_FLAGS}
diff --git a/3rdparty/ext_ocio/0001-Propagate-Android-CMake-configuration-to-external-pr.patch b/3rdparty/ext_ocio/0001-Propagate-Android-CMake-configuration-to-external-pr.patch
new file mode 100644
index 0000000000..30d46b2970
--- /dev/null
+++ b/3rdparty/ext_ocio/0001-Propagate-Android-CMake-configuration-to-external-pr.patch
@@ -0,0 +1,154 @@
+From 926888f9ef7a1dc41e64f94aa9bdc3bac5d4e526 Mon Sep 17 00:00:00 2001
+From: "L. E. Segovia" <13498015+amyspark at users.noreply.github.com>
+Date: Wed, 5 Jan 2022 23:25:14 +0000
+Subject: [PATCH] Propagate Android CMake configuration to external projects
+
+Signed-off-by: L. E. Segovia <13498015+amyspark at users.noreply.github.com>
+---
+ share/cmake/modules/FindHalf.cmake | 8 ++++++++
+ share/cmake/modules/FindImath.cmake | 8 ++++++++
+ share/cmake/modules/Findexpat.cmake | 8 ++++++++
+ share/cmake/modules/Findlcms2.cmake | 8 ++++++++
+ share/cmake/modules/Findpybind11.cmake | 8 ++++++++
+ share/cmake/modules/Findpystring.cmake | 9 +++++++++
+ share/cmake/modules/Findyaml-cpp.cmake | 9 +++++++++
+ 7 files changed, 58 insertions(+)
+
+diff --git a/share/cmake/modules/FindHalf.cmake b/share/cmake/modules/FindHalf.cmake
+index 9b1e2ddd..774f75c4 100644
+--- a/share/cmake/modules/FindHalf.cmake
++++ b/share/cmake/modules/FindHalf.cmake
+@@ -190,6 +190,14 @@ if(NOT Half_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
+ ${Half_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
+ endif()
+
++ if (ANDROID)
++ set(Half_CMAKE_ARGS
++ ${Half_CMAKE_ARGS}
++ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
++ -DANDROID_ABI=${ANDROID_ABI}
++ -DANDROID_STL=${ANDROID_STL})
++ endif()
++
+ # Hack to let imported target be built from ExternalProject_Add
+ file(MAKE_DIRECTORY ${Half_INCLUDE_DIR})
+
+diff --git a/share/cmake/modules/FindImath.cmake b/share/cmake/modules/FindImath.cmake
+index f7cb7412..394bdf53 100644
+--- a/share/cmake/modules/FindImath.cmake
++++ b/share/cmake/modules/FindImath.cmake
+@@ -188,6 +188,14 @@ if(NOT Imath_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
+ ${Imath_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
+ endif()
+
++ if (ANDROID)
++ set(Imath_CMAKE_ARGS
++ ${Imath_CMAKE_ARGS}
++ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
++ -DANDROID_ABI=${ANDROID_ABI}
++ -DANDROID_STL=${ANDROID_STL})
++ endif()
++
+ # Hack to let imported target be built from ExternalProject_Add
+ file(MAKE_DIRECTORY ${Imath_INCLUDE_DIR})
+
+diff --git a/share/cmake/modules/Findexpat.cmake b/share/cmake/modules/Findexpat.cmake
+index 768d22d3..f8cd55d2 100644
+--- a/share/cmake/modules/Findexpat.cmake
++++ b/share/cmake/modules/Findexpat.cmake
+@@ -231,6 +231,14 @@ if(NOT expat_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
+ ${EXPAT_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
+ endif()
+
++ if (ANDROID)
++ set(EXPAT_CMAKE_ARGS
++ ${EXPAT_CMAKE_ARGS}
++ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
++ -DANDROID_ABI=${ANDROID_ABI}
++ -DANDROID_STL=${ANDROID_STL})
++ endif()
++
+ # Hack to let imported target be built from ExternalProject_Add
+ file(MAKE_DIRECTORY ${expat_INCLUDE_DIR})
+
+diff --git a/share/cmake/modules/Findlcms2.cmake b/share/cmake/modules/Findlcms2.cmake
+index ae08c65f..d4364c48 100644
+--- a/share/cmake/modules/Findlcms2.cmake
++++ b/share/cmake/modules/Findlcms2.cmake
+@@ -150,6 +150,14 @@ if(NOT lcms2_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
+ ${lcms2_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
+ endif()
+
++ if (ANDROID)
++ set(lcms2_CMAKE_ARGS
++ ${lcms2_CMAKE_ARGS}
++ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
++ -DANDROID_ABI=${ANDROID_ABI}
++ -DANDROID_STL=${ANDROID_STL})
++ endif()
++
+ # Hack to let imported target be built from ExternalProject_Add
+ file(MAKE_DIRECTORY ${lcms2_INCLUDE_DIR})
+
+diff --git a/share/cmake/modules/Findpybind11.cmake b/share/cmake/modules/Findpybind11.cmake
+index ba991bd4..1e56b40a 100644
+--- a/share/cmake/modules/Findpybind11.cmake
++++ b/share/cmake/modules/Findpybind11.cmake
+@@ -171,6 +171,14 @@ if(NOT pybind11_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
+ ${pybind11_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
+ endif()
+
++ if (ANDROID)
++ set(pybind11_CMAKE_ARGS
++ ${pybind11_CMAKE_ARGS}
++ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
++ -DANDROID_ABI=${ANDROID_ABI}
++ -DANDROID_STL=${ANDROID_STL})
++ endif()
++
+ ExternalProject_Add(pybind11_install
+ GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
+ GIT_TAG "v${pybind11_FIND_VERSION}"
+diff --git a/share/cmake/modules/Findpystring.cmake b/share/cmake/modules/Findpystring.cmake
+index 87e93057..6f8530e6 100644
+--- a/share/cmake/modules/Findpystring.cmake
++++ b/share/cmake/modules/Findpystring.cmake
+@@ -109,6 +109,15 @@ if(NOT pystring_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
+ ${pystring_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
+ endif()
+
++
++ if (ANDROID)
++ set(pystring_CMAKE_ARGS
++ ${pystring_CMAKE_ARGS}
++ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
++ -DANDROID_ABI=${ANDROID_ABI}
++ -DANDROID_STL=${ANDROID_STL})
++ endif()
++
+ if(NOT BUILD_SHARED_LIBS)
+ #TODO: Find a way to merge in the static libs when built with internal pystring
+ message(WARNING
+diff --git a/share/cmake/modules/Findyaml-cpp.cmake b/share/cmake/modules/Findyaml-cpp.cmake
+index 773fbe16..cf259a59 100644
+--- a/share/cmake/modules/Findyaml-cpp.cmake
++++ b/share/cmake/modules/Findyaml-cpp.cmake
+@@ -195,6 +195,15 @@ if(NOT yaml-cpp_FOUND AND NOT OCIO_INSTALL_EXT_PACKAGES STREQUAL NONE)
+ ${yaml-cpp_CMAKE_ARGS} -DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET})
+ endif()
+
++
++ if (ANDROID)
++ set(yaml-cpp_CMAKE_ARGS
++ ${yaml-cpp_CMAKE_ARGS}
++ -DANDROID_PLATFORM=${ANDROID_PLATFORM}
++ -DANDROID_ABI=${ANDROID_ABI}
++ -DANDROID_STL=${ANDROID_STL})
++ endif()
++
+ if(NOT BUILD_SHARED_LIBS)
+ #TODO: Find a way to merge in the static libs when built with internal yamlcpp
+ message(WARNING
+--
+2.34.1
+
diff --git a/3rdparty/ext_ocio/CMakeLists.txt b/3rdparty/ext_ocio/CMakeLists.txt
index 6b96feac80..d10775b44f 100644
--- a/3rdparty/ext_ocio/CMakeLists.txt
+++ b/3rdparty/ext_ocio/CMakeLists.txt
@@ -12,6 +12,8 @@ ExternalProject_Add(
URL https://github.com/AcademySoftwareFoundation/OpenColorIO/archive/445c45b0160d55b3334fb7530c1164e041a0e34f.tar.gz
URL_HASH SHA256=7bbc20f5340ee1f59ca649dc0297536912d73ce01d18a967ce7bfe4acaed1820
+ PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/0001-Propagate-Android-CMake-configuration-to-external-pr.patch
+
INSTALL_DIR ${EXTPREFIX_ocio}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTPREFIX_ocio} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DOCIO_BUILD_NUKE:BOOL=OFF -DOCIO_BUILD_DOCS:BOOL=OFF -DOCIO_BUILD_TESTS:BOOL=OFF -DOCIO_BUILD_GPU_TESTS:BOOL=OFF -DOCIO_BUILD_PYTHON:BOOL=OFF -DOCIO_INSTALL_EXT_PACKAGES=MISSING ${SSE_OPTIMIZATIONS_STRING}
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 10a6279231..5ac8d6ed36 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -832,6 +832,9 @@ if (OPENCOLORIO_VERSION VERSION_GREATER_EQUAL "2.0.0")
set(HAVE_OCIO_V2 TRUE)
endif()
configure_file(config-ocio.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ocio.h)
+if (OpenColorIO_FOUND)
+ list (APPEND ANDROID_EXTRA_LIBS ${OPENCOLORIO_LIBRARIES})
+endif()
set_package_properties(PythonLibrary PROPERTIES
DESCRIPTION "Python Library"
diff --git a/packaging/android/androidbuild.sh b/packaging/android/androidbuild.sh
index 30098bba92..d94ba88212 100755
--- a/packaging/android/androidbuild.sh
+++ b/packaging/android/androidbuild.sh
@@ -64,6 +64,7 @@ configure_ext() {
-DCMAKE_INSTALL_PREFIX=$THIRDPARTY_INSTALL \
-DCMAKE_TOOLCHAIN_FILE=$CMAKE_ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$ANDROID_ABI \
+ -DANDROID_STL=c++_shared \
-DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL \
-DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \
-DCMAKE_FIND_ROOT_PATH="$QT_ANDROID;$BUILD_ROOT/i"
@@ -78,6 +79,7 @@ configure_plugins() {
-DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-DCMAKE_TOOLCHAIN_FILE=$CMAKE_ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=$ANDROID_ABI \
+ -DANDROID_STL=c++_shared \
-DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL \
-DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \
-DCMAKE_FIND_ROOT_PATH="$QT_ANDROID;$BUILD_ROOT/i;$INSTALL_PREFIX"
@@ -123,6 +125,7 @@ build_ext() {
cmake --build . --config $BUILD_TYPE --target ext_mypaint -- -j$PROC_COUNT
cmake --build . --config $BUILD_TYPE --target ext_webp -- -j$PROC_COUNT
cmake --build . --config $BUILD_TYPE --target ext_vc -- -j$PROC_COUNT
+ # cmake --build . --config $BUILD_TYPE --target ext_ocio -- -j$PROC_COUNT
cd $BUILD_ROOT
}
diff --git a/plugins/dockers/lut/lutdocker_dock.cpp b/plugins/dockers/lut/lutdocker_dock.cpp
index aa17a18827..d104ae1d95 100644
--- a/plugins/dockers/lut/lutdocker_dock.cpp
+++ b/plugins/dockers/lut/lutdocker_dock.cpp
@@ -516,9 +516,8 @@ void LutDockerDock::resetOcioConfiguration()
if (m_ocioConfig) {
OCIO::SetCurrentConfig(m_ocioConfig);
}
- }
- catch (OCIO::Exception &exception) {
- dbgKrita << "OpenColorIO Error:" << exception.what() << "Cannot create the LUT docker";
+ } catch (OCIO::Exception &exception) {
+ errKrita << "OpenColorIO Error:" << exception.what() << "Cannot create the LUT docker";
}
More information about the kimageshop
mailing list