Skip to content

CDRIVER-4625 Add mcd-rpc library and tests #1296

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 14 commits into from
Jun 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .evergreen/scripts/check-preludes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
checks = [
{
"name": "libmongoc",
"headers": list(MONGOC_PREFIX.glob("*.h")),
"headers": list(MONGOC_PREFIX.glob("mongoc-*.h")),
"exclusions": [
MONGOC_PREFIX / "mongoc-prelude.h",
MONGOC_PREFIX / "mongoc.h"
MONGOC_PREFIX / "mongoc.h",
],
"include": "#include \"mongoc-prelude.h\""
},
{
"name": "libbson",
"headers": list(BSON_PREFIX.glob("*.h")),
"exclusions": [
BSON_PREFIX / "bson-prelude.h",
BSON_PREFIX / "bson-dsl.h",
BSON_PREFIX / "bson.h"
BSON_PREFIX / "bson-prelude.h",
BSON_PREFIX / "bson.h",
],
"include": "#include \"bson-prelude.h\""
},
Expand Down
2 changes: 1 addition & 1 deletion .evergreen/scripts/check-public-decls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exclude="\.\/src\/libmongoc\/src\/mongoc\/mongoc-macros.h|.\/src\/libmongoc\/src
find ./src/libmongoc/src/mongoc -regex $pattern -regextype posix-extended -not -regex $exclude | sort >/tmp/public_headers.txt

# get all public headers with BSON_BEGIN_DECLS.
find ./src/libmongoc/src/mongoc -regextype posix-extended -regex $pattern -not -regex $exclude | xargs grep -l "BSON_BEGIN_DECLS" | sort >/tmp/public_headers_with_extern_c.txt
find ./src/libmongoc/src/mongoc -regex $pattern -regextype posix-extended -not -regex $exclude | xargs grep -l "BSON_BEGIN_DECLS" | sort >/tmp/public_headers_with_extern_c.txt

echo "checking if any public headers are missing 'extern C' declaration"

Expand Down
24 changes: 24 additions & 0 deletions src/libmongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ endif ()

set (SOURCES ${SOURCES}
${PROJECT_SOURCE_DIR}/src/mongoc/mcd-azure.c
${PROJECT_SOURCE_DIR}/src/mongoc/mcd-rpc.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-aggregate.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-apm.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-array.c
Expand Down Expand Up @@ -525,6 +526,7 @@ set (SOURCES ${SOURCES}
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cursor-array.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-database.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-error.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-flags.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-find-and-modify.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-generation-map.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-init.c
Expand All @@ -548,6 +550,7 @@ set (SOURCES ${SOURCES}
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-matcher-op.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-memcmp.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-cmd.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-opcode.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-optional.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-opts-helpers.c
${PROJECT_SOURCE_DIR}/src/mongoc/mongoc-opts.c
Expand Down Expand Up @@ -758,6 +761,17 @@ if (MONGOC_ENABLE_MONGODB_AWS_AUTH)
endif()
endif ()

if (MONGOC_ENABLE_STATIC_BUILD)
add_library (mcd_rpc STATIC EXCLUDE_FROM_ALL ${PROJECT_SOURCE_DIR}/src/mongoc/mcd-rpc.c)
target_include_directories (mcd_rpc PUBLIC ${PROJECT_SOURCE_DIR}/src)
target_link_libraries (mcd_rpc PUBLIC ${BSON_STATIC_LIBRARIES})
if (NOT WIN32 AND ENABLE_PIC)
target_compile_options (mcd_rpc PUBLIC -fPIC)
endif ()
target_compile_definitions (mcd_rpc PUBLIC ${BSON_STATIC_PUBLIC_DEFINITIONS})
set_target_properties (mcd_rpc PROPERTIES OUTPUT_NAME "mcd-rpc")
endif ()

add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} ${HEADERS_FORWARDING})
set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden)
target_link_libraries (mongoc_shared PRIVATE ${LIBRARIES} PUBLIC ${BSON_LIBRARIES})
Expand Down Expand Up @@ -982,6 +996,7 @@ set (test-libmongoc-sources
${PROJECT_SOURCE_DIR}/tests/test-mcd-azure-imds.c
${PROJECT_SOURCE_DIR}/tests/test-service-gcp.c
${PROJECT_SOURCE_DIR}/tests/test-mcd-integer.c
${PROJECT_SOURCE_DIR}/tests/test-mcd-rpc.c
${PROJECT_SOURCE_DIR}/tests/TestSuite.c
${PROJECT_SOURCE_DIR}/tests/unified/operation.c
${PROJECT_SOURCE_DIR}/tests/unified/entity-map.c
Expand Down Expand Up @@ -1260,6 +1275,15 @@ export (EXPORT mongoc-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-targets.cmake"
)

if (TARGET mcd_rpc)
# Note: the (mongo::)bson_static target must be included separately via find_package or include.
export (
TARGETS mcd_rpc
NAMESPACE mongo::
FILE "${CMAKE_CURRENT_BINARY_DIR}/mongoc/mcd-rpc-targets.cmake"
)
endif ()

configure_file (src/mongoc-config.cmake
"${CMAKE_CURRENT_BINARY_DIR}/mongoc/mongoc-${MONGOC_API_VERSION}-config.cmake"
@ONLY
Expand Down
4 changes: 4 additions & 0 deletions src/libmongoc/src/mongoc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ extra_dist_generated (
set (src_libmongoc_src_mongoc_DIST_noinst_hs
mcd-azure.h
mcd-integer.h
mcd-rpc.h
mcd-time.h
mongoc-aggregate-private.h
mongoc-apm-private.h
Expand Down Expand Up @@ -182,6 +183,7 @@ set (src_libmongoc_src_mongoc_DIST_noinst_hs

set (src_libmongoc_src_mongoc_DIST_cs
mcd-azure.c
mcd-rpc.c
mongoc-aggregate.c
mongoc-apm.c
mongoc-array.c
Expand Down Expand Up @@ -211,6 +213,7 @@ set (src_libmongoc_src_mongoc_DIST_cs
mongoc-cursor-cmd-deprecated.c
mongoc-database.c
mongoc-error.c
mongoc-flags.c
mongoc-find-and-modify.c
mongoc-generation-map.c
mongoc-host-list.c
Expand All @@ -233,6 +236,7 @@ set (src_libmongoc_src_mongoc_DIST_cs
mongoc-memcmp.c
mongoc-cmd.c
mongoc-ocsp-cache.c
mongoc-opcode.c
mongoc-optional.c
mongoc-opts.c
mongoc-opts-helpers.c
Expand Down
Loading