summaryrefslogtreecommitdiff
path: root/Build/source/libs/libpng/libpng-src/ci
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/libs/libpng/libpng-src/ci')
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/.shellcheckrc11
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt19
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh88
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh156
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh140
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh99
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh90
7 files changed, 427 insertions, 176 deletions
diff --git a/Build/source/libs/libpng/libpng-src/ci/.shellcheckrc b/Build/source/libs/libpng/libpng-src/ci/.shellcheckrc
new file mode 100644
index 00000000000..0260dcca30f
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/.shellcheckrc
@@ -0,0 +1,11 @@
+# Disable the "variable appears unused" warning caused by the use of getopts
+# with an obligatory (but unused) variable name in the main function.
+disable=SC2034
+
+# Disable all the "quote to prevent globbing or word splitting" advice.
+# We need word splitting for well-known variables like MAKEFLAGS and CFLAGS.
+disable=SC2086,SC2206
+
+# Disable the "possible misspelling" warnings that might be flagged, e.g.,
+# inside function ci_trace_build.
+disable=SC2153
diff --git a/Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt b/Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt
new file mode 100644
index 00000000000..9cf106272ac
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt
@@ -0,0 +1,19 @@
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh b/Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh
new file mode 100644
index 00000000000..123ed482f10
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+set -e
+
+# Copyright (c) 2019-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source="ci/lib/ci.lib.sh"
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
+
+CI_SHELLCHECK="$(command -v shellcheck || true)"
+CI_YAMLLINT="$(command -v yamllint || true)"
+CI_LINT_COUNTER=0
+
+function ci_lint_ci_config_files {
+ ci_info "linting: CI config files"
+ local MY_FILE
+ if [[ -x $CI_YAMLLINT ]]
+ then
+ ci_spawn "$CI_YAMLLINT" --version
+ for MY_FILE in "$CI_TOPLEVEL_DIR"/.*.yml
+ do
+ ci_spawn "$CI_YAMLLINT" --strict "$MY_FILE" ||
+ CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
+ done
+ else
+ ci_warn "program not found: 'yamllint'; skipping checks"
+ fi
+}
+
+function ci_lint_ci_scripts {
+ ci_info "linting: CI scripts"
+ local MY_FILE
+ if [[ -x $CI_SHELLCHECK ]]
+ then
+ ci_spawn "$CI_SHELLCHECK" --version
+ for MY_FILE in "$CI_SCRIPT_DIR"/*.sh
+ do
+ ci_spawn "$CI_SHELLCHECK" -x "$MY_FILE" ||
+ CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
+ done
+ else
+ ci_warn "program not found: 'shellcheck'; skipping checks"
+ fi
+}
+
+function ci_lint_ci_scripts_license {
+ ci_info "linting: CI scripts license"
+ ci_spawn grep -F "MIT License" ci/LICENSE_MIT.txt || {
+ ci_warn "bad or missing CI license file: '$CI_SCRIPT_DIR/LICENSE_MIT.txt'"
+ CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
+ }
+}
+
+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!
+ [[ $# -eq 0 ]] || ci_err "unexpected argument: '$1'"
+ ci_lint_ci_config_files
+ ci_lint_ci_scripts
+ ci_lint_ci_scripts_license
+ if [[ $CI_LINT_COUNTER -eq 0 ]]
+ then
+ ci_info "success!"
+ exit 0
+ else
+ ci_info "failed on $CI_LINT_COUNTER file(s)"
+ exit 1
+ fi
+}
+
+main "$@"
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh b/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh
index 4e11addfb9d..1d3e9734e69 100644
--- a/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh
@@ -1,46 +1,30 @@
#!/usr/bin/env bash
set -e
-# ci_verify_cmake.sh
-# Continuously integrate libpng using CMake.
+# 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")"
-CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_cmake.build"
-CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_cmake.install"
+# shellcheck source="ci/lib/ci.lib.sh"
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
+
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
+CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
+CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
+CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.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 {
- printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
-}
-
-function ci_err {
- printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*"
- exit 2
-}
+CI_BUILD_TO_SRC_RELDIR="../.."
+CI_BUILD_TO_INSTALL_RELDIR="../ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
-function ci_spawn {
- printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
- printf >&2 " %q" "$@"
- printf >&2 "\\n"
- "$@"
-}
-
-function ci_init_cmake_build {
- CI_SYSTEM_NAME="$(uname -s)"
- CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+ # Ensure that the mandatory variables are initialized.
CI_CMAKE="${CI_CMAKE:-cmake}"
CI_CTEST="${CI_CTEST:-ctest}"
CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}"
@@ -54,17 +38,21 @@ function ci_init_cmake_build {
[[ $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"
+ ci_err_internal "missing \$CI_CMAKE_GENERATOR_PLATFORM"
fi
}
-function ci_trace_cmake_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 directory: $CI_BUILDDIR"
- ci_info "install directory: $CI_INSTALLDIR"
+ 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 "build directory: $CI_BUILD_DIR"
+ ci_info "install directory: $CI_INSTALL_DIR"
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'"
@@ -93,14 +81,17 @@ function ci_trace_cmake_build {
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_cleanup_old_build {
+ if [[ -e $CI_BUILD_DIR || -e $CI_INSTALL_DIR ]]
+ then
+ ci_info "## START OF PRE-BUILD CLEANUP ##"
+ ci_spawn rm -fr "$CI_BUILD_DIR"
+ ci_spawn rm -fr "$CI_INSTALL_DIR"
+ ci_info "## END OF PRE-BUILD CLEANUP ##"
+ fi
}
-function ci_build_cmake {
+function ci_build {
ci_info "## START OF BUILD ##"
ci_spawn "$(command -v "$CI_CMAKE")" --version
ci_spawn "$(command -v "$CI_CTEST")" --version
@@ -118,14 +109,16 @@ function ci_build_cmake {
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")
+ [[ $CI_AR ]] && {
+ # Use the full path of CI_AR to work around a CMake error.
+ ALL_CMAKE_VARS+=(-DCMAKE_AR="$(command -v "$CI_AR")")
+ }
+ [[ $CI_RANLIB ]] && {
+ # Use the full path of CI_RANLIB to work around a CMake error.
+ ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$(command -v "$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 ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS)
local ALL_CTEST_FLAGS=($CI_CTEST_FLAGS)
@@ -134,47 +127,68 @@ function ci_build_cmake {
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.
- # 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 cd "$CI_BUILDDIR"
- [[ $CI_SRCDIR -ef $CI_SRCDIR_FROM_BUILDDIR ]] ||
- ci_err "assertion failed: testing: '$CI_SRCDIR' -ef '$CI_SRCDIR_FROM_BUILDDIR'"
- 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" \
+ # Build!
+ # Use $CI_BUILD_TO_SRC_RELDIR and $CI_BUILD_TO_INSTALL_RELDIR
+ # instead of $CI_SRC_DIR and $CI_INSTALL_DIR from this point onwards.
+ ci_spawn mkdir -p "$CI_BUILD_DIR"
+ ci_spawn cd "$CI_BUILD_DIR"
+ [[ $CI_BUILD_TO_SRC_RELDIR -ef $CI_SRC_DIR ]] ||
+ ci_err_internal "bad or missing \$CI_BUILD_TO_SRC_RELDIR"
+ ci_spawn mkdir -p "$CI_INSTALL_DIR"
+ [[ $CI_BUILD_TO_INSTALL_RELDIR -ef $CI_INSTALL_DIR ]] ||
+ ci_err_internal "bad or missing \$CI_BUILD_TO_INSTALL_RELDIR"
+ # Spawn "cmake ...".
+ ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_BUILD_TO_INSTALL_RELDIR" \
"${ALL_CMAKE_VARS[@]}" \
- "$CI_SRCDIR_FROM_BUILDDIR"
+ "$CI_BUILD_TO_SRC_RELDIR"
+ # Spawn "cmake --build ...".
ci_spawn "$CI_CMAKE" --build . \
--config "$CI_CMAKE_BUILD_TYPE" \
"${ALL_CMAKE_BUILD_FLAGS[@]}"
- [[ $CI_NO_TEST ]] ||
+ ci_expr $((CI_NO_TEST)) || {
+ # Spawn "ctest" if testing is not disabled.
ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \
"${ALL_CTEST_FLAGS[@]}"
- [[ $CI_NO_INSTALL ]] ||
+ }
+ ci_expr $((CI_NO_INSTALL)) || {
+ # Spawn "cmake --build ... --target install" if installation is not disabled.
ci_spawn "$CI_CMAKE" --build . \
--config "$CI_CMAKE_BUILD_TYPE" \
--target install \
"${ALL_CMAKE_BUILD_FLAGS[@]}"
- [[ $CI_NO_CLEAN ]] ||
+ }
+ ci_expr $((CI_NO_CLEAN)) || {
+ # Spawn "make --build ... --target clean" if cleaning is not disabled.
ci_spawn "$CI_CMAKE" --build . \
--config "$CI_CMAKE_BUILD_TYPE" \
--target clean \
"${ALL_CMAKE_BUILD_FLAGS[@]}"
+ }
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))
+ 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_cmake_build
- ci_trace_cmake_build
- ci_cleanup_old_cmake_build
- ci_build_cmake
+ ci_cleanup_old_build
+ ci_build
}
main "$@"
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh b/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh
index a8e88787aed..9be76d98620 100644
--- a/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh
@@ -1,56 +1,48 @@
#!/usr/bin/env bash
set -e
-# ci_verify_configure.sh
-# Continuously integrate libpng using the configure script.
+# 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")"
-CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_configure.build"
-CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_configure.install"
+# 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
-}
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
+CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
+CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
+CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
-function ci_spawn {
- printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
- printf >&2 " %q" "$@"
- printf >&2 "\\n"
- "$@"
-}
-
-function ci_init_configure_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}"
- # 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}"
+ [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] || {
+ # For native builds, 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'"
+ [[ ! $CI_CONFIGURE_VARS ]] ||
+ ci_err "unsupported: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
+ [[ ! $CI_MAKE_VARS ]] ||
+ ci_err "unsupported: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
}
-function ci_trace_configure_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 directory: $CI_BUILDDIR"
- ci_info "install directory: $CI_INSTALLDIR"
+ 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 "build directory: $CI_BUILD_DIR"
+ ci_info "install directory: $CI_INSTALL_DIR"
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'"
@@ -80,14 +72,17 @@ function ci_trace_configure_build {
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_cleanup_old_build {
+ if [[ -e $CI_BUILD_DIR || -e $CI_INSTALL_DIR ]]
+ then
+ ci_info "## START OF PRE-BUILD CLEANUP ##"
+ ci_spawn rm -fr "$CI_BUILD_DIR"
+ ci_spawn rm -fr "$CI_INSTALL_DIR"
+ ci_info "## END OF PRE-BUILD CLEANUP ##"
+ fi
}
-function ci_build_configure {
+function ci_build {
ci_info "## START OF BUILD ##"
# Export the configure build environment.
[[ $CI_CC ]] && ci_spawn export CC="$CI_CC"
@@ -96,33 +91,58 @@ function ci_build_configure {
[[ $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 ]] && ci_spawn export LD="$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 mkdir -p "$CI_BUILDDIR"
- ci_spawn cd "$CI_BUILDDIR"
- ci_spawn "$CI_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS
+ # Build!
+ ci_spawn mkdir -p "$CI_BUILD_DIR"
+ ci_spawn cd "$CI_BUILD_DIR"
+ # Spawn "configure".
+ ci_spawn "$CI_SRC_DIR/configure" --prefix="$CI_INSTALL_DIR" $CI_CONFIGURE_FLAGS
+ # Spawn "make".
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_expr $((CI_NO_TEST)) || {
+ # Spawn "make test" if testing is not disabled.
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
+ }
+ ci_expr $((CI_NO_INSTALL)) || {
+ # Spawn "make install" if installation is not disabled.
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install
+ }
+ ci_expr $((CI_NO_CLEAN)) || {
+ # Spawn "make clean" and "make distclean" if cleaning is not disabled.
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean
+ }
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_configure_build
- ci_trace_configure_build
- ci_cleanup_old_configure_build
- ci_build_configure
+ ci_cleanup_old_build
+ ci_build
}
main "$@"
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 "$@"
diff --git a/Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh b/Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh
new file mode 100644
index 00000000000..1f3c698b5d7
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh
@@ -0,0 +1,90 @@
+# Copyright (c) 2019-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+test -f "$BASH_SOURCE" ||
+ echo >&2 "warning: this module requires Bash version 3 or newer"
+test "${#BASH_SOURCE[@]}" -gt 1 ||
+ echo >&2 "warning: this module should be sourced from a Bash script"
+
+# Reset the locale to avoid surprises from locale-dependent commands.
+export LC_ALL=C
+export LANG=C
+export LANGUAGE=C
+
+# Reset CDPATH to avoid surprises from the "cd" command.
+export CDPATH=""
+
+# Initialize the global constants CI_SCRIPT_{NAME,DIR} and CI_TOPLEVEL_DIR.
+CI_SCRIPT_NAME="$(basename -- "$0")"
+CI_SCRIPT_DIR="$(cd "$(dirname -- "$0")" && pwd)"
+CI_TOPLEVEL_DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
+
+# Initialize the global constants CI_BUILD_{...} for the host build platform.
+CI_BUILD_ARCH="${CI_BUILD_ARCH:-"$(uname -m | tr 'A-Z/\.-' 'a-z____')"}"
+CI_BUILD_SYSTEM="${CI_BUILD_SYSTEM:-"$(uname -s | tr 'A-Z/\.-' 'a-z____')"}"
+
+# Initialize the global constants CI_TARGET_{...} for the target platform.
+CI_TARGET_ARCH="${CI_TARGET_ARCH:-"$CI_BUILD_ARCH"}"
+CI_TARGET_SYSTEM="${CI_TARGET_SYSTEM:-"$CI_BUILD_SYSTEM"}"
+
+function ci_info {
+ printf >&2 "%s: %s\\n" "$CI_SCRIPT_NAME" "$*"
+}
+
+function ci_warn {
+ printf >&2 "%s: warning: %s\\n" "$CI_SCRIPT_NAME" "$*"
+}
+
+function ci_err {
+ printf >&2 "%s: error: %s\\n" "$CI_SCRIPT_NAME" "$*"
+ exit 2
+}
+
+function ci_err_internal {
+ printf >&2 "%s: internal error: %s\\n" "$CI_SCRIPT_NAME" "$*"
+ printf >&2 "ABORTED\\n"
+ # Exit with the conventional SIGABRT code.
+ exit 134
+}
+
+function ci_expr {
+ if [[ ${*:-0} == [0-9] ]]
+ then
+ # This is the same as in the else-branch below, albeit much faster
+ # for our intended use cases.
+ return $((!$1))
+ else
+ # The funny-looking compound command "... && return $? || return $?"
+ # allows the execution to continue uninterrupted under "set -e".
+ expr >/dev/null "$@" && return $? || return $?
+ fi
+}
+
+function ci_spawn {
+ printf >&2 "%s: executing:" "$CI_SCRIPT_NAME"
+ printf >&2 " %q" "$@"
+ printf >&2 "\\n"
+ "$@"
+}
+
+# Ensure that the internal initialization is correct.
+[[ $CI_TOPLEVEL_DIR/ci/lib/ci.lib.sh -ef ${BASH_SOURCE[0]} ]] ||
+ ci_err_internal "bad or missing \$CI_TOPLEVEL_DIR"
+[[ $CI_SCRIPT_DIR/$CI_SCRIPT_NAME -ef $0 ]] ||
+ ci_err_internal "bad or missing \$CI_SCRIPT_DIR/\$CI_SCRIPT_NAME"
+[[ $CI_BUILD_ARCH && $CI_BUILD_SYSTEM ]] ||
+ ci_err_internal "missing \$CI_BUILD_ARCH or \$CI_BUILD_SYSTEM"
+[[ $CI_TARGET_ARCH && $CI_TARGET_SYSTEM ]] ||
+ ci_err_internal "missing \$CI_TARGET_ARCH or \$CI_TARGET_SYSTEM"
+
+# Ensure that the user initialization is correct.
+[[ ${CI_NO_TEST:-0} == [01] ]] ||
+ ci_err "bad boolean option: \$CI_NO_TEST: '$CI_NO_TEST'"
+[[ ${CI_NO_INSTALL:-0} == [01] ]] ||
+ ci_err "bad boolean option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
+[[ ${CI_NO_CLEAN:-0} == [01] ]] ||
+ ci_err "bad boolean option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"