Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into fix_uwp
Browse files Browse the repository at this point in the history
  • Loading branch information
BillyONeal committed Mar 19, 2019
2 parents b914ad9 + 355889b commit 7d2b63c
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 12 deletions.
47 changes: 36 additions & 11 deletions Build_android/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ set -e

DO_BOOST=1
DO_OPENSSL=1
DO_CMAKE=1
DO_CPPRESTSDK=1

BOOSTVER=1.65.1
OPENSSLVER=1.0.2k
BOOSTVER=1.69.0
OPENSSLVER=1.1.0j
CMAKEVER=3.14.0

API=15
STL=c++_static
STL=c++_shared

function usage {
echo "Usage: $0 [--skip-boost] [--skip-openssl] [--skip-cpprestsdk] [-h] [--ndk <android-ndk>]"
Expand All @@ -51,6 +53,9 @@ do
"--skip-openssl")
DO_OPENSSL=0
;;
"--skip-cmake")
DO_CMAKE=0
;;
"--skip-cpprestsdk")
DO_CPPRESTSDK=0
;;
Expand All @@ -59,6 +64,11 @@ do
DO_BOOST=1
BOOSTVER=$1
;;
"--cmake")
shift
DO_CMAKE=1
CMAKEVER=$1
;;
"--openssl")
shift
DO_OPENSSL=1
Expand Down Expand Up @@ -130,8 +140,8 @@ if [ "${DO_OPENSSL}" == "1" ]; then (
if [ ! -d "openssl" ]; then mkdir openssl; fi
cd openssl
cp -af "${DIR}/openssl/." .
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_GCC_VERSION=4.9 ANDROID_ABI=armeabi-v7a OPENSSL_PREFIX=armeabi-v7a OPENSSL_VERSION=$OPENSSLVER
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_GCC_VERSION=4.9 ANDROID_ABI=x86 OPENSSL_PREFIX=x86 OPENSSL_VERSION=$OPENSSLVER
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_ABI=armeabi-v7a OPENSSL_PREFIX=armeabi-v7a OPENSSL_VERSION=$OPENSSLVER -j $NCPU
make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_ABI=x86 OPENSSL_PREFIX=x86 OPENSSL_VERSION=$OPENSSLVER -j $NCPU
) fi

