Commit 0d9d7850 authored by Sharaf Zaman's avatar Sharaf Zaman

Configurable architecture for android builds

We can now build APK for different architectures.

Builds with: arm, arm64, x86
parent 29de9479
......@@ -12,7 +12,7 @@ ExternalProject_Add( ext_exiv2
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/gcccheck.patch
INSTALL_DIR ${PREFIX_ext_exiv2}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_exiv2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DEXIV2_ENABLE_BUILD_SAMPLES=OFF -DEXIV2_ENABLE_BUILD_PO=OFF -DEXIV2_ENABLE_NLS=OFF -DICONV_INCLUDE_DIR=${PREFIX_ext_exiv2}/include -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DEXPAT_LIBRARY=$ENV{BUILD_ROOT}/i/lib/libexpat.so -DEXPAT_INCLUDE_DIR=$ENV{BUILD_ROOT}/i/include
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_exiv2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DEXIV2_ENABLE_BUILD_SAMPLES=OFF -DEXIV2_ENABLE_BUILD_PO=OFF -DEXIV2_ENABLE_NLS=OFF -DICONV_INCLUDE_DIR=${PREFIX_ext_exiv2}/include -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DEXPAT_LIBRARY=$ENV{BUILD_ROOT}/i/lib/libexpat.so -DEXPAT_INCLUDE_DIR=$ENV{BUILD_ROOT}/i/include -DANDROID_ABI=${ANDROID_ABI}
UPDATE_COMMAND ""
DEPENDS ext_iconv ext_expat
......
......@@ -21,7 +21,7 @@ ExternalProject_Add( ext_expat
URL_MD5 dd7dab7a5fea97d2a6a43f511449b7cd
INSTALL_DIR ${PREFIX_ext_expat}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_expat} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_expat} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_ABI=${ANDROID_ABI}
BUILD_COMMAND make
INSTALL_COMMAND make install
......
......@@ -10,6 +10,6 @@ ExternalProject_Add( ext_gsl
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/gsl-android.patch
INSTALL_DIR ${EXTPREFIX_gsl}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTPREFIX_gsl} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTPREFIX_gsl} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_ABI=${ANDROID_ABI}
UPDATE_COMMAND ""
)
......@@ -20,7 +20,7 @@ ExternalProject_Add( ext_lcms2
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/lcms2-9.diff
INSTALL_DIR ${PREFIX_ext_lcms2}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_lcms2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DBUILD_TESTS=FALSE -DBUILD_UTILS=FALSE -DBUILD_STATIC=FALSE -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_lcms2} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DBUILD_TESTS=FALSE -DBUILD_UTILS=FALSE -DBUILD_STATIC=FALSE -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_ABI=${ANDROID_ABI}
UPDATE_COMMAND ""
)
......
......@@ -6,7 +6,7 @@ ExternalProject_Add( ext_png
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/androidpng.patch
INSTALL_DIR ${PREFIX_ext_png}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_png} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DPNG_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_png} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DPNG_TESTS=OFF -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_ABI=${ANDROID_ABI}
UPDATE_COMMAND ""
......
......@@ -7,7 +7,7 @@ if (ANDROID)
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/find_quazip.diff
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/liblocation.diff
INSTALL_DIR ${PREFIX_ext_quazip}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_quazip} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DQt5Core_DIR=$ENV{QT_ANDROID}/lib/cmake/Qt5Core/
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_quazip} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DQt5Core_DIR=$ENV{QT_ANDROID}/lib/cmake/Qt5Core/ -DANDROID_ABI=${ANDROID_ABI}
UPDATE_COMMAND ""
DEPENDS ext_zlib
......
......@@ -6,7 +6,7 @@ ExternalProject_Add(
URL http://files.kde.org/krita/build/dependencies/zlib-1.2.11.tar.gz
URL_MD5 1c9f62f0778697a09d36121ead88e08e
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_zlib} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${PREFIX_ext_zlib} -DCMAKE_BUILD_TYPE=${GLOBAL_BUILD_TYPE} ${GLOBAL_PROFILE} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} -DANDROID_PLATFORM=${ANDROID_PLATFORM} -DANDROID_ABI=${ANDROID_ABI}
UPDATE_COMMAND ""
)
......
......@@ -268,7 +268,6 @@ if(ANDROID)
set (KF5_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/kf5/kde/install/lib)
set(ECM_DIR ${CMAKE_CURRENT_BINARY_DIR}/kf5/kde/install/share/ECM/cmake)
set(KF5Config_DIR ${KF5_LIBRARIES}/cmake/KF5Config/)
set(KF5Config_DIR ${KF5_LIBRARIES}/cmake/KF5Config/)
set(KF5I18n_DIR ${KF5_LIBRARIES}/cmake/KF5I18n/)
set(KF5WidgetsAddons_DIR ${KF5_LIBRARIES}/cmake/KF5WidgetsAddons)
set(KF5Completion_DIR ${KF5_LIBRARIES}/cmake/KF5Completion)
......
......@@ -20,11 +20,13 @@ dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
ext {
abi = System.getenv('ANDROID_ABI')
}
task ("configure") {
doLast {
def abi = System.getenv('ANDROID_ABI')
if (abi == null) {
abi = 'armeabi-v7a'
logger.error('ANDROID_ABI not specified using the default one instead: armeabi-7a')
}
......@@ -42,9 +44,9 @@ task ("configure") {
// copy libs(plugins) which start with krita*.so and rename
// them to start with `lib_`
task copyLibs(type: Copy, dependsOn: configure) {
task copyLibs(type: Copy) {
from "${System.getenv('INSTALL_PREFIX')}/lib"
into 'libs/armeabi-v7a'
into "libs/${abi ?: 'armeabi-v7a'}"
rename ('^krita(.*).so$', 'lib_krita$1.so')
}
......
#!/bin/sh
#!/bin/bash
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
: ${BUILD_ROOT? "Built roott path must be set"}
CURDIR="$(pwd)"/
VERSION="1_69"
if [[ -z $ANDROID_ABI ]]; then
echo "ANDROID_ABI not specified, using the default one: armeabi-v7a"
ANDROID_ABI=armeabi-v7a
fi
git clone https://github.com/moritz-wundke/Boost-for-Android $BUILD_ROOT/d/boost
cd $BUILD_ROOT/d/boost
./build-android.sh --prefix=$BUILD_ROOT/i --with-libraries=system \
--boost=1.69.0 --arch=armeabi-v7a \
--boost=1.69.0 --arch=$ANDROID_ABI \
$CMAKE_ANDROID_NDK
cd $BUILD_ROOT/i/armeabi-v7a/lib
cd $BUILD_ROOT/i/$ANDROID_ABI/lib
# possible only because just one library is being used
mv libboost_system-clang-mt-a32-$VERSION.a libboost_system.a
mv libboost_system-*-$VERSION.a libboost_system.a
#!/bin/sh
#!/bin/bash
# See more: 3rdparty/README.md
# Build external dependencies in $KRITA_ROOT/3rdparty
......@@ -11,20 +11,21 @@
: ${QT_ANDROID?"Path to QT root is required"}
: ${BUILD_ROOT? "Build root must be set"}
export ANDROID_ARCHITECTURE=arm
export ANDROID_ABI=armeabi-v7a
export ANDROID_TOOLCHAIN=arm-linux-androideabi
export ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
if [[ -z $ANDROID_ABI ]]; then
echo "ANDROID_ABI not specified, using the default one: armeabi-v7a"
ANDROID_ABI=armeabi-v7a
fi
ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
cmake $KRITA_ROOT/3rdparty \
-DINSTALL_ROOT=$BUILD_ROOT/i \
-DEXTERNALS_DOWNLOAD_DIR=$BUILD_ROOT/d \
-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT/i \
-DCMAKE_TOOLCHAIN_FILE=$CMAKE_ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL \
-DANDROID_ABI=$ANDROID_ABI \
-DANDROID_STL=c++_static
-DINSTALL_ROOT=$BUILD_ROOT/i \
-DEXTERNALS_DOWNLOAD_DIR=$BUILD_ROOT/d \
-DCMAKE_INSTALL_PREFIX=$BUILD_ROOT/i \
-DCMAKE_TOOLCHAIN_FILE=$CMAKE_ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL \
-DANDROID_ABI=$ANDROID_ABI \
-DANDROID_STL=c++_static
......
......@@ -9,10 +9,20 @@
: ${KRITA_ROOT?"Project root path must be set"}
: ${BUILD_ROOT? "Build root must be set"}
export ANDROID_ARCHITECTURE=arm
export ANDROID_ABI=armeabi-v7a
export ANDROID_TOOLCHAIN=arm-linux-androideabi
export ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
if [[ -z $ANDROID_ABI ]]; then
echo "ANDROID_ABI not specified, using the default one: armeabi-v7a"
ANDROID_ABI=armeabi-v7a
fi
if [[ $ANDROID_ABI == "armeabi-v7a" ]]; then
ANDROID_ARCHITECTURE=arm
elif [[ $ANDROID_ABI == "arm64-v8a" ]]; then
ANDROID_ARCHITECTURE=arm64
elif [[ $ANDROID_ABI == "x86" || $ANDROID_ABI == "x86_64" ]]; then
ANDROID_ARCHITECTURE=$ANDROID_ABI
fi
ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
cd $BUILD_ROOT
......@@ -38,7 +48,7 @@ sed -i -- 's/make-options -j8/make-options -j4 VERBOSE=1/g' kdesrc-conf-android/
if [ -e $qt_android_libs ]
then
sed -E -i "s|-DCMAKE_PREFIX_PATH=.*?\\ |-DCMAKE_PREFIX_PATH=$QT_ANDROID- -DCMAKE_ANDROID_NDK=$CMAKE_ANDROID_NDK -DECM_ADDITIONAL_FIND_ROOT_PATH=$QT_ANDROID\;$CURDIR/kf5/kde/install -DANDROID_STL=c++_static -DCMAKE_TOOLCHAIN_FILE=$CURDIR/kf5/kde/install/share/ECM/toolchain/Android.cmake -DKCONFIG_USE_DBUS=OFF -DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL -DANDROID_API_LEVEL=$ANDROID_API_LEVEL |g" kdesrc-conf-android/kdesrc-buildrc
sed -E -i "s|-DCMAKE_PREFIX_PATH=.*?\\ |-DCMAKE_PREFIX_PATH=$QT_ANDROID- -DCMAKE_ANDROID_NDK=$CMAKE_ANDROID_NDK -DECM_ADDITIONAL_FIND_ROOT_PATH=$QT_ANDROID\;$CURDIR/kf5/kde/install -DANDROID_STL=c++_static -DCMAKE_TOOLCHAIN_FILE=$CURDIR/kf5/kde/install/share/ECM/toolchain/Android.cmake -DKCONFIG_USE_DBUS=OFF -DANDROID_PLATFORM=$ANDROID_NATIVE_API_LEVEL -DANDROID_API_LEVEL=$ANDROID_API_LEVEL -DANDROID_ABI=$ANDROID_ABI -DANDROID_ARCHITECTURE=$ANDROID_ARCHITECTURE |g" kdesrc-conf-android/kdesrc-buildrc
sed -i -- "s/cxxflags.*/& -D__ANDROID_API__=$ANDROID_API_LEVEL/" kdesrc-conf-android/kdesrc-buildrc
else
echo "Qt Android libraries path doesn't exist. Exiting."
......@@ -48,8 +58,9 @@ fi
sed -E -i "s|use-modules.+|use-modules kconfig ki18n |g" kdesrc-conf-android/kdesrc-buildrc
rm -rf kde/build/* # clean build folders
./kdesrc-build libintl-lite \
ki18n kcoreaddons \
./kdesrc-build libintl-lite
./kdesrc-build ki18n kcoreaddons \
frameworks-android \
kwidgetsaddons kcompletion \
kguiaddons kitemmodels \
......
#!/bin/sh
#!/bin/bash
: ${KRITA_ROOT?"Project root path must be set"}
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
......@@ -9,11 +9,13 @@
CURDIR="$(pwd)"/
export ANDROID_ARCHITECTURE=arm
export ANDROID_ABI=armeabi-v7a
export ANDROID_TOOLCHAIN=arm-linux-androideabi
export ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
if [[ -z $ANDROID_ABI ]]; then
echo "ANDROID_ABI not specified, using the default one: armeabi-v7a"
ANDROID_ABI=armeabi-v7a
fi
ANDROID_NATIVE_API_LEVEL=android-$ANDROID_API_LEVEL
: ${PY_INCLUDE_PATH?"Python include path must be set"}
: ${PY_LIBRARY?"Python lib path must be set"}
......@@ -36,5 +38,6 @@ cmake $KRITA_ROOT -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \
-DBoost_NO_SYSTEM_PATHS=TRUE \
-DQTANDROID_EXPORTED_TARGET=krita \
-DANDROID_APK_DIR=$KRITA_ROOT/packaging/android/apk \
-DANDROID_STL=c++_shared
-DANDROID_STL=c++_shared \
-DANDROID_ABI=$ANDROID_ABI
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment