summaryrefslogtreecommitdiff
path: root/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh')
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh99
1 files changed, 54 insertions, 45 deletions
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh b/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh
index 78e7469d752..beda3b470e6 100644
--- a/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh
@@ -1,38 +1,21 @@
#!/usr/bin/env bash
set -e
-# ci_verify_makefiles.sh
-# Continuously integrate libpng using the legacy makefiles.
+# Copyright (c) 2019-2024 Cosmin Truta.
#
-# Copyright (c) 2019-2023 Cosmin Truta.
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
#
-# This software is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h.
+# SPDX-License-Identifier: MIT
-CI_SCRIPTNAME="$(basename "$0")"
-CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
-CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
+# shellcheck source="ci/lib/ci.lib.sh"
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
-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"
- "$@"
-}
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
-function ci_init_makefiles_build {
- CI_SYSTEM_NAME="$(uname -s)"
- CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+ # Ensure that the mandatory variables are initialized.
CI_MAKE="${CI_MAKE:-make}"
case "$CI_CC" in
( *clang* )
@@ -44,11 +27,15 @@ 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 "build arch: $CI_BUILD_ARCH"
+ ci_info "build system: $CI_BUILD_SYSTEM"
+ [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
+ ci_info "target arch: $CI_TARGET_ARCH"
+ ci_info "target system: $CI_TARGET_SYSTEM"
+ }
+ 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 +66,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,37 +109,55 @@ function ci_build_makefiles {
[[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS")
ALL_MAKE_VARS+=($CI_MAKE_VARS)
# Build!
- cd "$CI_SRCDIR"
local MY_MAKEFILE
for MY_MAKEFILE in $CI_MAKEFILES
do
ci_info "using makefile: $MY_MAKEFILE"
+ # Spawn "make".
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
"${ALL_MAKE_FLAGS[@]}" \
"${ALL_MAKE_VARS[@]}"
- [[ $CI_NO_TEST ]] ||
+ ci_expr $((CI_NO_TEST)) || {
+ # Spawn "make test" if testing is not disabled.
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
"${ALL_MAKE_FLAGS[@]}" \
"${ALL_MAKE_VARS[@]}" \
test
- [[ $CI_NO_CLEAN ]] ||
+ }
+ ci_expr $((CI_NO_CLEAN)) || {
+ # Spawn "make clean" if cleaning is not disabled.
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
"${ALL_MAKE_FLAGS[@]}" \
"${ALL_MAKE_VARS[@]}" \
clean
+ }
done
ci_info "## END OF BUILD ##"
}
+function usage {
+ echo "usage: $CI_SCRIPT_NAME"
+ exit 0
+}
+
function main {
+ local opt
+ while getopts ":" opt
+ do
+ # This ain't a while-loop. It only pretends to be.
+ [[ $1 == -[?h]* || $1 == --help ]] && usage
+ ci_err "unknown option: '$1'"
+ done
+ shift $((OPTIND - 1))
+ # And... go!
+ ci_init_build
+ ci_trace_build
[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
- ci_err "unexpected command arguments: '$*'"
+ ci_err "unexpected argument: '$1'"
}
- ci_init_makefiles_build
- ci_trace_makefiles_build
- ci_cleanup_old_makefiles_build
- ci_build_makefiles
+ ci_cleanup_old_build
+ ci_build
}
main "$@"