Skip to content

Commit a10cca4

Browse files
Don't use Batch scripts to compile for MinGW
Batch scripting is fraught with peril and will almost never do what one expects. Any other scripting language is preferable. Since we have Bash available and the tools to properly convert paths, just use Bash to do this work.
1 parent 01341de commit a10cca4

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

.evergreen/scripts/compile-windows-mingw.bat

Lines changed: 0 additions & 11 deletions
This file was deleted.

.evergreen/scripts/compile-windows.sh

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,6 @@ fi
7979
declare -a extra_configure_flags
8080
IFS=' ' read -ra extra_configure_flags <<<"${EXTRA_CONFIGURE_FLAGS:-}"
8181

82-
if [[ "${CC}" =~ mingw ]]; then
83-
# MinGW has trouble compiling src/cpp-check.cpp without some assistance.
84-
configure_flags_append "-DCMAKE_CXX_STANDARD=11"
85-
86-
env \
87-
CONFIGURE_FLAGS="${configure_flags[*]} ${extra_configure_flags[*]}" \
88-
INSTALL_DIR="${install_dir}" \
89-
NJOBS="$(nproc)" \
90-
cmd.exe /c "$(native-path "${script_dir}/compile-windows-mingw.bat")"
91-
exit
92-
fi
93-
9482
declare build_config
9583

9684
if [[ "${RELEASE}" == "ON" ]]; then
@@ -112,6 +100,27 @@ fi
112100

113101
"${cmake_binary:?}" --version
114102

103+
if [[ "${CC}" =~ mingw ]]; then
104+
# MinGW has trouble compiling src/cpp-check.cpp without some assistance.
105+
configure_flags_append "-DCMAKE_CXX_STANDARD=11"
106+
cmake_binary=$(native-path "$cmake_binary")
107+
108+
build_dir=$(native-path "$mongoc_dir")
109+
env \
110+
"CC=gcc" \
111+
"CXX=g++" \
112+
"$cmake_binary" \
113+
-G "MinGW Makefiles" \
114+
-D CMAKE_PREFIX_PATH="$(native-path "$install_dir/lib/cmake")" \
115+
"${configure_flags[@]}" \
116+
"${extra_configure_flags[@]}" \
117+
-B "$build_dir" \
118+
-S "$(native-path "$mongoc_dir")"
119+
120+
env "$cmake_binary" --build "$build_dir" --parallel "$(nproc)"
121+
exit 0
122+
fi
123+
115124
declare compile_flags=(
116125
"/m" # Number of concurrent processes. No value=# of cpus
117126
)

0 commit comments

Comments
 (0)