Updated android build scripts for ci.

This commit is contained in:
akallabeth 2020-04-08 12:37:36 +02:00 committed by akallabeth
parent c367f65d42
commit f2d5cf2b41
12 changed files with 83 additions and 1747 deletions

View File

@ -615,7 +615,7 @@ if(ANDROID)
endif()
endif()
list (APPEND CMAKE_INCLUDE_PATH ${FREERDP_EXTERNAL_PATH}/include)
list (APPEND CMAKE_INCLUDE_PATH ${FREERDP_EXTERNAL_PATH}/${ANDROID_ABI}/include)
list (APPEND CMAKE_LIBRARY_PATH ${FREERDP_EXTERNAL_PATH}/${ANDROID_ABI}/ )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH )

View File

@ -1,5 +1,5 @@
message("PRELOADING android cache")
set(CMAKE_TOOLCHAIN_FILE "cmake/AndroidToolchain.cmake" CACHE PATH "ToolChain file")
set(CMAKE_TOOLCHAIN_FILE "$ANDROID_NDK/build/cmake/android.toolchain.cmake" CACHE PATH "ToolChain file")
set(WITH_SANITIZE_ADDRESS ON)
set(FREERDP_EXTERNAL_SSL_PATH $ENV{ANDROID_SSL_PATH} CACHE PATH "android ssl")
# ANDROID_NDK and ANDROID_SDK must be set as environment variable

File diff suppressed because it is too large Load Diff

View File

@ -72,13 +72,23 @@ IF(MSVC)
ENDIF(MSVC)
IF(ANDROID)
FIND_LIBRARY(OPENSSL_LIBRARIES
FIND_LIBRARY(SSL_LIBRARY
NAMES
"freerdp-openssl"
"ssl"
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
)
FIND_LIBRARY(CRYPTO_LIBRARY
NAMES
"crypto"
${_OPENSSL_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
"lib"
)
list(APPEND OPENSSL_LIBRARIES ${CRYPTO_LIBRARY} ${SSL_LIBRARY})
ELSEIF(WIN32 AND NOT CYGWIN)
# MINGW should go here too
IF(MSVC)

View File

@ -17,8 +17,8 @@ DEPS_ONLY=0
NDK_TARGET=14
JPEG_TAG=master
OPENH264_TAG=v1.7.0
OPENSSL_TAG=OpenSSL_1_1_0h
OPENH264_TAG=v1.8.0
OPENSSL_TAG=OpenSSL_1_1_1f
SRC_DIR=$SCRIPT_PATH/..
BUILD_DST=$SCRIPT_PATH/../client/Android/Studio/freeRDPCore/src/main/jniLibs

View File

@ -17,8 +17,8 @@ DEPS_ONLY=0
NDK_TARGET=21
JPEG_TAG=master
OPENH264_TAG=v1.7.0
OPENSSL_TAG=OpenSSL_1_1_0h
OPENH264_TAG=v1.8.0
OPENSSL_TAG=OpenSSL_1_1_1f
SRC_DIR=$SCRIPT_PATH/..
BUILD_DST=$SCRIPT_PATH/../client/Android/Studio/freeRDPCore/src/main/jniLibs

View File

@ -81,7 +81,7 @@ common_run mkdir -p $BUILD_SRC
CMAKE_CMD_ARGS="-DANDROID_NDK=$ANDROID_NDK \
-DANDROID_NATIVE_API_LEVEL=android-${NDK_TARGET} \
-DCMAKE_TOOLCHAIN_FILE=$SRC_DIR/cmake/AndroidToolchain.cmake \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DCMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE \
-DFREERDP_EXTERNAL_PATH=$BUILD_DST \
-DCMAKE_MAKE_PROGRAM=make"

View File

@ -17,7 +17,7 @@ function build {
common_run export QUIET_CCAR="$CCACHE "
common_run export QUIET_CXX="$CCACHE "
common_run $MAKE
common_run $MAKE -j
# Install creates a non optimal directory layout, fix that
common_run $MAKE PREFIX=$BUILD_SRC/libs/$1 install
common_run cd $BASE

View File

@ -8,54 +8,34 @@ COMPILER=4.9
source $(dirname "${BASH_SOURCE[0]}")/android-build-common.sh
function build {
if [ $# -ne 5 ];
if [ $# -ne 2 ];
then
echo "Invalid arguments $@"
exit 1
fi
CONFIG=$1
ARCH_PREFIX=$2
DST_PREFIX=$3
TOOLCHAIN_PREFIX=$4
PLATFORM_PREFIX=$5
DST_PREFIX=$2
TMP_DIR=$ANDROID_NDK/toolchains/$TOOLCHAIN_PREFIX$COMPILER/prebuilt/
HOST_PLATFORM=$(ls $TMP_DIR)
if [ ! -d $TMP_DIR$HOST_POLATFORM ];
then
echo "could not determine NDK host platform in $ANDROID_NDK/toolchains/$TOOLCHAIN_PREFIX$COMPILER/prebuilt/"
exit 1
fi
common_run export CROSS_SYSROOT=$ANDROID_NDK/platforms/android-$NDK_TARGET/$PLATFORM_PREFIX
common_run export ANDROID_DEV=$ANDROID_NDK/platforms/android-$NDK_TARGET/$PLATFORM_PREFIX/usr
common_run export CROSS_COMPILE="$CCACHE $ARCH_PREFIX"
common_run export PATH=$ANDROID_NDK/toolchains/$TOOLCHAIN_PREFIX$COMPILER/prebuilt/$HOST_PLATFORM/bin/:$ORG_PATH
common_run export CC=clang
common_run export PATH=$(${SCRIPT_PATH}/toolchains_path.py --ndk ${ANDROID_NDK}):$ORG_PATH
echo "CONFIG=$CONFIG"
echo "ARCH_PREFIX=$ARCH_PREFIX"
echo "DST_PREFIX=$DST_PREFIX"
echo "TOOLCHAIN_PREFIX=$TOOLCHAIN_PREFIX"
echo "PLATFORM_PREFIX=$PLATFORM_PREFIX"
echo "CROSS_SYSROOT=$CROSS_SYSROOT"
echo "CROSS_COMPILE=$CROSS_COMPILE"
echo "PATH=$PATH"
BASE=$(pwd)
DST_DIR=$BUILD_DST/$DST_PREFIX
common_run cd $BUILD_SRC
common_run ./Configure --config=$SCRIPT_PATH/openssl-mips64.conf --openssldir=$DST_DIR $CONFIG no-shared
common_run make CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" -j depend
common_run make CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" -j build_libs
common_run ./Configure ${CONFIG} -D__ANDROID_API__=$NDK_TARGET
common_run make SHLIB_EXT=.so -j build_libs
if [ ! -d $DST_DIR ];
then
common_run mkdir -p $DST_DIR
fi
SONAME=libfreerdp-openssl.so
common_run ${CROSS_COMPILE}gcc --sysroot=${CROSS_SYSROOT} -shared -fPIC -Wl,-soname,$SONAME -o $DST_DIR/$SONAME -Wl,-whole-archive libcrypto.a libssl.a -Wl,-no-whole-archive
common_run cp *.so $DST_DIR/
common_run cd $BASE
}
@ -69,33 +49,17 @@ for ARCH in $BUILD_ARCH
do
case $ARCH in
"armeabi")
build "android" "arm-linux-androideabi-" \
$ARCH "arm-linux-androideabi-" "arch-arm"
;;
"armeabi-v7a")
build "android-armeabi" "arm-linux-androideabi-" \
$ARCH "arm-linux-androideabi-" "arch-arm"
;;
"mips")
build "android-mips" "mipsel-linux-android-" \
$ARCH "mipsel-linux-android-" "arch-mips"
;;
"mips64")
build "android64-mips64" "mips64el-linux-android-" \
$ARCH "mips64el-linux-android-" "arch-mips64"
build "android-arm" "armeabi-v7a"
;;
"x86")
build "android-x86" "i686-linux-android-" \
$ARCH "x86-" "arch-x86"
build "android-x86" "x86"
;;
"arm64-v8a")
build "android64-aarch64" "aarch64-linux-android-" \
$ARCH "aarch64-linux-android-" "arch-arm64"
build "android-arm64" "arm64-v8a"
;;
"x86_64")
build "android64" "x86_64-linux-android-" \
$ARCH "x86_64-" "arch-x86_64"
build "android-x86_64" "x86_64"
;;
*)
echo "[WARNING] Skipping unsupported architecture $ARCH"

