From 98c5261b40b830ac969f062f1569fe75be3e281c Mon Sep 17 00:00:00 2001 From: Markus87 Date: Wed, 14 Oct 2020 00:50:53 +0200 Subject: [PATCH] Fixed port of mongo-c-driver/mongo-cxx-driver for android (#13850) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fixed port of mongo-c-driver/mongo-cxx-driver for android * mongo-c-driver - Default value of ENABLE_SHM_COUNTERS is AUTO * Use vcpkg provided variable VCPKG_TARGET_IS_ANDROID to detect android Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> * Increased port-version of mongo-c-driver * Increased port-version of mongo-cxx-driver Co-authored-by: Jack·Boos·Yu <47264268+JackBoosY@users.noreply.github.com> --- ports/mongo-c-driver/CONTROL | 1 + ports/mongo-c-driver/portfile.cmake | 10 ++++++++++ ports/mongo-cxx-driver/CONTROL | 1 + ports/mongo-cxx-driver/fix-android.patch | 13 +++++++++++++ ports/mongo-cxx-driver/portfile.cmake | 1 + 5 files changed, 26 insertions(+) create mode 100644 ports/mongo-cxx-driver/fix-android.patch diff --git a/ports/mongo-c-driver/CONTROL b/ports/mongo-c-driver/CONTROL index 17df29f60de..7bbddb172e2 100644 --- a/ports/mongo-c-driver/CONTROL +++ b/ports/mongo-c-driver/CONTROL @@ -1,5 +1,6 @@ Source: mongo-c-driver Version: 1.16.1-1 +Port-Version: 1 Build-Depends: libbson, openssl (!windows), zlib Description: Client library written in C for MongoDB. Homepage: https://github.com/mongodb/mongo-c-driver diff --git a/ports/mongo-c-driver/portfile.cmake b/ports/mongo-c-driver/portfile.cmake index 3516886b128..74a1d8c0d27 100644 --- a/ports/mongo-c-driver/portfile.cmake +++ b/ports/mongo-c-driver/portfile.cmake @@ -28,6 +28,14 @@ else() set(ENABLE_SSL "OPENSSL") endif() +if(VCPKG_TARGET_IS_ANDROID) + set(ENABLE_SRV OFF) + set(ENABLE_SHM_COUNTERS OFF) +else() + set(ENABLE_SRV AUTO) + set(ENABLE_SHM_COUNTERS AUTO) +endif() + file(READ ${CMAKE_CURRENT_LIST_DIR}/CONTROL _contents) string(REGEX MATCH "\nVersion:[ ]*[^ \n]+" _contents "${_contents}") string(REGEX REPLACE ".+Version:[ ]*([\\.0-9]+).*" "\\1" BUILD_VERSION "${_contents}") @@ -41,6 +49,8 @@ vcpkg_configure_cmake( -DENABLE_BSON=SYSTEM -DENABLE_TESTS=OFF -DENABLE_EXAMPLES=OFF + -DENABLE_SRV=${ENABLE_SRV} + -DENABLE_SHM_COUNTERS=${ENABLE_SHM_COUNTERS} -DENABLE_SSL=${ENABLE_SSL} -DENABLE_ZLIB=SYSTEM -DENABLE_STATIC=${ENABLE_STATIC} diff --git a/ports/mongo-cxx-driver/CONTROL b/ports/mongo-cxx-driver/CONTROL index ecd41b43cbc..0f56760127a 100644 --- a/ports/mongo-cxx-driver/CONTROL +++ b/ports/mongo-cxx-driver/CONTROL @@ -1,5 +1,6 @@ Source: mongo-cxx-driver Version: 3.4.0-5 +Port-Version: 1 Build-Depends: libbson, mongo-c-driver, boost-smart-ptr, boost-optional, boost-utility Homepage: https://github.com/mongodb/mongo-cxx-driver Description: MongoDB C++ Driver. diff --git a/ports/mongo-cxx-driver/fix-android.patch b/ports/mongo-cxx-driver/fix-android.patch new file mode 100644 index 00000000000..01527392f6a --- /dev/null +++ b/ports/mongo-cxx-driver/fix-android.patch @@ -0,0 +1,13 @@ +diff --git "a/src/mongocxx/options/change_stream.cpp" "b/src/mongocxx/options/change_stream.cpp" +index 2c651a7e0..2e9c34eb6 100644 +--- "a/src/mongocxx/options/change_stream.cpp" ++++ "b/src/mongocxx/options/change_stream.cpp" +@@ -108,7 +108,7 @@ bsoncxx::document::value change_stream::as_bson() const { + if ((count < 0) || (count >= std::numeric_limits::max())) { + throw mongocxx::logic_error{mongocxx::error_code::k_invalid_parameter}; + } +- out.append(bsoncxx::builder::basic::kvp("maxAwaitTimeMS", count)); ++ out.append(bsoncxx::builder::basic::kvp("maxAwaitTimeMS", static_cast(count))); + } + + return out.extract(); diff --git a/ports/mongo-cxx-driver/portfile.cmake b/ports/mongo-cxx-driver/portfile.cmake index 695843e288c..dc409fcfdfb 100644 --- a/ports/mongo-cxx-driver/portfile.cmake +++ b/ports/mongo-cxx-driver/portfile.cmake @@ -16,6 +16,7 @@ vcpkg_from_github( fix-dependency-libbson.patch fix-dependency-mongocdriver.patch github-654.patch + fix-android.patch ) if ("mnmlstc" IN_LIST FEATURES)