From b9111845451fc7ee292cadf696010f6daded1713 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20C=2E=20S=C3=A1nchez?= Date: Fri, 3 Sep 2021 13:16:48 -0400 Subject: [PATCH] MONGOCRYPT-330 reduce overlinking for pkg-config script (#191) --- .evergreen/pkgconfig-tests.sh | 20 ++++++++++++++++---- CMakeLists.txt | 1 - test/example-no-bson.c | 23 +++++++++++++++++++++++ 3 files changed, 39 insertions(+), 5 deletions(-) create mode 100644 test/example-no-bson.c diff --git a/.evergreen/pkgconfig-tests.sh b/.evergreen/pkgconfig-tests.sh index 5dca7412f..5f579f680 100755 --- a/.evergreen/pkgconfig-tests.sh +++ b/.evergreen/pkgconfig-tests.sh @@ -68,16 +68,22 @@ export PKG_CONFIG_PATH="$(system_path $(/usr/bin/dirname $(/usr/bin/find $pkgcon cd $libmongocrypt_root gcc $(pkg-config --cflags libmongocrypt-static libbson-static-1.0) -o example-state-machine test/example-state-machine.c $(pkg-config --libs libmongocrypt-static) ./example-state-machine +# Build example-no-bson, static linking against libmongocrypt +gcc $(pkg-config --cflags libmongocrypt-static) -o example-no-bson test/example-no-bson.c $(pkg-config --libs libmongocrypt-static) +./example-no-bson -rm -f example-state-machine +rm -f example-state-machine example-no-bson # Build example-state-machine, dynamic linking against libmongocrypt gcc $(pkg-config --cflags libmongocrypt libbson-static-1.0) -o example-state-machine test/example-state-machine.c $(pkg-config --libs libmongocrypt) +# Build example-no-bson, dynamic linking against libmongocrypt +gcc $(pkg-config --cflags libmongocrypt) -o example-no-bson test/example-no-bson.c $(pkg-config --libs libmongocrypt) export LD_LIBRARY_PATH="$(system_path $pkgconfig_tests_root/install/libmongocrypt/lib):$(system_path $pkgconfig_tests_root/install/libmongocrypt/lib64)" ./example-state-machine +./example-no-bson unset LD_LIBRARY_PATH -rm -f example-state-machine +rm -f example-state-machine example-no-bson # Clean up prior to next execution cd $pkgconfig_tests_root @@ -95,17 +101,23 @@ $CMAKE --build . --target install --config RelWithDebInfo # Build example-state-machine, static linking against libmongocrypt cd $libmongocrypt_root gcc $(pkg-config --cflags libmongocrypt-static libbson-static-1.0) -o example-state-machine test/example-state-machine.c $(pkg-config --libs libmongocrypt-static) +# Build example-no-bson, static linking against libmongocrypt +gcc $(pkg-config --cflags libmongocrypt-static) -o example-no-bson test/example-no-bson.c $(pkg-config --libs libmongocrypt-static) export LD_LIBRARY_PATH="$(system_path $pkgconfig_tests_root/install/lib):$(system_path $pkgconfig_tests_root/install/lib64)" ./example-state-machine +./example-no-bson unset LD_LIBRARY_PATH -rm -f example-state-machine +rm -f example-state-machine example-no-bson # Build example-state-machine, dynamic linking against libmongocrypt gcc $(pkg-config --cflags libmongocrypt libbson-static-1.0) -o example-state-machine test/example-state-machine.c $(pkg-config --libs libmongocrypt) +# Build example-no-bson, dynamic linking against libmongocrypt +gcc $(pkg-config --cflags libmongocrypt) -o example-no-bson test/example-no-bson.c $(pkg-config --libs libmongocrypt) export LD_LIBRARY_PATH="$(system_path $pkgconfig_tests_root/install/lib):$(system_path $pkgconfig_tests_root/install/lib64):$(system_path $pkgconfig_tests_root/install/libmongocrypt/lib):$(system_path $pkgconfig_tests_root/install/libmongocrypt/lib64)" ./example-state-machine +./example-no-bson unset LD_LIBRARY_PATH -rm -f example-state-machine +rm -f example-state-machine example-no-bson diff --git a/CMakeLists.txt b/CMakeLists.txt index cd4d4792e..dabce9e6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,6 @@ configure_file (src/mongocrypt.h.in src/mongocrypt.h) set (PROJECT_VERSION "${BUILD_VERSION}") set (PROJECT_DESCRIPTION "The libmongocrypt client-side field level encryption library.") if (NOT ENABLE_BUILD_FOR_PPA) - set (PKG_CONFIG_REQUIRES "libbson-static-1.0") set (PKG_CONFIG_STATIC_REQUIRES "libbson-static-1.0") endif () if (ENABLE_SHARED_BSON) diff --git a/test/example-no-bson.c b/test/example-no-bson.c new file mode 100644 index 000000000..b29bca9ae --- /dev/null +++ b/test/example-no-bson.c @@ -0,0 +1,23 @@ +/* + * Copyright 2021-present MongoDB, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +int main () { + printf ("mongocrypt_version=%s\n", mongocrypt_version(0)); + return 0; +}