diff --git a/ci/ci_autotools.sh b/ci/ci_autotools.sh index 6f4dc1305..4b4d04b87 100755 --- a/ci/ci_autotools.sh +++ b/ci/ci_autotools.sh @@ -4,12 +4,13 @@ set -e # ci_autotools.sh # Continuously integrate libpng using the GNU Autotools. # -# Copyright (c) 2019-2020 Cosmin Truta. +# Copyright (c) 2019-2021 Cosmin Truta. # # This software is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h. +readonly CI_SYSNAME="$(uname -s)" readonly CI_SCRIPTNAME="$(basename "$0")" readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" @@ -35,8 +36,10 @@ function ci_spawn { function ci_init_autotools { # Initialize the CI_ variables with default values, where applicable. CI_MAKE="${CI_MAKE:-make}" - [[ $(uname -s || echo unknown) == Darwin ]] && CI_CC="${CI_CC:-clang}" + [[ $CI_SYSNAME == Darwin || $CI_SYSNAME == *BSD || $CI_SYSNAME == DragonFly ]] && + CI_CC="${CI_CC:-clang}" # Print the CI_ variables. + ci_info "system name: $CI_SYSNAME" ci_info "source directory: $CI_SRCDIR" ci_info "build directory: $CI_BUILDDIR" ci_info "install directory: $CI_INSTALLDIR" diff --git a/ci/ci_cmake.sh b/ci/ci_cmake.sh index 37792b4b5..cbee18083 100755 --- a/ci/ci_cmake.sh +++ b/ci/ci_cmake.sh @@ -4,19 +4,18 @@ set -e # ci_cmake.sh # Continuously integrate libpng using CMake. # -# Copyright (c) 2019-2020 Cosmin Truta. +# Copyright (c) 2019-2021 Cosmin Truta. # # This software is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h. +readonly CI_SYSNAME="$(uname -s)" readonly CI_SCRIPTNAME="$(basename "$0")" 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" "$*" @@ -38,12 +37,34 @@ function ci_init_cmake { # Initialize the CI_ variables with default values, where applicable. CI_CMAKE="${CI_CMAKE:-cmake}" CI_CTEST="${CI_CTEST:-ctest}" - [[ $(uname -s || echo unknown) == Darwin ]] && CI_CC="${CI_CC:-clang}" + [[ $CI_SYSNAME == Darwin || $CI_SYSNAME == *BSD || $CI_SYSNAME == DragonFly ]] && + CI_CC="${CI_CC:-clang}" CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}" + [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]] && { + # Initialize the CI_..._NATIVE variables. + if [[ -x $CYGPATH ]] + then + CI_SRCDIR_NATIVE="$("$CYGPATH" -w "$CI_SRCDIR")" + CI_BUILDDIR_NATIVE="$("$CYGPATH" -w "$CI_BUILDDIR")" + CI_INSTALLDIR_NATIVE="$("$CYGPATH" -w "$CI_INSTALLDIR")" + else + CI_SRCDIR_NATIVE="$(cd "$CI_SRCDIR" ; pwd -W || pwd -P)" + CI_BUILDDIR_NATIVE="$(cd "$CI_BUILDDIR" ; pwd -W || pwd -P)" + CI_INSTALLDIR_NATIVE="$(cd "$CI_INSTALLDIR" ; pwd -W || pwd -P)" + fi + # 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 + } # Print the CI_ variables. + ci_info "system name: $CI_SYSNAME" ci_info "source directory: $CI_SRCDIR" + [[ $CI_SRCDIR_NATIVE ]] && ci_info "source directory (native): $CI_SRCDIR_NATIVE" ci_info "build directory: $CI_BUILDDIR" + [[ $CI_BUILDDIR_NATIVE ]] && ci_info "build directory (native): $CI_BUILDDIR_NATIVE" ci_info "install directory: $CI_INSTALLDIR" + [[ $CI_INSTALLDIR_NATIVE ]] && ci_info "install directory (native): $CI_INSTALLDIR_NATIVE" ci_info "environment option: \$CI_CMAKE='$CI_CMAKE'" ci_info "environment option: \$CI_CMAKE_GENERATOR='$CI_CMAKE_GENERATOR'" ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM='$CI_CMAKE_GENERATOR_PLATFORM'" @@ -81,25 +102,21 @@ function ci_build_cmake { ALL_CMAKE_VARS+=($CI_CMAKE_VARS) local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) local -a ALL_CTEST_FLAGS=($CI_CTEST_FLAGS) + # Initialize SRCDIR_NATIVE and INSTALLDIR_NATIVE. + local SRCDIR_NATIVE="${CI_SRCDIR_NATIVE:-"$CI_SRCDIR"}" + local INSTALLDIR_NATIVE="${CI_INSTALLDIR_NATIVE:-"$CI_INSTALLDIR"}" # Export the CMake build environment. [[ $CI_CMAKE_GENERATOR ]] && 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 rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" ci_spawn mkdir -p "$CI_BUILDDIR" ci_spawn cd "$CI_BUILDDIR" ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" \ - -DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR_REL_BUILDDIR" \ - "$CI_SRCDIR_REL_BUILDDIR" + -DCMAKE_INSTALL_PREFIX="$INSTALLDIR_NATIVE" \ + "$SRCDIR_NATIVE" ci_spawn "$CI_CMAKE" --build . \ --config "$CI_CMAKE_BUILD_TYPE" \ "${ALL_CMAKE_BUILD_FLAGS[@]}" diff --git a/ci/ci_legacy.sh b/ci/ci_legacy.sh index 58a8005ea..d373adeb7 100755 --- a/ci/ci_legacy.sh +++ b/ci/ci_legacy.sh @@ -4,12 +4,13 @@ set -e # ci_legacy.sh # Continuously integrate libpng using the legacy makefiles. # -# Copyright (c) 2019-2020 Cosmin Truta. +# Copyright (c) 2019-2021 Cosmin Truta. # # This software is released under the libpng license. # For conditions of distribution and use, see the disclaimer # and license in png.h. +readonly CI_SYSNAME="$(uname -s)" readonly CI_SCRIPTNAME="$(basename "$0")" readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" @@ -34,13 +35,15 @@ function ci_spawn { function ci_init_legacy { # Initialize the CI_ variables with default values, where applicable. CI_MAKE="${CI_MAKE:-make}" - [[ $(uname -s || echo unknown) == Darwin ]] && CI_CC="${CI_CC:-clang}" + [[ $CI_SYSNAME == Darwin || $CI_SYSNAME == *BSD || $CI_SYSNAME == DragonFly ]] && + CI_CC="${CI_CC:-clang}" [[ $CI_CC == *clang* ]] && - CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-scripts/makefile.clang}" - CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-scripts/makefile.gcc}" - CI_LD="${CI_LD:-$CI_CC}" - CI_LIBS="${CI_LIBS:--lz -lm}" + CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.clang"}" + CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.gcc"}" + CI_LD="${CI_LD:-"$CI_CC"}" + CI_LIBS="${CI_LIBS:-"-lz -lm"}" # Print the CI_ variables. + ci_info "system name: $CI_SYSNAME" ci_info "source directory: $CI_SRCDIR" ci_info "build directory: $CI_BUILDDIR" ci_info "environment option: \$CI_LEGACY_MAKEFILES='$CI_LEGACY_MAKEFILES'"