Skip to content
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
25 changes: 14 additions & 11 deletions .evergreen/scripts/build-example-projects.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,31 @@
set -o errexit
set -o pipefail

if [ "$USE_STATIC_LIBS" ]; then
DIR=static
declare link_type
if [[ "${USE_STATIC_LIBS:-}" == 1 ]]; then
link_type=static
else
DIR=shared
link_type=shared
fi
: "${link_type:?}"

cd examples/projects

for project in bsoncxx mongocxx; do
(
cd $project
cd "${project:?}"

if ! (cd cmake/$DIR && ./build.sh >|output.txt 2>&1); then
echo "Example $project/cmake/$DIR failed" 1>&2
cat cmake/$DIR/output.txt 1>&2
if ! (cd "cmake/${link_type:?}" && ./build.sh >|output.txt 2>&1); then
echo "Example ${project:?}/cmake/${link_type:?} failed" 1>&2
cat "cmake/${link_type:?}/output.txt" 1>&2
exit 1
fi

if [[ ! ("$OSTYPE" =~ cygwin) ]]; then
if ! (cd pkg-config/$DIR && ./build.sh >|output.txt 2>&1); then
echo "Example $project/pkg-config/$DIR failed" 1>&2
cat pkg-config/$DIR/output.txt 1>&2
# pkg-config is only applicable to non-Visual Studio generators.
if [[ "${generator:-}" != Visual\ Studio\ * ]]; then
if ! (cd "pkg-config/${link_type:?}" && ./build.sh >|output.txt 2>&1); then
echo "Example ${project:?}/pkg-config/${link_type:?} failed" 1>&2
cat "pkg-config/${link_type:?}/output.txt" 1>&2
exit 1
fi
fi
Expand Down
3 changes: 3 additions & 0 deletions .evergreen/scripts/install-build-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ install_build_tools() {
uv tool install -q ninja || return
fi

uv tool install -q pkgconf || return

cmake --version | head -n 1 || return
echo "ninja version: $(ninja --version)" || return
echo "pkgconf version: $(pkgconf --version 2>/dev/null)" || return
}
9 changes: 7 additions & 2 deletions .evergreen/scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,13 @@ CMAKE_PREFIX_PATH="${mongoc_dir:?}:${working_dir:?}/build/install"
export CMAKE_PREFIX_PATH

PKG_CONFIG_PATH=""
PKG_CONFIG_PATH+=":${mongoc_dir:?}/${LIB_DIR:?}/pkgconfig"
PKG_CONFIG_PATH+=":${working_dir:?}/build/install/${LIB_DIR:?}/pkgconfig"
if [[ "${OSTYPE:?}" == cygwin ]]; then
PKG_CONFIG_PATH+=";$(cygpath -aw "${mongoc_dir:?}/${LIB_DIR:?}/pkgconfig")"
PKG_CONFIG_PATH+=";$(cygpath -aw "${working_dir:?}/build/install/${LIB_DIR:?}/pkgconfig")"
else
PKG_CONFIG_PATH+=":${mongoc_dir:?}/${LIB_DIR:?}/pkgconfig"
PKG_CONFIG_PATH+=":${working_dir:?}/build/install/${LIB_DIR:?}/pkgconfig"
fi
export PKG_CONFIG_PATH

if [[ "${generator:-}" != Visual\ Studio\ * ]]; then
Expand Down
2 changes: 1 addition & 1 deletion examples/mongocxx/tutorial.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Compile with: c++ --std=c++11 tutorial.cpp $(pkg-config --cflags --libs libmongocxx)
// Compile with: c++ --std=c++11 tutorial.cpp $(pkgconf --cflags --libs libmongocxx)

// The following is a formatted copy from the tutorial
// https://www.mongodb.com/docs/languages/cpp/cpp-driver/current/tutorial/.
Expand Down
2 changes: 1 addition & 1 deletion examples/projects/bsoncxx/pkg-config/shared/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -o pipefail

# Sanity-check that static library macros are not set when building against the shared library.
# Users don't need to include this section in their projects.
if ! pkg-config --cflags libbsoncxx | grep -v -q -- -DBSONCXX_STATIC; then
if ! pkgconf --cflags libbsoncxx | grep -v -q -- -DBSONCXX_STATIC; then
echo "Expected BSONCXX_STATIC to not be set" >&2
exit 1
fi
Expand Down
4 changes: 2 additions & 2 deletions examples/projects/bsoncxx/pkg-config/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ set -o pipefail

# Sanity-check that static library macros are set when building against the static library. Users
# don't need to include this section in their projects.
if ! pkg-config --cflags libbsoncxx-static | grep -q -- -DBSONCXX_STATIC; then
if ! pkgconf --cflags libbsoncxx-static | grep -q -- -DBSONCXX_STATIC; then
echo "Expected BSONCXX_STATIC to be set" >&2
exit 1
fi

# Sanity-check that static libbson is required. Regression test for CXX-3290.
if ! pkg-config --print-requires libbsoncxx-static | grep -q -- bson2-static; then
if ! pkgconf --print-requires libbsoncxx-static | grep -q -- bson2-static; then
echo "Expected bson2-static to be required" >&2
exit 1
fi
Expand Down
6 changes: 4 additions & 2 deletions examples/projects/mongocxx/pkg-config/shared/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
set -o errexit
set -o pipefail

command -V pkgconf

# Sanity-check that static library macros are not set when building against the shared library.
# Users don't need to include this section in their projects.
if ! pkg-config --cflags libmongocxx | grep -v -q -- -DBSONCXX_STATIC; then
if ! pkgconf --cflags libmongocxx | grep -v -q -- -DBSONCXX_STATIC; then
echo "Expected BSONCXX_STATIC to not be set" >&2
exit 1
fi

if ! pkg-config --cflags libmongocxx | grep -v -q -- -DMONGOCXX_STATIC; then
if ! pkgconf --cflags libmongocxx | grep -v -q -- -DMONGOCXX_STATIC; then
echo "Expected MONGOCXX_STATIC to not be set" >&2
exit 1
fi
Expand Down
6 changes: 3 additions & 3 deletions examples/projects/mongocxx/pkg-config/static/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ set -o pipefail

# Sanity-check that static library macros are set when building against the static library. Users
# don't need to include this section in their projects.
if ! pkg-config --cflags libmongocxx-static | grep -q -- -DBSONCXX_STATIC; then
if ! pkgconf --cflags libmongocxx-static | grep -q -- -DBSONCXX_STATIC; then
echo "Expected BSONCXX_STATIC to be set" >&2
exit 1
fi

if ! pkg-config --cflags libmongocxx-static | grep -q -- -DMONGOCXX_STATIC; then
if ! pkgconf --cflags libmongocxx-static | grep -q -- -DMONGOCXX_STATIC; then
echo "Expected MONGOCXX_STATIC to be set" >&2
exit 1
fi

# Sanity-check that static libmongoc is required. Regression test for CXX-3290.
if ! pkg-config --print-requires libmongocxx-static | grep -q -- mongoc2-static; then
if ! pkgconf --print-requires libmongocxx-static | grep -q -- mongoc2-static; then
echo "Expected mongoc2-static to be required" >&2
exit 1
fi
Expand Down