Skip to content

Commit

Permalink
MONGOCRYPT-330 reduce overlinking for pkg-config script (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
rcsanchez97 authored Sep 3, 2021
1 parent 8eeeee9 commit b911184
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 5 deletions.
20 changes: 16 additions & 4 deletions .evergreen/pkgconfig-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions test/example-no-bson.c
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <mongocrypt.h>

int main () {
printf ("mongocrypt_version=%s\n", mongocrypt_version(0));
return 0;
}

0 comments on commit b911184

Please sign in to comment.