diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-01-31 12:17:37 +0000 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2023-02-14 11:06:38 +0000 |
commit | 870f69c34cb771329e15b527e896c13ff51ee334 (patch) | |
tree | 41cc3805578a4d9ebff024648d272090d2d59902 | |
parent | 62b03ef3a635f4b06c444e8e2823d8e8679f582b (diff) | |
download | libgit2-870f69c34cb771329e15b527e896c13ff51ee334.tar.gz |
ci: convert PATH correctly to Cygwin format on Windows
We provide `BUILD_PATH` to our build script; provide it and mutate
`PATH` when running our tests as well.
We were previously using `cygpath` to try to convert a _list_ of Windows
paths into cygwin / Unix style `PATH` format. This does not work -- it
treats the path list as a single path (with semicolons -- understandably
as those are allowed characters in a Windows path).
For example, `C:\One;C:\Two;C:\Three` is converted to
`/c/one;c:/two;c:/three`.
Add a new function to convert path lists, so that paths are split by
semicolon and fed to `cygpath` independently, then re-joined with a
colon. This means that our example `C:\One;C:\Two;C:\Three` is correctly
converted to `/c/one:/c/two:/c/three`.
-rwxr-xr-x | ci/build.sh | 20 | ||||
-rwxr-xr-x | ci/test.sh | 12 |
2 files changed, 28 insertions, 4 deletions
diff --git a/ci/build.sh b/ci/build.sh index 21a45af5f..80e7a61ae 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -13,16 +13,30 @@ BUILD_PATH=${BUILD_PATH:=$PATH} CMAKE=$(which cmake) CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles} +indent() { sed "s/^/ /"; } + +cygfullpath() { + result=$(echo "${1}" | tr \; \\n | while read -r element; do + if [ "${last}" != "" ]; then echo -n ":"; fi + echo -n $(cygpath "${element}") + last="${element}" + done) + if [ "${result}" = "" ]; then exit 1; fi + echo "${result}" +} + if [[ "$(uname -s)" == MINGW* ]]; then - BUILD_PATH=$(cygpath "$BUILD_PATH") + BUILD_PATH=$(cygfullpath "${BUILD_PATH}") fi -indent() { sed "s/^/ /"; } echo "Source directory: ${SOURCE_DIR}" echo "Build directory: ${BUILD_DIR}" echo "" +echo "Platform:" +uname -s | indent + if [ "$(uname -s)" = "Darwin" ]; then echo "macOS version:" sw_vers | indent @@ -40,7 +54,7 @@ echo "Kernel version:" uname -a 2>&1 | indent echo "CMake version:" -env PATH="${BUILD_PATH}" "${CMAKE}" --version 2>&1 | indent +env PATH="${BUILD_PATH}" "${CMAKE}" --version | head -1 2>&1 | indent if test -n "${CC}"; then echo "Compiler version:" diff --git a/ci/test.sh b/ci/test.sh index c507ed0f4..9bb374a03 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -81,8 +81,18 @@ run_test() { indent() { sed "s/^/ /"; } +cygfullpath() { + result=$(echo "${1}" | tr \; \\n | while read -r element; do + if [ "${last}" != "" ]; then echo -n ":"; fi + echo -n $(cygpath "${element}") + last="${element}" + done) + if [ "${result}" = "" ]; then exit 1; fi + echo "${result}" +} + if [[ "$(uname -s)" == MINGW* ]]; then - BUILD_PATH=$(cygpath "$BUILD_PATH") + BUILD_PATH=$(cygfullpath "$BUILD_PATH") fi |