- Notifications
You must be signed in to change notification settings - Fork 126
Allow all dependencies (curl, websockets, grpc) to use boringssl instead of openssl when making packaged C++ SDK. #207
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
85 commits Select commit Hold shift + click to select a range
2155b63 Add boringssl rules.
jonsimantov 8e01d52 Patch boringssl to look like openssl.
jonsimantov be3173b Force boringssl for curl build.
jonsimantov 5562af2 Merge branch 'feature/fix-corrupt-mac-libs' into feature/js-switch-to…
jonsimantov 8656c5b Merge branch 'feature/fix-corrupt-mac-libs' into feature/js-switch-to…
jonsimantov 90912c2 Populate the boringssl aliases with paths to the built libs.
jonsimantov 23f1e1e Install golang (required for boringssl) in prereqs.
jonsimantov 1b15f97 Additional work to get boringssl to be used by all deps.
jonsimantov 9f56b89 Move boringssl declares earlier.
jonsimantov 86c27f1 Merge branch 'dev' into feature/js-switch-to-boringssl
jonsimantov 3d96595 Fix spelling of Nanopb library.
jonsimantov 56fb379 Merge branch 'feature/js-switch-to-boringssl' of https://github.com/f…
jonsimantov 5f3138b Fix packaging script to rename dependencies in *all* libraries, not j…
jonsimantov 75c4ee5 Don't build boringssl on desktop.
jonsimantov e257fc6 Try the newer binutils again.
jonsimantov 091b16d Don't use if(DESKTOP) in external_rules.cmake
jonsimantov 8019d82 Make BoringSSL build cross-platform and propagate some build flags to
jonsimantov 334e94c Fix OSX architecture to not emit the flag if it's blank.
jonsimantov 692b59e Disable an MSVC warning-as-error that boringssl triggers.
jonsimantov 62a9104 Merge branch 'feature/js-switch-to-boringssl' of https://github.com/f…
jonsimantov 5526066 For BoringSSL, only build the ssl and crypto targets.
jonsimantov 459b2dd Remove flag to disable warning.
jonsimantov 1ee06fb Set no-asm mode for boringssl in the main package as well.
jonsimantov 9886184 Rename Curl option for Windows that changed names in the newer version.
jonsimantov db060cb Don't build CURL tests.
jonsimantov 972a2cc Pass MSVC runtime flags directly to sub-build.
jonsimantov 3685d0b Move openssl-specific cmake subbuild options out, in case we use addi…
jonsimantov c164701 Pass along Linux c++11 ABI option, and MSVC runtime.
jonsimantov 83b6bf9 Pass along Linux c++11 ABI option, and MSVC runtime.
jonsimantov 85151d5 Revert "Pass MSVC runtime flags directly to sub-build."
jonsimantov b1562c0 Merge branch 'feature/js-switch-to-boringssl' of https://github.com/f…
jonsimantov 84002a6 Fix cmake format issue.
jonsimantov ef11889 Fix cmake.
jonsimantov 6c705b3 Fix subbuild flags and add generator.
jonsimantov 86202ff Change strequals to strequal
jonsimantov 00e7aa8 Add C++11 ABI option to main CMake file, and fix stdlib.h include file
jonsimantov fa063b4 Get the correct ssl and crypto path on Windows.
jonsimantov 31f5ca1 Swap the library order, as ssl needs to be linked before crypto.
jonsimantov 06e457c Fix the link order of libssl.a and libcrypto.a, which for some reason
jonsimantov c6e7c01 Fix extraneous libcrypto linkage.
jonsimantov df68f32 Repeat the same SSL workaround for Firebase C++ tests also.
jonsimantov 284b5f5 Fix target link libraries for ssl/crypto.
jonsimantov a63f09a Remove workaround since now the imported OpenSSL::SSL library is set to
jonsimantov e16bdc8 Fix database test dependency for boringssl.
jonsimantov 5dbdc00 Add additional dependencies for app, required for unit tests building
jonsimantov d486c8e Clean up platform-specific dependencies - we only need crypt32 on
jonsimantov b6d505d Fix Windows generated package names to be merged in.
jonsimantov 2af8037 Fix bad ssl library prefix in packaging script, and make the grpc libs
jonsimantov 0481990 Fix database libcrypto dependendency
jonsimantov fea8495 Fix linux 32-bit build error due to cflags mis-setting.
jonsimantov 91afab6 On Windows, the cmake subbuild needs to be passed --config Release for
jonsimantov e7812a2 Turn on verbose mode for all builds.
jonsimantov 8eec1a2 Turn on verbose mode in CI build, and turn off in packaging build.
jonsimantov 91b2303 Remove openssl from vcpkg list, as it's causing tests to use it rather
jonsimantov 7302e31 Change around dependencies for libssl and libcrypto on Windows.
jonsimantov 148c9c2 Add some diagnostics to detect if the openssl library changes, and also
jonsimantov c110209 Add a workaround to copy the built BoringSSL libraries to
jonsimantov 52bca9c Fix workaround path.
jonsimantov a6f0220 Remove the code to only build boringssl once.
jonsimantov 7a7babf Only build boringssl in the cmake configure step, not during the build
jonsimantov ce1e6ef Cleaned up the openssl/boringssl definitions a bit.
jonsimantov fa15d8d Remove extra checks on boringssl changing, which breaks non-desktop
jonsimantov 5479fe9 Inspect all built libraries, not just firebase ones.
jonsimantov ddd952e Also specify CMAKE_MSVC_RUNTIME_LIBRARY for sub-build.
jonsimantov 050b869 Attempt to fix setting MSVC runtime for sub-build.
jonsimantov c365615 Also try MSVC_RUNTIME_LIBRARY
jonsimantov 78a1d13 Cleaned up the MSVC runtime passing to subbuild.
jonsimantov 7c291af Fix badly-formatted comment.
jonsimantov aa7cb0e Add CFLAGS back in for windows.
jonsimantov 8158b25 Fix another cmake typo.
jonsimantov 59232cb Remove verbose output from github workflow.
jonsimantov c326461 Merge branch 'dev' into feature/js-switch-to-boringssl
jonsimantov 787c744 Address PR comments by adding some comments and making a few minor ch…
jonsimantov 9a6208d Fix bad conditional.
jonsimantov 8803578 Added a comment about tweaking the files on desktop after download.
jonsimantov 1f8dfd3 Add FIREBASE_USE_BORINGSSL option, off by default but on for standalo…
jonsimantov 628cb6e Fix boringSSL path when linking SDK from source.
jonsimantov 5ca920c Add option to integration_tests workflow to build tests using openssl…
jonsimantov 559ba8e Reworded parameter.
jonsimantov 98652b2 Move SSL parameter above optional params.
jonsimantov 8a27f75 Rephrased comment
jonsimantov 11a9b5c Add SSL variant to job name.
jonsimantov 04fb042 Remove extraneous ADDITIONAL_LIBS variable, which was used in an earl…
jonsimantov 587d96c Fix build integration tests on Windows.
jonsimantov b8a1b2b Also ensure openssl is installed by prereqs script.
jonsimantov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -66,6 +66,8 @@ option(FIREBASE_CPP_BUILD_PACKAGE | |
| "Bundle the Firebase C++ libraries into a zip file." OFF) | ||
| option(FIREBASE_CPP_USE_PRIOR_GRADLE_BUILD | ||
| "When building with Gradle, use the previously built libraries." OFF) | ||
| option(FIREBASE_USE_BORINGSSL | ||
| "Build against BoringSSL instead of using your system's OpenSSL." OFF) | ||
| | ||
| set(FIREBASE_ANDROID_STL "" CACHE STRING "STL implementation to use.") | ||
| if (NOT FIREBASE_ANDROID_STL STREQUAL "") | ||
| | @@ -115,6 +117,13 @@ else() | |
| set(DESKTOP OFF) | ||
| endif() | ||
| | ||
| if(DESKTOP AND NOT MSVC AND NOT APPLE) | ||
| # Linux-specific option. | ||
| add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) | ||
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | ||
| set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=0") | ||
| endif() | ||
| | ||
| # Set directories needed by the Firebase subprojects | ||
| # Directory to store generated files. | ||
| set(FIREBASE_GEN_FILE_DIR ${CMAKE_BINARY_DIR}/generated) | ||
| | @@ -174,6 +183,87 @@ else() | |
| set(FIRESTORE_SOURCE_DIR ${FIREBASE_BINARY_DIR}/external/src/firestore) | ||
| endif() | ||
| | ||
| if(DESKTOP) | ||
| # Use the static versions of the OpenSSL libraries. | ||
| set(OPENSSL_USE_STATIC_LIBS TRUE) | ||
| if (MSVC) | ||
| # Get the correct version of the OpenSSL libraries based on building for MT. | ||
| if ("${CMAKE_CXX_FLAGS_DEBUG}" MATCHES "/MTd" OR | ||
| "${CMAKE_CXX_FLAGS_RELEASE}" MATCHES "/MT") | ||
| set(OPENSSL_MSVC_STATIC_RT TRUE) | ||
| else() | ||
| set(OPENSSL_MSVC_STATIC_RT FALSE) | ||
| endif() | ||
| endif() | ||
| | ||
| if(FIREBASE_USE_BORINGSSL) | ||
| # Use BoringSSL instead of OpenSSL. | ||
| set(BORINGSSL_ROOT_DIR ${PROJECT_BINARY_DIR}/external/src/boringssl/src CACHE STRING "" FORCE) | ||
| set(BORINGSSL_BINARY_DIR ${PROJECT_BINARY_DIR}/external/src/boringssl-build CACHE STRING "" FORCE) | ||
| set(OPENSSL_ROOT_DIR ${BORINGSSL_ROOT_DIR} CACHE STRING "" FORCE) | ||
| | ||
| # The call below to build_external_dependencies will make sure that these | ||
| # libraries exist before the libraries are imported via add_library. | ||
| if (MSVC) | ||
| if (CMAKE_BUILD_TYPE) | ||
| set(BORINGSSL_LIB_SUBDIR "${CMAKE_BUILD_TYPE}") | ||
| else() | ||
| set(BORINGSSL_LIB_SUBDIR "Debug") | ||
| endif() | ||
| set(OPENSSL_SSL_LIBRARY ${BORINGSSL_BINARY_DIR}/ssl/${BORINGSSL_LIB_SUBDIR}/ssl.lib CACHE FILEPATH "" FORCE) | ||
| set(OPENSSL_CRYPTO_LIBRARY ${BORINGSSL_BINARY_DIR}/crypto/${BORINGSSL_LIB_SUBDIR}/crypto.lib CACHE FILEPATH "" FORCE) | ||
| else() | ||
| set(OPENSSL_SSL_LIBRARY ${BORINGSSL_BINARY_DIR}/ssl/libssl.a CACHE FILEPATH "" FORCE) | ||
| set(OPENSSL_CRYPTO_LIBRARY ${BORINGSSL_BINARY_DIR}/crypto/libcrypto.a CACHE FILEPATH "" FORCE) | ||
| endif() | ||
| endif() | ||
| endif() | ||
| | ||
| | ||
| if(DESKTOP) | ||
| message(STATUS "Building external project dependencies...") | ||
jonsimantov marked this conversation as resolved. Show resolved Hide resolved | ||
| build_external_dependencies() | ||
| message(STATUS "Build of external project dependencies complete.") | ||
| | ||
| if(FIREBASE_USE_BORINGSSL) | ||
| set(OPENSSL_FOUND TRUE CACHE BOOL "" FORCE) | ||
| set(OPENSSL_NO_ASM TRUE) # Force cross-platform BoringSSL, no ASM. | ||
| set(OPENSSL_INCLUDE_DIR ${BORINGSSL_ROOT_DIR}/include CACHE PATH "" FORCE) | ||
| set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY}) | ||
| set(OPENSSL_SSL_LIBRARIES ${OPENSSL_SSL_LIBRARY}) | ||
| set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES}) | ||
| set(OPENSSL_VERSION '1.1.0' CACHE STRING "" FORCE) | ||
| | ||
| add_library(OpenSSL::SSL STATIC IMPORTED) | ||
| add_library(OpenSSL::Crypto STATIC IMPORTED) | ||
| set_target_properties(OpenSSL::SSL PROPERTIES | ||
| IMPORTED_LOCATION "${OPENSSL_SSL_LIBRARY}" | ||
| INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}" | ||
| INTERFACE_LINK_LIBRARIES OpenSSL::Crypto | ||
| ) | ||
| | ||
| set_target_properties(OpenSSL::Crypto PROPERTIES | ||
| IMPORTED_LOCATION "${OPENSSL_CRYPTO_LIBRARY}" | ||
| INTERFACE_INCLUDE_DIRECTORIES "${OPENSSL_INCLUDE_DIR}" | ||
| ) | ||
| # Now if we do find_package(OpenSSL) it should give us BoringSSL. | ||
| find_package(OpenSSL) | ||
| | ||
| if(NOT "${OPENSSL_INCLUDE_DIR}" MATCHES boringssl OR | ||
| NOT "${OPENSSL_SSL_LIBRARY}" MATCHES boringssl OR | ||
| NOT "${OPENSSL_CRYPTO_LIBRARY}" MATCHES boringssl) | ||
| message(FATAL_ERROR "BoringSSL was not configured correctly.\nINCLUDE_DIR=${OPENSSL_INCLUDE_DIR}\nSSL_LIBRARY=${OPENSSL_SSL_LIBRARY}\nCRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}") | ||
| endif() | ||
| else() | ||
| # Don't use BoringSSL, use OpenSSL. If you are linking against the libraries directly | ||
| # from source, you probably want this instead. | ||
| # | ||
| # If the find_package fails to find OpenSSL, set OPENSSL_ROOT_DIR to OpenSSL'S install | ||
| # location on your system. | ||
| find_package(OpenSSL REQUIRED) | ||
| endif() | ||
| endif() | ||
| | ||
| # Include Firestore's external build early to resolve conflicts on packages. | ||
| if(FIRESTORE_USE_EXTERNAL_CMAKE_BUILD) | ||
| set(FIRESTORE_BINARY_DIR ${FIRESTORE_SOURCE_DIR}-build) | ||
| | @@ -223,37 +313,28 @@ endif() | |
| | ||
| # Some of the external libraries are not used for mobile. | ||
| if(DESKTOP) | ||
| # Use the static versions of the OpenSSL libraries. | ||
| set(OPENSSL_USE_STATIC_LIBS TRUE) | ||
| if (MSVC) | ||
| # Get the correct version of the OpenSSL libraries based on building for MT. | ||
| if ("${CMAKE_CXX_FLAGS_DEBUG}" MATCHES "/MT" OR | ||
| "${CMAKE_CXX_FLAGS_RELEASE}" MATCHES "/MT") | ||
| set(OPENSSL_MSVC_STATIC_RT TRUE) | ||
| else() | ||
| set(OPENSSL_MSVC_STATIC_RT FALSE) | ||
| endif() | ||
| endif() | ||
| | ||
| # Build curl as a static library | ||
| set(CURL_STATICLIB ON CACHE BOOL "") | ||
| if (WIN32) | ||
| set(CMAKE_USE_WINSSL ON CACHE BOOL "") | ||
| # Enable Windows native SSL/TLS in libcurl. | ||
| set(CMAKE_USE_SCHANNEL ON CACHE BOOL "") | ||
jonsimantov marked this conversation as resolved. Show resolved Hide resolved | ||
| endif() | ||
| | ||
| # Current Curl library defaults to requiring some dependencies we don't need, disable them. | ||
| set(CMAKE_USE_LIBSSH2 OFF) | ||
| set(HTTP_ONLY ON) | ||
| set(BUILD_TESTING OFF) | ||
| add_external_library(curl) | ||
| | ||
| add_external_library(libuv) | ||
| | ||
| find_package(OpenSSL) | ||
| | ||
| add_external_library(zlib) | ||
| | ||
| add_external_library(uWebSockets) | ||
| | ||
| # Binutils on Mac doesn't support thread-local storage (required by | ||
| # websockets), but because we only use websockets via the scheduler, | ||
| # we don't need it. | ||
| | ||
| # websockets), but because we only use websockets via the scheduler, we don't | ||
| # need it. Deactivate this by blanking out the __thread keyword. | ||
| set(websockets_additional_defines "-D__thread=") | ||
| | ||
| # uWebSockets does not come with a CMakeLists file, so define the target. | ||
| | @@ -304,7 +385,8 @@ if(DESKTOP) | |
| ) | ||
| target_link_libraries(libuWS | ||
| PRIVATE | ||
| ${OPENSSL_LIBRARIES} | ||
| OpenSSL::SSL | ||
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since ssl->crypto dependency is captured already in ssl, do we need to specify these 2 libraries separately here? | ||
| OpenSSL::Crypto | ||
| uv_a | ||
| zlibstatic | ||
| ) | ||
| | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.