From b445aade83e55bb62095e7efdcfd38b540609750 Mon Sep 17 00:00:00 2001 From: Cosmin Truta Date: Sun, 27 Nov 2022 21:05:42 +0200 Subject: ci: Rename the ci_* scripts Give the CI scripts new names that better reflect what they do, and make room for activities such as linting or dependency installation: * Rename ci_autotools.sh to ci_verify_configure.sh. * Rename ci_cmake.sh to ci_verify_cmake.sh. * Rename ci_legacy.sh to ci_verify_makefiles.sh. Also rename CI_LEGACY_MAKEFILES to CI_MAKEFILES. Update the config files for Travis CI and AppVeyor CI accordingly. --- .appveyor.yml | 18 ++--- .travis.yml | 14 ++-- ci/ci_autotools.sh | 117 -------------------------------- ci/ci_cmake.sh | 169 ---------------------------------------------- ci/ci_legacy.sh | 147 ---------------------------------------- ci/ci_verify_cmake.sh | 169 ++++++++++++++++++++++++++++++++++++++++++++++ ci/ci_verify_configure.sh | 117 ++++++++++++++++++++++++++++++++ ci/ci_verify_makefiles.sh | 147 ++++++++++++++++++++++++++++++++++++++++ 8 files changed, 449 insertions(+), 449 deletions(-) delete mode 100755 ci/ci_autotools.sh delete mode 100755 ci/ci_cmake.sh delete mode 100755 ci/ci_legacy.sh create mode 100755 ci/ci_verify_cmake.sh create mode 100755 ci/ci_verify_configure.sh create mode 100755 ci/ci_verify_makefiles.sh diff --git a/.appveyor.yml b/.appveyor.yml index 88dc11ef3..f447877fe 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -28,16 +28,16 @@ environment: AUTOMATION: cmake ARCH: x86_64 - TOOLCHAIN: msys2 - AUTOMATION: autotools + AUTOMATION: configure ARCH: i686 - TOOLCHAIN: msys2 - AUTOMATION: autotools + AUTOMATION: configure ARCH: x86_64 - TOOLCHAIN: msys2 - AUTOMATION: legacy + AUTOMATION: makefiles ARCH: i686 - TOOLCHAIN: msys2 - AUTOMATION: legacy + AUTOMATION: makefiles ARCH: x86_64 install: @@ -57,13 +57,13 @@ before_build: - 'set CI_CMAKE_BUILD_FLAGS=--parallel 2' - 'set CI_CTEST_FLAGS=--parallel 2' - 'set CI_MAKE_FLAGS=-j2' - - 'set CI_LEGACY_MAKEFILES=scripts/makefile.gcc scripts/makefile.msys scripts/makefile.std' + - 'set CI_MAKEFILES=scripts/makefile.gcc scripts/makefile.msys scripts/makefile.std' build_script: - - 'if "%TOOLCHAIN%"=="vstudio" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_cmake.sh"' - - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_cmake.sh"' - - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="autotools" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_autotools.sh"' - - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="legacy" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_legacy.sh"' + - 'if "%TOOLCHAIN%"=="vstudio" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"' + - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="cmake" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_cmake.sh"' + - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="configure" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_configure.sh"' + - 'if "%TOOLCHAIN%"=="msys2" if "%AUTOMATION%"=="makefiles" C:\msys64\usr\bin\bash.exe -l "%APPVEYOR_BUILD_FOLDER%\ci\ci_verify_makefiles.sh"' cache: - C:\tools\vcpkg\installed diff --git a/.travis.yml b/.travis.yml index 70457cd39..c48df0876 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,11 +17,11 @@ env: - AUTOMATION=cmake CI_NO_TEST=1 - AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=ON" CI_SANITIZERS="address,undefined" - AUTOMATION=cmake CI_CMAKE_VARS="-DPNG_HARDWARE_OPTIMIZATIONS=OFF" CI_SANITIZERS="address,undefined" - - AUTOMATION=autotools CI_NO_TEST=1 - - AUTOMATION=autotools CI_CONFIGURE_FLAGS="--enable-hardware-optimizations" - - AUTOMATION=autotools CI_CONFIGURE_FLAGS="--disable-hardware-optimizations" - - AUTOMATION=legacy CI_NO_TEST=1 - - AUTOMATION=legacy CI_SANITIZERS="address,undefined" + - AUTOMATION=configure CI_NO_TEST=1 + - AUTOMATION=configure CI_CONFIGURE_FLAGS="--enable-hardware-optimizations" + - AUTOMATION=configure CI_CONFIGURE_FLAGS="--disable-hardware-optimizations" + - AUTOMATION=makefiles CI_NO_TEST=1 + - AUTOMATION=makefiles CI_SANITIZERS="address,undefined" matrix: include: @@ -39,7 +39,7 @@ before_script: - 'export CI_CTEST_FLAGS="--parallel 2"' - 'export CI_MAKE_FLAGS=-j2' - 'export CI_CC=$TRAVIS_COMPILER' - - 'export CI_LEGACY_MAKEFILES="scripts/makefile.$TRAVIS_COMPILER scripts/makefile.std"' + - 'export CI_MAKEFILES="scripts/makefile.$TRAVIS_COMPILER scripts/makefile.std"' script: - - './ci/ci_$AUTOMATION.sh' + - './ci/ci_verify_$AUTOMATION.sh' diff --git a/ci/ci_autotools.sh b/ci/ci_autotools.sh deleted file mode 100755 index 0728540bd..000000000 --- a/ci/ci_autotools.sh +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env bash -set -e - -# ci_autotools.sh -# Continuously integrate libpng using the GNU Autotools. -# -# 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. - -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" "$*" -} - -function ci_err { - printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" - exit 2 -} - -function ci_spawn { - printf >&2 "%s: executing:" "$CI_SCRIPTNAME" - printf >&2 " %q" "$@" - printf >&2 "\\n" - "$@" -} - -function ci_init_autotools { - CI_SYSTEM_NAME="$(uname -s)" - CI_MACHINE_NAME="$(uname -m)" - CI_MAKE="${CI_MAKE:-make}" - # 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 "## START OF CONFIGURATION ##" - 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" - ci_info "environment option: \$CI_CONFIGURE_FLAGS: '$CI_CONFIGURE_FLAGS'" - ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" - ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" - ci_info "environment option: \$CI_CC: '$CI_CC'" - ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" - ci_info "environment option: \$CI_CPP: '$CI_CPP'" - ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" - ci_info "environment option: \$CI_AR: '$CI_AR'" - ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" - ci_info "environment option: \$CI_LD: '$CI_LD'" - ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" - ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" - 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'" - ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" - [[ $CI_CC ]] && - ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" - [[ $CI_CPP ]] && - ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" - [[ $CI_AR ]] && - ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" - [[ $CI_RANLIB ]] && - ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" - [[ $CI_LD ]] && - ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" - ci_info "## END OF CONFIGURATION ##" -} - -function ci_build_autotools { - ci_info "## START OF BUILD ##" - # Export the configure build environment. - [[ $CI_CC ]] && ci_spawn export CC="$CI_CC" - [[ $CI_CC_FLAGS ]] && ci_spawn export CFLAGS="$CI_CC_FLAGS" - [[ $CI_CPP ]] && ci_spawn export CPP="$CI_CPP" - [[ $CI_CPP_FLAGS ]] && ci_spawn export CPPFLAGS="$CI_CPP_FLAGS" - [[ $CI_AR ]] && ci_spawn export AR="$CI_AR" - [[ $CI_RANLIB ]] && ci_spawn export RANLIB="$CI_RANLIB" - [[ $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 ${CFLAGS:-"-O2"}" - ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS" - } - # 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_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS - ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS - [[ $CI_NO_TEST ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test - [[ $CI_NO_INSTALL ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install - [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean - [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean - ci_info "## END OF BUILD ##" -} - -ci_init_autotools -ci_trace_autotools -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" -} -ci_build_autotools diff --git a/ci/ci_cmake.sh b/ci/ci_cmake.sh deleted file mode 100755 index 71af270da..000000000 --- a/ci/ci_cmake.sh +++ /dev/null @@ -1,169 +0,0 @@ -#!/usr/bin/env bash -set -e - -# ci_cmake.sh -# Continuously integrate libpng using CMake. -# -# 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. - -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" "$*" -} - -function ci_err { - printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" - exit 2 -} - -function ci_spawn { - printf >&2 "%s: executing:" "$CI_SCRIPTNAME" - printf >&2 " %q" "$@" - printf >&2 "\\n" - "$@" -} - -function ci_init_cmake { - CI_SYSTEM_NAME="$(uname -s)" - CI_MACHINE_NAME="$(uname -m)" - CI_CMAKE="${CI_CMAKE:-cmake}" - CI_CTEST="${CI_CTEST:-ctest}" - CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}" - [[ -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")" - 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 - # 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 "## START OF CONFIGURATION ##" - 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" - [[ $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'" - ci_info "environment option: \$CI_CMAKE_BUILD_TYPE: '$CI_CMAKE_BUILD_TYPE'" - ci_info "environment option: \$CI_CMAKE_BUILD_FLAGS: '$CI_CMAKE_BUILD_FLAGS'" - ci_info "environment option: \$CI_CMAKE_VARS: '$CI_CMAKE_VARS'" - ci_info "environment option: \$CI_CTEST: '$CI_CTEST'" - ci_info "environment option: \$CI_CTEST_FLAGS: '$CI_CTEST_FLAGS'" - ci_info "environment option: \$CI_CC: '$CI_CC'" - ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" - ci_info "environment option: \$CI_AR: '$CI_AR'" - ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" - ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" - 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'" - ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")" - ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")" - [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && - ci_info "executable: $(command -V ninja)" - [[ $CI_CC ]] && - ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" - [[ $CI_AR ]] && - ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" - [[ $CI_RANLIB ]] && - ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" - ci_info "## END OF CONFIGURATION ##" -} - -function ci_build_cmake { - ci_info "## START OF BUILD ##" - ci_spawn "$(command -v "$CI_CMAKE")" --version - ci_spawn "$(command -v "$CI_CTEST")" --version - # Initialize ALL_CC_FLAGS as a string. - local ALL_CC_FLAGS="$CI_CC_FLAGS" - [[ $CI_SANITIZERS ]] && ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS" - # Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays. - local -a ALL_CMAKE_VARS=() - [[ $CI_CC ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC") - [[ $ALL_CC_FLAGS ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS") - [[ $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_VERBOSE_MAKEFILE=ON) - [[ $CI_NO_TEST ]] && ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) - 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 environment variables. - [[ $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" - # 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="$INSTALLDIR_NATIVE" \ - "$SRCDIR_NATIVE" - ci_spawn "$CI_CMAKE" --build . \ - --config "$CI_CMAKE_BUILD_TYPE" \ - "${ALL_CMAKE_BUILD_FLAGS[@]}" - [[ $CI_NO_TEST ]] || - ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \ - "${ALL_CTEST_FLAGS[@]}" - [[ $CI_NO_INSTALL ]] || - ci_spawn "$CI_CMAKE" --build . \ - --config "$CI_CMAKE_BUILD_TYPE" \ - --target install \ - "${ALL_CMAKE_BUILD_FLAGS[@]}" - [[ $CI_NO_CLEAN ]] || - ci_spawn "$CI_CMAKE" --build . \ - --config "$CI_CMAKE_BUILD_TYPE" \ - --target clean \ - "${ALL_CMAKE_BUILD_FLAGS[@]}" - ci_info "## END OF BUILD ##" -} - -ci_init_cmake -ci_trace_cmake -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" -} -ci_build_cmake diff --git a/ci/ci_legacy.sh b/ci/ci_legacy.sh deleted file mode 100755 index cfe1f53a3..000000000 --- a/ci/ci_legacy.sh +++ /dev/null @@ -1,147 +0,0 @@ -#!/usr/bin/env bash -set -e - -# ci_legacy.sh -# Continuously integrate libpng using the legacy makefiles. -# -# 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. - -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" "$*" -} - -function ci_err { - printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" - exit 2 -} - -function ci_spawn { - printf >&2 "%s: executing:" "$CI_SCRIPTNAME" - printf >&2 " %q" "$@" - printf >&2 "\\n" - "$@" -} - -function ci_init_legacy { - CI_SYSTEM_NAME="$(uname -s)" - CI_MACHINE_NAME="$(uname -m)" - CI_MAKE="${CI_MAKE:-make}" - 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"}" -} - -function ci_trace_legacy { - ci_info "## START OF CONFIGURATION ##" - 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'" - ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" - ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" - ci_info "environment option: \$CI_MAKE_VARS: '$CI_MAKE_VARS'" - ci_info "environment option: \$CI_CC: '$CI_CC'" - ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" - ci_info "environment option: \$CI_CPP: '$CI_CPP'" - ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" - ci_info "environment option: \$CI_AR: '$CI_AR'" - ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" - ci_info "environment option: \$CI_LD: '$CI_LD'" - ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" - ci_info "environment option: \$CI_LIBS: '$CI_LIBS'" - ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" - ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" - ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" - ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" - [[ $CI_CC ]] && - ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" - [[ $CI_CPP ]] && - ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" - [[ $CI_AR ]] && - ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" - [[ $CI_RANLIB ]] && - ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" - [[ $CI_LD ]] && - ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" - ci_info "## END OF CONFIGURATION ##" -} - -function ci_build_legacy { - ci_info "## START OF BUILD ##" - # Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings. - local ALL_CC_FLAGS="$CI_CC_FLAGS" - local ALL_LD_FLAGS="$CI_LD_FLAGS" - [[ $CI_SANITIZERS ]] && { - 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. - local -a ALL_MAKE_FLAGS=($CI_MAKE_FLAGS) - local -a ALL_MAKE_VARS=() - [[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC") - [[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS") - [[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP") - [[ $CI_CPP_FLAGS ]] && ALL_MAKE_VARS+=(CPPFLAGS="$CI_CPP_FLAGS") - [[ $CI_AR ]] && ALL_MAKE_VARS+=( - AR="${CI_AR:-ar}" - AR_RC="${CI_AR:-ar} rc" - ) - [[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB") - [[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD") - [[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS") - ALL_MAKE_VARS+=(LIBS="$CI_LIBS") - ALL_MAKE_VARS+=($CI_MAKE_VARS) - # Build! - ci_spawn cd "$CI_SRCDIR" - local MY_MAKEFILE - for MY_MAKEFILE in $CI_LEGACY_MAKEFILES - do - ci_info "using makefile: $MY_MAKEFILE" - ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ - "${ALL_MAKE_FLAGS[@]}" \ - "${ALL_MAKE_VARS[@]}" - [[ $CI_NO_TEST ]] || - ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ - "${ALL_MAKE_FLAGS[@]}" \ - "${ALL_MAKE_VARS[@]}" \ - test - [[ $CI_NO_CLEAN ]] || - ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ - "${ALL_MAKE_FLAGS[@]}" \ - "${ALL_MAKE_VARS[@]}" \ - clean - done - ci_info "## END OF BUILD ##" -} - -ci_init_legacy -ci_trace_legacy -[[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected command arguments: '$*'" -} -ci_build_legacy diff --git a/ci/ci_verify_cmake.sh b/ci/ci_verify_cmake.sh new file mode 100755 index 000000000..a92e62899 --- /dev/null +++ b/ci/ci_verify_cmake.sh @@ -0,0 +1,169 @@ +#!/usr/bin/env bash +set -e + +# ci_verify_cmake.sh +# Continuously integrate libpng using CMake. +# +# 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. + +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" "$*" +} + +function ci_err { + printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" + exit 2 +} + +function ci_spawn { + printf >&2 "%s: executing:" "$CI_SCRIPTNAME" + printf >&2 " %q" "$@" + printf >&2 "\\n" + "$@" +} + +function ci_init_cmake { + CI_SYSTEM_NAME="$(uname -s)" + CI_MACHINE_NAME="$(uname -m)" + CI_CMAKE="${CI_CMAKE:-cmake}" + CI_CTEST="${CI_CTEST:-ctest}" + CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}" + [[ -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")" + 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 + # 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 "## START OF CONFIGURATION ##" + 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" + [[ $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'" + ci_info "environment option: \$CI_CMAKE_BUILD_TYPE: '$CI_CMAKE_BUILD_TYPE'" + ci_info "environment option: \$CI_CMAKE_BUILD_FLAGS: '$CI_CMAKE_BUILD_FLAGS'" + ci_info "environment option: \$CI_CMAKE_VARS: '$CI_CMAKE_VARS'" + ci_info "environment option: \$CI_CTEST: '$CI_CTEST'" + ci_info "environment option: \$CI_CTEST_FLAGS: '$CI_CTEST_FLAGS'" + ci_info "environment option: \$CI_CC: '$CI_CC'" + ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" + ci_info "environment option: \$CI_AR: '$CI_AR'" + ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" + ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + 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'" + ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")" + ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")" + [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && + ci_info "executable: $(command -V ninja)" + [[ $CI_CC ]] && + ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" + [[ $CI_AR ]] && + ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" + [[ $CI_RANLIB ]] && + ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" + ci_info "## END OF CONFIGURATION ##" +} + +function ci_build_cmake { + ci_info "## START OF BUILD ##" + ci_spawn "$(command -v "$CI_CMAKE")" --version + ci_spawn "$(command -v "$CI_CTEST")" --version + # Initialize ALL_CC_FLAGS as a string. + local ALL_CC_FLAGS="$CI_CC_FLAGS" + [[ $CI_SANITIZERS ]] && ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS" + # Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays. + local -a ALL_CMAKE_VARS=() + [[ $CI_CC ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC") + [[ $ALL_CC_FLAGS ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS") + [[ $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_VERBOSE_MAKEFILE=ON) + [[ $CI_NO_TEST ]] && ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF) + 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 environment variables. + [[ $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" + # 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="$INSTALLDIR_NATIVE" \ + "$SRCDIR_NATIVE" + ci_spawn "$CI_CMAKE" --build . \ + --config "$CI_CMAKE_BUILD_TYPE" \ + "${ALL_CMAKE_BUILD_FLAGS[@]}" + [[ $CI_NO_TEST ]] || + ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \ + "${ALL_CTEST_FLAGS[@]}" + [[ $CI_NO_INSTALL ]] || + ci_spawn "$CI_CMAKE" --build . \ + --config "$CI_CMAKE_BUILD_TYPE" \ + --target install \ + "${ALL_CMAKE_BUILD_FLAGS[@]}" + [[ $CI_NO_CLEAN ]] || + ci_spawn "$CI_CMAKE" --build . \ + --config "$CI_CMAKE_BUILD_TYPE" \ + --target clean \ + "${ALL_CMAKE_BUILD_FLAGS[@]}" + ci_info "## END OF BUILD ##" +} + +ci_init_cmake +ci_trace_cmake +[[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" +} +ci_build_cmake diff --git a/ci/ci_verify_configure.sh b/ci/ci_verify_configure.sh new file mode 100755 index 000000000..df822061a --- /dev/null +++ b/ci/ci_verify_configure.sh @@ -0,0 +1,117 @@ +#!/usr/bin/env bash +set -e + +# ci_verify_configure.sh +# Continuously integrate libpng using the configure script. +# +# 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. + +CI_SCRIPTNAME="$(basename "$0")" +CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)" +CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")" +CI_BUILDDIR="$CI_SRCDIR/out/configure.build" +CI_INSTALLDIR="$CI_SRCDIR/out/configure.install" + +function ci_info { + printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" +} + +function ci_err { + printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" + exit 2 +} + +function ci_spawn { + printf >&2 "%s: executing:" "$CI_SCRIPTNAME" + printf >&2 " %q" "$@" + printf >&2 "\\n" + "$@" +} + +function ci_init_configure { + CI_SYSTEM_NAME="$(uname -s)" + CI_MACHINE_NAME="$(uname -m)" + CI_MAKE="${CI_MAKE:-make}" + # 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_configure { + ci_info "## START OF CONFIGURATION ##" + 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" + ci_info "environment option: \$CI_CONFIGURE_FLAGS: '$CI_CONFIGURE_FLAGS'" + ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" + ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" + ci_info "environment option: \$CI_CC: '$CI_CC'" + ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" + ci_info "environment option: \$CI_CPP: '$CI_CPP'" + ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" + ci_info "environment option: \$CI_AR: '$CI_AR'" + ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" + ci_info "environment option: \$CI_LD: '$CI_LD'" + ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" + ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + 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'" + ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" + [[ $CI_CC ]] && + ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" + [[ $CI_CPP ]] && + ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" + [[ $CI_AR ]] && + ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" + [[ $CI_RANLIB ]] && + ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" + [[ $CI_LD ]] && + ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" + ci_info "## END OF CONFIGURATION ##" +} + +function ci_build_configure { + ci_info "## START OF BUILD ##" + # Export the configure build environment. + [[ $CI_CC ]] && ci_spawn export CC="$CI_CC" + [[ $CI_CC_FLAGS ]] && ci_spawn export CFLAGS="$CI_CC_FLAGS" + [[ $CI_CPP ]] && ci_spawn export CPP="$CI_CPP" + [[ $CI_CPP_FLAGS ]] && ci_spawn export CPPFLAGS="$CI_CPP_FLAGS" + [[ $CI_AR ]] && ci_spawn export AR="$CI_AR" + [[ $CI_RANLIB ]] && ci_spawn export RANLIB="$CI_RANLIB" + [[ $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 ${CFLAGS:-"-O2"}" + ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS" + } + # 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_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS + ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS + [[ $CI_NO_TEST ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test + [[ $CI_NO_INSTALL ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install + [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean + [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean + ci_info "## END OF BUILD ##" +} + +ci_init_configure +ci_trace_configure +[[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" +} +ci_build_configure diff --git a/ci/ci_verify_makefiles.sh b/ci/ci_verify_makefiles.sh new file mode 100755 index 000000000..17658f711 --- /dev/null +++ b/ci/ci_verify_makefiles.sh @@ -0,0 +1,147 @@ +#!/usr/bin/env bash +set -e + +# ci_verify_makefiles.sh +# Continuously integrate libpng using the legacy makefiles. +# +# 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. + +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" "$*" +} + +function ci_err { + printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*" + exit 2 +} + +function ci_spawn { + printf >&2 "%s: executing:" "$CI_SCRIPTNAME" + printf >&2 " %q" "$@" + printf >&2 "\\n" + "$@" +} + +function ci_init_makefiles { + CI_SYSTEM_NAME="$(uname -s)" + CI_MACHINE_NAME="$(uname -m)" + CI_MAKE="${CI_MAKE:-make}" + 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_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.clang"}" ;; + ( *gcc* ) + CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.gcc"}" ;; + ( cc | c89 | c99 ) + CI_MAKEFILES="${CI_MAKEFILES:-"scripts/makefile.std"}" ;; + esac + CI_LD="${CI_LD:-"$CI_CC"}" + CI_LIBS="${CI_LIBS:-"-lz -lm"}" +} + +function ci_trace_makefiles { + ci_info "## START OF CONFIGURATION ##" + 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_MAKEFILES: '$CI_MAKEFILES'" + ci_info "environment option: \$CI_MAKE: '$CI_MAKE'" + ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'" + ci_info "environment option: \$CI_MAKE_VARS: '$CI_MAKE_VARS'" + ci_info "environment option: \$CI_CC: '$CI_CC'" + ci_info "environment option: \$CI_CC_FLAGS: '$CI_CC_FLAGS'" + ci_info "environment option: \$CI_CPP: '$CI_CPP'" + ci_info "environment option: \$CI_CPP_FLAGS: '$CI_CPP_FLAGS'" + ci_info "environment option: \$CI_AR: '$CI_AR'" + ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'" + ci_info "environment option: \$CI_LD: '$CI_LD'" + ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" + ci_info "environment option: \$CI_LIBS: '$CI_LIBS'" + ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" + ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" + ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" + [[ $CI_CC ]] && + ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" + [[ $CI_CPP ]] && + ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" + [[ $CI_AR ]] && + ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" + [[ $CI_RANLIB ]] && + ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" + [[ $CI_LD ]] && + ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" + ci_info "## END OF CONFIGURATION ##" +} + +function ci_build_makefiles { + ci_info "## START OF BUILD ##" + # Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings. + local ALL_CC_FLAGS="$CI_CC_FLAGS" + local ALL_LD_FLAGS="$CI_LD_FLAGS" + [[ $CI_SANITIZERS ]] && { + 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. + local -a ALL_MAKE_FLAGS=($CI_MAKE_FLAGS) + local -a ALL_MAKE_VARS=() + [[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC") + [[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS") + [[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP") + [[ $CI_CPP_FLAGS ]] && ALL_MAKE_VARS+=(CPPFLAGS="$CI_CPP_FLAGS") + [[ $CI_AR ]] && ALL_MAKE_VARS+=( + AR="${CI_AR:-ar}" + AR_RC="${CI_AR:-ar} rc" + ) + [[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB") + [[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD") + [[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS") + ALL_MAKE_VARS+=(LIBS="$CI_LIBS") + ALL_MAKE_VARS+=($CI_MAKE_VARS) + # Build! + ci_spawn cd "$CI_SRCDIR" + local MY_MAKEFILE + for MY_MAKEFILE in $CI_MAKEFILES + do + ci_info "using makefile: $MY_MAKEFILE" + ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ + "${ALL_MAKE_FLAGS[@]}" \ + "${ALL_MAKE_VARS[@]}" + [[ $CI_NO_TEST ]] || + ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ + "${ALL_MAKE_FLAGS[@]}" \ + "${ALL_MAKE_VARS[@]}" \ + test + [[ $CI_NO_CLEAN ]] || + ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ + "${ALL_MAKE_FLAGS[@]}" \ + "${ALL_MAKE_VARS[@]}" \ + clean + done + ci_info "## END OF BUILD ##" +} + +ci_init_makefiles +ci_trace_makefiles +[[ $# -eq 0 ]] || { + ci_info "note: this program accepts environment options only" + ci_err "unexpected command arguments: '$*'" +} +ci_build_makefiles -- cgit v1.2.1