diff options
author | Cosmin Truta <ctruta@gmail.com> | 2020-12-31 03:29:11 -0500 |
---|---|---|
committer | Cosmin Truta <ctruta@gmail.com> | 2020-12-31 03:29:11 -0500 |
commit | c2e2cd2ec5424b47104b6b15ce897af84256f5bf (patch) | |
tree | f38546e95ec07c03a7a0d17683c7a2e588e85ad2 | |
parent | c3f209178b43e327472e76562ec0ce1c3a3101bb (diff) | |
download | libpng-c2e2cd2ec5424b47104b6b15ce897af84256f5bf.tar.gz |
ci: Fix the Visual Studio verification on AppVeyor CI
The Unix paths in Bash do not mix well with the Windows paths in CMake.
The uppercase and the lowercase environment variables do not mix well
in MSBuild. Et cetera.
On AppVeyor CI, verification of Windows builds with the Visual Studio
toolchain used to work, perhaps due to one or more lucky coincidences,
but it stopped working after an upgrade on the AppVeyor CI site.
Update ci_cmake.sh as follows:
* Use POSIX commands like "mkdir" and "rm" instead of CMake commands
like "make_directory" and "remove_directory".
* Avoid using absolute paths in the CMake command line; use relative
paths that are accessible from both Bash and Windows.
* Clean up incidental mixtures of Windows and Bash-on-Windows
environment variables like {$TEMP,$Temp,$temp} and {$TMP,$Tmp,$tmp}.
-rwxr-xr-x | ci/ci_cmake.sh | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/ci/ci_cmake.sh b/ci/ci_cmake.sh index 3e6c42eaf..37792b4b5 100755 --- a/ci/ci_cmake.sh +++ b/ci/ci_cmake.sh @@ -15,6 +15,8 @@ readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" readonly CI_BUILDDIR="$CI_SRCDIR/out/cmake.build" readonly CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install" +readonly CI_SRCDIR_REL_BUILDDIR="../.." +readonly CI_INSTALLDIR_REL_BUILDDIR="../../out/cmake.install" function ci_info { printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" @@ -74,7 +76,6 @@ function ci_build_cmake { [[ $CI_AR ]] && ALL_CMAKE_VARS+=(-DCMAKE_AR="$CI_AR") [[ $CI_RANLIB ]] && ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$CI_RANLIB") ALL_CMAKE_VARS+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE") - ALL_CMAKE_VARS+=(-DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR") ALL_CMAKE_VARS+=(-DCMAKE_VERBOSE_MAKEFILE=ON) [[ $CI_NO_TEST ]] && ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) ALL_CMAKE_VARS+=($CI_CMAKE_VARS) @@ -85,12 +86,20 @@ function ci_build_cmake { ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR" [[ $CI_CMAKE_GENERATOR_PLATFORM ]] && ci_spawn export CMAKE_GENERATOR_PLATFORM="$CI_CMAKE_GENERATOR_PLATFORM" + # Fix the build environment, if necessary. + [[ $CI_CMAKE_GENERATOR == "Visual Studio "* ]] && { + # Clean up incidental mixtures of Windows and Bash-on-Windows + # environment variables, to avoid confusing MSBuild. + [[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP + [[ $TMP && ( $Tmp || $tmp ) ]] && unset TMP + } # Build and install. - ci_spawn "$CI_CMAKE" -E remove_directory "$CI_BUILDDIR" - ci_spawn "$CI_CMAKE" -E remove_directory "$CI_INSTALLDIR" - ci_spawn "$CI_CMAKE" -E make_directory "$CI_BUILDDIR" + ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" + ci_spawn mkdir -p "$CI_BUILDDIR" ci_spawn cd "$CI_BUILDDIR" - ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" "$CI_SRCDIR" + ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" \ + -DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR_REL_BUILDDIR" \ + "$CI_SRCDIR_REL_BUILDDIR" ci_spawn "$CI_CMAKE" --build . \ --config "$CI_CMAKE_BUILD_TYPE" \ "${ALL_CMAKE_BUILD_FLAGS[@]}" |