Skip to content

Restore cmake_policy in GenerateUninstaller, fix EVG batch scripts, and use Ninja with mingw-w64 #2070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .evergreen/config_generator/etc/distros.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,12 @@ def compiler_to_vars(compiler):
'CMAKE_GENERATOR_PLATFORM': to_platform(vs),
}

case _, ['mingw', *rest]:
return {
'CC': '-'.join(['gcc'] + rest),
'CXX': '-'.join(['g++'] + rest),
}

case compiler, _:
return {
'CC': compiler,
Expand Down
14 changes: 8 additions & 6 deletions .evergreen/generated_configs/legacy-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -804,33 +804,35 @@ tasks:
type: test
params:
working_dir: mongoc
redirect_standard_error_to_output: true
include_expansions_in_env:
- distro_id
shell: bash
script: |-
set -o errexit
. .evergreen/scripts/find-cmake-latest.sh
export CMAKE="$(find_cmake_latest)"
export CC="C:/mingw-w64/x86_64-4.9.1-posix-seh-rt_v3-rev1/mingw64/bin/gcc.exe"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd
CMAKE="$(cygpath -aw "$CMAKE")"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-mingw.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-mingw.cmd
- name: install-uninstall-check-msvc
commands:
- func: find-cmake-latest
- command: shell.exec
type: test
params:
working_dir: mongoc
redirect_standard_error_to_output: true
include_expansions_in_env:
- distro_id
shell: bash
script: |-
set -o errexit
. .evergreen/scripts/find-cmake-latest.sh
export CMAKE="$(find_cmake_latest)"
export CC="Visual Studio 14 2015 Win64"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd
CMAKE="$(cygpath -aw "$CMAKE")"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-msvc.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-msvc.cmd
- name: install-uninstall-check
commands:
- func: find-cmake-latest
Expand Down
12 changes: 6 additions & 6 deletions .evergreen/generated_configs/tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5181,8 +5181,8 @@ tasks:
- func: find-cmake-latest
- func: sasl-sspi-winssl-compile
vars:
CC: mingw
CXX: mingw
CC: gcc
CXX: g++
- func: upload-build
- name: sasl-sspi-winssl-windows-2019-mingw-test-8.0-server-auth
run_on: windows-vsCurrent-small
Expand All @@ -5195,8 +5195,8 @@ tasks:
- command: expansions.update
params:
updates:
- { key: CC, value: mingw }
- { key: CXX, value: mingw }
- { key: CC, value: gcc }
- { key: CXX, value: g++ }
- { key: AUTH, value: auth }
- { key: MONGODB_VERSION, value: "8.0" }
- { key: TOPOLOGY, value: server }
Expand All @@ -5216,8 +5216,8 @@ tasks:
- command: expansions.update
params:
updates:
- { key: CC, value: mingw }
- { key: CXX, value: mingw }
- { key: CC, value: gcc }
- { key: CXX, value: g++ }
- { key: AUTH, value: auth }
- { key: MONGODB_VERSION, value: latest }
- { key: TOPOLOGY, value: server }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,11 @@ def __init__(
r"""
. .evergreen/scripts/find-cmake-latest.sh
export CMAKE="$(find_cmake_latest)"
export CC="C:/mingw-w64/x86_64-4.9.1-posix-seh-rt_v3-rev1/mingw64/bin/gcc.exe"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd""",
CMAKE="$(cygpath -aw "$CMAKE")"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-mingw.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-mingw.cmd""",
include_expansions_in_env=["distro_id"],
redirect_standard_error_to_output=True,
)
],
),
Expand All @@ -302,10 +303,11 @@ def __init__(
r"""
. .evergreen/scripts/find-cmake-latest.sh
export CMAKE="$(find_cmake_latest)"
export CC="Visual Studio 14 2015 Win64"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-windows.cmd""",
CMAKE="$(cygpath -aw "$CMAKE")"
BSON_ONLY=1 cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-msvc.cmd
cmd.exe /c .\\.evergreen\\scripts\\install-uninstall-check-msvc.cmd""",
include_expansions_in_env=["distro_id"],
redirect_standard_error_to_output=True,
)
],
),
Expand Down
7 changes: 2 additions & 5 deletions .evergreen/scripts/compile-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ IFS=' ' read -ra extra_configure_flags <<<"${EXTRA_CONFIGURE_FLAGS:-}"

configure_flags_append "-DCMAKE_INSTALL_PREFIX=$(native-path "${install_dir}")"
configure_flags_append "-DCMAKE_PREFIX_PATH=$(native-path "${install_dir}")"
configure_flags_append "-DENABLE_AUTOMATIC_INIT_AND_CLEANUP=OFF"
configure_flags_append "-DENABLE_MAINTAINER_FLAGS=ON"

configure_flags_append_if_not_null C_STD_VERSION "-DCMAKE_C_STANDARD=${C_STD_VERSION:-}"
Expand Down Expand Up @@ -98,17 +97,15 @@ CMAKE_BUILD_PARALLEL_LEVEL="$(nproc)"
declare build_dir
build_dir="cmake-build"

if [[ "${CC}" =~ mingw ]]; then
if [[ "${CC}" =~ 'gcc' ]]; then
# MinGW has trouble compiling src/cpp-check.cpp without some assistance.
configure_flags_append "-DCMAKE_CXX_STANDARD=11"

env \
"CC=gcc" \
"CXX=g++" \
"${cmake_binary:?}" \
-S . \
-B "${build_dir:?}" \
-G "MinGW Makefiles" \
-G "Ninja" \
"${configure_flags[@]}" \
"${extra_configure_flags[@]}"

Expand Down
180 changes: 180 additions & 0 deletions .evergreen/scripts/install-uninstall-check-mingw.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
REM Supported/used environment variables:
REM BSON_ONLY Whether to build only the BSON library.

