From c74f0510cec174d550ac18866ec3c88ef03cf54e Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 16 Jan 2017 14:57:28 +0100 Subject: [PATCH 1/7] Updated android build scripts for OpenSSL 1.1 --- scripts/0001-64bit-architecture-support.patch | 26 ------------------- scripts/android-build-common.sh | 3 +++ scripts/android-build-openssl.sh | 5 ++-- scripts/android-build.conf | 5 +--- scripts/openssl-mips64.conf | 6 +++++ 5 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 scripts/0001-64bit-architecture-support.patch create mode 100644 scripts/openssl-mips64.conf diff --git a/scripts/0001-64bit-architecture-support.patch b/scripts/0001-64bit-architecture-support.patch deleted file mode 100644 index 255a796b7..000000000 --- a/scripts/0001-64bit-architecture-support.patch +++ /dev/null @@ -1,26 +0,0 @@ -From 6e9a00d9ac02c3b3adc0613798678eadb0c4dae5 Mon Sep 17 00:00:00 2001 -From: Armin Novak -Date: Thu, 2 Jun 2016 13:55:27 +0200 -Subject: [PATCH] 64bit architecture support. - ---- - Configure | 3 +++ - 1 file changed, 3 insertions(+) - -diff --git a/Configure b/Configure -index c98107a..fa20eca 100755 ---- a/Configure -+++ b/Configure -@@ -473,6 +473,9 @@ my %table=( - "android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", - "android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", - "android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", -+"android64", "gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib64 -m64 -DL_ENDIAN -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_UNROLL:${x86_64_asm}:android:dlfcn:linux-shared:-fPIC:-m64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", -+"android64-aarch64","gcc:-march=armv8-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", -+"android64-mips64","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib64 -mabi=64 -O3 -Wall -DBN_DIV3W::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC:-mabi=64:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR):::64", - - #### *BSD [do see comment about ${BSDthreads} above!] - "BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", --- -2.1.4 - diff --git a/scripts/android-build-common.sh b/scripts/android-build-common.sh index 0945877d6..77313184a 100644 --- a/scripts/android-build-common.sh +++ b/scripts/android-build-common.sh @@ -1,5 +1,8 @@ #!/bin/bash +SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}") +SCRIPT_PATH=$(realpath "$SCRIPT_PATH") + if [ -z $BUILD_ARCH ]; then BUILD_ARCH="armeabi armeabi-v7a mips mips64 x86 x86_64 arm64-v8a" fi diff --git a/scripts/android-build-openssl.sh b/scripts/android-build-openssl.sh index e94b4e586..709c3df37 100755 --- a/scripts/android-build-openssl.sh +++ b/scripts/android-build-openssl.sh @@ -45,9 +45,8 @@ function build { BASE=$(pwd) DST_DIR=$BUILD_DST/$DST_PREFIX common_run cd $BUILD_SRC - common_run git am $(dirname "${BASH_SOURCE[0]}")/0001-64bit-architecture-support.patch common_run git clean -xdf - common_run ./Configure --openssldir=$DST_DIR $CONFIG shared + common_run ./Configure --config=$SCRIPT_PATH/openssl-mips64.conf --openssldir=$DST_DIR $CONFIG shared common_run make CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" depend common_run make CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" build_libs @@ -77,7 +76,7 @@ do $ARCH "arm-linux-androideabi-" "arch-arm" ;; "armeabi-v7a") - build "android-armv7" "arm-linux-androideabi-" \ + build "android-armeabi" "arm-linux-androideabi-" \ $ARCH "arm-linux-androideabi-" "arch-arm" ;; "mips") diff --git a/scripts/android-build.conf b/scripts/android-build.conf index 82669b572..4d9260613 100644 --- a/scripts/android-build.conf +++ b/scripts/android-build.conf @@ -9,9 +9,6 @@ # If you require support for older NDK API levels, # create seperate configurations for each NDK API level # and architecture you want to support. -SCRIPT_PATH=$(dirname "${BASH_SOURCE[0]}") -SCRIPT_PATH=$(realpath "$SCRIPT_PATH") - WITH_JPEG=0 WITH_OPENH264=0 WITH_OPENSSL=1 @@ -21,7 +18,7 @@ NDK_TARGET=21 JPEG_TAG=master OPENH264_TAG=v1.6.0 -OPENSSL_TAG=OpenSSL_1_0_2h +OPENSSL_TAG=OpenSSL_1_1_0c SRC_DIR=$SCRIPT_PATH/.. BUILD_DST=$SCRIPT_PATH/../client/Android/Studio/freeRDPCore/src/main/jniLibs diff --git a/scripts/openssl-mips64.conf b/scripts/openssl-mips64.conf new file mode 100644 index 000000000..b3c612c51 --- /dev/null +++ b/scripts/openssl-mips64.conf @@ -0,0 +1,6 @@ +%targets = ( +"android64-mips64" => { + inherit_from => [ "android64" ], + }, +); + From 62544e0b8a35f7e604f2b7d49f9d38a66ab2da02 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 16 Jan 2017 15:23:11 +0100 Subject: [PATCH 2/7] Added android release build configurations. --- docs/README.android | 9 +++++++++ scripts/android-build-32.conf | 29 +++++++++++++++++++++++++++++ scripts/android-build-64.conf | 29 +++++++++++++++++++++++++++++ scripts/android-build.conf | 2 +- 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 scripts/android-build-32.conf create mode 100644 scripts/android-build-64.conf diff --git a/docs/README.android b/docs/README.android index 02312d513..1e4ff67dc 100644 --- a/docs/README.android +++ b/docs/README.android @@ -45,6 +45,15 @@ Currently the default script builds for: When the script is finished the libraries are ready for android studio to be picked up in client/Android/Studio/freeRDPCore/src/main/jniLibs +The default configuration build configuration can be found in +./scripts/android-build.conf and is configured to provide debug builds. +They are limited to API level 21 and above. + +If release binaries (and old android API support) are required, build 32 bit architectures with +./scripts/android-build-freerdp.sh --ndk --sdk --conf ./scripts/android-build-32.conf +and 64 bit architectures with +./scripts/android-build-freerdp.sh --ndk --sdk --conf ./scripts/android-build-32.conf + Building the APK (Android Studio) ================ diff --git a/scripts/android-build-32.conf b/scripts/android-build-32.conf new file mode 100644 index 000000000..36e821e33 --- /dev/null +++ b/scripts/android-build-32.conf @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Android build confguration +# +# Note: This is a simple configuration to build all +# architectures in one rush. +# Since android 64 bit support was introduced with NDK API 21 +# this is the minimal common denominator. +# If you require support for older NDK API levels, +# create seperate configurations for each NDK API level +# and architecture you want to support. +WITH_JPEG=0 +WITH_OPENH264=1 +WITH_OPENSSL=1 +BUILD_DEPS=1 +DEPS_ONLY=0 +NDK_TARGET=14 + +JPEG_TAG=master +OPENH264_TAG=v1.6.0 +OPENSSL_TAG=OpenSSL_1_1_0c + +SRC_DIR=$SCRIPT_PATH/.. +BUILD_DST=$SCRIPT_PATH/../client/Android/Studio/freeRDPCore/src/main/jniLibs +BUILD_SRC=$SRC_DIR/build + +CMAKE_BUILD_TYPE=Release + +BUILD_ARCH="armeabi armeabi-v7a x86 mips" diff --git a/scripts/android-build-64.conf b/scripts/android-build-64.conf new file mode 100644 index 000000000..aafe72fe9 --- /dev/null +++ b/scripts/android-build-64.conf @@ -0,0 +1,29 @@ +#!/bin/bash +# +# Android build confguration +# +# Note: This is a simple configuration to build all +# architectures in one rush. +# Since android 64 bit support was introduced with NDK API 21 +# this is the minimal common denominator. +# If you require support for older NDK API levels, +# create seperate configurations for each NDK API level +# and architecture you want to support. +WITH_JPEG=0 +WITH_OPENH264=1 +WITH_OPENSSL=1 +BUILD_DEPS=1 +DEPS_ONLY=0 +NDK_TARGET=21 + +JPEG_TAG=master +OPENH264_TAG=v1.6.0 +OPENSSL_TAG=OpenSSL_1_1_0c + +SRC_DIR=$SCRIPT_PATH/.. +BUILD_DST=$SCRIPT_PATH/../client/Android/Studio/freeRDPCore/src/main/jniLibs +BUILD_SRC=$SRC_DIR/build + +CMAKE_BUILD_TYPE=Release + +BUILD_ARCH="arm64-v8a x86_64 mips64" diff --git a/scripts/android-build.conf b/scripts/android-build.conf index 4d9260613..510028e9b 100644 --- a/scripts/android-build.conf +++ b/scripts/android-build.conf @@ -10,7 +10,7 @@ # create seperate configurations for each NDK API level # and architecture you want to support. WITH_JPEG=0 -WITH_OPENH264=0 +WITH_OPENH264=1 WITH_OPENSSL=1 BUILD_DEPS=1 DEPS_ONLY=0 From 548927eb2ed88b93fc1ea0867af5dba893759607 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 16 Jan 2017 16:39:06 +0100 Subject: [PATCH 3/7] Renamed OpenSSL library To avoid collisions with system provided OpenSSL use a different (unique) library name for android builds. --- .../freerdp/freerdpcore/services/LibFreeRDP.java | 2 +- cmake/FindOpenSSL.cmake | 16 ++++++++++++---- scripts/android-build-openssl.sh | 5 ++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java index b06f75dcb..0670165e7 100644 --- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -28,7 +28,7 @@ public class LibFreeRDP { static { final String[] libraries = { - "openh264", "crypto", "ssl", "jpeg", "winpr", + "openh264", "freerdp-openssl", "jpeg", "winpr", "freerdp", "freerdp-client", "freerdp-android"}; final String LD_PATH = System.getProperty("java.library.path"); diff --git a/cmake/FindOpenSSL.cmake b/cmake/FindOpenSSL.cmake index e7ad8bfcf..d45657bdd 100644 --- a/cmake/FindOpenSSL.cmake +++ b/cmake/FindOpenSSL.cmake @@ -24,10 +24,10 @@ # (To distribute this file outside of CMake, substitute the full # License text for the above reference.) -if (UNIX) +if (UNIX AND NOT ANDROID) find_package(PkgConfig QUIET) pkg_check_modules(_OPENSSL QUIET openssl) -endif (UNIX) +endif (UNIX AND NOT ANDROID) # http://www.slproweb.com/products/Win32OpenSSL.html SET(_OPENSSL_ROOT_HINTS @@ -71,7 +71,15 @@ IF(WIN32) endif() ENDIF(WIN32) -IF(WIN32 AND NOT CYGWIN) +IF(ANDROID) + FIND_LIBRARY(OPENSSL_LIBRARIES + NAMES + "freerdp-openssl" + ${_OPENSSL_ROOT_HINTS_AND_PATHS} + PATH_SUFFIXES + "lib" + ) +ELSEIF(WIN32 AND NOT CYGWIN) # MINGW should go here too IF(MSVC) # /MD and /MDd are the standard values - if someone wants to use @@ -230,7 +238,7 @@ ELSE(WIN32 AND NOT CYGWIN) SET(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY}) -ENDIF(WIN32 AND NOT CYGWIN) +ENDIF(ANDROID) function(from_hex HEX DEC) string(TOUPPER "${HEX}" HEX) diff --git a/scripts/android-build-openssl.sh b/scripts/android-build-openssl.sh index 709c3df37..f23031eea 100755 --- a/scripts/android-build-openssl.sh +++ b/scripts/android-build-openssl.sh @@ -46,7 +46,7 @@ function build { DST_DIR=$BUILD_DST/$DST_PREFIX common_run cd $BUILD_SRC common_run git clean -xdf - common_run ./Configure --config=$SCRIPT_PATH/openssl-mips64.conf --openssldir=$DST_DIR $CONFIG shared + common_run ./Configure --config=$SCRIPT_PATH/openssl-mips64.conf --openssldir=$DST_DIR $CONFIG no-shared common_run make CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" depend common_run make CALC_VERSIONS="SHLIB_COMPAT=; SHLIB_SOVER=" build_libs @@ -55,8 +55,7 @@ function build { common_run mkdir -p $DST_DIR fi - common_run cp -L libssl.so $DST_DIR - common_run cp -L libcrypto.so $DST_DIR + common_run ${CROSS_COMPILE}gcc --sysroot=${CROSS_SYSROOT} -shared -o $DST_DIR/libfreerdp-openssl.so -Wl,-whole-archive libcrypto.a libssl.a -Wl,-no-whole-archive common_run cd $BASE } From 77a8821b1b7d244ae251b2ec81575e0009aca527 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 16 Jan 2017 16:40:06 +0100 Subject: [PATCH 4/7] Updated gradle settings. --- client/Android/Studio/aFreeRDP/build.gradle | 2 +- client/Android/Studio/build.gradle | 2 +- client/Android/Studio/freeRDPCore/build.gradle | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/client/Android/Studio/aFreeRDP/build.gradle b/client/Android/Studio/aFreeRDP/build.gradle index 65d4b4481..a28990d9c 100644 --- a/client/Android/Studio/aFreeRDP/build.gradle +++ b/client/Android/Studio/aFreeRDP/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 25 - buildToolsVersion "25.0.1" + buildToolsVersion "25.0.2" defaultConfig { applicationId "com.freerdp.afreerdp" diff --git a/client/Android/Studio/build.gradle b/client/Android/Studio/build.gradle index e7e3c60b0..2e3698033 100644 --- a/client/Android/Studio/build.gradle +++ b/client/Android/Studio/build.gradle @@ -4,7 +4,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:2.2.2' + classpath 'com.android.tools.build:gradle:2.2.3' } } diff --git a/client/Android/Studio/freeRDPCore/build.gradle b/client/Android/Studio/freeRDPCore/build.gradle index 0deda572e..db5d1f6e6 100644 --- a/client/Android/Studio/freeRDPCore/build.gradle +++ b/client/Android/Studio/freeRDPCore/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 25 - buildToolsVersion "25.0.1" + buildToolsVersion "25.0.2" defaultConfig { minSdkVersion 14 @@ -22,5 +22,5 @@ android { } dependencies { - compile 'com.android.support:appcompat-v7:25.0.1' + compile 'com.android.support:appcompat-v7:25.1.0' } From 6d93b92d64053ce25642c908168b6e083a2b25c3 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 16 Jan 2017 18:08:07 +0100 Subject: [PATCH 5/7] Updated library names after change in #3704 --- client/Android/CMakeLists.txt | 2 ++ .../java/com/freerdp/freerdpcore/services/LibFreeRDP.java | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/client/Android/CMakeLists.txt b/client/Android/CMakeLists.txt index cf62fddc5..7fcdb6354 100644 --- a/client/Android/CMakeLists.txt +++ b/client/Android/CMakeLists.txt @@ -48,5 +48,7 @@ set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} winpr freerdp freerdp-client) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} dl) set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} jnigraphics) +set_target_properties(${MODULE_NAME} PROPERTIES OUTPUT_NAME ${MODULE_NAME}${FREERDP_API_VERSION}) + target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS}) install(TARGETS ${MODULE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT libraries EXPORT AndroidTargets) diff --git a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java index 0670165e7..9e96075fe 100644 --- a/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java +++ b/client/Android/Studio/freeRDPCore/src/main/java/com/freerdp/freerdpcore/services/LibFreeRDP.java @@ -28,8 +28,8 @@ public class LibFreeRDP { static { final String[] libraries = { - "openh264", "freerdp-openssl", "jpeg", "winpr", - "freerdp", "freerdp-client", "freerdp-android"}; + "openh264", "freerdp-openssl", "jpeg", "winpr2", + "freerdp2", "freerdp-client2", "freerdp-android2"}; final String LD_PATH = System.getProperty("java.library.path"); for (String lib : libraries) { From 5be65ac76ecc14da0b67aaebbae9e68683635efd Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Tue, 17 Jan 2017 13:17:25 +0100 Subject: [PATCH 6/7] Fixed SONAME --- scripts/android-build-openssl.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/android-build-openssl.sh b/scripts/android-build-openssl.sh index f23031eea..de2c7474b 100755 --- a/scripts/android-build-openssl.sh +++ b/scripts/android-build-openssl.sh @@ -55,7 +55,8 @@ function build { common_run mkdir -p $DST_DIR fi - common_run ${CROSS_COMPILE}gcc --sysroot=${CROSS_SYSROOT} -shared -o $DST_DIR/libfreerdp-openssl.so -Wl,-whole-archive libcrypto.a libssl.a -Wl,-no-whole-archive + 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 cd $BASE } From 676871e0fde0e58834dd105c1182a7d6f3962425 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Wed, 18 Jan 2017 16:52:52 +0100 Subject: [PATCH 7/7] Disabled OpenH264 in default android build. --- scripts/android-build-32.conf | 2 +- scripts/android-build-64.conf | 2 +- scripts/android-build.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/android-build-32.conf b/scripts/android-build-32.conf index 36e821e33..c2c43d571 100644 --- a/scripts/android-build-32.conf +++ b/scripts/android-build-32.conf @@ -10,7 +10,7 @@ # create seperate configurations for each NDK API level # and architecture you want to support. WITH_JPEG=0 -WITH_OPENH264=1 +WITH_OPENH264=0 WITH_OPENSSL=1 BUILD_DEPS=1 DEPS_ONLY=0 diff --git a/scripts/android-build-64.conf b/scripts/android-build-64.conf index aafe72fe9..c7f6e81da 100644 --- a/scripts/android-build-64.conf +++ b/scripts/android-build-64.conf @@ -10,7 +10,7 @@ # create seperate configurations for each NDK API level # and architecture you want to support. WITH_JPEG=0 -WITH_OPENH264=1 +WITH_OPENH264=0 WITH_OPENSSL=1 BUILD_DEPS=1 DEPS_ONLY=0 diff --git a/scripts/android-build.conf b/scripts/android-build.conf index 510028e9b..4d9260613 100644 --- a/scripts/android-build.conf +++ b/scripts/android-build.conf @@ -10,7 +10,7 @@ # create seperate configurations for each NDK API level # and architecture you want to support. WITH_JPEG=0 -WITH_OPENH264=1 +WITH_OPENH264=0 WITH_OPENSSL=1 BUILD_DEPS=1 DEPS_ONLY=0