From c8b75376cb329d837adda6daf14cded7ca6f00e3 Mon Sep 17 00:00:00 2001 From: Jonas Vautherin Date: Thu, 5 Dec 2024 00:01:17 +0100 Subject: [PATCH] Try to use boringssl instead of openssl for https on Android --- third_party/CMakeLists.txt | 4 +-- third_party/boringssl/CMakeLists.txt | 52 ++++++++++++++++++++++++++++ third_party/grpc/CMakeLists.txt | 2 +- 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 third_party/boringssl/CMakeLists.txt diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 45d8c7bde9..c83c063abb 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -14,7 +14,7 @@ if (SUPERBUILD) build_target(liblzma) if(NOT BUILD_WITHOUT_CURL) - build_target(openssl) + build_target(boringssl) if(NOT IOS) build_target(zlib-ng) @@ -25,7 +25,7 @@ if (SUPERBUILD) if(BUILD_MAVSDK_SERVER) if (BUILD_WITHOUT_CURL) - build_target(openssl) + build_target(boringssl) endif() build_target(cares) diff --git a/third_party/boringssl/CMakeLists.txt b/third_party/boringssl/CMakeLists.txt new file mode 100644 index 0000000000..fe7289f9a2 --- /dev/null +++ b/third_party/boringssl/CMakeLists.txt @@ -0,0 +1,52 @@ +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() + +# We disable ASM optimizations for MSVC and iOS (see above for iOS), which +# might have a performance impact on secure communications. +# This should be benchmarked/evaluated before we decide if it is worth +# enabling them or not in our case. +# +# More information here: https://github.com/grpc/grpc/issues/9440 +if (IOS OR MSVC) + list(APPEND CMAKE_ARGS + "-DOPENSSL_NO_ASM=ON" + ) +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}" + ) diff --git a/third_party/grpc/CMakeLists.txt b/third_party/grpc/CMakeLists.txt index 66786f2640..4661c29c6e 100644 --- a/third_party/grpc/CMakeLists.txt +++ b/third_party/grpc/CMakeLists.txt @@ -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.68.2.tar.gz PREFIX grpc CMAKE_ARGS "${CMAKE_ARGS}" )