mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
ci: Update the CI scripts
Apply the following changes: * Update CI_BUILDDIR and CI_INSTALLDIR to reflect the new script names. * Introduce CI_SRCDIR_FROM_BUILDDIR and CI_INSTALLDIR_FROM_BUILDDIR to the cmake build, to ensure that the Windows tools can handle native Windows paths correctly when executed via Bash-on-Windows. * Stop guessing and using CI_SRCDIR_NATIVE and CI_INSTALLDIR_NATIVE in the cmake build, since we now have a better solution. * Show the ninja program version in ninja-based cmake builds. * Move the cleanup of previous builds into separate functions, and do it in a cleaner manner. No pun intended.
This commit is contained in:
parent
59fa76e164
commit
66fede80d2
@ -4,7 +4,7 @@ set -e
|
|||||||
# ci_verify_cmake.sh
|
# ci_verify_cmake.sh
|
||||||
# Continuously integrate libpng using CMake.
|
# Continuously integrate libpng using CMake.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2019-2022 Cosmin Truta.
|
# Copyright (c) 2019-2023 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
|
||||||
@ -13,8 +13,14 @@ set -e
|
|||||||
CI_SCRIPTNAME="$(basename "$0")"
|
CI_SCRIPTNAME="$(basename "$0")"
|
||||||
CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
|
CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
|
CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
|
||||||
CI_BUILDDIR="$CI_SRCDIR/out/cmake.build"
|
CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_cmake.build"
|
||||||
CI_INSTALLDIR="$CI_SRCDIR/out/cmake.install"
|
CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_cmake.install"
|
||||||
|
|
||||||
|
# Keep the following relative paths in sync with the absolute paths.
|
||||||
|
# We use them for the benefit of native Windows tools that might be
|
||||||
|
# otherwise confused by the path encoding used by Bash-on-Windows.
|
||||||
|
CI_SRCDIR_FROM_BUILDDIR="../.."
|
||||||
|
CI_INSTALLDIR_FROM_BUILDDIR="../ci_verify_cmake.install"
|
||||||
|
|
||||||
function ci_info {
|
function ci_info {
|
||||||
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
|
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
|
||||||
@ -32,7 +38,7 @@ function ci_spawn {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function ci_init_cmake {
|
function ci_init_cmake_build {
|
||||||
CI_SYSTEM_NAME="$(uname -s)"
|
CI_SYSTEM_NAME="$(uname -s)"
|
||||||
CI_MACHINE_NAME="$(uname -m)"
|
CI_MACHINE_NAME="$(uname -m)"
|
||||||
CI_CMAKE="${CI_CMAKE:-cmake}"
|
CI_CMAKE="${CI_CMAKE:-cmake}"
|
||||||
@ -42,21 +48,6 @@ function ci_init_cmake {
|
|||||||
CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}"
|
CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}"
|
||||||
if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]]
|
if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]]
|
||||||
then
|
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 $(command -v 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
|
# Clean up incidental mixtures of Windows and Bash-on-Windows
|
||||||
# environment variables, to avoid confusing MSBuild.
|
# environment variables, to avoid confusing MSBuild.
|
||||||
[[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP
|
[[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP
|
||||||
@ -67,19 +58,13 @@ function ci_init_cmake {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function ci_trace_cmake {
|
function ci_trace_cmake_build {
|
||||||
ci_info "## START OF CONFIGURATION ##"
|
ci_info "## START OF CONFIGURATION ##"
|
||||||
ci_info "system name: $CI_SYSTEM_NAME"
|
ci_info "system name: $CI_SYSTEM_NAME"
|
||||||
ci_info "machine hardware name: $CI_MACHINE_NAME"
|
ci_info "machine hardware name: $CI_MACHINE_NAME"
|
||||||
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'"
|
||||||
@ -99,8 +84,6 @@ function ci_trace_cmake {
|
|||||||
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||||
ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")"
|
ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")"
|
||||||
ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")"
|
ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")"
|
||||||
[[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] &&
|
|
||||||
ci_info "executable: $(command -V ninja)"
|
|
||||||
[[ $CI_CC ]] &&
|
[[ $CI_CC ]] &&
|
||||||
ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
|
ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
|
||||||
[[ $CI_AR ]] &&
|
[[ $CI_AR ]] &&
|
||||||
@ -110,16 +93,25 @@ function ci_trace_cmake {
|
|||||||
ci_info "## END OF CONFIGURATION ##"
|
ci_info "## END OF CONFIGURATION ##"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ci_cleanup_old_cmake_build {
|
||||||
|
[[ ! -e $CI_BUILDDIR ]] ||
|
||||||
|
ci_spawn rm -fr "$CI_BUILDDIR"
|
||||||
|
[[ ! -e $CI_INSTALLDIR ]] ||
|
||||||
|
ci_spawn rm -fr "$CI_INSTALLDIR"
|
||||||
|
}
|
||||||
|
|
||||||
function ci_build_cmake {
|
function ci_build_cmake {
|
||||||
ci_info "## START OF BUILD ##"
|
ci_info "## START OF BUILD ##"
|
||||||
ci_spawn "$(command -v "$CI_CMAKE")" --version
|
ci_spawn "$(command -v "$CI_CMAKE")" --version
|
||||||
ci_spawn "$(command -v "$CI_CTEST")" --version
|
ci_spawn "$(command -v "$CI_CTEST")" --version
|
||||||
|
[[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] &&
|
||||||
|
ci_spawn "$(command -v ninja)" --version
|
||||||
# Initialize ALL_CC_FLAGS as a string.
|
# Initialize ALL_CC_FLAGS as a string.
|
||||||
local ALL_CC_FLAGS="$CI_CC_FLAGS"
|
local ALL_CC_FLAGS="$CI_CC_FLAGS"
|
||||||
[[ $CI_SANITIZERS ]] &&
|
[[ $CI_SANITIZERS ]] &&
|
||||||
ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS"
|
ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS"
|
||||||
# Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays.
|
# Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays.
|
||||||
local -a ALL_CMAKE_VARS=()
|
local ALL_CMAKE_VARS=()
|
||||||
[[ $CI_CMAKE_TOOLCHAIN_FILE ]] &&
|
[[ $CI_CMAKE_TOOLCHAIN_FILE ]] &&
|
||||||
ALL_CMAKE_VARS+=(-DCMAKE_TOOLCHAIN_FILE="$CI_CMAKE_TOOLCHAIN_FILE")
|
ALL_CMAKE_VARS+=(-DCMAKE_TOOLCHAIN_FILE="$CI_CMAKE_TOOLCHAIN_FILE")
|
||||||
[[ $CI_CC ]] &&
|
[[ $CI_CC ]] &&
|
||||||
@ -135,23 +127,26 @@ function ci_build_cmake {
|
|||||||
[[ $CI_NO_TEST ]] &&
|
[[ $CI_NO_TEST ]] &&
|
||||||
ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF)
|
ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF)
|
||||||
ALL_CMAKE_VARS+=($CI_CMAKE_VARS)
|
ALL_CMAKE_VARS+=($CI_CMAKE_VARS)
|
||||||
local -a ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS)
|
local ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS)
|
||||||
local -a ALL_CTEST_FLAGS=($CI_CTEST_FLAGS)
|
local 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.
|
# Export the CMake environment variables.
|
||||||
[[ $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"
|
||||||
# Build and install.
|
# Build and install.
|
||||||
ci_spawn rm -fr "$CI_BUILDDIR" "$CI_INSTALLDIR"
|
# Use $CI_SRCDIR_FROM_BUILDDIR and $CI_INSTALLDIR_FROM_BUILDDIR
|
||||||
|
# instead of $CI_SRCDIR and $CI_INSTALLDIR from this point onwards.
|
||||||
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_SRCDIR -ef $CI_SRCDIR_FROM_BUILDDIR ]] ||
|
||||||
-DCMAKE_INSTALL_PREFIX="$INSTALLDIR_NATIVE" \
|
ci_err "assertion failed: testing: '$CI_SRCDIR' -ef '$CI_SRCDIR_FROM_BUILDDIR'"
|
||||||
"$SRCDIR_NATIVE"
|
ci_spawn mkdir -p "$CI_INSTALLDIR"
|
||||||
|
[[ $CI_INSTALLDIR -ef $CI_INSTALLDIR_FROM_BUILDDIR ]] ||
|
||||||
|
ci_err "assertion failed: testing: '$CI_INSTALLDIR' -ef '$CI_INSTALLDIR_FROM_BUILDDIR'"
|
||||||
|
ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR_FROM_BUILDDIR" \
|
||||||
|
"${ALL_CMAKE_VARS[@]}" \
|
||||||
|
"$CI_SRCDIR_FROM_BUILDDIR"
|
||||||
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[@]}"
|
||||||
@ -171,10 +166,15 @@ function ci_build_cmake {
|
|||||||
ci_info "## END OF BUILD ##"
|
ci_info "## END OF BUILD ##"
|
||||||
}
|
}
|
||||||
|
|
||||||
ci_init_cmake
|
function main {
|
||||||
ci_trace_cmake
|
[[ $# -eq 0 ]] || {
|
||||||
[[ $# -eq 0 ]] || {
|
|
||||||
ci_info "note: this program accepts environment options only"
|
ci_info "note: this program accepts environment options only"
|
||||||
ci_err "unexpected command arguments: '$*'"
|
ci_err "unexpected command arguments: '$*'"
|
||||||
|
}
|
||||||
|
ci_init_cmake_build
|
||||||
|
ci_trace_cmake_build
|
||||||
|
ci_cleanup_old_cmake_build
|
||||||
|
ci_build_cmake
|
||||||
}
|
}
|
||||||
ci_build_cmake
|
|
||||||
|
main "$@"
|
||||||
|
@ -4,7 +4,7 @@ set -e
|
|||||||
# ci_verify_configure.sh
|
# ci_verify_configure.sh
|
||||||
# Continuously integrate libpng using the configure script.
|
# Continuously integrate libpng using the configure script.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2019-2022 Cosmin Truta.
|
# Copyright (c) 2019-2023 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
|
||||||
@ -13,8 +13,8 @@ set -e
|
|||||||
CI_SCRIPTNAME="$(basename "$0")"
|
CI_SCRIPTNAME="$(basename "$0")"
|
||||||
CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
|
CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
|
CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
|
||||||
CI_BUILDDIR="$CI_SRCDIR/out/configure.build"
|
CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_configure.build"
|
||||||
CI_INSTALLDIR="$CI_SRCDIR/out/configure.install"
|
CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_configure.install"
|
||||||
|
|
||||||
function ci_info {
|
function ci_info {
|
||||||
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
|
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
|
||||||
@ -32,7 +32,7 @@ function ci_spawn {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function ci_init_configure {
|
function ci_init_configure_build {
|
||||||
CI_SYSTEM_NAME="$(uname -s)"
|
CI_SYSTEM_NAME="$(uname -s)"
|
||||||
CI_MACHINE_NAME="$(uname -m)"
|
CI_MACHINE_NAME="$(uname -m)"
|
||||||
CI_MAKE="${CI_MAKE:-make}"
|
CI_MAKE="${CI_MAKE:-make}"
|
||||||
@ -44,7 +44,7 @@ function ci_init_configure {
|
|||||||
[[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
|
[[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
|
||||||
}
|
}
|
||||||
|
|
||||||
function ci_trace_configure {
|
function ci_trace_configure_build {
|
||||||
ci_info "## START OF CONFIGURATION ##"
|
ci_info "## START OF CONFIGURATION ##"
|
||||||
ci_info "system name: $CI_SYSTEM_NAME"
|
ci_info "system name: $CI_SYSTEM_NAME"
|
||||||
ci_info "machine hardware name: $CI_MACHINE_NAME"
|
ci_info "machine hardware name: $CI_MACHINE_NAME"
|
||||||
@ -80,6 +80,13 @@ function ci_trace_configure {
|
|||||||
ci_info "## END OF CONFIGURATION ##"
|
ci_info "## END OF CONFIGURATION ##"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ci_cleanup_old_configure_build {
|
||||||
|
[[ ! -e $CI_BUILDDIR ]] ||
|
||||||
|
ci_spawn rm -fr "$CI_BUILDDIR"
|
||||||
|
[[ ! -e $CI_INSTALLDIR ]] ||
|
||||||
|
ci_spawn rm -fr "$CI_INSTALLDIR"
|
||||||
|
}
|
||||||
|
|
||||||
function ci_build_configure {
|
function ci_build_configure {
|
||||||
ci_info "## START OF BUILD ##"
|
ci_info "## START OF BUILD ##"
|
||||||
# Export the configure build environment.
|
# Export the configure build environment.
|
||||||
@ -96,7 +103,6 @@ function ci_build_configure {
|
|||||||
ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS"
|
ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS"
|
||||||
}
|
}
|
||||||
# Build and install.
|
# Build and install.
|
||||||
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_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS
|
ci_spawn "$CI_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS
|
||||||
@ -108,10 +114,15 @@ function ci_build_configure {
|
|||||||
ci_info "## END OF BUILD ##"
|
ci_info "## END OF BUILD ##"
|
||||||
}
|
}
|
||||||
|
|
||||||
ci_init_configure
|
function main {
|
||||||
ci_trace_configure
|
[[ $# -eq 0 ]] || {
|
||||||
[[ $# -eq 0 ]] || {
|
|
||||||
ci_info "note: this program accepts environment options only"
|
ci_info "note: this program accepts environment options only"
|
||||||
ci_err "unexpected command arguments: '$*'"
|
ci_err "unexpected command arguments: '$*'"
|
||||||
|
}
|
||||||
|
ci_init_configure_build
|
||||||
|
ci_trace_configure_build
|
||||||
|
ci_cleanup_old_configure_build
|
||||||
|
ci_build_configure
|
||||||
}
|
}
|
||||||
ci_build_configure
|
|
||||||
|
main "$@"
|
||||||
|
@ -4,7 +4,7 @@ set -e
|
|||||||
# ci_verify_makefiles.sh
|
# ci_verify_makefiles.sh
|
||||||
# Continuously integrate libpng using the legacy makefiles.
|
# Continuously integrate libpng using the legacy makefiles.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2019-2022 Cosmin Truta.
|
# Copyright (c) 2019-2023 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
|
||||||
@ -13,7 +13,6 @@ set -e
|
|||||||
CI_SCRIPTNAME="$(basename "$0")"
|
CI_SCRIPTNAME="$(basename "$0")"
|
||||||
CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
|
CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
|
CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
|
||||||
CI_BUILDDIR="$CI_SRCDIR"
|
|
||||||
|
|
||||||
function ci_info {
|
function ci_info {
|
||||||
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
|
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
|
||||||
@ -31,7 +30,7 @@ function ci_spawn {
|
|||||||
"$@"
|
"$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
function ci_init_makefiles {
|
function ci_init_makefiles_build {
|
||||||
CI_SYSTEM_NAME="$(uname -s)"
|
CI_SYSTEM_NAME="$(uname -s)"
|
||||||
CI_MACHINE_NAME="$(uname -m)"
|
CI_MACHINE_NAME="$(uname -m)"
|
||||||
CI_MAKE="${CI_MAKE:-make}"
|
CI_MAKE="${CI_MAKE:-make}"
|
||||||
@ -45,12 +44,11 @@ function ci_init_makefiles {
|
|||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
function ci_trace_makefiles {
|
function ci_trace_makefiles_build {
|
||||||
ci_info "## START OF CONFIGURATION ##"
|
ci_info "## START OF CONFIGURATION ##"
|
||||||
ci_info "system name: $CI_SYSTEM_NAME"
|
ci_info "system name: $CI_SYSTEM_NAME"
|
||||||
ci_info "machine hardware name: $CI_MACHINE_NAME"
|
ci_info "machine hardware name: $CI_MACHINE_NAME"
|
||||||
ci_info "source directory: $CI_SRCDIR"
|
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_MAKEFILES: '$CI_MAKEFILES'"
|
||||||
ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
|
ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
|
||||||
ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
|
ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
|
||||||
@ -81,6 +79,19 @@ function ci_trace_makefiles {
|
|||||||
ci_info "## END OF CONFIGURATION ##"
|
ci_info "## END OF CONFIGURATION ##"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ci_cleanup_old_makefiles_build {
|
||||||
|
# Any old makefile-based build will most likely leave a mess
|
||||||
|
# of object files behind if interrupted, e.g., via Ctrl+C.
|
||||||
|
# There may be other files behind, depending on what makefile
|
||||||
|
# had been used. We cannot easily enumerate all of those.
|
||||||
|
# Fortunately, for a clean makefiles-based build, it should be
|
||||||
|
# sufficient to remove the old object files only.
|
||||||
|
[[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.o") ]] ||
|
||||||
|
ci_spawn rm -f "$CI_SRCDIR"/*.o
|
||||||
|
[[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.obj") ]] ||
|
||||||
|
ci_spawn rm -f "$CI_SRCDIR"/*.obj
|
||||||
|
}
|
||||||
|
|
||||||
function ci_build_makefiles {
|
function ci_build_makefiles {
|
||||||
ci_info "## START OF BUILD ##"
|
ci_info "## START OF BUILD ##"
|
||||||
# Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings.
|
# Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings.
|
||||||
@ -91,8 +102,8 @@ function ci_build_makefiles {
|
|||||||
ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS"
|
ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS"
|
||||||
}
|
}
|
||||||
# Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays.
|
# Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays.
|
||||||
local -a ALL_MAKE_FLAGS=($CI_MAKE_FLAGS)
|
local ALL_MAKE_FLAGS=($CI_MAKE_FLAGS)
|
||||||
local -a ALL_MAKE_VARS=()
|
local ALL_MAKE_VARS=()
|
||||||
[[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC")
|
[[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC")
|
||||||
[[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS")
|
[[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS")
|
||||||
[[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP")
|
[[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP")
|
||||||
@ -107,7 +118,7 @@ function ci_build_makefiles {
|
|||||||
[[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS")
|
[[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS")
|
||||||
ALL_MAKE_VARS+=($CI_MAKE_VARS)
|
ALL_MAKE_VARS+=($CI_MAKE_VARS)
|
||||||
# Build!
|
# Build!
|
||||||
ci_spawn cd "$CI_SRCDIR"
|
cd "$CI_SRCDIR"
|
||||||
local MY_MAKEFILE
|
local MY_MAKEFILE
|
||||||
for MY_MAKEFILE in $CI_MAKEFILES
|
for MY_MAKEFILE in $CI_MAKEFILES
|
||||||
do
|
do
|
||||||
@ -129,10 +140,15 @@ function ci_build_makefiles {
|
|||||||
ci_info "## END OF BUILD ##"
|
ci_info "## END OF BUILD ##"
|
||||||
}
|
}
|
||||||
|
|
||||||
ci_init_makefiles
|
function main {
|
||||||
ci_trace_makefiles
|
[[ $# -eq 0 ]] || {
|
||||||
[[ $# -eq 0 ]] || {
|
|
||||||
ci_info "note: this program accepts environment options only"
|
ci_info "note: this program accepts environment options only"
|
||||||
ci_err "unexpected command arguments: '$*'"
|
ci_err "unexpected command arguments: '$*'"
|
||||||
|
}
|
||||||
|
ci_init_makefiles_build
|
||||||
|
ci_trace_makefiles_build
|
||||||
|
ci_cleanup_old_makefiles_build
|
||||||
|
ci_build_makefiles
|
||||||
}
|
}
|
||||||
ci_build_makefiles
|
|
||||||
|
main "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user