From 9d01df379517d16572b5c32baa5c48f06aeab443 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 10 Jan 2018 18:59:17 -0500 Subject: makepkg: improve modifying OPTIONS and BUILDENV --- .config/pacman/makepkg.conf | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/.config/pacman/makepkg.conf b/.config/pacman/makepkg.conf index 2e627b8..fe64828 100644 --- a/.config/pacman/makepkg.conf +++ b/.config/pacman/makepkg.conf @@ -9,16 +9,36 @@ PACKAGER="Luke Shumaker " MAKEFLAGS="-j$(($(nproc)+1))" -if type ccache &>/dev/null; then - f=false +lukeshu_set_BUILDENV() { + local thing=$1 + local i for i in "${!BUILDENV[@]}"; do - if [[ "${BUILDENV[$i]}" == '!ccache' ]]; then - BUILDENV[$i]='ccache' - f=true - fi + case "${BUILDENV[$i]}" in + "!${thing#!}"|"${thing#!}") + BUILDENV[$i]=$thing + return + ;; + esac + done + BUILDENV+=("$thing") +} + +lukeshu_set_OPTIONS() { + local thing=$1 + local i + for i in "${!OPTIONS[@]}"; do + case "${OPTIONS[$i]}" in + "!${thing#!}"|"${thing#!}") + OPTIONS[$i]=$thing + return + ;; + esac done - if [[ $f == false ]]; then - BUILDENV+=('ccache') - fi - unset f i + OPTIONS+=("$thing") +} + +lukeshu_set_OPTIONS debug + +if type ccache &>/dev/null; then + lukeshu_set_BUILDENV ccache fi -- cgit v1.1-4-g5e80