Skip to content

Commit 9c5a54e

Browse files
committed
Dev: replace boringssl with openssl
1 parent 4492de7 commit 9c5a54e

File tree

3 files changed

+48
-33
lines changed

3 files changed

+48
-33
lines changed

build-docker

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,5 @@ $DOCKER run -i --rm \
8383
--build-compiler "${BUILD_COMPILER}" \
8484
--android-api "${ANDROID_API}" \
8585
--ndk-home "/usr/local/ndk/${ANDROID_NDK_VERSION}" \
86+
--name "readdle-swift-${SWIFT_VERSION}_android" \
8687
--archs "${TARGET_ARCHS}"

scripts/build.sh

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -244,8 +244,6 @@ libxml2_version=$(versionFromTag ${swift_source_dir}/libxml2)
244244
curl_desc=$(describe ${swift_source_dir}/curl | tr '_' '.')
245245
curl_version=${curl_desc#curl-}
246246

247-
boringssl_version=$(describe ${source_dir}/boringssl)
248-
249247
function quiet_pushd {
250248
pushd "$1" >/dev/null 2>&1
251249
}
@@ -289,7 +287,7 @@ echo "Building from:"
289287
echo " - Swift ${swift_version}"
290288
echo " - libxml2 ${libxml2_version}"
291289
echo " - curl ${curl_version}"
292-
echo " - BoringSSL ${boringssl_version}"
290+
echo " - OpenSSL 3.6.0"
293291

294292
# make sure the products_dir is writeable
295293
ls -lad $products_dir
@@ -365,29 +363,42 @@ for arch in $archs; do
365363
quiet_popd
366364
groupend
367365

368-
groupstart "Building boringssl for ${compiler_target_host}"
369-
quiet_pushd ${source_dir}/boringssl
370-
run cmake \
371-
-GNinja \
372-
-B ${build_dir}/$arch/boringssl \
373-
-DANDROID_ABI=$android_abi \
374-
-DANDROID_PLATFORM=android-$android_api \
375-
-DCMAKE_TOOLCHAIN_FILE=$ndk_home/build/cmake/android.toolchain.cmake \
376-
-DCMAKE_BUILD_TYPE=$build_type \
377-
-DCMAKE_INSTALL_PREFIX=$sdk_root/usr \
378-
-DCMAKE_EXTRA_LINK_FLAGS="-Wl,-z,max-page-size=16384" \
379-
-DBUILD_SHARED_LIBS=OFF \
380-
-DBUILD_STATIC_LIBS=ON \
381-
-DBUILD_TESTING=OFF
382-
383-
quiet_pushd ${build_dir}/$arch/boringssl
384-
run ninja -j$parallel_jobs
385-
quiet_popd
386-
387-
header "Installing BoringSSL for $arch"
388-
quiet_pushd ${build_dir}/$arch/boringssl
389-
run ninja -j$parallel_jobs install
390-
quiet_popd
366+
groupstart "Building openssl for ${compiler_target_host}"
367+
quiet_pushd ${source_dir}/openssl
368+
(
369+
# Isolated environment
370+
export ANDROID_NDK_ROOT="$ANDROID_NDK_HOME"
371+
export PATH="$ANDROID_NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH"
372+
export CFLAGS="-O3 -g -DNDEBUG -fpic -ffunction-sections -fdata-sections -fstack-protector-strong -funwind-tables -no-canonical-prefixes"
373+
374+
case $arch in
375+
armv7)
376+
openssl_arch="android-arm"
377+
;;
378+
aarch64)
379+
openssl_arch="android-arm64"
380+
;;
381+
x86_64)
382+
openssl_arch="android-x86_64"
383+
;;
384+
x86)
385+
openssl_arch="android-x86"
386+
;;
387+
*)
388+
echo "Unknown architecture '$1'"
389+
usage
390+
exit 0
391+
;;
392+
esac
393+
394+
./Configure $openssl_arch \
395+
no-shared \
396+
no-engine \
397+
zlib \
398+
--prefix="$sdk_root/usr"
399+
400+
make && make install_sw
401+
)
391402
quiet_popd
392403
groupend
393404

@@ -637,7 +648,7 @@ mkdir -p ${swift_res_root}
637648

638649
cat > $swift_res_root/SDKSettings.json <<EOF
639650
{
640-
"DisplayName": "Swift Android SDK",
651+
"DisplayName": "Readdle Swift Android SDK",
641652
"Version": "${android_sdk_version}",
642653
"VersionMap": {},
643654
"CanonicalName": "linux-android"
@@ -792,6 +803,7 @@ EOF
792803
"sdkRootPath": "${ndk_sysroot}",
793804
"swiftResourcesPath": "${swift_res_root}/usr/lib/${SWIFT_RES_DIR}",
794805
"swiftStaticResourcesPath": "${swift_res_root}/usr/lib/${SWIFT_STATIC_RES_DIR}",
806+
"includeSearchPaths": ["${swift_res_root}/usr/include"],
795807
"toolsetPaths": [ "swift-toolset.json" ]
796808
EOF
797809
#"librarySearchPaths": [ "${swift_res_root}/usr/lib/swift-x86_64/android/x86_64" ],

scripts/fetch-source.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,12 @@ fi
154154
popd >/dev/null
155155
groupend
156156

157-
# Fetch BoringSSL
158-
groupstart "Fetching BoringSSL"
159-
[[ -d boringssl ]] || git clone https://boringssl.googlesource.com/boringssl
160-
pushd boringssl >/dev/null 2>&1
161-
git checkout ${BORINGSSL_VERSION}
162-
popd >/dev/null 2>&1
157+
# Fetch OpenSSL
158+
groupstart "Fetching OpenSSL"
159+
OPENSSL_VERSION=3.6.0
160+
DOWNLOAD_URL_OPENSSL=https://github.com/openssl/openssl/releases/download/openssl-$OPENSSL_VERSION/openssl-$OPENSSL_VERSION.tar.gz
161+
wget $DOWNLOAD_URL_OPENSSL -O openssl.tar.gz
162+
mkdir -p openssl
163+
tar -xvf openssl.tar.gz -C openssl --strip-components=1
164+
rm -rf openssl.tar.gz
163165
groupend

0 commit comments

Comments
 (0)