Commit 128cc2fb authored by Ilya Bizyaev's avatar Ilya Bizyaev 📱 Committed by Linus Jahn

Switch Android builds to CMake and use ECM

parent ffaf7e69
cmake_minimum_required(VERSION 2.8.11)
find_package(ECM 5.45.0 REQUIRED NO_MODULE)
set(CMAKE_CXX_STANDARD 14)
set(QT_MIN_VERSION "5.8.0")
......@@ -19,25 +20,32 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# CMake modules include
include(FeatureSummary)
include(GNUInstallDirs)
set(AUTOMOC_MOC_OPTIONS -Muri=im.kaidan.kaidan)
#
# Dependecies
#
# CMake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake" ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
# CMake modules include
include(GNUInstallDirs)
include(KDEInstallDirs)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(KDECMakeSettings)
include(ECMInstallIcons)
include(ECMAddAppIcon)
include(FeatureSummary)
kde_enable_exceptions()
# Find packages
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick Sql QuickControls2)
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick Svg Sql QuickControls2)
find_package(KF5Kirigami2 REQUIRED)
find_package(Gloox REQUIRED)
# optional QWidget style integration (not on ubuntu touch)
if(NOT UBUNTU_TOUCH)
# optional QWidget style integration (not on mobile)
if(NOT UBUNTU_TOUCH AND NOT ANDROID)
find_package(Qt5Widgets)
set_package_properties(Qt5Widgets PROPERTIES
DESCRIPTION "Integration with QWidget based desktop styles"
......@@ -52,6 +60,12 @@ else()
add_definitions(-DQAPPLICATION_CLASS=QGuiApplication)
endif()
if (ANDROID)
find_package(Qt5 REQUIRED COMPONENTS AndroidExtras)
find_library(CRYPTO_LIBRARIES crypto)
find_library(SSL_LIBRARIES ssl)
endif()
#
# Load submodules
......@@ -70,18 +84,25 @@ endif()
# Sources / Resources
#
# Include bundled icons on Ubuntu Touch,
# because its icon theme is missing some required icons
if(UBUNTU_TOUCH)
# Include bundled icons on Ubuntu Touch and Android
if(UBUNTU_TOUCH OR ANDROID)
set(KAIDAN_ICONS_QRC kirigami-icons.qrc)
endif()
# Bundle images on Android
if(ANDROID)
set(KAIDAN_IMAGES_QRC "data/images/images.qrc")
endif()
add_executable(${PROJECT_NAME}
${KAIDAN_SOURCES}
${KAIDAN_ICONS_QRC} # only set if enabled
${I18N_QRC_CPP} #
${KAIDAN_ICONS_QRC} # only set if enabled
${KAIDAN_IMAGES_QRC} #
${I18N_QRC_CPP} #
"kaidan_qml.qrc"
)
set_target_properties(${PROJECT_NAME} PROPERTIES C_VISIBILITY_PRESET default)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_VISIBILITY_PRESET default)
#
......@@ -93,10 +114,14 @@ target_link_libraries(${PROJECT_NAME}
Qt5::Sql
Qt5::Qml
Qt5::Quick
Qt5::Svg
${__Qt5Widgets_LIBRARIES}
${GLOOX_LIBRARIES}
)
if (ANDROID)
target_link_libraries(${PROJECT_NAME} Qt5::AndroidExtras Qt5::QuickControls2 KF5::Kirigami2 ${CRYPTO_LIBRARIES} ${SSL_LIBRARIES})
endif()
#
# Global C++ variables
......@@ -106,7 +131,7 @@ if(UBUNTU_TOUCH)
set(KAIDAN_COMPILE_DEFINITIONS
UBUNTU_TOUCH=True
)
else()
elseif(NOT ANDROID)
set(KAIDAN_COMPILE_DEFINITIONS
NOTIFICATIONS_LIBNOTIFY=True
)
......@@ -128,7 +153,7 @@ if(UBUNTU_TOUCH AND CLICK_ARCH)
${CMAKE_SOURCE_DIR}/misc/ubuntu-touch/manifest.json)
# install kaidan binary
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/bin/${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
# install kaidan media
......@@ -142,7 +167,7 @@ if(UBUNTU_TOUCH AND CLICK_ARCH)
)
elseif(UNIX AND NOT APPLE)
# install kaidan binary
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/bin/${PROJECT_NAME}
DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}
)
......
......@@ -83,7 +83,7 @@ Debian strech and older Ubuntu distros are not supported since they don't provid
sudo apt install apt-transport-https git-core cmake build-essential zlib1g-dev \
libgloox-dev libnotify-bin libqt5quick5 libqt5quickcontrols2-5 libqt5quickwidgets5 \
libqt5qml5 libqt5gui5 libqt5core5a qtdeclarative5-dev qttools5-dev qt5-default \
qtquickcontrols2-5-dev kirigami2-dev
qtquickcontrols2-5-dev kirigami2-dev extra-cmake-modules
```
#### Get the source code:
......@@ -103,7 +103,7 @@ make -j$(nproc)
#### Now you can run Kaidan:
```bash
./kaidan
./bin/kaidan
```
#### If you like it, install it by:
......
<RCC>
<qresource prefix="/org/kde/kirigami/icons/">
<qresource prefix="/icons/breeze">
<file alias="index.theme">3rdparty/breeze-icons/icons/index.theme</file>
</qresource>
<qresource prefix="/icons/breeze/actions/22">
<file alias="application-menu.svg">3rdparty/breeze-icons/icons/actions/22/application-menu.svg</file>
<file alias="bookmark-remove.svg">3rdparty/breeze-icons/icons/actions/22/bookmark-remove.svg</file>
<file alias="document-decrypt.svg">3rdparty/breeze-icons/icons/actions/22/document-decrypt.svg</file>
<file alias="contact-new.svg">3rdparty/breeze-icons/icons/actions/22/contact-new.svg</file>
<file alias="dialog-close.svg">3rdparty/breeze-icons/icons/actions/22/dialog-close.svg</file>
<file alias="document-send.svg">3rdparty/breeze-icons/icons/actions/16/document-send.svg</file>
<file alias="document-send-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/document-send-symbolic.svg</file>
<file alias="folder-sync.svg">3rdparty/breeze-icons/icons/actions/22/folder-sync.svg</file>
<file alias="go-next.svg">3rdparty/breeze-icons/icons/actions/22/go-next.svg</file>
<file alias="go-previous.svg">3rdparty/breeze-icons/icons/actions/22/go-previous.svg</file>
<file alias="go-next-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/go-next-symbolic.svg</file>
<file alias="go-previous-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/go-previous-symbolic.svg</file>
<file alias="go-up.svg">3rdparty/breeze-icons/icons/actions/22/go-up.svg</file>
<file alias="handle-left.svg">3rdparty/breeze-icons/icons/actions/22/handle-left.svg</file>
<file alias="handle-right.svg">3rdparty/breeze-icons/icons/actions/22/handle-right.svg</file>
......@@ -20,10 +20,26 @@
<file alias="overflow-menu.svg">3rdparty/breeze-icons/icons/actions/22/overflow-menu.svg</file>
<file alias="system-shutdown.svg">3rdparty/breeze-icons/icons/actions/22/system-shutdown.svg</file>
<file alias="view-list-icons.svg">3rdparty/breeze-icons/icons/actions/22/view-list-icons.svg</file>
</qresource>
<qresource prefix="/icons/breeze/actions/16">
<file alias="document-send.svg">3rdparty/breeze-icons/icons/actions/16/document-send.svg</file>
</qresource>
<qresource prefix="/icons/breeze/actions/symbolic">
<file alias="document-send-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/document-send-symbolic.svg</file>
<file alias="go-next-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/go-next-symbolic.svg</file>
<file alias="go-previous-symbolic.svg">3rdparty/breeze-icons/icons/actions/symbolic/go-previous-symbolic.svg</file>
</qresource>
<qresource prefix="/icons/breeze/mimetypes/64">
<file alias="image-jpeg.svg">3rdparty/breeze-icons/icons/mimetypes/64/image-jpeg.svg</file>
<file alias="video-mp4.svg">3rdparty/breeze-icons/icons/mimetypes/64/video-mp4.svg</file>
<file alias="x-office-document.svg">3rdparty/breeze-icons/icons/mimetypes/64/x-office-document.svg</file>
<file alias="audio-mp3.svg">3rdparty/breeze-icons/icons/mimetypes/64/audio-mp3.svg</file>
</qresource>
<qresource prefix="/icons/breeze/mimetypes/22">
<file alias="text-x-plain.svg">3rdparty/breeze-icons/icons/mimetypes/22/text-x-plain.svg</file>
</qresource>
</RCC>
<?xml version="1.0"?>
<manifest package="org.kaidanim.kaidan" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="0.4.0-dev" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --" android:icon="@mipmap/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="unspecified" android:launchMode="singleTop">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="Kaidan" android:icon="@mipmap/icon">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="Kaidan" android:screenOrientation="unspecified" android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
......
......@@ -38,6 +38,8 @@
#include <QQmlContext>
#include <QTranslator>
#include <QLibraryInfo>
#include <QIcon>
// gloox
#include <gloox/presence.h>
// Kaidan
......@@ -55,8 +57,10 @@
#endif
#include QT_STRINGIFY(QAPPLICATION_CLASS)
#ifndef Q_OS_ANDROID
// SingleApplication (Qt5 replacement for QtSingleApplication)
#include "singleapp/singleapplication.h"
#endif
#ifdef QMAKE_BUILD
#include "./3rdparty/kirigami/src/kirigamiplugin.h"
......@@ -117,9 +121,6 @@ int main(int argc, char *argv[])
qputenv("QT_QUICK_CONTROLS_MOBILE", "true");
#endif
// create a qt app
SingleApplication app(argc, argv, true);
// name, display name, description
QGuiApplication::setApplicationName(APPLICATION_NAME);
QGuiApplication::setApplicationDisplayName(APPLICATION_DISPLAY_NAME);
......@@ -127,6 +128,13 @@ int main(int argc, char *argv[])
// attributes
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
// create a qt app
#ifdef Q_OS_ANDROID
QGuiApplication app(argc, argv);
#else
SingleApplication app(argc, argv, true);
#endif
// register qMetaTypes
qRegisterMetaType<RosterModel*>("RosterModel*");
qRegisterMetaType<MessageModel*>("MessageModel*");
......@@ -176,6 +184,7 @@ int main(int argc, char *argv[])
break;
}
#ifndef Q_OS_ANDROID
// check if another instance already runs
if (app.isSecondary() && !parser.isSet("multiple")) {
qDebug().noquote() << QString("Another instance of %1 is already running.")
......@@ -187,6 +196,7 @@ int main(int argc, char *argv[])
app.sendMessage(parser.positionalArguments()[0].toUtf8());
return 0;
}
#endif
//
......@@ -195,19 +205,24 @@ int main(int argc, char *argv[])
Kaidan kaidan(&app, !parser.isSet("disable-xml-log"));
#ifndef Q_OS_ANDROID
// receive messages from other instances of Kaidan
kaidan.connect(&app, &SingleApplication::receivedMessage,
&kaidan, &Kaidan::receiveMessage);
#endif
// open the XMPP-URI/link (if given)
if (!parser.positionalArguments().isEmpty())
kaidan.addOpenUri(parser.positionalArguments()[0].toUtf8());
//
// QML-GUI
//
if (QIcon::themeName().isEmpty()) {
QIcon::setThemeName("breeze");
}
QQmlApplicationEngine engine;
#ifndef SAILFISH_OS
......
......@@ -34,7 +34,7 @@ import im.kaidan.kaidan 1.0
Kirigami.GlobalDrawer {
id: globalDrawer
title: "Kaidan"
titleIcon: "kaidan"
titleIcon: kaidan.getResourcePath("images/kaidan.svg");
bannerImageSource: kaidan.getResourcePath("images/banner.png");
// make drawer floating (overlay)
modal: true
......
#!/bin/bash
# NOTE: To use this script, you need to set ANDROID_NDK_ROOT to your NDK root folder.
if [ -z "$ANDROID_NDK_ROOT" ]; then
echo "ANDROID_NDK_ROOT has to be set"
exit 1
fi
KAIDAN_SOURCES=$(dirname "$(readlink -f "${0}")")/..
echo "*****************************************"
echo "Fetching Gloox and OpenSSL"
echo "*****************************************"
echo "Cloning Gloox from SVN"
svn co svn://svn.camaya.net/gloox/branches/1.0 /tmp/gloox
echo "Downloading OpenSSL release tarball"
wget https://www.openssl.org/source/openssl-1.0.2n.tar.gz -O /tmp/openssl.tar.gz --continue
echo "Extracting OpenSSL tarball"
mkdir /tmp/openssl
tar -xzvf /tmp/openssl.tar.gz -C /tmp/openssl --strip-components=1
echo "Fetching OpenSSL's Setenv-android.sh"
wget https://wiki.openssl.org/images/7/70/Setenv-android.sh -O /tmp/openssl/Setenv-android.sh --continue
dos2unix /tmp/openssl/Setenv-android.sh
sed -i 's/arm-linux-androideabi-4.8/arm-linux-androideabi-4.9/g' /tmp/openssl/Setenv-android.sh
sed -i 's/android-18/android-21/g' /tmp/openssl/Setenv-android.sh
chmod +x /tmp/openssl/Setenv-android.sh
echo "*****************************************"
echo "Preparing Android toolchain"
echo "*****************************************"
echo "ARM, API 21"
$ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py --arch arm --api 21 --install-dir /tmp/android-arm-toolchain
echo "*****************************************"
echo "Building OpenSSL"
echo "*****************************************"
{
cd /tmp/openssl/
source ./Setenv-android.sh
./config shared --openssldir=$KAIDAN_SOURCES/3rdparty/openssl/
make all -j$(nproc)
make install -j$(nproc)
}
echo "*****************************************"
echo "Building Gloox"
echo "*****************************************"
{
# Add the standalone toolchain to the search path.
export PATH=/tmp/android-arm-toolchain/bin:$PATH
# Tell configure what tools to use.
export target_host=arm-linux-androideabi
export AR=$target_host-ar
export AS=$target_host-clang
export CC=$target_host-clang
export CXX=$target_host-clang++
export LD=$target_host-ld
export STRIP=$target_host-strip
# Tell configure what flags Android requires.
export CFLAGS="-fPIE -fPIC"
export LDFLAGS="-pie"
cd /tmp/gloox
./autogen.sh
./configure --host=arm --with-openssl=$KAIDAN_SOURCES/3rdparty/openssl/ --prefix=$KAIDAN_SOURCES/3rdparty/gloox/
make install -j$(nproc)
}
echo "*****************************************"
echo "Cleaning up"
echo "*****************************************"
rm -rf /tmp/gloox
rm -rf /tmp/openssl
rm -rf /tmp/android-arm-toolchain
rm /tmp/openssl.tar.gz
echo "*****************************************"
echo "Rendering logos"
echo "*****************************************"
rendersvg() {
inkscape -z -e $2 -w $3 -h $3 $1
optipng -quiet $2
}
mkdir -p \
$KAIDAN_SOURCES/misc/android/res/mipmap-ldpi \
$KAIDAN_SOURCES/misc/android/res/mipmap-mdpi \
$KAIDAN_SOURCES/misc/android/res/mipmap-hdpi \
$KAIDAN_SOURCES/misc/android/res/mipmap-xhdpi \
$KAIDAN_SOURCES/misc/android/res/mipmap-xxhdpi \
$KAIDAN_SOURCES/misc/android/res/mipmap-xxxhdpi
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-ldpi/icon.png 36
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-ldpi/logo.png 144
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-mdpi/icon.png 48
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-mdpi/logo.png 192
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-hdpi/icon.png 72
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-hdpi/logo.png 288
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-xhdpi/icon.png 96
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-xhdpi/logo.png 384
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-xxhdpi/icon.png 144
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-xxhdpi/logo.png 576
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-xxxhdpi/icon.png 192
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg $KAIDAN_SOURCES/misc/android/res/mipmap-xxxhdpi/logo.png 768
#!/bin/bash
# NOTE: To use this script, you need to set ANDROID_NDK_ROOT, ANDROID_SDK_ROOT
# and QT_ANDROID to your Qt for Android installation
if [ -z "$ANDROID_NDK_ROOT" ]; then
echo "ANDROID_NDK_ROOT has to be set"
exit 1
fi
if [ -z "$ANDROID_SDK_ROOT" ]; then
echo "ANDROID_SDK_ROOT has to be set"
exit 1
fi
if [ -z "$QT_ANDROID" ]; then
echo "QT_ANDROID has to be set"
exit 1
fi
KAIDAN_SOURCES=$(dirname "$(readlink -f "${0}")")/..
GLOOX_PATH=/tmp/gloox
OPENSSL_PATH=/tmp/openssl
OPENSSL_SETENV=$OPENSSL_PATH/Setenv-android.sh
CUSTOM_ANDROID_TOOLCHAIN=/tmp/android-arm-toolchain
ANDROID_API_VERSION=21
ANDROID_SDK_BUILD_TOOLS_REVISION=25.0.3
echo "*****************************************"
echo "Fetching dependencies if required"
echo "*****************************************"
if [ ! -d "$GLOOX_PATH" ]; then
echo "Cloning Gloox from SVN"
svn co svn://svn.camaya.net/gloox/branches/1.0 $GLOOX_PATH
fi
if [ ! -d "$OPENSSL_PATH" ]; then
echo "Cloning OpenSSL into $OPENSSL_PATH"
git clone --depth=1 git://git.openssl.org/openssl.git $OPENSSL_PATH
fi
if [ ! -f "$OPENSSL_SETENV" ]; then
echo "Fetching OpenSSL's Setenv-android.sh"
wget https://wiki.openssl.org/images/7/70/Setenv-android.sh -O $OPENSSL_SETENV --continue
dos2unix $OPENSSL_SETENV
sed -i 's/arm-linux-androideabi-4.8/arm-linux-androideabi-4.9/g' $OPENSSL_SETENV
sed -i 's/android-18/android-$ANDROID_API_VERSION/g' $OPENSSL_SETENV
chmod +x $OPENSSL_SETENV
fi
if [ ! -f "$KAIDAN_SOURCES/3rdparty/kirigami/.git" ] || [ ! -f "$KAIDAN_SOURCES/3rdparty/breeze-icons/.git" ]; then
echo "Cloning Kirigami and Breeze icons"
git submodule update --init
fi
if [ ! -d "$CUSTOM_ANDROID_TOOLCHAIN" ]; then
echo "*****************************************"
echo "Preparing Android toolchain"
echo "*****************************************"
echo "ARM, API $ANDROID_API_VERSION"
$ANDROID_NDK_ROOT/build/tools/make_standalone_toolchain.py --arch arm --api $ANDROID_API_VERSION --install-dir $CUSTOM_ANDROID_TOOLCHAIN
fi
if [ ! -f "$CUSTOM_ANDROID_TOOLCHAIN/lib/libssl.so" ]; then
echo "*****************************************"
echo "Building OpenSSL"
echo "*****************************************"
{
cd $OPENSSL_PATH
source ./Setenv-android.sh
export ANDROID_NDK=$ANDROID_NDK_ROOT
./Configure shared android-armeabi --prefix=$CUSTOM_ANDROID_TOOLCHAIN
make build_libs -j$(nproc) SHLIB_VERSION_NUMBER= SHLIB_EXT=.so
make install_sw SHLIB_VERSION_NUMBER= SHLIB_EXT=.so
}
fi
if [ ! -f "$CUSTOM_ANDROID_TOOLCHAIN/lib/libgloox.a" ]; then
echo "*****************************************"
echo "Building Gloox"
echo "*****************************************"
{
# Add the standalone toolchain to the search path.
export PATH=$CUSTOM_ANDROID_TOOLCHAIN/bin:$PATH
# Tell configure what tools to use.
export target_host=arm-linux-androideabi
export AR=$target_host-ar
export AS=$target_host-clang
export CC=$target_host-clang
export CXX=$target_host-clang++
export LD=$target_host-ld
export STRIP=$target_host-strip
# Tell configure what flags Android requires.
export CFLAGS="-fPIE -fPIC"
export LDFLAGS="-pie"
cd $GLOOX_PATH
./autogen.sh
./configure --host=arm --with-openssl=$CUSTOM_ANDROID_TOOLCHAIN --prefix=$CUSTOM_ANDROID_TOOLCHAIN
make -j$(nproc)
make install
}
fi
cdnew() {
if [ -d "$1" ]; then
rm -rf "$1"
fi
mkdir $1
cd $1
}
if [ ! -f "$CUSTOM_ANDROID_TOOLCHAIN/lib/libKF5Kirigami2.so" ]; then
echo "*****************************************"
echo "Building Kirigami"
echo "*****************************************"
{
cdnew $KAIDAN_SOURCES/3rdparty/kirigami/build
cmake .. \
-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \
-DECM_ADDITIONAL_FIND_ROOT_PATH=$QT_ANDROID \
-DCMAKE_PREFIX_PATH=$QT_ANDROID/ \
-DANDROID_NDK=$ANDROID_NDK_ROOT \
-DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \
-DANDROID_SDK_BUILD_TOOLS_REVISION=$ANDROID_SDK_BUILD_TOOLS_REVISION \
-DCMAKE_INSTALL_PREFIX=$CUSTOM_ANDROID_TOOLCHAIN
make -j$(nproc)
make install
rm -rf $KAIDAN_SOURCES/3rdparty/kirigami/build
}
fi
if [ ! -d "$KAIDAN_SOURCES/misc/android/res/mipmap-ldpi" ]; then
echo "*****************************************"
echo "Rendering logos"
echo "*****************************************"
rendersvg() {
inkscape -z -e $2 -w $3 -h $3 $1
optipng -quiet $2
}
androidlogo() {
mkdir $KAIDAN_SOURCES/misc/android/res/mipmap-$1
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg "$KAIDAN_SOURCES/misc/android/res/mipmap-$1/icon.png" $2
rendersvg $KAIDAN_SOURCES/misc/kaidan-small-margin.svg "$KAIDAN_SOURCES/misc/android/res/mipmap-$1/logo.png" $(( $2 * 4 ))
}
androidlogo ldpi 36
androidlogo mdpi 48
androidlogo hdpi 72
androidlogo xhdpi 96
androidlogo xxhdpi 144
androidlogo xxxhdpi 192
fi
echo "*****************************************"
echo "Building Kaidan"
echo "*****************************************"
{
cdnew $KAIDAN_SOURCES/build
cmake .. \
-DQTANDROID_EXPORTED_TARGET=kaidan -DECM_DIR=/usr/share/ECM/cmake \
-DCMAKE_TOOLCHAIN_FILE=/usr/share/ECM/toolchain/Android.cmake \
-DECM_ADDITIONAL_FIND_ROOT_PATH="$QT_ANDROID;$CUSTOM_ANDROID_TOOLCHAIN" \
-DCMAKE_PREFIX_PATH=$QT_ANDROID \
-DANDROID_NDK=$ANDROID_NDK_ROOT -DCMAKE_ANDROID_NDK=$ANDROID_NDK_ROOT \
-DANDROID_SDK_ROOT=$ANDROID_SDK_ROOT \
-DANDROID_SDK_BUILD_TOOLS_REVISION=$ANDROID_SDK_BUILD_TOOLS_REVISION \
-DCMAKE_INSTALL_PREFIX=$CUSTOM_ANDROID_TOOLCHAIN \
-DANDROID_APK_DIR=../misc/android \
-DKF5Kirigami2_DIR=$CUSTOM_ANDROID_TOOLCHAIN/lib/cmake/KF5Kirigami2 -DI18N=1
make create-apk-kaidan -j$(nproc)
}
if [ ! -z "$INSTALL" ]; then
echo "*****************************************"
echo "Installing to device"
echo "*****************************************"
cd $KAIDAN_SOURCES/build
make install-apk-kaidan
fi
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