diff options
author | Cosmin Truta <ctruta@gmail.com> | 2020-05-24 22:09:45 -0400 |
---|---|---|
committer | Cosmin Truta <ctruta@gmail.com> | 2020-05-24 22:09:45 -0400 |
commit | 2f753e260c5e4106654afb4b09d70b7e0109d05e (patch) | |
tree | c1690802b3196acda664156a5b828a0392089bb8 | |
parent | f5d5f5ae0e25d8bb205cde036b270d5c06ee4063 (diff) | |
download | libpng-2f753e260c5e4106654afb4b09d70b7e0109d05e.tar.gz |
ci: Verify the install target
Add support for the install target in ci_autotools.sh and ci_cmake.sh.
Also add the environment option CI_NO_INSTALL.
-rwxr-xr-x | ci/ci_autotools.sh | 10 | ||||
-rwxr-xr-x | ci/ci_cmake.sh | 39 |
2 files changed, 35 insertions, 14 deletions
diff --git a/ci/ci_autotools.sh b/ci/ci_autotools.sh index ce9157bb7..14108da63 100755 --- a/ci/ci_autotools.sh +++ b/ci/ci_autotools.sh @@ -14,6 +14,7 @@ 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" function ci_info { printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" @@ -38,6 +39,7 @@ function ci_init_autotools { # Print the CI_ variables. 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'" @@ -45,6 +47,7 @@ function ci_init_autotools { ci_info "environment option: \$CI_CC_FLAGS='$CI_CC_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'" # Avoid using the CI_ variables that cannot be customized reliably. [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'" @@ -56,13 +59,14 @@ function ci_build_autotools { [[ $CI_CC ]] && ci_spawn export CC="$CI_CC" [[ $CI_CC_FLAGS ]] && ci_spawn export CFLAGS="$CI_CC_FLAGS" [[ $CI_SANITIZERS ]] && ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS -O2 $CFLAGS" - # Build! - ci_spawn rm -fr "$CI_BUILDDIR" + # 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" $CI_CONFIGURE_FLAGS + 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 "success!" diff --git a/ci/ci_cmake.sh b/ci/ci_cmake.sh index 1a4e5965e..0fec46012 100755 --- a/ci/ci_cmake.sh +++ b/ci/ci_cmake.sh @@ -14,6 +14,7 @@ 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" function ci_info { printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*" @@ -40,6 +41,7 @@ function ci_init_cmake { # Print the CI_ variables. ci_info "source directory: $CI_SRCDIR" ci_info "build directory: $CI_BUILDDIR" + ci_info "install directory: $CI_INSTALLDIR" 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'" @@ -52,6 +54,7 @@ function ci_init_cmake { ci_info "environment option: \$CI_CC_FLAGS='$CI_CC_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'" # Print the CMake/CTest program versions. ci_spawn "$(command -v "$CI_CMAKE")" --version @@ -62,30 +65,44 @@ function ci_build_cmake { # 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 as an array; - # expand CI_CMAKE_VARS at the end of ALL_CMAKE_VARS. + # 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") - 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") + [[ $CI_CC ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC") + [[ $ALL_CC_FLAGS ]] && ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS") + 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) + local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS) + local -a ALL_CTEST_FLAGS=($CI_CTEST_FLAGS) # 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" - # Build! + # 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 cd "$CI_BUILDDIR" ci_spawn "$CI_CMAKE" "${ALL_CMAKE_VARS[@]}" "$CI_SRCDIR" - ci_spawn "$CI_CMAKE" --build . --config "$CI_CMAKE_BUILD_TYPE" $CI_CMAKE_BUILD_FLAGS + 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" $CI_CTEST_FLAGS + 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" $CI_CMAKE_BUILD_FLAGS --target clean + ci_spawn "$CI_CMAKE" --build . \ + --config "$CI_CMAKE_BUILD_TYPE" \ + --target clean \ + "${ALL_CMAKE_BUILD_FLAGS[@]}" ci_info "success!" } |