Skip to content

Commit 756e9e1

Browse files
committed
CDRIVER-2157 link a sample program with MinGW-64
1 parent 6540c10 commit 756e9e1

File tree

7 files changed

+174
-51
lines changed

7 files changed

+174
-51
lines changed

.evergreen/check-installed-files.bat

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

.evergreen/config.yml

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -756,8 +756,8 @@ tasks:
756756
# Build libmongoc with CMake (not Autotools) and compile a program
757757
# that links dynamically or statically to it, using variables from
758758
# CMake's find_package command.
759-
LINK_STATIC= cmd.exe /c .\\.evergreen\\link-sample-program.bat
760-
LINK_STATIC=1 cmd.exe /c .\\.evergreen\\link-sample-program.bat
759+
LINK_STATIC= cmd.exe /c .\\.evergreen\\link-sample-program-msvc.bat
760+
LINK_STATIC=1 cmd.exe /c .\\.evergreen\\link-sample-program-msvc.bat
761761
762762
- name: link-with-cmake-windows-ssl
763763
depends_on:
@@ -778,8 +778,26 @@ tasks:
778778
# that links dynamically or statically to it, using variables from
779779
# CMake's find_package command.
780780
export ENABLE_SSL=1
781-
LINK_STATIC= cmd.exe /c .\\.evergreen\\link-sample-program.bat
782-
LINK_STATIC=1 cmd.exe /c .\\.evergreen\\link-sample-program.bat
781+
LINK_STATIC= cmd.exe /c .\\.evergreen\\link-sample-program-msvc.bat
782+
LINK_STATIC=1 cmd.exe /c .\\.evergreen\\link-sample-program-msvc.bat
783+
784+
- name: link-with-cmake-mingw
785+
depends_on:
786+
- name: "make-release-archive"
787+
variant: releng
788+
commands:
789+
- func: "bootstrap mongo-orchestration"
790+
vars:
791+
VERSION: "3.4"
792+
- command: shell.exec
793+
type: test
794+
params:
795+
working_dir: "mongoc"
796+
script: |
797+
# Build libmongoc with CMake (not Autotools) and compile a program
798+
# that links dynamically or statically to it, using variables from
799+
# pkg-config.exe.
800+
cmd.exe /c .\\.evergreen\\link-sample-program-mingw.bat
783801
784802
- name: link-with-pkg-config
785803
depends_on:
@@ -6494,6 +6512,9 @@ buildvariants:
64946512
distros:
64956513
- windows-64-vs2015-compile
64966514
- windows-64-vs2015-test
6515+
- name: "link-with-cmake-mingw"
6516+
distros:
6517+
- windows-64-vs2013-compile
64976518
- name: "link-with-pkg-config"
64986519
distros:
64996520
- ubuntu1604-build
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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 CMAKE_FLAGS=-DENABLE_SSL=OPENSSL -DENABLE_SASL=CYRUS
8+
set TAR=C:\cygwin\bin\tar
9+
set CMAKE=C:\cmake\bin\cmake
10+
set CMAKE_MAKE_PROGRAM=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\mingw32-make.exe
11+
set CC=C:\mingw-w64\x86_64-4.9.1-posix-seh-rt_v3-rev1\mingw64\bin\gcc.exe
12+
rem Ensure Cygwin executables like sh.exe are not in PATH
13+
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
14+
15+
set SRCROOT=%CD%
16+
set BUILD_DIR=%CD%\build-dir
17+
rmdir /S /Q %BUILD_DIR%
18+
mkdir %BUILD_DIR%
19+
20+
set INSTALL_DIR=%CD%\install-dir
21+
rmdir /S /Q %INSTALL_DIR%
22+
mkdir %INSTALL_DIR%
23+
24+
set PATH=%PATH%;"c:\Program Files (x86)\MSBuild\14.0\Bin"
25+
set PATH=%PATH%;"c:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin"
26+
set PATH=%PATH%;%INSTALL_DIR%\bin
27+
28+
cd %BUILD_DIR%
29+
%TAR% xf ..\..\mongoc.tar.gz -C . --strip-components=1
30+
31+
rem Build libbson
32+
cd src\libbson
33+
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -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 ..\..
45+
rem Build libmongoc
46+
%CMAKE% -G "MinGW Makefiles" -DCMAKE_MAKE_PROGRAM=%CMAKE_MAKE_PROGRAM% -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %CMAKE_FLAGS% .
47+
%CMAKE_MAKE_PROGRAM%
48+
if errorlevel 1 (
49+
exit /B 1
50+
)
51+
52+
%CMAKE_MAKE_PROGRAM% install
53+
if errorlevel 1 (
54+
exit /B 1
55+
)
56+
57+
call ..\.evergreen\check-installed-files.bat
58+
if errorlevel 1 (
59+
exit /B 1
60+
)
61+
62+
if not exist %INSTALL_DIR%\lib\libmongoc-static-1.0.a (
63+
echo libmongoc-static-1.0.a missing!
64+
exit /B 1
65+
) else (
66+
echo libmongoc-static-1.0.a check ok
67+
)
68+
69+
cd %SRCROOT%
70+
71+
rem Test our pkg-config file
72+
set EXAMPLE_DIR=%SRCROOT%\examples\
73+
cd %EXAMPLE_DIR%
74+
75+
rem Proceed from here once we have pkg-config on Windows
76+
exit /B 0
77+
78+
set PKG_CONFIG_PATH=%INSTALL_DIR%\lib\pkgconfig
79+
80+
rem http://stackoverflow.com/questions/2323292
81+
for /f %%i in ('pkg-config --libs --cflags libmongoc-1.0') do set PKG_CONFIG_OUT=%%i
82+
83+
echo PKG_CONFIG_OUT is %PKG_CONFIG_OUT%
84+
85+
%CC% -o hello_mongoc hello_mongoc.c %PKG_CONFIG_OUT%
86+
87+
rem Works on windows-64-vs2013-compile, VS 2013 is a.k.a. "Visual Studio 12"
88+
rem And yes, they should've named the flag "dependencies".
89+
"c:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\dumpbin.exe" /dependents Debug\hello_mongoc.exe
90+
91+
rem Add DLLs to PATH
92+
set PATH=%PATH%;%INSTALL_DIR%\bin
93+
94+
Debug\hello_mongoc.exe %MONGODB_EXAMPLE_URI%