rem Ensure Cygwin executables like sh.exe are not in PATH
rem set PATH=C:\Windows\system32;C:\Windows

echo on
echo

set SRCROOT=%CD%
set TAR=C:\cygwin\bin\tar

set version=1.31.0
set major=1

if "%BSON_ONLY%"=="1" (
set BUILD_DIR=%CD%\build-dir-bson
set INSTALL_DIR=%CD%\install-dir-bson
) else (
set BUILD_DIR=%CD%\build-dir-mongoc
set INSTALL_DIR=%CD%\install-dir-mongoc
)
rmdir /S /Q %BUILD_DIR% 2>nul || true
mkdir %BUILD_DIR% || goto :error

rmdir /S /Q %INSTALL_DIR% 2>nul || true
mkdir %INSTALL_DIR% || goto :error

set PATH=%PATH%;%INSTALL_DIR%\bin

cd %BUILD_DIR% || goto :error

if "%BSON_ONLY%"=="1" (
set BSON_ONLY_OPTION=-DENABLE_MONGOC=OFF
) else (
set BSON_ONLY_OPTION=-DENABLE_MONGOC=ON
)

rem Build libmongoc, with flags that the downstream R driver mongolite uses
%CMAKE% -G "Ninja" -DCMAKE_INSTALL_PREFIX=%INSTALL_DIR% -DCMAKE_PREFIX_PATH=%INSTALL_DIR%\lib\cmake %BSON_ONLY_OPTION% .. || goto :error
%CMAKE% --build . || goto :error
%CMAKE% --build . --target install || goto :error

REM no kms-message components should be installed
if exist %INSTALL_DIR%\include\kms_message\kms_message.h (
echo kms_message.h found!
goto :error
) else (
echo kms_message.h check ok
)
if exist %INSTALL_DIR%\lib\libkms_message-static.a (
echo libkms_message-static.a found!
goto :error
) else (
echo libkms_message-static.a check ok
)
if exist %INSTALL_DIR%\lib\cmake\kms_message\kms_message-config.cmake (
echo kms_message-config.cmake found!
goto :error
) else (
echo kms_message-config.cmake check ok
)

echo > %INSTALL_DIR%\lib\canary.txt || goto :error

dir %INSTALL_DIR%\share\mongo-c-driver || goto :error

rem CDRIVER-6062: uninstall script may return non-zero exit code despite success.
%CMAKE% --build . --target uninstall || true

if exist %INSTALL_DIR%\lib\pkgconfig\bson%major%.pc (
echo bson%major%.pc found!
goto :error
) else (
echo bson%major%.pc check ok
)
if not exist %INSTALL_DIR%\lib\canary.txt (
echo canary.txt not found!
goto :error
) else (
echo canary.txt check ok
)
if not exist %INSTALL_DIR%\lib (
echo %INSTALL_DIR%\lib not found!
goto :error
) else (
echo %INSTALL_DIR%\lib check ok
)
if "%BSON_ONLY%" NEQ "1" (
if exist %INSTALL_DIR%\lib\pkgconfig\mongoc%major%.pc (
echo mongoc%major%.pc found!
goto :error
) else (
echo mongoc%major%.pc check ok
)
if exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config.cmake (
echo mongoc-1.0-config.cmake found!
goto :error
) else (
echo mongoc-1.0-config.cmake check ok
)
if exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-1.0-config-version.cmake (
echo mongoc-1.0-config-version.cmake found!
goto :error
) else (
echo mongoc-1.0-config-version.cmake check ok
)
if exist %INSTALL_DIR%\lib\cmake\mongoc-1.0\mongoc-targets.cmake (
echo mongoc-targets.cmake found!
goto :error
) else (
echo mongoc-targets.cmake check ok
)
)
if exist %INSTALL_DIR%\include\bson-%version%\bson\bson.h (
echo bson\bson.h found!
goto :error
) else (
echo bson\bson.h check ok
)
if exist %INSTALL_DIR%\include\bson-%version% (
echo %INSTALL_DIR%\include\bson-%version% found!
goto :error
) else (
echo %INSTALL_DIR%\include\bson-%version% check ok
)
if "%BSON_ONLY%" NEQ "1" (
if exist %INSTALL_DIR%\include\libmongoc-1.0\mongoc\mongoc.h (
echo mongoc\mongoc.h found!
goto :error
) else (
echo mongoc\mongoc.h check ok
)
if exist %INSTALL_DIR%\include\libmongoc-1.0\mongoc.h (
echo mongoc.h found!
goto :error
) else (
echo mongoc.h check ok
)
if exist %INSTALL_DIR%\include\libmongoc-1.0 (
echo %INSTALL_DIR%\include\libmongoc-1.0 found!
goto :error
) else (
echo %INSTALL_DIR%\include\libmongoc-1.0 check ok
)
)
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall-bson.cmd (
echo uninstall-bson.cmd found!
goto :error
) else (
echo uninstall-bson.cmd check ok
)
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall.cmd (
echo uninstall.cmd found!
goto :error
) else (
echo uninstall.cmd check ok
)
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall-bson.sh (
echo uninstall-bson.sh found!
goto :error
) else (
echo uninstall-bson.sh check ok
)
if exist %INSTALL_DIR%\share\mongo-c-driver\uninstall.sh (
echo uninstall.sh found!
goto :error
) else (
echo uninstall.sh check ok
)
if exist %INSTALL_DIR%\share\mongo-c-driver (
echo %INSTALL_DIR%\share\mongo-c-driver found!
goto :error
) else (
echo %INSTALL_DIR%\share\mongo-c-driver check ok
)

goto :EOF
:error
exit /B %errorlevel%
Loading