Skip to content

Commit

Permalink
[mongo-c-driver] Fix UWP builds. Deploy THIRD_PARTY_NOTICES.
Browse files Browse the repository at this point in the history
  • Loading branch information
ras0219-msft committed Apr 6, 2017
1 parent 3839b44 commit 0163b19
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ports/mongo-c-driver/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: mongo-c-driver
Version: 1.5.1
Build-Depends: libbson
Version: 1.5.1-1
Build-Depends: libbson, openssl [uwp]
Description: Client library written in C for MongoDB.
44 changes: 44 additions & 0 deletions ports/mongo-c-driver/fix-uwp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
diff --git a/src/mongoc/mongoc-gridfs-file.c b/src/mongoc/mongoc-gridfs-file.c
index 5beb610..7e74ff7 100644
--- a/src/mongoc/mongoc-gridfs-file.c
+++ b/src/mongoc/mongoc-gridfs-file.c
@@ -734,7 +734,7 @@ _mongoc_gridfs_file_refresh_page (mongoc_gridfs_file_t *file)
bson_t query;
bson_t child;
bson_t opts;
- const bson_t *chunk;
+ const bson_t *chunk = 0;
const char *key;
bson_iter_t iter;
int64_t existing_chunks;
diff --git a/src/mongoc/mongoc-handshake.c b/src/mongoc/mongoc-handshake.c
index 4e181bd..b274fc1 100644
--- a/src/mongoc/mongoc-handshake.c
+++ b/src/mongoc/mongoc-handshake.c
@@ -195,7 +195,8 @@ _get_os_version (void)
char *ret = bson_malloc (HANDSHAKE_OS_VERSION_MAX);
bool found = false;

-#ifdef _WIN32
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
+#elif defined (_WIN32)
OSVERSIONINFO osvi;
ZeroMemory (&osvi, sizeof (OSVERSIONINFO));
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
diff --git a/src/mongoc/mongoc-util.c b/src/mongoc/mongoc-util.c
index 6dbb26d..7f33780 100644
--- a/src/mongoc/mongoc-util.c
+++ b/src/mongoc/mongoc-util.c
@@ -46,7 +46,11 @@ _mongoc_hex_md5 (const char *input)
void
_mongoc_usleep (int64_t usec)
{
-#ifdef _WIN32
+#if defined (WINAPI_FAMILY_PARTITION) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP | WINAPI_PARTITION_SYSTEM)
+ if (usec / 1000 > MAXDWORD || usec < 0)
+ __fastfail(-1);
+ Sleep((DWORD)(usec / 1000));
+#elif defined(_WIN32)
LARGE_INTEGER ft;
HANDLE timer;

14 changes: 13 additions & 1 deletion ports/mongo-c-driver/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,27 @@ vcpkg_apply_patches(
SOURCE_PATH ${SOURCE_PATH}
PATCHES
${CMAKE_CURRENT_LIST_DIR}/bson.patch
${CMAKE_CURRENT_LIST_DIR}/fix-uwp.patch
)

set(ENABLE_SSL "WINDOWS")
if(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
set(ENABLE_SSL "OPENSSL")
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DBSON_ROOT_DIR=${CURRENT_INSTALLED_DIR}
-DENABLE_TESTS=OFF
-DENABLE_EXAMPLES=OFF
-DENABLE_SSL=${ENABLE_SSL}
)

vcpkg_install_cmake()

# This rename is needed because the official examples expect to use #include <mongoc.h>
# See Microsoft/vcpkg#904
file(RENAME
${CURRENT_PACKAGES_DIR}/include/libmongoc-1.0
${CURRENT_PACKAGES_DIR}/temp)
Expand All @@ -49,4 +58,7 @@ else()
file(REMOVE ${CURRENT_PACKAGES_DIR}/debug/lib/mongoc-static-1.0.lib)
endif()

file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/mongo-c-driver RENAME copyright)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/mongo-c-driver RENAME copyright)
file(COPY ${SOURCE_PATH}/THIRD_PARTY_NOTICES DESTINATION ${CURRENT_PACKAGES_DIR}/share/mongo-c-driver)

vcpkg_copy_pdbs()

0 comments on commit 0163b19

Please sign in to comment.