ci: Update the CI scripts

Implement the following updates:
 * Add CI_SYSNAME and set it to `uname -s`.
 * Set the default CI_CC value to "clang" on all BSD systems.
 * Replace CI_SRCDIR_REL_BUILDDIR and CI_INSTALLDIR_REL_BUILDDIR
   with CI_SRCDIR_NATIVE and CI_INSTALLDIR_NATIVE.
   The former variables were hard-coded and error-prone; the new
   variables are computed and safe to use.
This commit is contained in:
Cosmin Truta 2021-03-15 20:23:26 -04:00
parent a37d483651
commit 8c3fdb0ac1
3 changed files with 44 additions and 21 deletions

View File

@ -4,12 +4,13 @@ set -e
# ci_autotools.sh # ci_autotools.sh
# Continuously integrate libpng using the GNU Autotools. # 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. # This software is released under the libpng license.
# For conditions of distribution and use, see the disclaimer # For conditions of distribution and use, see the disclaimer
# and license in png.h. # and license in png.h.
readonly CI_SYSNAME="$(uname -s)"
readonly CI_SCRIPTNAME="$(basename "$0")" readonly CI_SCRIPTNAME="$(basename "$0")"
readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
@ -35,8 +36,10 @@ function ci_spawn {
function ci_init_autotools { function ci_init_autotools {
# Initialize the CI_ variables with default values, where applicable. # Initialize the CI_ variables with default values, where applicable.
CI_MAKE="${CI_MAKE:-make}" 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. # Print the CI_ variables.
ci_info "system name: $CI_SYSNAME"
ci_info "source directory: $CI_SRCDIR" ci_info "source directory: $CI_SRCDIR"
ci_info "build directory: $CI_BUILDDIR" ci_info "build directory: $CI_BUILDDIR"
ci_info "install directory: $CI_INSTALLDIR" ci_info "install directory: $CI_INSTALLDIR"

View File

@ -4,19 +4,18 @@ set -e
# ci_cmake.sh # ci_cmake.sh
# Continuously integrate libpng using CMake. # 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. # This software is released under the libpng license.
# For conditions of distribution and use, see the disclaimer # For conditions of distribution and use, see the disclaimer
# and license in png.h. # and license in png.h.
readonly CI_SYSNAME="$(uname -s)"
readonly CI_SCRIPTNAME="$(basename "$0")" readonly CI_SCRIPTNAME="$(basename "$0")"
readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
readonly CI_BUILDDIR="$CI_SRCDIR/out/cmake.build" readonly CI_BUILDDIR="$CI_SRCDIR/out/cmake.build"
readonly CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install" readonly CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install"
readonly CI_SRCDIR_REL_BUILDDIR="../.."
readonly CI_INSTALLDIR_REL_BUILDDIR="../../out/cmake.install"
function ci_info { function ci_info {
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
@ -38,12 +37,34 @@ function ci_init_cmake {
# Initialize the CI_ variables with default values, where applicable. # Initialize the CI_ variables with default values, where applicable.
CI_CMAKE="${CI_CMAKE:-cmake}" CI_CMAKE="${CI_CMAKE:-cmake}"
CI_CTEST="${CI_CTEST:-ctest}" 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_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. # Print the CI_ variables.
ci_info "system name: $CI_SYSNAME"
ci_info "source directory: $CI_SRCDIR" ci_info "source directory: $CI_SRCDIR"
[[ $CI_SRCDIR_NATIVE ]] && ci_info "source directory (native): $CI_SRCDIR_NATIVE"
ci_info "build directory: $CI_BUILDDIR" ci_info "build directory: $CI_BUILDDIR"
[[ $CI_BUILDDIR_NATIVE ]] && ci_info "build directory (native): $CI_BUILDDIR_NATIVE"
ci_info "install directory: $CI_INSTALLDIR" 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='$CI_CMAKE'"
ci_info "environment option: \$CI_CMAKE_GENERATOR='$CI_CMAKE_GENERATOR'" ci_info "environment option: \$CI_CMAKE_GENERATOR='$CI_CMAKE_GENERATOR'"
ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM='$CI_CMAKE_GENERATOR_PLATFORM'" 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) ALL_CMAKE_VARS+=($CI_CMAKE_VARS)
local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS)
local -a ALL_CTEST_FLAGS=($CI_CTEST_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. # Export the CMake build environment.
[[ $CI_CMAKE_GENERATOR ]] && [[ $CI_CMAKE_GENERATOR ]] &&
ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR" ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR"
[[ $CI_CMAKE_GENERATOR_PLATFORM ]] && [[ $CI_CMAKE_GENERATOR_PLATFORM ]] &&
ci_spawn export CMAKE_GENERATOR_PLATFORM="$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. # Build and install.
ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR" ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR"
ci_spawn mkdir -p "$CI_BUILDDIR" ci_spawn mkdir -p "$CI_BUILDDIR"
ci_spawn cd "$CI_BUILDDIR" ci_spawn cd "$CI_BUILDDIR"
ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" \ ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" \
-DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR_REL_BUILDDIR" \ -DCMAKE_INSTALL_PREFIX="$INSTALLDIR_NATIVE" \
"$CI_SRCDIR_REL_BUILDDIR" "$SRCDIR_NATIVE"
ci_spawn "$CI_CMAKE" --build . \ ci_spawn "$CI_CMAKE" --build . \
--config "$CI_CMAKE_BUILD_TYPE" \ --config "$CI_CMAKE_BUILD_TYPE" \
"${ALL_CMAKE_BUILD_FLAGS[@]}" "${ALL_CMAKE_BUILD_FLAGS[@]}"

View File

@ -4,12 +4,13 @@ set -e
# ci_legacy.sh # ci_legacy.sh
# Continuously integrate libpng using the legacy makefiles. # 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. # This software is released under the libpng license.
# For conditions of distribution and use, see the disclaimer # For conditions of distribution and use, see the disclaimer
# and license in png.h. # and license in png.h.
readonly CI_SYSNAME="$(uname -s)"
readonly CI_SCRIPTNAME="$(basename "$0")" readonly CI_SCRIPTNAME="$(basename "$0")"
readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" readonly CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" readonly CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
@ -34,13 +35,15 @@ function ci_spawn {
function ci_init_legacy { function ci_init_legacy {
# Initialize the CI_ variables with default values, where applicable. # Initialize the CI_ variables with default values, where applicable.
CI_MAKE="${CI_MAKE:-make}" 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_CC == *clang* ]] &&
CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-scripts/makefile.clang}" CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.clang"}"
CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-scripts/makefile.gcc}" CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.gcc"}"
CI_LD="${CI_LD:-$CI_CC}" CI_LD="${CI_LD:-"$CI_CC"}"
CI_LIBS="${CI_LIBS:--lz -lm}" CI_LIBS="${CI_LIBS:-"-lz -lm"}"
# Print the CI_ variables. # Print the CI_ variables.
ci_info "system name: $CI_SYSNAME"
ci_info "source directory: $CI_SRCDIR" ci_info "source directory: $CI_SRCDIR"
ci_info "build directory: $CI_BUILDDIR" ci_info "build directory: $CI_BUILDDIR"
ci_info "environment option: \$CI_LEGACY_MAKEFILES='$CI_LEGACY_MAKEFILES'" ci_info "environment option: \$CI_LEGACY_MAKEFILES='$CI_LEGACY_MAKEFILES'"