Skip to content

Commit 58dfcfd

Browse files
author
Martin Schwamberger
committed
Merge branch 'master' of github.com:letsdev/lib-openssl
* 'master' of github.com:letsdev/lib-openssl: Update travis xcode version Android add -no-asm. Adjust patch files. Fix armeabi-v7a clang compiler Add patch files for each android arch. Remove armeabi architecture Fix connection Set xcode-10-1 File cleanup Renomve -no-asm flag. Activate all android architectures Fix clang, add asm include Simplified patch. Add host_tag method Fixed issue with sysroot. Added local patch. Fixed patch and path in build-android. android patch Update substidution. Set ios sdk 12.2 Set version 1.0.2s Update Jenkinsfile Update dockerfile to ndk19 Update travis xcode image Update travis deployment tag
2 parents 2245624 + f00153c commit 58dfcfd

13 files changed

Lines changed: 216 additions & 190 deletions

.travis.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ matrix:
55
services:
66
- docker
77
- os: osx
8-
osx_image: xcode10.0
8+
osx_image: xcode10.2
99

1010
env:
1111
- RELEASE_FILES=$TRAVIS_BUILD_DIR/target/*.zip
@@ -33,8 +33,13 @@ script:
3333
else
3434
mvn package -P ios
3535
fi
36+
- |
37+
if [ $TRAVIS_OS_NAME == "linux" ]; then
38+
export TRAVIS_TAG=$TRAVIS_TAG-Android
39+
else
40+
export TRAVIS_TAG=$TRAVIS_TAG-iOS
41+
fi
3642
37-
3843
before_deploy:
3944
- git config --local user.name "cwack"
4045
- git config --local user.email "christian.wack@letsdev.de"

Dockerfile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ubuntu:bionic-20180224
1+
FROM ubuntu:18.04
22

33
#SDK TOOLS 26.1.1
44
ENV ANDROID_SDK_HOME="/opt/android-sdk" \
@@ -52,16 +52,17 @@ RUN echo "************ Installing Build Tools ************" \
5252

5353
# CMake
5454
RUN echo "************ Installing C++ Support ************" \
55-
&& sdkmanager 'cmake;3.6.4111459'
55+
&& sdkmanager 'cmake;3.10.2.4988404'
5656

57+
ENV NDK_VERSION=19c
5758
# NDK
58-
RUN echo "************ Installing Android NDK 18b ************" \
59+
RUN echo "************ Installing Android NDK ${NDK_VERSION} ************" \
5960
&& wget --output-document=$HOME/ndk.zip -q \
60-
"https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.zip" \
61+
"https://dl.google.com/android/repository/android-ndk-r${NDK_VERSION}-linux-x86_64.zip" \
6162
&& mkdir -p $ANDROID_NDK_HOME \
6263
&& unzip -q $HOME/ndk.zip -d $ANDROID_NDK_HOME \
63-
&& mv $ANDROID_NDK_HOME/android-ndk-r18b/* $ANDROID_NDK_HOME \
64-
&& rm -f $HOME/ndk.zip && rm -d $ANDROID_NDK_HOME/android-ndk-r18b
64+
&& mv $ANDROID_NDK_HOME/android-ndk-r${NDK_VERSION}/* $ANDROID_NDK_HOME \
65+
&& rm -f $HOME/ndk.zip && rm -d $ANDROID_NDK_HOME/android-ndk-r${NDK_VERSION}
6566

6667
RUN useradd build -m -u 112
6768
USER build

Jenkinsfile

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,41 +10,38 @@ node('docker') {
1010
dockerImage = docker.build('openssl')
1111
}
1212

13-
def options = """
14-
-v $WORKSPACE:/home/build/app
15-
-v $HOME/.m2:/home/build/.m2
16-
-v $HOME/.gitconfig:/home/build/.gitconfig
17-
-v $HOME/ld-config:/home/build/ld-config
13+
GString options = """
14+
-v ${env.WORKSPACE}:/home/build/app
15+
-v ${env.HOME}/.m2:/home/build/.m2
16+
-v ${env.HOME}/.gitconfig:/home/build/.gitconfig
17+
-v ${env.HOME}/ld-config:/home/build/ld-config
1818
"""
1919
def pom = readMavenPom file: 'pom.xml'
2020
def VERSION = pom.version
2121

2222
parallel(
23-
failFast: true,
24-
android: {
25-
stage('android') {
26-
dockerImage.inside(options) {
27-
sh 'chmod a+x ./*.sh'
28-
sh "./build-android.sh ${VERSION}"
29-
sh 'mvn deploy -P android'
23+
failFast: true,
24+
android: {
25+
stage('android') {
26+
dockerImage.inside(options) {
27+
sh "./build-android.sh ${VERSION}"
28+
sh 'mvn deploy -P android'
29+
}
3030
}
31-
}
32-
},
33-
ios: {
34-
stage('ios') {
35-
node('ios') {
36-
deleteDir()
37-
checkout scm
38-
sh 'chmod a+x ./*.sh'
39-
sh "./build-ios.sh ${VERSION}"
40-
sh 'mvn deploy -P ios'
31+
},
32+
ios: {
33+
stage('xcode-10-1') {
34+
node('ios') {
35+
deleteDir()
36+
checkout scm
37+
sh "./build-ios.sh ${VERSION}"
38+
sh 'mvn deploy -P ios'
39+
}
4140
}
4241
}
43-
}
4442
)
4543

4644
stage('tag') {
47-
de.letsdev.git.LdGit ldGit = new de.letsdev.git.LdGit()
48-
ldGit.pushTag(VERSION)
45+
tagPush(VERSION)
4946
}
5047
}

build-android.sh

100644100755
Lines changed: 86 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22
set -e
33

44
VERSION=$1
55

6-
if [ -z $VERSION ]; then
6+
if [[ -z ${VERSION} ]]; then
77
echo "Missing VERSION as first parameter"
88
exit 99
99
fi
@@ -15,13 +15,14 @@ download_openssl
1515
## Parameters
1616
## --------------------
1717

18-
ANDROID_SDK=21
18+
ANDROID_SDK=28
19+
ANDROID_MIN_SDK=21
1920

2021
## --------------------
2122
## Variables
2223
## --------------------
2324

24-
if [ ! -d "${ANDROID_NDK_HOME}" ]; then
25+
if [[ ! -d "${ANDROID_NDK_HOME}" ]]; then
2526
echo "ANDROID_NDK_HOME not defined or directory does not exist"
2627
exit 1
2728
fi
@@ -49,14 +50,14 @@ function clear_android_env {
4950
}
5051

5152
function build_android_arch {
52-
log_title "$1"
53-
if [ -z $1 ]; then
53+
log_title "${1}"
54+
if [[ -z $1 ]]; then
5455
echo 'no ABI set'
5556
exit 1
56-
elif [ -z $2 ]; then
57+
elif [[ -z $2 ]]; then
5758
echo 'no ARCH set'
5859
exit 1
59-
elif [ -z $3 ]; then
60+
elif [[ -z $3 ]]; then
6061
echo 'no toolchain name set'
6162
exit 1
6263
fi
@@ -65,58 +66,62 @@ function build_android_arch {
6566
local TOOLCHAIN_NAME=$3
6667
local COMPILER=$4
6768

68-
local SRC_DIR=${BUILD_DIR}/android-$ABI
69-
local LOG_FILE="$SRC_DIR/android-$ABI-$VERSION.log"
69+
local SRC_DIR=${BUILD_DIR}/android-${ABI}
70+
local LOG_FILE="$SRC_DIR/android-${ABI}-${VERSION}.log"
7071

71-
local TOOL_NAME=${ARCH}-linux-android
72-
local TOOLCHAIN_ROOT_PATH=$BUILD_DIR/toolchains/${TOOL_NAME}
73-
local TOOLCHAIN_PATH=$TOOLCHAIN_ROOT_PATH/bin
74-
local NDK_TOOLCHAIN_BASENAME=$TOOLCHAIN_PATH/$TOOLCHAIN_NAME
72+
HOST_TAG=$(host_tag)
73+
echo ${HOST_TAG}
74+
75+
local TOOLCHAIN_ROOT_PATH=${ANDROID_NDK_HOME}/toolchains/llvm/prebuilt/${HOST_TAG}
76+
local CLANG_TOOLCHAIN=${TOOLCHAIN_NAME}
77+
if [[ ${ABI} == "armeabi-v7a" ]]; then
78+
local V7A_BIN="armv7a-linux-androideabi"
79+
echo "Update clang ${ABI} bin toolchain name to ${V7A_BIN}"
80+
CLANG_TOOLCHAIN=${V7A_BIN}
81+
fi
82+
local NDK_TOOLCHAIN_BASENAME="${TOOLCHAIN_ROOT_PATH}/bin/${TOOLCHAIN_NAME}"
83+
local NDK_TOOLCHAIN_CLANG_BASENAME="${TOOLCHAIN_ROOT_PATH}/bin/${CLANG_TOOLCHAIN}"
84+
local CMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake
7585
echo "NDK_TOOLCHAIN_BASENAME ${NDK_TOOLCHAIN_BASENAME}"
7686

7787
# indicate new build
7888
echo ">>>"
7989
echo "Begin: $(date)"
8090
# folder, zip, target, target dir
81-
unarchive $OPENSSL_NAME $OPENSSL_PATH "android-$ABI" $SRC_DIR
82-
83-
if [ -d $TOOLCHAIN_PATH ]; then
84-
echo "toolchain ${TOOL_NAME} exists"
85-
else
86-
echo "toolchain ${TOOL_NAME} missing, create it"
87-
$ANDROID_NDK_HOME/build/tools/make-standalone-toolchain.sh \
88-
--platform=android-$ANDROID_SDK \
89-
--stl=libc++_shared \
90-
--arch=$ARCH \
91-
--install-dir=$TOOLCHAIN_ROOT_PATH \
92-
--verbose
93-
fi
94-
95-
export SYSROOT=$TOOLCHAIN_ROOT_PATH/sysroot
96-
export CC="$NDK_TOOLCHAIN_BASENAME-clang --sysroot=${SYSROOT}"
97-
export CXX=$NDK_TOOLCHAIN_BASENAME-clang++
91+
unarchive ${OPENSSL_NAME} ${OPENSSL_PATH} "android-${ABI}" ${SRC_DIR}
92+
local TARGET_PATCH_CONFIGURE="${SRC_DIR}/Configure"
93+
echo "Applying Patch for ${TARGET_PATCH_CONFIGURE}"
94+
patch ${TARGET_PATCH_CONFIGURE} patches/Configure.patch
95+
96+
export SYSROOT=${TOOLCHAIN_ROOT_PATH}/sysroot
97+
export CC="${NDK_TOOLCHAIN_CLANG_BASENAME}${ANDROID_SDK}-clang --sysroot=${SYSROOT}"
98+
export CXX=${NDK_TOOLCHAIN_CLANG_BASENAME}${ANDROID_SDK}-clang++
9899
export LINK=${CXX}
99-
export LD=$NDK_TOOLCHAIN_BASENAME-ld
100-
export AR=$NDK_TOOLCHAIN_BASENAME-ar
101-
export AS=$NDK_TOOLCHAIN_BASENAME-as
102-
export RANLIB=$NDK_TOOLCHAIN_BASENAME-ranlib
103-
export STRIP=$NDK_TOOLCHAIN_BASENAME-strip
104-
100+
export LD=${NDK_TOOLCHAIN_BASENAME}-ld
101+
export AR=${NDK_TOOLCHAIN_BASENAME}-ar
102+
export AS=${NDK_TOOLCHAIN_BASENAME}-as
103+
export RANLIB=${NDK_TOOLCHAIN_BASENAME}-ranlib
104+
export STRIP=${NDK_TOOLCHAIN_BASENAME}-strip
105+
105106
export ARCH_FLAGS=$5
106107
export ARCH_LINK=$6
107-
export CPPFLAGS=" ${ARCH_FLAGS} -fPIC -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing "
108-
export CXXFLAGS=" ${ARCH_FLAGS} -fPIC -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -frtti -fexceptions "
109-
export CFLAGS=" ${ARCH_FLAGS} -fPIC -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing "
108+
export CPPFLAGS=" ${ARCH_FLAGS} -fPIC -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -I${SYSROOT}/usr/include/${TOOLCHAIN_NAME}"
109+
export CXXFLAGS=" ${ARCH_FLAGS} -fPIC -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -frtti -fexceptions -I${SYSROOT}/usr/include/${TOOLCHAIN_NAME}"
110+
export CFLAGS=" ${ARCH_FLAGS} -fPIC -ffunction-sections -funwind-tables -fstack-protector -fno-strict-aliasing -I${SYSROOT}/usr/include/${TOOLCHAIN_NAME}"
110111
export LDFLAGS=" ${ARCH_LINK} "
111112

112-
echo "Configuring android-$ABI"
113-
(cd "$SRC_DIR"; ./Configure $OPENSSL_CONFIG_OPTIONS -DOPENSSL_PIC -fPIC "$COMPILER" > "$LOG_FILE" 2>&1)
113+
echo "Configuring android-${ABI}"
114+
(cd "${SRC_DIR}"; ./Configure ${OPENSSL_CONFIG_OPTIONS} -DOPENSSL_PIC -fPIC "${COMPILER}" > "${LOG_FILE}" 2>&1)
115+
116+
local TARGET_PATCH_MAKEFILE="${SRC_DIR}/Makefile"
117+
echo "Applying Patch for ${TARGET_PATCH_MAKEFILE}"
118+
patch ${TARGET_PATCH_MAKEFILE} patches/Makefile-${ABI}.patch
114119

115-
echo "Building android-$ABI..."
116-
(cd "$SRC_DIR"; make build_libs >> "$LOG_FILE" 2>&1)
120+
echo "Building android-${ABI}..."
121+
(cd "${SRC_DIR}"; make build_libs "CMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}" >> "${LOG_FILE}" 2>&1)
117122

118123
clear_android_env
119-
check_files $ABI $LOG_FILE
124+
check_files ${ABI} ${LOG_FILE}
120125
echo "Finished: $(date)"
121126
}
122127

@@ -131,22 +136,21 @@ function build_android {
131136

132137
# abi, arch, toolchain, openssl-config, arch_flags, arch_link
133138
build_android_arch 'arm64-v8a' 'arm64' 'aarch64-linux-android' 'android'
134-
build_android_arch 'armeabi-v7a' 'arm' 'arm-linux-androideabi' 'android-armv7' $ARMV7_ARCH_FLAGS $ARMV7_ARCH_LINK
135-
build_android_arch 'armeabi' 'arm' 'arm-linux-androideabi' 'android' $ARM_ARCH_FLAGS
136-
build_android_arch 'x86' 'x86' 'i686-linux-android' 'android-x86' $X86_ARCH_FLAGS
139+
build_android_arch 'armeabi-v7a' 'arm' 'arm-linux-androideabi' 'android-armv7' ${ARMV7_ARCH_FLAGS} ${ARMV7_ARCH_LINK}
140+
build_android_arch 'x86' 'x86' 'i686-linux-android' 'android-x86' ${X86_ARCH_FLAGS}
137141
build_android_arch 'x86_64' 'x86_64' 'x86_64-linux-android' 'android'
138142
}
139143

140144
function check_files() {
141-
local FILE_SSL=$BUILD_DIR/android-$1/libssl.a
142-
local FILE_CRYPTO=$BUILD_DIR/android-$1/libcrypto.a
143-
if [ ! -f $FILE_SSL ]; then
144-
echo "Missing $FILE_SSL"
145+
local FILE_SSL=${BUILD_DIR}/android-$1/libssl.a
146+
local FILE_CRYPTO=${BUILD_DIR}/android-$1/libcrypto.a
147+
if [[ ! -f ${FILE_SSL} ]]; then
148+
echo "Missing ${FILE_SSL}"
145149
cat $2
146150
exit 1
147151
fi
148-
if [ ! -f $FILE_CRYPTO ]; then
149-
echo "Missing $FILE_CRYPTO"
152+
if [[ ! -f ${FILE_CRYPTO} ]]; then
153+
echo "Missing ${FILE_CRYPTO}"
150154
cat $2
151155
exit 2
152156
fi
@@ -157,25 +161,40 @@ function distribute_android {
157161
log_title "Distribute Android"
158162

159163
local PLATFORM="Android"
160-
local NAME="$PLATFORM"
161-
local DIR="$DIST_DIR/$NAME/openssl"
162-
local ANDROID_ABIS="arm64-v8a armeabi-v7a armeabi x86 x86_64"
164+
local NAME="${PLATFORM}"
165+
local DIR="${DIST_DIR}/${NAME}/openssl"
166+
local ANDROID_ABIS="arm64-v8a armeabi-v7a x86 x86_64"
163167

164-
for ABI in $ANDROID_ABIS; do
165-
local ABI_DIR=$DIR/$ABI
166-
mkdir -p $ABI_DIR/include
167-
mkdir -p $ABI_DIR/lib
168-
169-
echo "Copy $ABI"
170-
cp -LR $BUILD_DIR/android-$ABI/include/* $ABI_DIR/include
171-
cp $BUILD_DIR/android-$ABI/libcrypto.a $ABI_DIR/lib/libcrypto.a
172-
cp $BUILD_DIR/android-$ABI/libssl.a $ABI_DIR/lib/libssl.a
168+
for ABI in ${ANDROID_ABIS}; do
169+
local ABI_DIR=${DIR}/${ABI}
170+
mkdir -p ${ABI_DIR}/include
171+
mkdir -p ${ABI_DIR}/lib
172+
173+
echo "Copy ${ABI}"
174+
cp -LR ${BUILD_DIR}/android-${ABI}/include/* ${ABI_DIR}/include
175+
cp ${BUILD_DIR}/android-${ABI}/libcrypto.a ${ABI_DIR}/lib/libcrypto.a
176+
cp ${BUILD_DIR}/android-${ABI}/libssl.a ${ABI_DIR}/lib/libssl.a
173177
done
174178
}
175179

180+
function host_tag {
181+
local name=`uname`
182+
local result
183+
if [[ ${name} =~ "Darwin" ]]; then
184+
result="darwin-x86_64"
185+
elif [[ ${name} =~ "Linux" ]]; then
186+
result="linux-x86_64"
187+
else
188+
echo "Can't find matching host tag for ${name}"
189+
exit 1
190+
fi
191+
echo ${result}
192+
}
193+
176194
## --------------------
177195
## Build (Main)
178196
## --------------------
197+
179198
clear_android_env
180199
build_android
181-
distribute_android
200+
distribute_android

0 commit comments

Comments
 (0)