summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosmin Truta <ctruta@gmail.com>2022-09-04 19:41:33 +0300
committerCosmin Truta <ctruta@gmail.com>2022-09-04 19:41:33 +0300
commit081e6751abc03348efe7acc0fd2289ec5eeae234 (patch)
tree2a68aea1a70ad88fe49a5aa3aa404f0674a314ef
parent103f8346e39779a9b8954e434b28bbdab36e90fb (diff)
downloadlibpng-081e6751abc03348efe7acc0fd2289ec5eeae234.tar.gz
ci: Update the CI scripts
Apply the following changes: * Set CI_CMAKE_GENERATOR to "Ninja" by default in ci_cmake.sh. * Set CI_CC to cc by default in ci_autotools.sh. * Rename CI_SYSNAME to CI_SYSTEM_NAME; add CI_MACHINE_NAME. * Apply other minor changes and fixes.
-rwxr-xr-xci/ci_autotools.sh39
-rwxr-xr-xci/ci_cmake.sh45
-rwxr-xr-xci/ci_legacy.sh46
3 files changed, 79 insertions, 51 deletions
diff --git a/ci/ci_autotools.sh b/ci/ci_autotools.sh
index 4b4d04b87..b141e7fca 100755
--- a/ci/ci_autotools.sh
+++ b/ci/ci_autotools.sh
@@ -4,18 +4,17 @@ set -e
# ci_autotools.sh
# Continuously integrate libpng using the GNU Autotools.
#
-# Copyright (c) 2019-2021 Cosmin Truta.
+# Copyright (c) 2019-2022 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/autotools.build"
-readonly CI_INSTALLDIR="$CI_SRCDIR/out/autotools.install"
+CI_SCRIPTNAME="$(basename "$0")"
+CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
+CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
+CI_BUILDDIR="$CI_SRCDIR/out/autotools.build"
+CI_INSTALLDIR="$CI_SRCDIR/out/autotools.install"
function ci_info {
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
@@ -34,12 +33,20 @@ function ci_spawn {
}
function ci_init_autotools {
- # Initialize the CI_ variables with default values, where applicable.
+ CI_SYSTEM_NAME="$(uname -s)"
+ CI_MACHINE_NAME="$(uname -m)"
CI_MAKE="${CI_MAKE:-make}"
- [[ $CI_SYSNAME == Darwin || $CI_SYSNAME == *BSD || $CI_SYSNAME == DragonFly ]] &&
- CI_CC="${CI_CC:-clang}"
- # Print the CI_ variables.
- ci_info "system name: $CI_SYSNAME"
+ # Set CI_CC to cc by default, if the cc command is available.
+ # The configure script defaults CC to gcc, which is not always a good idea.
+ [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}"
+ # Ensure that the CI_ variables that cannot be customized reliably are not initialized.
+ [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
+ [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
+}
+
+function ci_trace_autotools {
+ ci_info "system name: $CI_SYSTEM_NAME"
+ ci_info "machine hardware name: $CI_MACHINE_NAME"
ci_info "source directory: $CI_SRCDIR"
ci_info "build directory: $CI_BUILDDIR"
ci_info "install directory: $CI_INSTALLDIR"
@@ -58,9 +65,6 @@ function ci_init_autotools {
ci_info "environment option: \$CI_NO_TEST='$CI_NO_TEST'"
ci_info "environment option: \$CI_NO_INSTALL='$CI_NO_INSTALL'"
ci_info "environment option: \$CI_NO_CLEAN='$CI_NO_CLEAN'"
- # Avoid using the CI_ variables that cannot be customized reliably.
- [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
- [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
}
function ci_build_autotools {
@@ -74,7 +78,7 @@ function ci_build_autotools {
[[ $CI_LD ]] && ci_spawn export CPP="$CI_LD"
[[ $CI_LD_FLAGS ]] && ci_spawn export LDFLAGS="$CI_LD_FLAGS"
[[ $CI_SANITIZERS ]] && {
- ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS -O2 $CFLAGS"
+ ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS ${CFLAGS:-"-O2"}"
ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS"
}
# Build and install.
@@ -91,7 +95,8 @@ function ci_build_autotools {
}
ci_init_autotools
-[[ ! $* ]] || {
+ci_trace_autotools
+[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
ci_err "unexpected command arguments: '$*'"
}
diff --git a/ci/ci_cmake.sh b/ci/ci_cmake.sh
index cbee18083..f38ec6ff8 100755
--- a/ci/ci_cmake.sh
+++ b/ci/ci_cmake.sh
@@ -4,18 +4,17 @@ set -e
# ci_cmake.sh
# Continuously integrate libpng using CMake.
#
-# Copyright (c) 2019-2021 Cosmin Truta.
+# Copyright (c) 2019-2022 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"
+CI_SCRIPTNAME="$(basename "$0")"
+CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
+CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
+CI_BUILDDIR="$CI_SRCDIR/out/cmake.build"
+CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install"
function ci_info {
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
@@ -34,14 +33,19 @@ function ci_spawn {
}
function ci_init_cmake {
- # Initialize the CI_ variables with default values, where applicable.
+ CI_SYSTEM_NAME="$(uname -s)"
+ CI_MACHINE_NAME="$(uname -m)"
CI_CMAKE="${CI_CMAKE:-cmake}"
CI_CTEST="${CI_CTEST:-ctest}"
- [[ $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.
+ [[ -x $(command -v ninja) ]] && CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}"
+ if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]]
+ then
+ # Initialize the CI_...DIR_NATIVE variables, for the benefit of
+ # the native Windows build tools. The regular CI_...DIR variables
+ # can only be used inside Bash-on-Windows.
+ mkdir -p "$CI_BUILDDIR"
+ mkdir -p "$CI_INSTALLDIR"
if [[ -x $CYGPATH ]]
then
CI_SRCDIR_NATIVE="$("$CYGPATH" -w "$CI_SRCDIR")"
@@ -56,9 +60,14 @@ function ci_init_cmake {
# 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"
+ # Ensure that CI_CMAKE_GENERATOR_PLATFORM is initialized for this generator.
+ [[ $CI_CMAKE_GENERATOR_PLATFORM ]] || ci_err "missing: \$CI_CMAKE_GENERATOR_PLATFORM"
+ fi
+}
+
+function ci_trace_cmake {
+ ci_info "system name: $CI_SYSTEM_NAME"
+ ci_info "machine hardware name: $CI_MACHINE_NAME"
ci_info "source directory: $CI_SRCDIR"
[[ $CI_SRCDIR_NATIVE ]] && ci_info "source directory (native): $CI_SRCDIR_NATIVE"
ci_info "build directory: $CI_BUILDDIR"
@@ -81,7 +90,6 @@ function ci_init_cmake {
ci_info "environment option: \$CI_NO_TEST='$CI_NO_TEST'"
ci_info "environment option: \$CI_NO_INSTALL='$CI_NO_INSTALL'"
ci_info "environment option: \$CI_NO_CLEAN='$CI_NO_CLEAN'"
- # Print the CMake/CTest program versions.
ci_spawn "$(command -v "$CI_CMAKE")" --version
ci_spawn "$(command -v "$CI_CTEST")" --version
}
@@ -105,7 +113,7 @@ function ci_build_cmake {
# 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 environment variables.
[[ $CI_CMAKE_GENERATOR ]] &&
ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR"
[[ $CI_CMAKE_GENERATOR_PLATFORM ]] &&
@@ -137,7 +145,8 @@ function ci_build_cmake {
}
ci_init_cmake
-[[ ! $* ]] || {
+ci_trace_cmake
+[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
ci_err "unexpected command arguments: '$*'"
}
diff --git a/ci/ci_legacy.sh b/ci/ci_legacy.sh
index d373adeb7..830253f67 100755
--- a/ci/ci_legacy.sh
+++ b/ci/ci_legacy.sh
@@ -4,17 +4,16 @@ set -e
# ci_legacy.sh
# Continuously integrate libpng using the legacy makefiles.
#
-# Copyright (c) 2019-2021 Cosmin Truta.
+# Copyright (c) 2019-2022 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"
+CI_SCRIPTNAME="$(basename "$0")"
+CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
+CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
+CI_BUILDDIR="$CI_SRCDIR"
function ci_info {
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
@@ -33,17 +32,31 @@ function ci_spawn {
}
function ci_init_legacy {
- # Initialize the CI_ variables with default values, where applicable.
+ CI_SYSTEM_NAME="$(uname -s)"
+ CI_MACHINE_NAME="$(uname -m)"
CI_MAKE="${CI_MAKE:-make}"
- [[ $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"}"
+ case "$CI_SYSTEM_NAME" in
+ ( Darwin | *BSD | DragonFly )
+ [[ -x $(command -v clang) ]] && CI_CC="${CI_CC:-clang}" ;;
+ ( * )
+ [[ -x $(command -v gcc) ]] && CI_CC="${CI_CC:-gcc}" ;;
+ esac
+ CI_CC="${CI_CC:-cc}"
+ case "$CI_CC" in
+ ( *clang* )
+ CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.clang"}" ;;
+ ( *gcc* )
+ CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.gcc"}" ;;
+ ( cc | c89 | c99 )
+ CI_LEGACY_MAKEFILES="${CI_LEGACY_MAKEFILES:-"scripts/makefile.std"}" ;;
+ esac
CI_LD="${CI_LD:-"$CI_CC"}"
CI_LIBS="${CI_LIBS:-"-lz -lm"}"
- # Print the CI_ variables.
- ci_info "system name: $CI_SYSNAME"
+}
+
+function ci_trace_legacy {
+ ci_info "system name: $CI_SYSTEM_NAME"
+ ci_info "machine hardware name: $CI_MACHINE_NAME"
ci_info "source directory: $CI_SRCDIR"
ci_info "build directory: $CI_BUILDDIR"
ci_info "environment option: \$CI_LEGACY_MAKEFILES='$CI_LEGACY_MAKEFILES'"
@@ -69,7 +82,7 @@ function ci_build_legacy {
local ALL_CC_FLAGS="$CI_CC_FLAGS"
local ALL_LD_FLAGS="$CI_LD_FLAGS"
[[ $CI_SANITIZERS ]] && {
- ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS -O2 $ALL_CC_FLAGS"
+ ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS ${ALL_CC_FLAGS:-"-O2"}"
ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS"
}
# Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays.
@@ -112,7 +125,8 @@ function ci_build_legacy {
}
ci_init_legacy
-[[ ! $* ]] || {
+ci_trace_legacy
+[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
ci_err "unexpected command arguments: '$*'"
}