Commit d8e85d57 by Patrick Steinhardt

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.
parent ffac520e
...@@ -99,8 +99,8 @@ jobs: ...@@ -99,8 +99,8 @@ jobs:
- template: azure-pipelines/powershell.yml - template: azure-pipelines/powershell.yml
parameters: parameters:
environmentVariables: environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
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
- job: windows_mingw_x86 - job: windows_mingw_x86
displayName: 'Windows (x86; MinGW)' displayName: 'Windows (x86; MinGW)'
...@@ -115,8 +115,8 @@ jobs: ...@@ -115,8 +115,8 @@ jobs:
- template: azure-pipelines/powershell.yml - template: azure-pipelines/powershell.yml
parameters: parameters:
environmentVariables: environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
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
- job: documentation - job: documentation
displayName: 'Generate Documentation' displayName: 'Generate Documentation'
......
...@@ -9,7 +9,9 @@ set -e ...@@ -9,7 +9,9 @@ set -e
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )} SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
BUILD_DIR=$(pwd) BUILD_DIR=$(pwd)
BUILD_PATH=${BUILD_PATH:=$PATH}
CC=${CC:-cc} CC=${CC:-cc}
CMAKE=$(which cmake)
indent() { sed "s/^/ /"; } indent() { sed "s/^/ /"; }
...@@ -31,7 +33,7 @@ echo "Kernel version:" ...@@ -31,7 +33,7 @@ echo "Kernel version:"
uname -a 2>&1 | indent uname -a 2>&1 | indent
echo "CMake version:" echo "CMake version:"
cmake --version 2>&1 | indent env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent
echo "Compiler version:" echo "Compiler version:"
$CC --version 2>&1 | indent $CC --version 2>&1 | indent
echo "" echo ""
...@@ -41,11 +43,11 @@ echo "## Configuring build environment" ...@@ -41,11 +43,11 @@ echo "## Configuring build environment"
echo "##############################################################################" echo "##############################################################################"
echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS} echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS} env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON ${CMAKE_OPTIONS}
echo "" echo ""
echo "##############################################################################" echo "##############################################################################"
echo "## Building libgit2" echo "## Building libgit2"
echo "##############################################################################" echo "##############################################################################"
cmake --build . env PATH="$BUILD_PATH" "$CMAKE" --build .
...@@ -102,8 +102,8 @@ jobs: ...@@ -102,8 +102,8 @@ jobs:
- template: powershell.yml - template: powershell.yml
parameters: parameters:
environmentVariables: environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
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
RUN_INVASIVE_TESTS: true RUN_INVASIVE_TESTS: true
- job: windows_mingw_x86 - job: windows_mingw_x86
...@@ -119,8 +119,8 @@ jobs: ...@@ -119,8 +119,8 @@ jobs:
- template: powershell.yml - template: powershell.yml
parameters: parameters:
environmentVariables: environmentVariables:
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON CMAKE_OPTIONS: -G"MinGW Makefiles" -DDEPRECATE_HARD=ON
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
RUN_INVASIVE_TESTS: true RUN_INVASIVE_TESTS: true
- job: linux_x86_bionic_gcc_openssl - job: linux_x86_bionic_gcc_openssl
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment