Skip to content

Commit d8e85d5

Browse files
committed
azure: fix building in MinGW via Bash
Azure Pipelines supports bash tasks on Windows hosts due to it always having Git for Windows included. To support this, the Git for Window directory is added to the PATH environment to make the bash shell available for execution. Unfortunately, this breaks CMake with the MinGW generator, as it has sanity checks to verify that no bash executable is in the PATH. So we can either remove Git for Windows from the path, but then we're unable to execute bash jobs. Or we can add it to the path, but then we're unable to execute CMake with the MinGW generator. Let's re-model how we set the PATH environment. Instead of setting up PATH for the complete build job, we now set a variable "BUILD_PATH" for the job. This variable is only being used when executing CMake so that it encounters a sanitizied PATH environment without GfW's bash shell.
1 parent ffac520 commit d8e85d5

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ jobs:
9999
- template: azure-pipelines/powershell.yml
100100
parameters:
101101
environmentVariables:
102+
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
102103
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
103-
PATH: $(Agent.TempDirectory)\mingw64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
104104

105105
- job: windows_mingw_x86
106106
displayName: 'Windows (x86; MinGW)'
@@ -115,8 +115,8 @@ jobs:
115115
- template: azure-pipelines/powershell.yml
116116
parameters:
117117
environmentVariables:
118+
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
118119
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
119-
PATH: $(Agent.TempDirectory)\mingw32\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
120120

121121
- job: documentation
122122
displayName: 'Generate Documentation'

azure-pipelines/build.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ set -e
99

1010
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
1111
BUILD_DIR=$(pwd)
12+
BUILD_PATH=${BUILD_PATH:=$PATH}
1213
CC=${CC:-cc}
14+
CMAKE=$(which cmake)
1315

1416
indent() { sed "s/^/ /"; }
1517

@@ -31,7 +33,7 @@ echo "Kernel version:"
3133
uname -a 2>&1 | indent
3234

3335
echo "CMake version:"
34-
cmake --version 2>&1 | indent
36+
env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent
3537
echo "Compiler version:"
3638
$CC --version 2>&1 | indent
3739
echo ""
@@ -41,11 +43,11 @@ echo "## Configuring build environment"
4143
echo "##############################################################################"
4244

4345
echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
44-
cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
46+
env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
4547

4648
echo ""
4749
echo "##############################################################################"
4850
echo "## Building libgit2"
4951
echo "##############################################################################"
5052

51-
cmake --build .
53+
env PATH="$BUILD_PATH" "$CMAKE" --build .

azure-pipelines/nightly.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ jobs:
102102
- template: powershell.yml
103103
parameters:
104104
environmentVariables:
105+
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
105106
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
106-
PATH: $(Agent.TempDirectory)\mingw64\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
107107
RUN_INVASIVE_TESTS: true
108108

109109
- job: windows_mingw_x86
@@ -119,8 +119,8 @@ jobs:
119119
- template: powershell.yml
120120
parameters:
121121
environmentVariables:
122+
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
122123
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
123-
PATH: $(Agent.TempDirectory)\mingw32\bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\CMake\bin
124124
RUN_INVASIVE_TESTS: true
125125

126126
- job: linux_x86_bionic_gcc_openssl

0 commit comments

Comments
 (0)