Skip to content

Commit b857122

Browse files
committed
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`.
1 parent a7bc32e commit b857122

File tree

2 files changed

+28
-4
lines changed

2 files changed

+28
-4
lines changed

ci/build.sh

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,30 @@ BUILD_PATH=${BUILD_PATH:=$PATH}
1313
CMAKE=$(which cmake)
1414
CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles}
1515

16+
indent() { sed "s/^/ /"; }
17+
18+
cygfullpath() {
19+
result=$(echo "${1}" | tr \; \\n | while read -r element; do
20+
if [ "${last}" != "" ]; then echo -n ":"; fi
21+
echo -n $(cygpath "${element}")
22+
last="${element}"
23+
done)
24+
if [ "${result}" = "" ]; then exit 1; fi
25+
echo "${result}"
26+
}
27+
1628
if [[ "$(uname -s)" == MINGW* ]]; then
17-
BUILD_PATH=$(cygpath "$BUILD_PATH")
29+
BUILD_PATH=$(cygfullpath "${BUILD_PATH}")
1830
fi
1931
20-
indent() { sed "s/^/ /"; }
2132
2233
echo "Source directory: ${SOURCE_DIR}"
2334
echo "Build directory: ${BUILD_DIR}"
2435
echo ""
2536
37+
echo "Platform:"
38+
uname -s | indent
39+
2640
if [ "$(uname -s)" = "Darwin" ]; then
2741
echo "macOS version:"
2842
sw_vers | indent
@@ -40,7 +54,7 @@ echo "Kernel version:"
4054
uname -a 2>&1 | indent
4155
4256
echo "CMake version:"
43-
env PATH="${BUILD_PATH}" "${CMAKE}" --version 2>&1 | indent
57+
env PATH="${BUILD_PATH}" "${CMAKE}" --version | head -1 2>&1 | indent
4458
4559
if test -n "${CC}"; then
4660
echo "Compiler version:"

ci/test.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,18 @@ run_test() {
104104

105105
indent() { sed "s/^/ /"; }
106106

107+
cygfullpath() {
108+
result=$(echo "${1}" | tr \; \\n | while read -r element; do
109+
if [ "${last}" != "" ]; then echo -n ":"; fi
110+
echo -n $(cygpath "${element}")
111+
last="${element}"
112+
done)
113+
if [ "${result}" = "" ]; then exit 1; fi
114+
echo "${result}"
115+
}
116+
107117
if [[ "$(uname -s)" == MINGW* ]]; then
108-
BUILD_PATH=$(cygpath "$BUILD_PATH")
118+
BUILD_PATH=$(cygfullpath "$BUILD_PATH")
109119
fi
110120
111121

0 commit comments

Comments
 (0)