...
 
Commits (19)
......@@ -28,3 +28,8 @@ GSYMS
BROWSE
*.kate-swp
/po/
/kf5/
/build-android/
/b/
/i/
/d/
SET(PREFIX_ext_exiv2 "${EXTPREFIX}" )
if (ANDROID)
ExternalProject_Add( ext_exiv2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/exiv2-0.26-trunk.tar.gz
URL_MD5 5399e3b570d7f9205f0e76d47582da4c
PATCH_COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/tzname.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/patch_mingw.patch
COMMAND ${PATCH_COMMAND} -p1 -i ${CMAKE_CURRENT_SOURCE_DIR}/disable_exiv_apps.diff
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
UPDATE_COMMAND ""
DEPENDS ext_iconv ext_expat
)
else()
ExternalProject_Add( ext_exiv2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/exiv2-0.26-trunk.tar.gz
......@@ -16,3 +36,4 @@ ExternalProject_Add( ext_exiv2
UPDATE_COMMAND ""
DEPENDS ext_iconv ext_expat
)
endif()
......@@ -14,6 +14,20 @@ ExternalProject_Add( ext_expat
DEPENDS ext_patch
)
elseif (ANDROID)
ExternalProject_Add( ext_expat
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/expat-2.1.0.tar.gz
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}
BUILD_COMMAND make
INSTALL_COMMAND make install
UPDATE_COMMAND ""
)
else()
ExternalProject_Add( ext_expat
......@@ -22,9 +36,9 @@ ExternalProject_Add( ext_expat
URL_MD5 dd7dab7a5fea97d2a6a43f511449b7cd
INSTALL_DIR ${PREFIX_ext_expat}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${PREFIX_ext_expat} ${GLOBAL_AUTOMAKE_PROFILE}
BUILD_COMMAND make
INSTALL_COMMAND make install
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${PREFIX_ext_expat} ${GLOBAL_AUTOMAKE_PROFILE}
BUILD_COMMAND make
INSTALL_COMMAND make install
UPDATE_COMMAND ""
......
......@@ -8,7 +8,8 @@ ExternalProject_Add( ext_gsl
URL http://files.kde.org/krita/build/dependencies/gsl-2.3.0.tar.gz
URL_MD5 7e0478f7c5e62696fef480b9a46f708c
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} -DGSL_SHARED=ON -DBUILD_TESTING=OFF
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}
UPDATE_COMMAND ""
)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -386,6 +386,7 @@
# Compiles the source code, runs the program and sets ${VAR} to 1 if the
# return value is equal to ${RESULT}.
macro(check_run_result SRC RESULT VAR)
+ if (NOT ANDROID)
set(SRC_FILE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c)
file(WRITE ${SRC_FILE} "${SRC}")
try_run(RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} ${SRC_FILE}
@@ -393,6 +394,9 @@
if (RUN_RESULT EQUAL ${RESULT})
set(${VAR} 1)
endif ()
+ else()
+ set(${VAR} 1)
+ endif()
endmacro()
# Check IEEE comparisons, whether "x != x" is true for NaNs.
......@@ -4,11 +4,11 @@ ExternalProject_Add( ext_lcms2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/lcms2-2.9.tar.gz
URL_MD5 8de1b7724f578d2995c8fdfa35c3ad0e
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
UPDATE_COMMAND ""
DEPENDS ext_patch
)
......@@ -17,11 +17,11 @@ ExternalProject_Add( ext_lcms2
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL http://files.kde.org/krita/build/dependencies/lcms2-2.9.tar.gz
URL_MD5 8de1b7724f578d2995c8fdfa35c3ad0e
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
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}
UPDATE_COMMAND ""
)
endif ()
......@@ -4,8 +4,10 @@ ExternalProject_Add( ext_png
URL http://files.kde.org/krita/build/dependencies/libpng-1.6.34.tar.gz
URL_MD5 03fbc5134830240104e96d3cda648e71
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
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}
UPDATE_COMMAND ""
)
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -194,7 +194,7 @@
include(CheckCSourceCompiles)
option(ld-version-script "Enable linker version script" ON)
-if(ld-version-script AND NOT APPLE)
+if(ld-version-script AND NOT APPLE AND NOT ANDROID)
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
SET(PREFIX_ext_quazip "${EXTPREFIX}" )
ExternalProject_Add( ext_quazip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/stachenov/quazip/archive/0.7.6.zip
URL_MD5 a3335649c34053385d8390dd1a6f1ca4
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}
UPDATE_COMMAND ""
DEPENDS ext_zlib
if (ANDROID)
ExternalProject_Add( ext_quazip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/stachenov/quazip/archive/0.7.6.zip
URL_MD5 a3335649c34053385d8390dd1a6f1ca4
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/
UPDATE_COMMAND ""
DEPENDS ext_zlib
)
else()
ExternalProject_Add( ext_quazip
DOWNLOAD_DIR ${EXTERNALS_DOWNLOAD_DIR}
URL https://github.com/stachenov/quazip/archive/0.7.6.zip
URL_MD5 a3335649c34053385d8390dd1a6f1ca4
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}
UPDATE_COMMAND ""
DEPENDS ext_zlib
)
endif()
......@@ -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}
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}
UPDATE_COMMAND ""
)
......
......@@ -247,6 +247,39 @@ endif(MINGW)
#########################
########################
# FIXME: Apparently there is no better way to do this in android toolchain
if(ANDROID)
set (Qt5_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5/)
set (Qt5Core_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Core/)
set (Qt5Gui_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Gui/)
set (Qt5Widgets_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Widgets/)
set (Qt5Xml_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Xml/)
set (Qt5Network_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Network/)
set (Qt5PrintSupport_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5PrintSupport/)
set (Qt5Svg_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Svg/)
set (Qt5Test_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Test/)
set (Qt5Concurrent_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Concurrent/)
set (Qt5Multimedia_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Multimedia/)
set (Qt5Qml_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Qml/)
set (Qt5Quick_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5Quick/)
set (Qt5QuickWidgets_DIR $ENV{QT_ANDROID}/lib/cmake/Qt5QuickWidgets/)
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)
set(KF5GuiAddons_DIR ${KF5_LIBRARIES}/cmake/KF5GuiAddons)
set(KF5ItemViews_DIR ${KF5_LIBRARIES}/cmake/KF5ItemViews)
set(KF5WindowSystem_DIR ${KF5_LIBRARIES}/cmake/KF5WindowSystem)
set(KF5ItemModels_DIR ${KF5_LIBRARIES}/cmake/KF5ItemModels)
set(KF5CoreAddons_DIR ${KF5_LIBRARIES}/cmake/KF5CoreAddons)
endif()
find_package(ECM 5.22 REQUIRED NOMODULE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(ECMOptionalAddSubdirectory)
......@@ -404,7 +437,7 @@ set_package_properties(Qt5QuickWidgets PROPERTIES
PURPOSE "Optionally used for the touch gui for Krita")
endif()
if (NOT WIN32 AND NOT APPLE)
if (NOT WIN32 AND NOT APPLE AND NOT ANDROID)
find_package(Qt5 ${MIN_QT_VERSION} REQUIRED X11Extras)
......@@ -521,7 +554,20 @@ if(WIN32)
endif()
# set custom krita plugin installdir
set(KRITA_PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/kritaplugins)
if (ANDROID)
# use default ABI
if (NOT ANDROID_ABI)
set (ANDROID_ABI armeabi-v7a)
endif()
set (ANDROID_SDK_ROOT $ENV{ANDROID_SDK_ROOT})
set (KRITA_PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR})
# set (DATA_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/assets)
else()
set (KRITA_PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/kritaplugins)
endif()
###########################
############################
......@@ -529,6 +575,42 @@ set(KRITA_PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/kritaplugins)
############################
###########################
if (ANDROID)
set (PNG_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/i/lib/libpng16.so)
set (PNG_PNG_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/i/include/libpng16)
set (LibExiv2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/i/lib/libexiv2.so)
set (LibExiv2_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/i/include/)
set (LCMS2_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/i/include)
set (LCMS2_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/i/lib/liblcms2.so)
set (QUAZIP_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/i/include/quazip5)
set (QUAZIP_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/i/lib/libquazip5.so)
set (Boost_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/i/${ANDROID_ABI}/include/boost-1_69)
set (Boost_LIBRARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/i/${ANDROID_ABI}/lib)
set (GSL_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/i/lib/libgsl.so)
set (GSL_CBLAS_LIBRARIES ${CMAKE_CURRENT_BINARY_DIR}/i/lib/libgslcblas.so)
set (GSL_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/i/include/)
set (GSL_CONFIG ${CMAKE_CURRENT_BINARY_DIR}/i/bin/gsl-config)
set (EXPAT_LIBRARY ${CMAKE_CURRENT_BINARY_DIR}/i/lib/libexpat.so)
# libraries to be used when bundling android apk
# FIXME: better way to do this?
list (APPEND ANDROID_EXTRA_LIBS ${PNG_LIBRARY}
${LibExiv2_LIBRARIES}
${QUAZIP_LIBRARIES}
${LCMS2_LIBRARIES}
${EXPAT_LIBRARY}
${KF5_LIBRARIES}/libKF5Completion.so
${KF5_LIBRARIES}/libKF5WindowSystem.so
${KF5_LIBRARIES}/libKF5WidgetsAddons.so
${KF5_LIBRARIES}/libKF5ItemViews.so
${KF5_LIBRARIES}/libKF5ItemModels.so
${KF5_LIBRARIES}/libKF5GuiAddons.so
${KF5_LIBRARIES}/libKF5I18n.so
${KF5_LIBRARIES}/libKF5CoreAddons.so
${KF5_LIBRARIES}/libKF5ConfigGui.so
${KF5_LIBRARIES}/libKF5ConfigCore.so)
endif()
find_package(PNG REQUIRED)
if (APPLE)
......@@ -549,6 +631,9 @@ set_package_properties(GSL PROPERTIES
PURPOSE "Required by Krita's Transform tool.")
macro_bool_to_01(GSL_FOUND HAVE_GSL)
configure_file(config-gsl.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-gsl.h )
if (GSL_FOUND)
list (APPEND ANDROID_EXTRA_LIBS ${GSL_LIBRARIES} ${GSL_CBLAS_LIBRARIES})
endif()
###########################
############################
......@@ -773,7 +858,7 @@ set_package_properties(Poppler PROPERTIES
##
## Test for quazip
##
##
find_package(QuaZip 0.6)
set_package_properties(QuaZip PROPERTIES
DESCRIPTION "A library for reading and writing zip files"
......@@ -836,3 +921,28 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/po OR EXISTS ${CMAKE_CURRENT_BINARY_DIR}/p
find_package(KF5I18n CONFIG REQUIRED)
ki18n_install(po)
endif()
if(DEFINED QTANDROID_EXPORTED_TARGET AND NOT TARGET "create-apk")
set (_CMAKE_ANDROID_DIR "${ECM_DIR}/../toolchain")
list(LENGTH QTANDROID_EXPORTED_TARGET targetsCount)
include(${_CMAKE_ANDROID_DIR}/ECMAndroidDeployQt.cmake)
math(EXPR last "${targetsCount}-1")
foreach(idx RANGE 0 ${last})
list(GET QTANDROID_EXPORTED_TARGET ${idx} exportedTarget)
list(GET ANDROID_APK_DIR ${idx} APK_DIR)
if(APK_DIR AND NOT EXISTS "${ANDROID_APK_DIR}/AndroidManifest.xml" AND IS_ABSOLUTE ANDROID_APK_DIR)
message(FATAL_ERROR "Cannot find ${APK_DIR}/AndroidManifest.xml according to ANDROID_APK_DIR. ${ANDROID_APK_DIR} ${exportedTarget}")
elseif(NOT APK_DIR)
get_filename_component(_qt5Core_install_prefix "${Qt5Core_DIR}/../../../" ABSOLUTE)
set(APK_DIR "${_qt5Core_install_prefix}/src/android/templates/")
endif()
ecm_androiddeployqt("${exportedTarget}" "${ECM_ADDITIONAL_FIND_ROOT_PATH}")
set_target_properties(create-apk-${exportedTarget} PROPERTIES ANDROID_APK_DIR "${APK_DIR}")
endforeach()
else()
message(STATUS "You can export a target by specifying -DQTANDROID_EXPORTED_TARGET=<targetname> and -DANDROID_APK_DIR=<paths>")
endif()
To build for Android the first thing to do is to read the README.md in
$KRITA_ROOT/3rdparty
1) Set the neccessary environment variables
```
KRITA_ROOT # project root directory
CMAKE_ANDROID_NDK
QT_ANDROID # example: /opt/Qt/5.12/android_armv7/
ANDROID_API_LEVEL # example: 21 (I used 28)
ANDROID_SDK_ROOT
PY_INCLUDE_PATH # python3 includes directory usually /usr/includes/python3.5/
PY_LIBRARY # python3 lib directory usually /usr/lib/python3.5/
```
2) Create three directories in build root(BUILD_ROOT): `d, i, b`
3) First we'll have to build kf5 dependencies which we use `kdesrc-build`
to do. So, run `$KRITA_ROOT/packaging/android/build_kf5.sh`.
4) `cd` to `$BUILD_ROOT/b` and run
```$KRITA_ROOT/packaging/android/build_ext.sh```
5) Now we have to build boost.
Run:
```$KRITA_ROOT/packaging/android/build_boost.sh```
This should build without any errors.
6) set `INSTALL_PREFIX` environment variable to install built binaries into
the directory.
(please create a new directory and use that as a location to install)
Then run `$KRITA_ROOT/packaging/android/configure_krita.sh`
```shell
$KRITA_ROOT/packaging/android/configure_krita.sh
```
7) If build is configured properly then run
```shell
make -j5
make install
```
ARM binary should be ready
8) Now to create APK, run and sit back as gradle can be really slow
```shell
make create-apk
```
Now if `adb` is in your PATH then run `make install-apk-krita`, if it is not
in your `PATH` you can add it or use this:
```shell
$ANDROID_SDK_ROOT/platform-tools/adb -d -r krita_build_apk/build/outputs/apk/debug/krita_build_apk-debug.apk
```
Now if the app crashes you can use `logcat`, to see the trace.
......@@ -64,7 +64,11 @@ set(krita_QRCS
qt5_add_resources(krita_SRCS ${krita_QRCS})
add_executable(krita ${krita_SRCS})
if (ANDROID)
add_library(krita SHARED ${krita_SRCS})
else()
add_executable(krita ${krita_SRCS})
endif()
target_link_libraries(krita
PRIVATE
kritaui
......
......@@ -74,7 +74,6 @@
#endif
#include <QLibrary>
#endif
#if defined HAVE_KCRASH
#include <kcrash.h>
#elif defined USE_DRMINGW
......@@ -131,9 +130,12 @@ void resetRotation()
}
} // namespace
#endif
#ifdef Q_OS_ANDROID
__attribute__ ((visibility ("default")))
#endif
extern "C" int main(int argc, char **argv)
{
// The global initialization of the random generator
qsrand(time(0));
bool runningInKDE = !qgetenv("KDE_FULL_SESSION").isEmpty();
......
......@@ -8,6 +8,10 @@ include_directories(
${CMAKE_BINARY_DIR}/libs/flake
)
if (ANDROID)
add_definitions(-DQT_OPENGL_ES_3)
endif()
add_subdirectory(styles)
add_subdirectory(tests)
......
......@@ -32,6 +32,10 @@ else()
set(__per_arch_circle_mask_generator_objs kis_brush_mask_applicator_factories.cpp)
endif()
if (GSL_FOUND)
include_directories(${GSL_INCLUDE_DIR})
endif()
set(kritaimage_LIB_SRCS
tiles3/kis_tile.cc
tiles3/kis_tile_data.cc
......
......@@ -51,6 +51,10 @@ KoJsonTrader::KoJsonTrader()
d.cd("../../../");
searchDirs << d;
#endif
#ifdef Q_OS_ANDROID
appDir.cdUp();
#endif
searchDirs << appDir;
// help plugin trader find installed plugins when run from uninstalled tests
#ifdef CMAKE_INSTALL_PREFIX
......@@ -75,6 +79,11 @@ KoJsonTrader::KoJsonTrader()
#endif
QDir libDir(info.absoluteFilePath());
#ifdef Q_OS_ANDROID
libDir.cd("arm");
m_pluginPath = libDir.absolutePath();
break;
#else
// on many systems this will be the actual lib dir (and krita subdir contains plugins)
if (libDir.cd("kritaplugins")) {
m_pluginPath = libDir.absolutePath();
......@@ -95,6 +104,7 @@ KoJsonTrader::KoJsonTrader()
if (!m_pluginPath.isEmpty()) {
break;
}
#endif
}
}
......@@ -121,7 +131,12 @@ QList<QPluginLoader *> KoJsonTrader::query(const QString &servicetype, const QSt
QDirIterator dirIter(m_pluginPath, QDirIterator::Subdirectories);
while (dirIter.hasNext()) {
dirIter.next();
#ifdef Q_OS_ANDROID
// files starting with lib_krita are plugins, it is needed because of the loading rules in NDK
if (dirIter.fileInfo().isFile() && dirIter.fileName().startsWith("lib_krita")) {
#else
if (dirIter.fileInfo().isFile() && dirIter.fileName().startsWith("krita") && !dirIter.fileName().endsWith(".debug")) {
#endif
debugPlugin << dirIter.fileName();
QPluginLoader *loader = new QPluginLoader(dirIter.filePath());
QJsonObject json = loader->metaData().value("MetaData").toObject();
......
......@@ -7,6 +7,10 @@ include_directories(SYSTEM
${EIGEN3_INCLUDE_DIR}
)
if (ANDROID)
add_definitions(-DQT_OPENGL_ES_3)
endif()
add_subdirectory(plugins)
set(kritaqml_SRCS
......
......@@ -7,6 +7,11 @@ include_directories(SYSTEM
${OCIO_INCLUDE_DIR}
)
if (ANDROID)
add_definitions(-DQT_OPENGL_ES_3)
add_definitions(-DHAS_ONLY_OPENGL_ES)
endif()
add_subdirectory( tests )
if (APPLE)
......@@ -335,7 +340,7 @@ set(kritaui_LIB_SRCS
canvas/kis_mirror_axis.cpp
kis_abstract_perspective_grid.cpp
KisApplication.cpp
KisAutoSaveRecoveryDialog.cpp
KisDetailsPane.cpp
......@@ -558,11 +563,16 @@ target_link_libraries(kritaui KF5::CoreAddons KF5::Completion KF5::I18n KF5::Ite
kritaimpex kritacolor kritaimage kritalibbrush kritawidgets kritawidgetutils ${PNG_LIBRARIES} LibExiv2::LibExiv2
)
if (ANDROID)
target_link_libraries(kritaui GLESv3)
target_link_libraries(kritaui Qt5::Gui)
endif()
if (HAVE_QT_MULTIMEDIA)
target_link_libraries(kritaui Qt5::Multimedia)
endif()
if (NOT WIN32 AND NOT APPLE)
if (NOT WIN32 AND NOT APPLE AND NOT ANDROID)
target_link_libraries(kritaui ${X11_X11_LIB}
${X11_Xinput_LIB}
${XCB_LIBRARIES})
......@@ -577,7 +587,7 @@ endif ()
target_link_libraries(kritaui ${OPENEXR_LIBRARIES})
# Add VSync disable workaround
if(NOT WIN32 AND NOT APPLE)
if(NOT WIN32 AND NOT APPLE AND NOT ANDROID)
target_link_libraries(kritaui ${CMAKE_DL_LIBS} Qt5::X11Extras)
endif()
......
......@@ -21,6 +21,10 @@
#include "KoConfig.h"
#ifdef HAS_ONLY_OPENGL_ES
#define GL_MULTISAMPLE 0x809D
#endif
#include <QPainter>
#include <QToolButton>
#include <QApplication>
......
......@@ -46,7 +46,7 @@
#include "KisOpenGLModeProber.h"
#include <KoColorModelStandardIds.h>
#ifndef Q_OS_MACOS
#if !defined(Q_OS_MACOS) && !defined(HAS_ONLY_OPENGL_ES)
#include <QOpenGLFunctions_2_1>
#endif
......@@ -104,7 +104,7 @@ public:
QVector3D vertices[6];
QVector2D texCoords[6];
#ifndef Q_OS_MACOS
#if !defined(Q_OS_MACOS) && !defined(HAS_ONLY_OPENGL_ES)
QOpenGLFunctions_2_1 *glFn201;
#endif
......@@ -267,7 +267,7 @@ void KisOpenGLCanvas2::initializeGL()
{
KisOpenGL::initializeContext(context());
initializeOpenGLFunctions();
#ifndef Q_OS_MACOS
#if !defined(Q_OS_MACOS) && !defined(HAS_ONLY_OPENGL_ES)
if (!KisOpenGL::hasOpenGLES()) {
d->glFn201 = context()->versionFunctions<QOpenGLFunctions_2_1>();
if (!d->glFn201) {
......@@ -439,6 +439,7 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
d->solidColorShader->setUniformValue(d->solidColorShader->location(Uniform::ModelViewProjection), modelMatrix);
if (!KisOpenGL::hasOpenGLES()) {
#ifndef HAS_ONLY_OPENGL_ES
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_COLOR_LOGIC_OP);
......@@ -448,7 +449,12 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
}
#else
glLogicOp(GL_XOR);
#endif
#endif // Q_OS_OSX
#else // HAS_ONLY_OPENGL_ES
KIS_ASSERT_X(false, "KisOpenGLCanvas2::paintToolOutline",
"Unexpected KisOpenGL::hasOpenGLES returned false");
#endif // HAS_ONLY_OPENGL_ES
} else {
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ONE_MINUS_DST_COLOR, GL_ZERO, GL_ONE, GL_ONE);
......@@ -494,7 +500,12 @@ void KisOpenGLCanvas2::paintToolOutline(const QPainterPath &path)
}
if (!KisOpenGL::hasOpenGLES()) {
#ifndef HAS_ONLY_OPENGL_ES
glDisable(GL_COLOR_LOGIC_OP);
#else
KIS_ASSERT_X(false, "KisOpenGLCanvas2::paintToolOutline",
"Unexpected KisOpenGL::hasOpenGLES returned false");
#endif
} else {
glDisable(GL_BLEND);
}
......
......@@ -18,7 +18,13 @@
#include "opengl/kis_opengl_image_textures.h"
#ifdef HAS_ONLY_OPENGL_ES
#include <qopengl.h>
#endif
#ifndef HAS_ONLY_OPENGL_ES
#include <QOpenGLFunctions>
#endif
#include <QOpenGLContext>
#include <QMessageBox>
......@@ -458,12 +464,18 @@ void initializeRGBA16FTextures(QOpenGLContext *ctx, KisGLTexturesInfo &texturesI
texturesInfo.internalFormat = GL_RGBA16F;
dbgUI << "Using half (GLES or GL3)";
} else if (ctx->hasExtension("GL_ARB_texture_float")) {
#ifndef HAS_ONLY_OPENGL_ES
texturesInfo.internalFormat = GL_RGBA16F_ARB;
dbgUI << "Using ARB half";
}
else if (ctx->hasExtension("GL_ATI_texture_float")) {
texturesInfo.internalFormat = GL_RGBA_FLOAT16_ATI;
dbgUI << "Using ATI half";
#else
KIS_ASSERT_X(false, "initializeRGBA16FTextures",
"Unexpected KisOpenGL::hasOpenGLES and \
KisOpenGL::hasOpenGL3 returned false");
#endif
}
bool haveBuiltInOpenExr = false;
......@@ -476,6 +488,7 @@ void initializeRGBA16FTextures(QOpenGLContext *ctx, KisGLTexturesInfo &texturesI
destinationColorDepthId = Float16BitsColorDepthID;
dbgUI << "Pixel type half (GLES or GL3)";
} else if (haveBuiltInOpenExr && ctx->hasExtension("GL_ARB_half_float_pixel")) {
#ifndef HAS_ONLY_OPENGL_ES
texturesInfo.type = GL_HALF_FLOAT_ARB;
destinationColorDepthId = Float16BitsColorDepthID;
dbgUI << "Pixel type half";
......@@ -483,6 +496,11 @@ void initializeRGBA16FTextures(QOpenGLContext *ctx, KisGLTexturesInfo &texturesI
texturesInfo.type = GL_FLOAT;
destinationColorDepthId = Float32BitsColorDepthID;
dbgUI << "Pixel type float";
#else
KIS_ASSERT_X(false, "KisOpenGLCanvas2::paintToolOutline",
"Unexpected KisOpenGL::hasOpenGLES and \
KisOpenGL::hasOpenGL3 returned false");
#endif
}
texturesInfo.format = GL_RGBA;
}
......@@ -494,9 +512,14 @@ void KisOpenGLImageTextures::updateTextureFormat()
if (!(m_image && ctx)) return;
if (!KisOpenGL::hasOpenGLES()) {
#ifndef HAS_ONLY_OPENGL_ES
m_texturesInfo.internalFormat = GL_RGBA8;
m_texturesInfo.type = GL_UNSIGNED_BYTE;
m_texturesInfo.format = GL_BGRA;
#else
KIS_ASSERT_X(false, "KisOpenGLImageTextures::updateTextureFormat",
"Unexpected KisOpenGL::hasOpenGLES returned false");
#endif
} else {
m_texturesInfo.internalFormat = GL_BGRA8_EXT;
m_texturesInfo.type = GL_UNSIGNED_BYTE;
......@@ -528,11 +551,17 @@ void KisOpenGLImageTextures::updateTextureFormat()
m_texturesInfo.internalFormat = GL_RGBA32F;
dbgUI << "Using float (GLES or GL3)";
} else if (ctx->hasExtension("GL_ARB_texture_float")) {
#ifndef HAS_ONLY_OPENGL_ES
m_texturesInfo.internalFormat = GL_RGBA32F_ARB;
dbgUI << "Using ARB float";
} else if (ctx->hasExtension("GL_ATI_texture_float")) {
m_texturesInfo.internalFormat = GL_RGBA_FLOAT32_ATI;
dbgUI << "Using ATI float";
#else
KIS_ASSERT_X(false, "KisOpenGLCanvas2::updateTextureFormat",
"Unexpected KisOpenGL::hasOpenGLES and \
KisOpenGL::hasOpenGL3 returned false");
#endif
}
m_texturesInfo.type = GL_FLOAT;
......@@ -540,6 +569,7 @@ void KisOpenGLImageTextures::updateTextureFormat()
destinationColorDepthId = Float32BitsColorDepthID;
}
else if (colorDepthId == Integer16BitsColorDepthID) {
#ifndef HAS_ONLY_OPENGL_ES
if (!KisOpenGL::hasOpenGLES()) {
m_texturesInfo.internalFormat = GL_RGBA16;
m_texturesInfo.type = GL_UNSIGNED_SHORT;
......@@ -547,17 +577,23 @@ void KisOpenGLImageTextures::updateTextureFormat()
destinationColorDepthId = Integer16BitsColorDepthID;
dbgUI << "Using 16 bits rgba";
}
#endif
// TODO: for ANGLE, see if we can convert to 16f to support 10-bit display
}
}
else {
// We will convert the colorspace to 16 bits rgba, instead of 8 bits
if (colorDepthId == Integer16BitsColorDepthID && !KisOpenGL::hasOpenGLES()) {
#ifndef HAS_ONLY_OPENGL_ES
m_texturesInfo.internalFormat = GL_RGBA16;
m_texturesInfo.type = GL_UNSIGNED_SHORT;
m_texturesInfo.format = GL_BGRA;
destinationColorDepthId = Integer16BitsColorDepthID;
dbgUI << "Using conversion to 16 bits rgba";
#else
KIS_ASSERT_X(false, "KisOpenGLCanvas2::updateTextureFormat",
"Unexpected KisOpenGL::hasOpenGLES returned false");
#endif
} else if (colorDepthId == Float16BitsColorDepthID && KisOpenGL::hasOpenGLES()) {
// TODO: try removing opengl es limit
initializeRGBA16FTextures(ctx, m_texturesInfo, destinationColorDepthId);
......
......@@ -115,8 +115,7 @@ protected:
* can be observed with a KoResourceServerObserver
*
* The \p Policy template parameter defines the way how the lifetime
* of a resource is handled. There are to predefined policies:
* of a resource is handled. There are two predefined policies:
*
* o PointerStoragePolicy --- usual pointers with ownership over
......
......@@ -127,10 +127,16 @@ QString getInstallationPrefix() {
appdir.setPath(correctedPath);
appdir.cdUp();
return appdir.canonicalPath();
#else
#ifdef Q_OS_ANDROID
// qApp->applicationDirPath() isn't writable and android system won't allow
// any files other than libraries
return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + "/";
#else
return qApp->applicationDirPath() + "/../";
#endif
#endif
#endif
}
class Q_DECL_HIDDEN KoResourcePaths::Private {
......
<?xml version='1.0' encoding='utf-8'?>
<manifest package="org.kde.krita" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto">
<application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="krita">
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:name="org.krita.android.MainActivity"
android:label="krita"
android:screenOrientation="unspecified"
android:launchMode="singleTop">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Application arguments -->
<!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ -->
<!-- Application arguments -->
<meta-data android:name="android.app.lib_name" android:value="krita"/>
<meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/>
<meta-data android:name="android.app.repository" android:value="default"/>
<meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/>
<meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/>
<!-- Deploy Qt libs as part of package -->
<meta-data android:name="android.app.bundle_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/>
<meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/>
<!-- Run with local libs -->
<meta-data android:name="android.app.use_local_qt_libs" android:value="1"/>
<meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/>
<meta-data android:name="android.app.load_local_libs" android:value="plugins/platforms/android/libqtforandroid.so:plugins/bearer/libqandroidbearer.so:plugins/mediaservice/libqtmedia_android.so"/>
<meta-data android:name="android.app.load_local_jars" android:value="jar/QtAndroid.jar:jar/QtAndroidBearer.jar:jar/QtMultimedia.jar"/>
<meta-data android:name="android.app.static_init_classes" android:value="org.qtproject.qt5.android.multimedia.QtMultimediaUtils"/>
<!-- Used to specify custom system library path to run with local system libs -->
<!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> -->
<!-- Messages maps -->
<meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/>
<meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/>
<meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/>
<!-- Messages maps -->
<!-- Splash screen -->
<!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ -->
<!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ -->
<!-- Splash screen -->
<!-- Background running -->
<!-- Warning: changing this value to true may cause unexpected crashes if the
application still try to draw after
"applicationStateChanged(Qt::ApplicationSuspended)"
signal is sent! -->
<meta-data android:name="android.app.background_running" android:value="false"/>
<!-- Background running -->
<!-- auto screen scale factor -->
<meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/>
<!-- auto screen scale factor -->
<!-- extract android style -->
<!-- available android:values :
* default - In most cases this will be the same as "full", but it can also be something else if needed, e.g., for compatibility reasons
* full - useful QWidget & Quick Controls 1 apps
* minimal - useful for Quick Controls 2 apps, it is much faster than "full"
* none - useful for apps that don't use any of the above Qt modules
-->
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>
<activity android:name="org.qtproject.qt5.android.bindings.QtActivity" />
</application>
<supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/>
<!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application.
Remove the comment if you do not require these default permissions. -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
</manifest>
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
}
}
repositories {
google()
jcenter()
}
apply plugin: 'com.android.application'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
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')
}
def installPrefix = System.getenv('INSTALL_PREFIX')
if (installPrefix == null) {
throw new GradleException('Please set INSTALL_PREFIX to the location where binaries are installed')
}
def libs = new File(installPrefix, 'lib')
if (!libs.exists()) {
throw new GradleException('Please run `make install` first')
}
}
}
// copy libs(plugins) which start with krita*.so and rename
// them to start with `lib_`
task copyLibs(type: Copy, dependsOn: configure) {
from "${System.getenv('INSTALL_PREFIX')}/lib"
into 'libs/armeabi-v7a'
rename ('^krita(.*).so$', 'lib_krita$1.so')
}
task copyAssets(type: Copy) {
from "${System.getenv('INSTALL_PREFIX')}/share/"
into 'assets'
}
copyLibs.dependsOn configure
android {
/*******************************************************
* The following variables:
* - androidBuildToolsVersion,
* - androidCompileSdkVersion
* - qt5AndroidDir - holds the path to qt android files
* needed to build any Qt application
* on Android.
*
* are defined in gradle.properties file. This file is
* updated by QtCreator and androiddeployqt tools.
* Changing them manually might break the compilation!
*******************************************************/
compileSdkVersion androidCompileSdkVersion.toInteger()
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = [qt5AndroidDir + '/src', 'src', 'java']
aidl.srcDirs = [qt5AndroidDir + '/src', 'src', 'aidl']
res.srcDirs = [qt5AndroidDir + '/res', 'res']
resources.srcDirs = ['src']
renderscript.srcDirs = ['src']
assets.srcDirs = ['assets']
jniLibs.srcDirs = ['libs', 'lib']
}
}
// This is needed because, gradle by default ignores hidden assets.
aaptOptions {
ignoreAssetsPattern "!.foajasoie"
}
lintOptions {
abortOnError false
}
defaultConfig {
targetSdkVersion 26
minSdkVersion 21
}
preBuild.dependsOn(copyLibs)
preBuild.dependsOn(copyAssets)
}
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
package org.krita.android;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.AssetManager;
import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Copies the default configurations from assets to INTERNAL_STORAGE
* on first run of the app.
*/
class ConfigsManager {
private final String LOG_TAG = "krita.ConfigsManager";
private final String FIRST_RUN_COOKIE = "ORG_KRITA_FIRST_RUN";
private Activity mActivity;
private boolean isFirstRun() {
return mActivity.getPreferences(Context.MODE_PRIVATE)
.getBoolean(FIRST_RUN_COOKIE, true);
}
private void setFirstRunCookie() {
SharedPreferences sharedPref = mActivity.getPreferences(Context.MODE_PRIVATE);
SharedPreferences.Editor editor = sharedPref.edit();
editor.putBoolean(FIRST_RUN_COOKIE, false);
editor.apply();
}
void handleAssets(Activity activity) {
mActivity = activity;
if (!isFirstRun()) {
return;
}
Log.d(LOG_TAG, mActivity.getFilesDir().getPath());
copyAssets();
setFirstRunCookie();
}
private void copyAssets() {
recurse("");
}
/**
* Recurse into directories
* Do not start path with `/` or end with `/`
* @param path relative path to asset
*/
private void recurse(String path) {
AssetManager assetManager = mActivity.getAssets();
String assets[];
try {
assets = assetManager.list(path);
if (assets == null) {
return;
}
// no assets inside, so a file
if (assets.length == 0) {
copyFile(path);
}
else {
for (String asset : assets) {
recurse(toPath(path, asset));
}
}
} catch (IOException ex) {
Log.e(LOG_TAG, "Could not access assets stream", ex);
}
}
/**
* Asset manager API doesn't like trailing `/` at the end and
* some other things so we need this for proper path
* @param args file names or directories
* @return sanitized path
*/
private String toPath(String... args) {
StringBuilder result = new StringBuilder();
for (String item: args) {
if (!item.isEmpty()) {
if (result.length() != 0 && result.charAt(result.length() - 1) != '/') {
result.append('/');
}
result.append(item);
if (item.charAt(item.length() - 1) != '/') {
result.append('/');
}
}
}
// if last character is '/', then delete it
if (result.charAt(result.length() - 1) == '/') {
result.deleteCharAt(result.length() - 1);
}
return result.toString();
}
private void copyFile(String name) throws IOException {
InputStream in = null;
OutputStream out = null;
try {
in = mActivity.getAssets().open(name);
String fileSavePath = toPath(mActivity.getFilesDir().getPath(), "/share/", name);
// use the same directory structure
File base = new File(basePath(fileSavePath));
if (!base.exists()) {
base.mkdirs();
}
out = new FileOutputStream(fileSavePath);
byte[] buffer = new byte[4 * 1024];
int read;
while ((read = in.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
}
catch (IOException e) {
Log.w(LOG_TAG, "Could not copy file: " + name, e);
}
finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
/**
* Returns base path for example, in /data/foo it would
* return /data
* @param path to be sanitized
* @return base path
*/
private String basePath(String path) {
for (int i = path.length() - 1; i >= 0; --i) {
if (path.charAt(i) == '/') {
return path.substring(0, i);
}
}
return "";
}
}
package org.krita.android;
import android.os.Bundle;
import android.view.WindowManager;
import org.qtproject.qt5.android.bindings.QtActivity;
public class MainActivity extends QtActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
new ConfigsManager().handleAssets(this);
}
}
#!/bin/sh
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
: ${BUILD_ROOT? "Built roott path must be set"}
CURDIR="$(pwd)"/
VERSION="1_69"
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 \
$CMAKE_ANDROID_NDK
cd $BUILD_ROOT/i/armeabi-v7a/lib
# possible only because just one library is being used
mv libboost_system-clang-mt-a32-$VERSION.a libboost_system.a
#!/bin/sh
# See more: 3rdparty/README.md
# Build external dependencies in $KRITA_ROOT/3rdparty
# assuming in $KRITA_ROOT/b
: ${KRITA_ROOT?"Project root path must be set"}
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
: ${ANDROID_API_LEVEL?"Android API level is required"}
: ${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
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
# You can comment these and build them individually
cmake --build . --config RelWithDebInfo --target ext_png
cmake --build . --config RelWithDebInfo --target ext_zlib
cmake --build . --config RelWithDebInfo --target ext_quazip
cmake --build . --config RelWithDebInfo --target ext_lcms2
# this one SHOULD be built before exiv
cmake --build . --config RelWithDebInfo --target ext_expat
cmake --build . --config RelWithDebInfo --target ext_exiv2
cmake --build . --config RelWithDebInfo --target ext_gsl
<
#!/bin/bash
# parts used from KDE/KStars project
: ${QT_ANDROID?"Qt path must be set"}
: ${CMAKE_ANDROID_NDK?"Android NDK path must be set"}
: ${ANDROID_SDK_ROOT?"Android SDK path must be set"}
: ${ANDROID_API_LEVEL?"Android API level"}
: ${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
cd $BUILD_ROOT
CURDIR="$(pwd)"/
mkdir kf5
cd kf5
git clone git://anongit.kde.org/scratch/cordlandwehr/kdesrc-conf-android.git
mkdir -p extragear/kdesrc-build
git clone git://anongit.kde.org/kdesrc-build extragear/kdesrc-build
ln -s extragear/kdesrc-build/kdesrc-build kdesrc-build
ln -s kdesrc-conf-android/kdesrc-buildrc kdesrc-buildrc
# Change the build configuration
sed -E -i "s|build-dir.*|build-dir $CURDIR/kf5/kde/build/${android_architecture} |g" kdesrc-conf-android/kdesrc-buildrc
sed -E -i "s|source-dir.*|source-dir $CURDIR/kf5/kde/src |g" kdesrc-conf-android/kdesrc-buildrc
sed -E -i "s|kdedir.*|kdedir $CURDIR/kf5/kde/install/${android_architecture} |g" kdesrc-conf-android/kdesrc-buildrc
sed -i -- 's/make-options -j8/make-options -j4 VERBOSE=1/g' kdesrc-conf-android/kdesrc-buildrc