# -----
Expand All @@ -143,7 +153,7 @@ if [ "${DO_OPENSSL}" == "1" ]; then (
if [ "${DO_BOOST}" == "1" ]; then (
if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/moritz-wundke/Boost-for-Android; fi
cd Boost-for-Android
git checkout 84973078a3d7668067d422d4654696ef59ab9d6d
git checkout 1356b87fed389b4abf1ff671adec0b899877174b
PATH="$PATH:$NDK_DIR" \
CXXFLAGS="-std=gnu++11" \
./build-android.sh \
Expand All @@ -153,23 +163,38 @@ if [ "${DO_BOOST}" == "1" ]; then (
"${NDK_DIR}" || exit 1
) fi

# ------
# CMake
# ------
# We update CMake because the version included with Ubuntu is too old to handle Boost 1.69.

if [ "${DO_CMAKE}" == "1" ]; then (
if [ ! -d "cmake-${CMAKEVER}" ]; then wget https://github.com/Kitware/CMake/releases/download/v${CMAKEVER}/cmake-${CMAKEVER}-Linux-x86_64.sh; fi
chmod +x cmake-${CMAKEVER}-Linux-x86_64.sh
rm -rf cmake-${CMAKEVER}
mkdir cmake-${CMAKEVER}
cd cmake-${CMAKEVER}
../cmake-${CMAKEVER}-Linux-x86_64.sh --skip-license
) fi

# ----------
# casablanca
# ----------

if [ "${DO_CPPRESTSDK}" == "1" ]; then
# Use the builtin CMake toolchain configuration that comes with the NDK
function build_cpprestsdk { (
mkdir -p $1
cd $1
cmake "${DIR}/.." \
rm -rf $1
./cmake-${CMAKEVER}/bin/cmake \
-DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \
-DANDROID_NDK="${ANDROID_NDK}" \
-DANDROID_TOOLCHAIN=clang \
-DANDROID_ABI=$2 \
-DBOOST_VERSION="${BOOSTVER}" \
-DCMAKE_BUILD_TYPE=$3
make -j $NCPU
-DCMAKE_BUILD_TYPE=$3 \
-S "${DIR}/.." \
-B $1
make -j $NCPU -C $1
) }

# Build the cpprestsdk for each target configuration
Expand Down
76 changes: 76 additions & 0 deletions Build_android/openssl/openssl-1.1.0j.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
This patch applies several changes that enable OpenSSL 1.1.0g to be built
for Android using either Clang or GCC toolchains.

diff -Naur org/Configurations/10-main.conf mod/Configurations/10-main.conf
--- org/Configurations/10-main.conf 2017-11-02 07:29:01.000000000 -0700
+++ mod/Configurations/10-main.conf 2018-01-18 10:59:41.675138500 -0800
@@ -910,15 +910,27 @@
# systems are perfectly capable of executing binaries targeting
# Froyo. Keep in mind that in the nutshell Android builds are
# about JNI, i.e. shared libraries, not applications.
- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
+ cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")),
bin_cflags => "-pie",
},
+ "android-clang" => {
+ inherit_from => [ "linux-generic32" ],
+ cc => "clang",
+ cflags => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")),
+},
"android-x86" => {
inherit_from => [ "android", asm("x86_asm") ],
cflags => add(picker(release => "-fomit-frame-pointer")),
bn_ops => "BN_LLONG",
perlasm_scheme => "android",
},
+ "android-x86-clang" => {
+ inherit_from => [ "android-clang", asm("x86_asm") ],
+ cflags => add(picker(default => "-target i686-none-linux-android",
+ release => "-fomit-frame-pointer")),
+ bn_ops => "BN_LLONG",
+ perlasm_scheme => "android",
+ },
################################################################
# Contemporary Android applications can provide multiple JNI
# providers in .apk, targeting multiple architectures. Among
@@ -943,20 +955,38 @@
"android-armeabi" => {
inherit_from => [ "android", asm("armv4_asm") ],
},
+ "android-armeabi-clang" => {
+ inherit_from => [ "android-clang", asm("armv4_asm") ],
+ cflags => add("-target armv7-none-linux-androideabi"),
+ },
"android-mips" => {
inherit_from => [ "android", asm("mips32_asm") ],
perlasm_scheme => "o32",
},
-
+ "android-mips-clang" => {
+ inherit_from => [ "android-clang", asm("mips32_asm") ],
+ cflags => add("-target mipsel-none-linux-android"),
+ perlasm_scheme => "o32",
+ },
"android64" => {
inherit_from => [ "linux-generic64" ],
- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
+ cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")),
bin_cflags => "-pie",
},
+ "android64-clang" => {
+ inherit_from => [ "linux-generic64" ],
+ cc => "clang",
+ cflags => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")),
+ },
"android64-aarch64" => {
inherit_from => [ "android64", asm("aarch64_asm") ],
perlasm_scheme => "linux64",
},
+ "android64-aarch64-clang" => {
+ inherit_from => [ "android64-clang", asm("aarch64_asm") ],
+ cflags => add("-target aarch64-none-linux-android"),
+ perlasm_scheme => "linux64",
+ },

#### *BSD
"BSD-generic32" => {
4 changes: 3 additions & 1 deletion Release/cmake/cpprest_find_boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,14 @@ function(cpprest_find_boost)
endif()
elseif(ANDROID)
set(Boost_COMPILER "-clang")
if(ARM)
if(ANDROID_ABI STREQUAL "armeabi-v7a")
set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/armeabi-v7a" CACHE INTERNAL "")
set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/armeabi-v7a/lib" CACHE INTERNAL "")
set(Boost_ARCHITECTURE "-a32" CACHE INTERNAL "")
else()
set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/x86" CACHE INTERNAL "")
set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/x86/lib" CACHE INTERNAL "")
set(Boost_ARCHITECTURE "-x32" CACHE INTERNAL "")
endif()
cpprestsdk_find_boost_android_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS random system thread filesystem chrono atomic)
elseif(UNIX)
Expand Down

0 comments on commit 7d2b63c

Please sign in to comment.