Skip to content

Commit 67c88d2

Browse files
committed
CDRIVER-2416 move libbson dist-checks to libmongoc
1 parent 144e60f commit 67c88d2

17 files changed

+301
-363
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
rem Validations shared by link-sample-program-msvc-bson.bat and
2+
rem link-sample-program-mingw-bson.bat
3+
4+
echo off
5+
6+
rem Notice that the dll goes in "bin".
7+
set DLL=%INSTALL_DIR%\bin\libbson-1.0.dll
8+
if not exist %DLL% (
9+
echo %DLL% is missing!
10+
exit /B 1
11+
) else (
12+
echo libbson-1.0.dll check ok
13+
)
14+
if not exist %INSTALL_DIR%\lib\pkgconfig\libbson-1.0.pc (
15+
echo libbson-1.0.pc missing!
16+
exit /B 1
17+
) else (
18+
echo libbson-1.0.pc check ok
19+
)
20+
if not exist %INSTALL_DIR%\lib\cmake\libbson-1.0\libbson-1.0-config.cmake (
21+
echo libbson-1.0-config.cmake missing!
22+
exit /B 1
23+
) else (
24+
echo libbson-1.0-config.cmake check ok
25+
)
26+
if not exist %INSTALL_DIR%\lib\cmake\libbson-1.0\libbson-1.0-config-version.cmake (
27+
echo libbson-1.0-config-version.cmake missing!
28+
exit /B 1
29+
) else (
30+
echo libbson-1.0-config-version.cmake check ok
31+
)
32+
if not exist %INSTALL_DIR%\lib\pkgconfig\libbson-static-1.0.pc (
33+
echo libbson-static-1.0.pc missing!
34+
exit /B 1
35+
) else (
36+
echo libbson-static-1.0.pc check ok
37+
)
38+
if not exist %INSTALL_DIR%\lib\cmake\libbson-static-1.0\libbson-static-1.0-config.cmake (
39+
echo libbson-static-1.0-config.cmake missing!
40+
exit /B 1
41+
) else (
42+
echo libbson-static-1.0-config.cmake check ok
43+
)
44+
if not exist %INSTALL_DIR%\lib\cmake\libbson-static-1.0\libbson-static-1.0-config-version.cmake (
45+
echo libbson-static-1.0-config-version.cmake missing!
46+
exit /B 1
47+
) else (
48+
echo libbson-static-1.0-config-version.cmake check ok
49+
)
50+
51+
echo on

.evergreen/check-installed-files.bat

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
rem Validations shared by link-sample-program-msvc.bat and
22
rem link-sample-program-mingw.bat
33

4+
echo off
5+
46
rem Notice that the dll goes in "bin".
57
set DLL=%INSTALL_DIR%\bin\libmongoc-1.0.dll
68
if not exist %DLL% (
79
echo %DLL% is missing!
810
exit /B 1
11+
) else (
12+
echo libmongoc-1.0.dll check ok
913
)
1014
if not exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-1.0.pc (
1115
echo libmongoc-1.0.pc missing!
@@ -43,3 +47,5 @@ if not exist %INSTALL_DIR%\lib\cmake\libmongoc-static-1.0\libmongoc-static-1.0-c
4347
) else (
4448
echo libmongoc-static-1.0-config-version.cmake check ok
4549
)
50+
51+
echo on

.evergreen/config.yml

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,20 @@ functions:
405405
BUILD_MONGOC_WITH_CMAKE= LINK_STATIC=1 sh .evergreen/link-sample-program.sh
406406
BUILD_MONGOC_WITH_CMAKE=1 LINK_STATIC=1 sh .evergreen/link-sample-program.sh
407407
408+
"link sample program bson" :
409+
- command: shell.exec
410+
type: test
411+
params:
412+
working_dir: "mongoc"
413+
script: |
414+
set -o errexit
415+
# Build libbson with CMake, compile a program that links dynamically
416+
# or statically to libbson, using variables from pkg-config or from
417+
# CMake's find_package command.
418+
BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC= sh .evergreen/link-sample-program-bson.sh
419+
BUILD_SAMPLE_WITH_CMAKE= LINK_STATIC=1 sh .evergreen/link-sample-program-bson.sh
420+
BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC= sh .evergreen/link-sample-program-bson.sh
421+
BUILD_SAMPLE_WITH_CMAKE=1 LINK_STATIC=1 sh .evergreen/link-sample-program-bson.sh
408422
409423
pre:
410424
- func: "fetch source"
@@ -934,6 +948,52 @@ tasks:
934948
vars:
935949
ENABLE_SSL: "1"
936950

