mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
ci: Add ci.lib.ch; update ci_verify_*.sh accordingly
Move the common declarations and initializations from ci_verify_*.sh
to ci.lib.sh, and update them as follows:
* Simplify the ci_ function names.
* Refactor the CI_ variable names:
- Add the new variable CI_TOPLEVEL_DIR.
- Rename the variables CI_SCRIPTNAME, CI_SCRIPTDIR, etc.,
to CI_SCRIPT_NAME, CI_SCRIPT_DIR, etc.
- Rename the variables CI_SRCDIR_FROM_BUILDDIR, etc., to
CI_BUILD_TO_SRC_RELDIR, etc.
* Add new functions inside ci.lib.sh:
- Replace ci_err with ci_err_usage, ci_err_fatal, ci_err_internal.
- Add the new functions ci_warn and ci_assert.
* Simplify the ci_ function names inside ci_verify_*.sh.
This commit is contained in:
@@ -10,29 +10,12 @@ set -e
|
||||
#
|
||||
# SPDX-License-Identifier: BSL-1.0
|
||||
|
||||
CI_SCRIPTNAME="$(basename "$0")"
|
||||
CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
|
||||
source "$(dirname "$0")/lib/ci.lib.sh"
|
||||
cd "$CI_TOPLEVEL_DIR"
|
||||
|
||||
function ci_info {
|
||||
printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
|
||||
}
|
||||
CI_SRC_DIR="$CI_TOPLEVEL_DIR"
|
||||
|
||||
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_build {
|
||||
CI_SYSTEM_NAME="$(uname -s)"
|
||||
CI_MACHINE_NAME="$(uname -m)"
|
||||
function ci_init_build {
|
||||
CI_MAKE="${CI_MAKE:-make}"
|
||||
case "$CI_CC" in
|
||||
( *clang* )
|
||||
@@ -44,11 +27,11 @@ function ci_init_makefiles_build {
|
||||
esac
|
||||
}
|
||||
|
||||
function ci_trace_makefiles_build {
|
||||
function ci_trace_build {
|
||||
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 "source directory: $CI_SRC_DIR"
|
||||
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'"
|
||||
@@ -79,20 +62,24 @@ function ci_trace_makefiles_build {
|
||||
ci_info "## END OF CONFIGURATION ##"
|
||||
}
|
||||
|
||||
function ci_cleanup_old_makefiles_build {
|
||||
function ci_cleanup_old_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
|
||||
ci_info "## START OF PRE-BUILD CLEANUP ##"
|
||||
local MY_FILE
|
||||
find "$CI_SRC_DIR" -maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \) |
|
||||
while IFS="" read -r MY_FILE
|
||||
do
|
||||
ci_spawn rm -fr "$MY_FILE"
|
||||
done
|
||||
ci_info "## END OF PRE-BUILD CLEANUP ##"
|
||||
}
|
||||
|
||||
function ci_build_makefiles {
|
||||
function ci_build {
|
||||
ci_info "## START OF BUILD ##"
|
||||
# Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings.
|
||||
local ALL_CC_FLAGS="$CI_CC_FLAGS"
|
||||
@@ -118,7 +105,7 @@ function ci_build_makefiles {
|
||||
[[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS")
|
||||
ALL_MAKE_VARS+=($CI_MAKE_VARS)
|
||||
# Build!
|
||||
cd "$CI_SRCDIR"
|
||||
ci_assert "$CI_SRC_DIR" -ef .
|
||||
local MY_MAKEFILE
|
||||
for MY_MAKEFILE in $CI_MAKEFILES
|
||||
do
|
||||
@@ -143,12 +130,12 @@ function ci_build_makefiles {
|
||||
function main {
|
||||
[[ $# -eq 0 ]] || {
|
||||
ci_info "note: this program accepts environment options only"
|
||||
ci_err "unexpected command arguments: '$*'"
|
||||
ci_err "unsupported command argument: '$1'"
|
||||
}
|
||||
ci_init_makefiles_build
|
||||
ci_trace_makefiles_build
|
||||
ci_cleanup_old_makefiles_build
|
||||
ci_build_makefiles
|
||||
ci_init_build
|
||||
ci_trace_build
|
||||
ci_cleanup_old_build
|
||||
ci_build
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Reference in New Issue
Block a user