diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2024-02-24 01:06:57 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2024-02-24 01:06:57 +0000 |
commit | 0594e54cc7f3098934bba998fb5bcffb5eef6aec (patch) | |
tree | 8f90885a8db24b5c40433f0e76f70c6eca722eac /Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh | |
parent | d255cb14003f32f27ed6ab7182ab9e7b2f16d2b9 (diff) |
libpng 1.6.43
git-svn-id: svn://tug.org/texlive/trunk@70115 c570f23f-e606-0410-a88d-b1316a301751
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.sh | 144 |
1 files changed, 89 insertions, 55 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 beda3b470e6..e0681b4d8c6 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,5 +1,5 @@ #!/usr/bin/env bash -set -e +set -o errexit -o pipefail -o posix # Copyright (c) 2019-2024 Cosmin Truta. # @@ -8,7 +8,7 @@ set -e # # SPDX-License-Identifier: MIT -# shellcheck source="ci/lib/ci.lib.sh" +# shellcheck source=ci/lib/ci.lib.sh source "$(dirname "$0")/lib/ci.lib.sh" cd "$CI_TOPLEVEL_DIR" @@ -50,19 +50,25 @@ function ci_trace_build { ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'" ci_info "environment option: \$CI_LIBS: '$CI_LIBS'" ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'" + ci_info "environment option: \$CI_FORCE: '$CI_FORCE'" ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'" ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'" ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")" - [[ $CI_CC ]] && + [[ $CI_CC ]] && { ci_info "executable: \$CI_CC: $(command -V "$CI_CC")" - [[ $CI_CPP ]] && + } + [[ $CI_CPP ]] && { ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")" - [[ $CI_AR ]] && + } + [[ $CI_AR ]] && { ci_info "executable: \$CI_AR: $(command -V "$CI_AR")" - [[ $CI_RANLIB ]] && + } + [[ $CI_RANLIB ]] && { ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")" - [[ $CI_LD ]] && + } + [[ $CI_LD ]] && { ci_info "executable: \$CI_LD: $(command -V "$CI_LD")" + } ci_info "## END OF CONFIGURATION ##" } @@ -74,61 +80,87 @@ function ci_cleanup_old_build { # Fortunately, for a clean makefiles-based build, it should be # sufficient to remove the old object files only. 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 ##" + local find_args=(-maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \)) + [[ ! $(find "$CI_SRC_DIR" "${find_args[@]}" | head -n1) ]] || { + ci_warn "unexpected build found in '$CI_SRC_DIR'" + if ci_expr $((CI_FORCE)) + then + # Delete the old build. + local my_file + find "$CI_SRC_DIR" "${find_args[@]}" | + while IFS="" read -r my_file + do + ci_spawn rm -fr "$my_file" + done + ci_info "## END OF PRE-BUILD CLEANUP ##" + else + # Alert the user, but do not delete their existing files, + # and do not mess up their existing build. + ci_info "hint: consider using the option \$CI_FORCE=1" + ci_err "unable to continue" + fi + } } 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" - local ALL_LD_FLAGS="$CI_LD_FLAGS" - [[ $CI_SANITIZERS ]] && { - ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS ${ALL_CC_FLAGS:-"-O2"}" - ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS" - } - # Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays. - local ALL_MAKE_FLAGS=($CI_MAKE_FLAGS) - local ALL_MAKE_VARS=() - [[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC") - [[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS") - [[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP") - [[ $CI_CPP_FLAGS ]] && ALL_MAKE_VARS+=(CPPFLAGS="$CI_CPP_FLAGS") - [[ $CI_AR ]] && ALL_MAKE_VARS+=( - AR="${CI_AR:-ar}" - AR_RC="${CI_AR:-ar} rc" - ) - [[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB") - [[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD") - [[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS") - [[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS") - ALL_MAKE_VARS+=($CI_MAKE_VARS) - # Build! - local MY_MAKEFILE - for MY_MAKEFILE in $CI_MAKEFILES + # Initialize and populate the local arrays. + local all_make_flags=() + local all_make_vars=() + [[ $CI_MAKE_FLAGS ]] && { + all_make_flags+=($CI_MAKE_FLAGS) + } + [[ $CI_CC ]] && { + all_make_vars+=("CC=$CI_CC") + } + [[ $CI_CC_FLAGS || $CI_SANITIZERS ]] && { + [[ $CI_SANITIZERS ]] && CI_CC_FLAGS="${CI_CC_FLAGS:-"-O2"} -fsanitize=$CI_SANITIZERS" + all_make_vars+=("CFLAGS=$CI_CC_FLAGS") + } + [[ $CI_CPP ]] && { + all_make_vars+=("CPP=$CI_CPP") + } + [[ $CI_CPP_FLAGS ]] && { + all_make_vars+=("CPPFLAGS=$CI_CPP_FLAGS") + } + [[ $CI_AR ]] && { + all_make_vars+=("AR=$CI_AR") + } + [[ $CI_RANLIB ]] && { + all_make_vars+=("RANLIB=$CI_RANLIB") + } + [[ $CI_LD ]] && { + all_make_vars+=("LD=$CI_LD") + } + [[ $CI_LD_FLAGS || $CI_SANITIZERS ]] && { + [[ $CI_SANITIZERS ]] && CI_LD_FLAGS+="${CI_LD_FLAGS:+" "}-fsanitize=$CI_SANITIZERS" + all_make_vars+=("LDFLAGS=$CI_LD_FLAGS") + } + [[ $CI_LIBS ]] && { + all_make_vars+=("LIBS=$CI_LIBS") + } + all_make_vars+=($CI_MAKE_VARS) + # And... build! + local my_makefile + for my_makefile in $CI_MAKEFILES do - ci_info "using makefile: $MY_MAKEFILE" + ci_info "using makefile: $my_makefile" # Spawn "make". - ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \ - "${ALL_MAKE_FLAGS[@]}" \ - "${ALL_MAKE_VARS[@]}" + ci_spawn "$CI_MAKE" -f "$my_makefile" \ + "${all_make_flags[@]}" \ + "${all_make_vars[@]}" 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[@]}" \ + ci_spawn "$CI_MAKE" -f "$my_makefile" \ + "${all_make_flags[@]}" \ + "${all_make_vars[@]}" \ test } 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[@]}" \ + ci_spawn "$CI_MAKE" -f "$my_makefile" \ + "${all_make_flags[@]}" \ + "${all_make_vars[@]}" \ clean } done @@ -136,8 +168,9 @@ function ci_build { } function usage { - echo "usage: $CI_SCRIPT_NAME" - exit 0 + echo "usage: $CI_SCRIPT_NAME [<options>]" + echo "options: -?|-h|--help" + exit "${@:-0}" } function main { @@ -145,7 +178,7 @@ function main { while getopts ":" opt do # This ain't a while-loop. It only pretends to be. - [[ $1 == -[?h]* || $1 == --help ]] && usage + [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0 ci_err "unknown option: '$1'" done shift $((OPTIND - 1)) @@ -153,8 +186,9 @@ function main { ci_init_build ci_trace_build [[ $# -eq 0 ]] || { - ci_info "note: this program accepts environment options only" - ci_err "unexpected argument: '$1'" + echo >&2 "error: unexpected argument: '$1'" + echo >&2 "note: this program accepts environment options only" + usage 2 } ci_cleanup_old_build ci_build |