Android - add --with-zstd-includes and libs and build instructions.

Also reduce cut/paste in configure.ac around checking for files.

Change-Id: I33f789e99ed79f08cb9cfa5ed147b764332adfde
Signed-off-by: Michael Meeks <michael.meeks@collabora.com>
pull/5414/head
Michael Meeks 2022-10-10 20:49:59 +01:00 committed by Andras Timar
parent abc469466a
commit a8c449642e
4 changed files with 129 additions and 63 deletions

View File

@ -15,6 +15,27 @@ build the native parts on Windows.
Run ./autogen.sh && make
* Build zstd for Android
git clone https://android.googlesource.com/platform/external/zstd/ android-zstd
cd android-zstd
mkdir armabi-v7a
cd armabi-v7a
NDK_PATH=/opt/libreoffice/android-ndk-r20b
cmake \
-DCMAKE_TOOLCHAIN_FILE=${NDK_PATH}/build/cmake/android.toolchain.cmake \
-DANDROID_ABI=armeabi-v7a \
-DCMAKE_ANDROID_ARCH_ABI=armeabi-v7a \
-DANDROID_NDK=${NDK_PATH} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Android \
-DCMAKE_SYSTEM_VERSION=21 \
../build/cmake
make
* Build the POCO for Android
# clone the poco repository in the same folder where LibreOffice core and online folders are placed.
@ -125,7 +146,7 @@ build the native parts on Windows.
Don't forget to change --with-lo-builddir in the following:
./autogen.sh && ./configure CC=~/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang CXX=~/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ --host=arm-linux-androideabi --enable-androidapp --with-lo-builddir=/local/libreoffice/master-android --with-poco-includes=/opt/poco-android/include --with-poco-libs=/opt/poco-android/lib --disable-setcap --enable-silent-rules --enable-debug
./autogen.sh && ./configure CC=~/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang CXX=~/Android/Sdk/ndk-bundle/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang++ --host=arm-linux-androideabi --enable-androidapp --with-lo-builddir=/local/libreoffice/master-android --with-poco-includes=/opt/poco-android/include --with-poco-libs=/opt/poco-android/lib --with-zstd-includes=/opt/zstd-android/lib --with-zstd-libs=/opt/zstd-android/armabi-v7a/lib --disable-setcap --enable-silent-rules --enable-debug
* Build the JavaScript, HTML and CSS files also in the online-android folder

View File

@ -36,18 +36,26 @@ if(${ANDROID_ABI} STREQUAL "armeabi-v7a")
set(LOBUILDDIR_ABI @LOBUILDDIR@)
set(POCOINCLUDE_ABI @POCOINCLUDE@)
set(POCOLIB_ABI @POCOLIB@)
set(ZSTDINCLUDE_ABI @ZSTDINCLUDE@)
set(ZSTDLIB_ABI @ZSTDLIB@)
elseif(${ANDROID_ABI} STREQUAL "arm64-v8a")
set(LOBUILDDIR_ABI @LOBUILDDIR_ARM64_V8A@)
set(POCOINCLUDE_ABI @POCOINCLUDE_ARM64_V8A@)
set(POCOLIB_ABI @POCOLIB_ARM64_V8A@)
set(ZSTDINCLUDE_ABI @ZSTDINCLUDE_ARM64_V8A@)
set(ZSTDLIB_ABI @ZSTDLIB_ARM64_V8A@)
elseif(${ANDROID_ABI} STREQUAL "x86")
set(LOBUILDDIR_ABI @LOBUILDDIR_X86@)
set(POCOINCLUDE_ABI @POCOINCLUDE_X86@)
set(POCOLIB_ABI @POCOLIB_X86@)
set(ZSTDINCLUDE_ABI @ZSTDINCLUDE_X86@)
set(ZSTDLIB_ABI @ZSTDLIB_X86@)
elseif(${ANDROID_ABI} STREQUAL "x86_64")
set(LOBUILDDIR_ABI @LOBUILDDIR_X86_64@)
set(POCOINCLUDE_ABI @POCOINCLUDE_X86_64@)
set(POCOLIB_ABI @POCOLIB_X86_64@)
set(ZSTDINCLUDE_ABI @ZSTDINCLUDE_X86_64@)
set(ZSTDLIB_ABI @ZSTDLIB_X86_64@)
else()
MESSAGE(FATAL_ERROR "Cannot build for ABI ${ANDROID_ABI}, please add support for that.")
endif()
@ -63,6 +71,7 @@ target_include_directories(androidapp PRIVATE
../../../../../net
../../../../../wsd
${POCOINCLUDE_ABI} # POCO
${ZSTDINCLUDE_ABI} # ZSTD
${LOBUILDDIR_ABI}/workdir/UnpackedTarball/libpng # libpng
${LOBUILDDIR_ABI}/include # LibreOfficeKit
)
@ -125,5 +134,6 @@ target_link_libraries(androidapp
${POCOLIB_ABI}/libPocoXML@POCODEBUG@.a
${POCOLIB_ABI}/libPocoJSON@POCODEBUG@.a
${POCOLIB_ABI}/libPocoFoundation@POCODEBUG@.a
${ZSTDLIB_ABI}/libzstd.a
"${CMAKE_CURRENT_SOURCE_DIR}/lib/${ANDROID_ABI}/liblo-native-code.so"
)