View File

@ -17,8 +17,8 @@ DEPS_ONLY=0
NDK_TARGET=26
JPEG_TAG=master
OPENH264_TAG=v1.7.0
OPENSSL_TAG=OpenSSL_1_1_0h
OPENH264_TAG=v1.8.0
OPENSSL_TAG=OpenSSL_1_1_1f
SRC_DIR=$SCRIPT_PATH/..
BUILD_DST=$SCRIPT_PATH/../client/Android/Studio/freeRDPCore/src/main/jniLibs

View File

@ -1,6 +0,0 @@
%targets = (
"android64-mips64" => {
inherit_from => [ "android64" ],
},
);

49
scripts/toolchains_path.py Executable file
View File

@ -0,0 +1,49 @@
#!/usr/bin/env python3
"""
Get the toolchains path
https://proandroiddev.com/tutorial-compile-openssl-to-1-1-1-for-android-application-87137968fee
"""
import argparse
import atexit
import inspect
import os
import shutil
import stat
import sys
import textwrap
def get_host_tag_or_die():
"""Return the host tag for this platform. Die if not supported."""
if sys.platform.startswith('linux'):
return 'linux-x86_64'
elif sys.platform == 'darwin':
return 'darwin-x86_64'
elif sys.platform == 'win32' or sys.platform == 'cygwin':
host_tag = 'windows-x86_64'
if not os.path.exists(os.path.join(NDK_DIR, 'prebuilt', host_tag)):
host_tag = 'windows'
return host_tag
sys.exit('Unsupported platform: ' + sys.platform)
def get_toolchain_path_or_die(ndk, host_tag):
"""Return the toolchain path or die."""
toolchain_path = os.path.join(ndk, 'toolchains/llvm/prebuilt',
host_tag, 'bin')
if not os.path.exists(toolchain_path):
sys.exit('Could not find toolchain: {}'.format(toolchain_path))
return toolchain_path
def main():
"""Program entry point."""
parser = argparse.ArgumentParser(description='Optional app description')
parser.add_argument('--ndk', required=True,
help='The NDK Home directory')
args = parser.parse_args()
host_tag = get_host_tag_or_die()
toolchain_path = get_toolchain_path_or_die(args.ndk, host_tag)
print(toolchain_path)
if __name__ == '__main__':
main()