951+
- name: link-with-bson
952+
depends_on:
953+
- name: "make-release-archive"
954+
variant: releng
955+
commands:
956+
- func: "link sample program bson"
957+
958+
- name: link-with-bson-mac
959+
depends_on:
960+
- name: "make-release-archive"
961+
variant: releng
962+
commands:
963+
- func: "link sample program bson"
964+
965+
- name: link-with-bson-windows
966+
depends_on:
967+
- name: "make-release-archive"
968+
variant: releng
969+
commands:
970+
- command: shell.exec
971+
type: test
972+
params:
973+
working_dir: "mongoc"
974+
script: |
975+
set -o errexit
976+
# Build libbson with CMake and compile a program that links
977+
# dynamically or statically to it, using variables from CMake's
978+
# find_package command.
979+
LINK_STATIC= cmd.exe /c .\\.evergreen\\link-sample-program-msvc-bson.cmd
980+
LINK_STATIC=1 cmd.exe /c .\\.evergreen\\link-sample-program-msvc-bson.cmd
981+
982+
- name: link-with-bson-mingw
983+
depends_on:
984+
- name: "make-release-archive"
985+
variant: releng
986+
commands:
987+
- command: shell.exec
988+
type: test
989+
params:
990+
working_dir: "mongoc"
991+
script: |
992+
# Build libbson with CMake and compile a program that links
993+
# dynamically or statically to it, using variables from
994+
# pkg-config.exe.
995+
cmd.exe /c .\\.evergreen\\link-sample-program-mingw-bson.cmd
996+
937997
- name: test-dns-openssl
938998
depends_on:
939999
- name: "debug-compile-sasl-openssl"
@@ -7461,7 +7521,22 @@ buildvariants:
74617521
- name: "link-with-pkg-config-mac"
74627522
distros:
74637523
- macos-1012
7464-
7524+
- name: "link-with-bson"
7525+
distros:
7526+
- ubuntu1604-build
7527+
- ubuntu1604-test
7528+
- ubuntu1404-build
7529+
- ubuntu1404-test
7530+
- name: "link-with-bson-windows"
7531+
distros:
7532+
- windows-64-vs2015-compile
7533+
- windows-64-vs2015-test
7534+
- name: "link-with-bson-mac"
7535+
distros:
7536+
- macos-1012
7537+
- name: "link-with-bson-mingw"
7538+
distros:
7539+
- windows-64-vs2013-compile
74657540

74667541
- name: clang34ubuntu
74677542
display_name: "clang 3.4 (Ubuntu 14.04)"

src/libbson/.evergreen/link-sample-program.sh renamed to .evergreen/link-sample-program-bson.sh

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,11 @@ set -o xtrace # Write all commands first to stderr
33
set -o errexit # Exit the script with error if any of the commands fail
44

55
# Supported/used environment variables:
6-
# BUILD_LIBBSON_WITH_CMAKE Build libbson with CMake. Default: use Autotools.
76
# LINK_STATIC Whether to statically link to libbson
87
# BUILD_SAMPLE_WITH_CMAKE Link program w/ CMake. Default: use pkg-config.
98

109

11-
echo "BUILD_LIBBSON_WITH_CMAKE=$BUILD_LIBBSON_WITH_CMAKE LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE"
12-
13-
CMAKE=${CMAKE:-/opt/cmake/bin/cmake}
10+
echo "LINK_STATIC=$LINK_STATIC BUILD_SAMPLE_WITH_CMAKE=$BUILD_SAMPLE_WITH_CMAKE"
1411

1512
if command -v gtar 2>/dev/null; then
1613
TAR=gtar
@@ -19,10 +16,12 @@ else
1916
fi
2017

2118
if [ $(uname) = "Darwin" ]; then
19+
CMAKE=${CMAKE:-/Applications/cmake-3.2.2-Darwin-x86_64/CMake.app/Contents/bin/cmake}
2220
SO=dylib
2321
LIB_SO=libbson-1.0.0.dylib
2422
LDD="otool -L"
2523
else
24+
CMAKE=${CMAKE:-/opt/cmake/bin/cmake}
2625
SO=so
2726
LIB_SO=libbson-1.0.so.0
2827
LDD=ldd
@@ -39,24 +38,15 @@ rm -rf $INSTALL_DIR
3938
mkdir -p $INSTALL_DIR
4039

4140
cd $BUILD_DIR
42-
$TAR xf ../../../../libbson.tar.gz -C . --strip-components=1
41+
$TAR xf ../../mongoc.tar.gz -C . --strip-components=1
4342

4443
if [ "$LINK_STATIC" ]; then
45-
if [ "$BUILD_LIBBSON_WITH_CMAKE" ]; then
46-
# Our CMake system builds shared and static by default.
47-
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF .
48-
else
49-
./configure --prefix=$INSTALL_DIR --enable-static
50-
fi
44+
# Our CMake system builds shared and static by default.
45+
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF .
5146
make
5247
make install
5348
else
54-
if [ "$BUILD_LIBBSON_WITH_CMAKE" ]; then
55-
# Our CMake system builds shared and static by default.
56-
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF -DENABLE_STATIC=OFF .
57-
else
58-
./configure --prefix=$INSTALL_DIR
59-
fi
49+
$CMAKE -DCMAKE_INSTALL_PREFIX=$INSTALL_DIR -DENABLE_TESTS=OFF -DENABLE_STATIC=OFF .
6050
make
6151
make install
6252

@@ -160,7 +150,7 @@ cd $SRCROOT
160150