View File

@ -6673,7 +6673,7 @@ L.CanvasTileLayer = L.Layer.extend({
delta.length + ' vs. ' + (canvas.width * canvas.height * 4));
}
var len;
if (isKeyframe)
{
// FIXME: use zstd to de-compress directly into a Uint8ClampedArray
@ -6700,7 +6700,7 @@ L.CanvasTileLayer = L.Layer.extend({
// copy old data to work from:
var oldData = new Uint8ClampedArray(imgData.data);
var len = this._applyDeltaChunk(imgData, delta, oldData, canvas.width, canvas.height);
len = this._applyDeltaChunk(imgData, delta, oldData, canvas.width, canvas.height);
if (this._debugDeltas)
window.app.console.log('Applied chunk ' + i++ + ' of total size ' + delta.length +
' at stream offset ' + offset + ' size ' + len);

View File

@ -261,6 +261,18 @@ AC_ARG_WITH([poco-includes],
headers. If you are building for Android 64bit,
you need two, separated by a colon ':'.]))
AC_ARG_WITH([zstd-libs],
AS_HELP_STRING([--with-zstd-libs=<path>],
[Path to the directory containing libzstd.a
libraries. If you are building for Android 64bit,
you need two, separated by a colon ':'.]))
AC_ARG_WITH([zstd-includes],
AS_HELP_STRING([--with-zstd-includes=<path>],
[Path to the "include" directory with the zstd
headers. If you are building for Android 64bit,
you need two, separated by a colon ':'.]))
AC_ARG_WITH([poco-libs],
AS_HELP_STRING([--with-poco-libs=<path>],
[Path to the "lib" directory with the Poco
@ -477,6 +489,18 @@ if test "$enable_experimental" = "yes" ; then
fi
AC_SUBST(ENABLE_EXPERIMENTAL)
dnl check for a file at a path with an env-var with a given suffix
AC_DEFUN([CHK_FILE_VAR], dnl env-var, suffix, file-to-match, msg
[
if test -n "$[$1][$4]" -o "z[$4]" = "z"; then
if test -f "$[$1][$4]/[$2]"; then
AC_MSG_RESULT([$[$1]])
else
AC_MSG_ERROR([This is not a [$3] [$4] directory no: $[$1][$4]/[$2]])
fi
fi
]) dnl CHK_FILE_VAR
# macOS: When configuring for building the app itself, on macOS, we need these.
# But not when just configuring for building the JS on Linux, for copying over
# to the Mac.
@ -496,6 +520,16 @@ POCOLIB_ARM64_V8A=
POCOLIB_X86=
POCOLIB_X86_64=
POCODEBUG=
ZSTDINCLUDE=
ZSTDINCLUDE_ARM64_V8A=
ZSTDINCLUDE_X86=
ZSTDINCLUDE_X86_64=
ZSTDLIB=
ZSTDLIB_ARM64_V8A=
ZSTDLIB_X86=
ZSTDLIB_X86_64=
CORE_VERSION_HASH=""
if test \( "$enable_iosapp" = "yes" -a `uname -s` = "Darwin" \) -o \( "$enable_androidapp" = "yes" \); then
if test "$enable_androidapp" = "yes" ; then
@ -575,36 +609,11 @@ if test \( "$enable_iosapp" = "yes" -a `uname -s` = "Darwin" \) -o \( "$enable_a
fi
fi
# Sanity check
if test -f "$POCOINCLUDE/Poco/Poco.h"; then
AC_MSG_RESULT([$POCOINCLUDE])
else
AC_MSG_ERROR([This is not a Poco include directory: $POCOINCLUDE])
fi
if test -n "$POCOINCLUDE_ARM64_V8A" ; then
if test -f "$POCOINCLUDE_ARM64_V8A/Poco/Poco.h"; then
AC_MSG_RESULT([$POCOINCLUDE_ARM64_V8A])
else
AC_MSG_ERROR([This is not a Poco ARM64 include directory: $POCOINCLUDE_ARM64_V8A])
fi
fi
if test -n "$POCOINCLUDE_X86" ; then
if test -f "$POCOINCLUDE_X86/Poco/Poco.h"; then
AC_MSG_RESULT([$POCOINCLUDE_X86])
else
AC_MSG_ERROR([This is not a Poco x86 include directory: $POCOINCLUDE_X86])
fi
fi
if test -n "$POCOINCLUDE_X86_64" ; then
if test -f "$POCOINCLUDE_X86_64/Poco/Poco.h"; then
AC_MSG_RESULT([$POCOINCLUDE_X86_64])
else
AC_MSG_ERROR([This is not a Poco x86-64 include directory: $POCOINCLUDE_X86_64])
fi
fi
# Sanity checks
CHK_FILE_VAR(POCOINCLUDE,Poco/Poco.h,Poco include)
CHK_FILE_VAR(POCOINCLUDE,Poco/Poco.h,Poco include,_ARM64_V8A)
CHK_FILE_VAR(POCOINCLUDE,Poco/Poco.h,Poco include,_X64)
CHK_FILE_VAR(POCOINCLUDE,Poco/Poco.h,Poco include,_X86_64)
AC_MSG_CHECKING([for Poco lib directory to build against])
if test -z "$with_poco_libs"; then
@ -621,41 +630,53 @@ if test \( "$enable_iosapp" = "yes" -a `uname -s` = "Darwin" \) -o \( "$enable_a
fi
fi
# Sanity check
if test -f "$POCOLIB/libPocoFoundation.a"; then
AC_MSG_RESULT([$POCOLIB])
else
AC_MSG_ERROR([This is not a Poco lib directory: $POCOLIB])
fi
if test -n "$POCOLIB_ARM64_V8A" ; then
if test -f "$POCOLIB_ARM64_V8A/libPocoFoundation.a"; then
AC_MSG_RESULT([$POCOLIB_ARM64_V8A])
else
AC_MSG_ERROR([This is not a Poco ARM64 lib directory: $POCOLIB_ARM64_V8A])
fi
fi
if test -n "$POCOLIB_X86" ; then
if test -f "$POCOLIB_X86/libPocoFoundation.a"; then
AC_MSG_RESULT([$POCOLIB_X86])
else
AC_MSG_ERROR([This is not a Poco x86 lib directory: $POCOLIB_X86])
fi
fi
if test -n "$POCOLIB_X86_64" ; then
if test -f "$POCOLIB_X86_64/libPocoFoundation.a"; then
AC_MSG_RESULT([$POCOLIB_X86_64])
else
AC_MSG_ERROR([This is not a Poco x86-64 lib directory: $POCOLIB_X86_64])
fi
fi
# Sanity checks
CHK_FILE_VAR(POCOLIB,libPocoFoundation.a,Poco lib)
CHK_FILE_VAR(POCOLIB,libPocoFoundation.a,Poco lib,_ARM64_V8A)
CHK_FILE_VAR(POCOLIB,libPocoFoundation.a,Poco lib,_X64)
CHK_FILE_VAR(POCOLIB,libPocoFoundation.a,Poco lib,_X86_X64)
if test "$ENABLE_DEBUG" = "true" ; then
POCODEBUG=d
fi
AC_MSG_CHECKING([for zstd lib directory to build against])
if test -z "$with_zstd_libs"; then
AC_MSG_ERROR([You MUST use the --with-zstd-libs option when configuring the mobile app build tree.])
fi
ZSTDINCLUDE="$with_zstd_includes"
if test "$enable_androidapp" = "yes" ; then
if echo "$ZSTDINCLUDE" | grep -qs ':' ; then
ZSTDINCLUDE=`echo $with_zstd_includes | cut -d: -f1`
ZSTDINCLUDE_ARM64_V8A=`echo $with_zstd_includes | cut -d: -f2`
ZSTDINCLUDE_X86=`echo $with_zstd_includes | cut -d: -f3`
ZSTDINCLUDE_X86_64=`echo $with_zstd_includes | cut -d: -f4`
fi
fi
# Sanity checks
CHK_FILE_VAR(ZSTDINCLUDE,zstd.h,Zstd include)
CHK_FILE_VAR(ZSTDINCLUDE,zstd.h,Zstd include,_ARM64_V8A)
CHK_FILE_VAR(ZSTDINCLUDE,zstd.h,Zstd include,_X64)
CHK_FILE_VAR(ZSTDINCLUDE,zstd.h,Zstd include,_X86_64)
ZSTDLIB="$with_zstd_libs"
if test "$enable_androidapp" = "yes" ; then
if echo "$ZSTDLIB" | grep -qs ':' ; then
ZSTDLIB=`echo $with_zstd_libs | cut -d: -f1`
ZSTDLIB_ARM64_V8A=`echo $with_zstd_libs | cut -d: -f2`
ZSTDLIB_X86=`echo $with_zstd_libs | cut -d: -f3`
ZSTDLIB_X86_64=`echo $with_zstd_libs | cut -d: -f4`
fi
fi
CHK_FILE_VAR(ZSTDLIB,libzstd.a,Zstd lib)
CHK_FILE_VAR(ZSTDLIB,libzstd.a,Zstd lib,_ARM64_V8A)
CHK_FILE_VAR(ZSTDLIB,libzstd.a,Zstd lib,_X64)
CHK_FILE_VAR(ZSTDLIB,libzstd.a,Zstd lib,_X86_64)
fi
AC_SUBST(LOBUILDDIR)
AC_SUBST(ANDROID_ABI)
AC_SUBST(ANDROID_ABI_SPLIT)
@ -671,6 +692,14 @@ AC_SUBST(POCOLIB_ARM64_V8A)
AC_SUBST(POCOLIB_X86)
AC_SUBST(POCOLIB_X86_64)
AC_SUBST(POCODEBUG)
AC_SUBST(ZSTDINCLUDE)
AC_SUBST(ZSTDINCLUDE_ARM64_V8A)
AC_SUBST(ZSTDINCLUDE_X86)
AC_SUBST(ZSTDINCLUDE_X86_64)
AC_SUBST(ZSTDLIB)
AC_SUBST(ZSTDLIB_ARM64_V8A)
AC_SUBST(ZSTDLIB_X86)
AC_SUBST(ZSTDLIB_X86_64)
AC_SUBST([CORE_VERSION_HASH])
AC_DEFINE_UNQUOTED([CORE_VERSION_HASH],[["$CORE_VERSION_HASH"]],[LibreOffice core git hash if present])
@ -1046,6 +1075,12 @@ AS_IF([test -n "$with_poco_includes"],
AS_IF([test -n "$with_poco_libs"],
[LDFLAGS="$LDFLAGS -L${with_poco_libs}"])
AS_IF([test -n "$with_zstd_includes"],
[CPPFLAGS="$CPPFLAGS -isystem ${with_zstd_includes}"])
AS_IF([test -n "$with_zstd_libs"],
[LDFLAGS="$LDFLAGS -L${with_zstd_libs}"])
AS_IF([test -n "$LIBPNG_INCLUDES"],
[CPPFLAGS="$CPPFLAGS -isystem ${LIBPNG_INCLUDES}"])