.evergreen/link-sample-program.bat renamed to .evergreen/link-sample-program-msvc.bat

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ if "%ENABLE_SSL%"=="1" (
4444
msbuild.exe /m ALL_BUILD.vcxproj
4545
msbuild.exe INSTALL.vcxproj
4646

47-
rem Notice that the dll goes in "bin".
48-
set DLL=%INSTALL_DIR%\bin\libmongoc-1.0.dll
49-
if not exist %DLL% (
50-
echo %DLL% is missing!
51-
exit /B 1
47+
call ..\.evergreen\check-installed-files.bat
48+
if errorlevel 1 (
49+
exit /B %errorlevel%
5250
)
5351

5452
rem Shim library around the DLL.
@@ -60,49 +58,12 @@ if not exist %SHIM% (
6058
echo %SHIM% check ok
6159
)
6260

63-
if not exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-1.0.pc (
64-
echo libmongoc-1.0.pc missing!
65-
exit /B 1
66-
) else (
67-
echo libmongoc-1.0.pc check ok
68-
)
69-
if not exist %INSTALL_DIR%\lib\cmake\libmongoc-1.0\libmongoc-1.0-config.cmake (
70-
echo libmongoc-1.0-config.cmake missing!
71-
exit /B 1
72-
) else (
73-
echo libmongoc-1.0-config.cmake check ok
74-
)
75-
if not exist %INSTALL_DIR%\lib\cmake\libmongoc-1.0\libmongoc-1.0-config-version.cmake (
76-
echo libmongoc-1.0-config-version.cmake missing!
77-
exit /B 1
78-
) else (
79-
echo libmongoc-1.0-config-version.cmake check ok
80-
)
81-
8261
if not exist %INSTALL_DIR%\lib\mongoc-static-1.0.lib (
8362
echo mongoc-static-1.0.lib missing!
8463
exit /B 1
8564
) else (
8665
echo mongoc-static-1.0.lib check ok
8766
)
88-
if not exist %INSTALL_DIR%\lib\pkgconfig\libmongoc-static-1.0.pc (
89-
echo libmongoc-static-1.0.pc missing!
90-
exit /B 1
91-
) else (
92-
echo libmongoc-static-1.0.pc check ok
93-
)
94-
if not exist %INSTALL_DIR%\lib\cmake\libmongoc-static-1.0\libmongoc-static-1.0-config.cmake (
95-
echo libmongoc-static-1.0-config.cmake missing!
96-
exit /B 1
97-
) else (
98-
echo libmongoc-static-1.0-config.cmake check ok
99-
)
100-
if not exist %INSTALL_DIR%\lib\cmake\libmongoc-static-1.0\libmongoc-static-1.0-config-version.cmake (
101-
echo libmongoc-static-1.0-config-version.cmake missing!
102-
exit /B 1
103-
) else (
104-
echo libmongoc-static-1.0-config-version.cmake check ok
105-
)
10667

10768
cd %SRCROOT%
10869

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,8 +751,12 @@ foreach(FLAG ${SASL_LIBS} ${SSL_LIBS} ${SHM_LIB} ${THREAD_LIB} ${ZLIB_LIBS} ${SN
751751
get_filename_component(FLAG_FILE "${FLAG}" NAME_WE)
752752
STRING(REGEX REPLACE "^lib" "" FLAG_FILE "${FLAG_FILE}")
753753
set(MONGOC_LIBS "${MONGOC_LIBS} -L${FLAG_DIR} -l${FLAG_FILE}")
754+
elseif (FLAG MATCHES "^-.*")
755+
# Flag starts with dash, add it as-is.
756+
set(pkg_config_libs "${pkg_config_libs} ${FLAG}")
754757
else ()
755-
set(MONGOC_LIBS "${MONGOC_LIBS} ${FLAG}")
758+
# Flag doesn't start with dash, add it with a dash.
759+
set(MONGOC_LIBS "${MONGOC_LIBS} -l${FLAG}")
756760
endif ()
757761
endforeach()
758762

src/mongoc/mongoc-cluster-cyrus.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,7 @@
1717
#include "mongoc-config.h"
1818

1919
#ifdef MONGOC_ENABLE_SASL_CYRUS
20-
#include <sasl/sasl.h>
21-
#include <sasl/saslutil.h>
2220
#include "mongoc-cyrus-private.h"
23-
#include "mongoc-cluster-private.h"
24-
#include "mongoc-cluster-sasl-private.h"
2521
#include "mongoc-cluster-cyrus-private.h"
2622
#include "mongoc-error.h"
2723
#include "mongoc-trace-private.h"

src/mongoc/mongoc-cluster-sasl.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17+
/* for size_t */
18+
#include <bson.h>
1719
#include "mongoc-config.h"
1820

1921
#ifdef MONGOC_ENABLE_SASL

0 commit comments

Comments
 (0)