161151
if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then
162152
# Test our CMake package config file with CMake's find_package command.
163-
EXAMPLE_DIR=$SRCROOT/examples/cmake/find_package
153+
EXAMPLE_DIR=$SRCROOT/src/libbson/examples/cmake/find_package
164154

165155
if [ "$LINK_STATIC" ]; then
166156
EXAMPLE_DIR="${EXAMPLE_DIR}_static"
@@ -172,7 +162,7 @@ if [ "$BUILD_SAMPLE_WITH_CMAKE" ]; then
172162
else
173163
# Test our pkg-config file.
174164
export PKG_CONFIG_PATH=$INSTALL_DIR/lib/pkgconfig
175-
cd $SRCROOT/examples
165+
cd $SRCROOT/src/libbson/examples
176166

177167
if [ "$LINK_STATIC" ]; then
178168
echo "pkg-config output:"
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
rem Ensure Cygwin executables like sh.exe are not in PATH
2+
rem set PATH=C:\Windows\system32;C:\Windows
3+
4+
echo on
5+
echo
6+
7+
set TAR=C:\cygwin\bin\tar
8+
set CMAKE=C:\cmake\bin\cmake
9+
set CMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\mingw32-make.exe
10+
set CC=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\gcc.exe
11+
rem Ensure Cygwin executables like sh.exe are not in PATH
12+
set PATH=C:\cygwin\bin;C:\Windows\system32;C:\Windows;C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin;C:\mongoc;src\libbson
13+
14+
set SRCROOT=%CD%
15+
set BUILD_DIR=%CD%\build-dir
16+
rmdir /S /Q %BUILD_DIR%
17+
mkdir %BUILD_DIR%
18+
19+
set INSTALL_DIR=%CD%\install-dir
20+
rmdir /S /Q %INSTALL_DIR%
21+
mkdir %INSTALL_DIR%
22+
23+
set PATH=%PATH%;"c:\Program Files (x86)\MSBuild\14.0\Bin"
24+
set PATH=%PATH%;"c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin"
25+
set PATH=%PATH%;%INSTALL_DIR%\bin
26+
27+
cd %BUILD_DIR%
28+
%TAR% xf ..\..\mongoc.tar.gz -C . --strip-components=1
29+
30+
rem Build libmongoc, with flags that the downstream R driver mongolite uses
31+
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_CFLAGS="-std=c99 -pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake .
32+
%CMAKE_MAKE_PROGRAM%
33+
if errorlevel 1 (
34+
exit /B 1
35+
)
36+
37+
%CMAKE_MAKE_PROGRAM% install
38+
if errorlevel 1 (
39+
exit /B 1
40+
)
41+
42+
call ..\.evergreen\check-installed-files-bson.bat
43+
if errorlevel 1 (
44+
exit /B 1
45+
)
46+
47+
if not exist %INSTALL_DIR%\lib\libbson-static-1.0.a (
48+
echo libbson-static-1.0.a missing!
49+
exit /B 1
50+
) else (
51+
echo libbson-static-1.0.a check ok
52+
)
53+
54+
cd %SRCROOT%
55+
56+
rem Test our pkg-config file
57+
set EXAMPLE_DIR=%SRCROOT%\src\libbson\examples\
58+
cd %EXAMPLE_DIR%
59+
60+
rem Proceed from here once we have pkg-config on Windows
61+
exit /B 0
62+
63+
set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig
64+
65+
rem http://stackoverflow.com/questions/2323292
66+
for /f %%i in ('pkg-config --libs --cflags libbson-1.0') do set PKG_CONFIG_OUT=%%i
67+
68+
echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT%
69+
70+
%CC% -o hello_bson hello_bson.c %PKG_CONFIG_OUT%
71+
72+
rem Works on windows-64-vs2013-compile, VS 2013 is a.k.a. "Visual Studio 12"
73+
rem And yes, they should've named the flag "dependencies".
74+
"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\dumpbin.exe" /dependents Debug\hello_bson.exe
75+
76+
rem Add DLLs to PATH
77+
set PATH=%PATH%;%INSTALL_DIR%\bin
78+
79+
Debug\hello_bson.exe %MONGODB_EXAMPLE_URI%

.evergreen/link-sample-program-mingw.cmd

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ set PATH=%PATH%;%INSTALL_DIR%\bin
2828
cd %BUILD_DIR%
2929
%TAR% xf ..\..\mongoc.tar.gz -C . --strip-components=1
3030

31-
rem Build libbson, with flags that the downstream R driver mongolite uses
32-
cd src\libbson
33-
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_CFLAGS="-std=c99 -pedantic" -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% .
34-
%CMAKE_MAKE_PROGRAM%
35-
if errorlevel 1 (
36-
exit /B 1
37-
)
38-
39-
%CMAKE_MAKE_PROGRAM% install
40-
if errorlevel 1 (
41-
exit /B 1
42-
)
43-
44-
cd ..\..
4531
rem Build libmongoc, with flags that the downstream R driver mongolite uses
4632
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_CFLAGS="-std=c99 -pedantic" -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %CMAKE_FLAGS% .
4733
%CMAKE_MAKE_PROGRAM%

0 commit comments

Comments
 (0)