Skip to content

Commit

Permalink
Use boringssl instead of openssl on Android
Browse files Browse the repository at this point in the history
This is because openssl3 does not support the system certificates on
Android and does not seem to plan to support them.
  • Loading branch information
JonasVautherin committed Dec 10, 2024
1 parent e1fe983 commit 7f76824
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
12 changes: 10 additions & 2 deletions third_party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ if (SUPERBUILD)
build_target(liblzma)

if(NOT BUILD_WITHOUT_CURL)
build_target(openssl)
if(ANDROID)
build_target(boringssl)
else()
build_target(openssl)
endif()

if(NOT IOS)
build_target(zlib-ng)
Expand All @@ -25,7 +29,11 @@ if (SUPERBUILD)

if(BUILD_MAVSDK_SERVER)
if (BUILD_WITHOUT_CURL)
build_target(openssl)
if(ANDROID)
build_target(boringssl)
else()
build_target(openssl)
endif()
endif()

build_target(cares)
Expand Down
46 changes: 46 additions & 0 deletions third_party/boringssl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 3.10.2)

project(external-boringssl)
include(ExternalProject)

list(APPEND CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX}"
"-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}"
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON"
"-DBUILD_SHARED_LIBS=OFF"
)

if(ANDROID)
list(APPEND CMAKE_ARGS
"-DANDROID_ABI:STRING=${ANDROID_ABI}"
"-DANDROID_STL:STRING=${ANDROID_STL}"
"-DANDROID_PLATFORM=${ANDROID_PLATFORM}"
)
elseif(IOS)
list(APPEND CMAKE_ARGS
"-DIOS_PLATFORM=${IOS_PLATFORM}"
)
endif()

if (IOS)
list(APPEND CMAKE_ARGS
"-DOPENSSL_NO_ASM=ON" # https://github.com/grpc/grpc/issues/9440
)
else()
list(APPEND CMAKE_ARGS
"-DOPENSSL_NO_ASM=OFF"
)
endif()

message(STATUS "Preparing external project \"boringssl\" with args:")
foreach(CMAKE_ARG ${CMAKE_ARGS})
message(STATUS "-- ${CMAKE_ARG}")
endforeach()

ExternalProject_add(
boringssl
URL https://github.com/google/boringssl/releases/download/0.20241203.0/boringssl-0.20241203.0.tar.gz
URL_MD5 3320699951028ba64150b5296bc9d0e6
PREFIX boringssl
CMAKE_ARGS "${CMAKE_ARGS}"
)
2 changes: 1 addition & 1 deletion third_party/grpc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ endforeach()

ExternalProject_add(
grpc
URL https://github.com/grpc/grpc/archive/v1.61.1.tar.gz
URL https://github.com/grpc/grpc/archive/v1.61.3.tar.gz
PREFIX grpc
CMAKE_ARGS "${CMAKE_ARGS}"
)

0 comments on commit 7f76824

Please sign in to comment.