build: Allow for only specific scripts to be built

This commit is contained in:
Ethan P 2021-03-30 20:38:37 -07:00
parent 0cefe6efe1
commit bd7cb3ea9e
No known key found for this signature in database
GPG Key ID: 6963FD04F6CF35EA

View File

@ -370,6 +370,7 @@ OPT_INLINE=true
OPT_MINIFY="lib" OPT_MINIFY="lib"
OPT_PREFIX="/usr/local" OPT_PREFIX="/usr/local"
OPT_BAT="$(basename "$EXECUTABLE_BAT")" OPT_BAT="$(basename "$EXECUTABLE_BAT")"
BUILD_FILTER=()
DOCS_URL="https://github.com/eth-p/bat-extras/blob/master/doc" DOCS_URL="https://github.com/eth-p/bat-extras/blob/master/doc"
DOCS_MAINTAINER="eth-p <eth-p@hidden.email>" DOCS_MAINTAINER="eth-p <eth-p@hidden.email>"
@ -389,8 +390,12 @@ while shiftopt; do
--minify) shiftval; OPT_MINIFY="$OPT_VAL" ;; --minify) shiftval; OPT_MINIFY="$OPT_VAL" ;;
*) *)
printc_err "%{RED}%s: unknown option '%s'%{CLEAR}" "$PROGRAM" "$OPT" if ! [[ -f "${SRC}/${OPT}.sh" ]]; then
exit 1 printc_err "%{RED}%s: unknown option '%s'%{CLEAR}" "$PROGRAM" "$OPT"
exit 1
fi
BUILD_FILTER+=("$OPT")
;; ;;
esac esac
done done
@ -445,9 +450,32 @@ SOURCES=()
printc_msg "%{YELLOW}Preparing scripts...%{CLEAR}\n" printc_msg "%{YELLOW}Preparing scripts...%{CLEAR}\n"
for file in "$SRC"/*.sh; do for file in "$SRC"/*.sh; do
SOURCES+=("$file") file_bin="$(basename -- "$file" ".sh")"
buildable=false
if ! "$buildable" && [[ "${#BUILD_FILTER[@]}" -eq 0 ]]; then
buildable=true
elif ! "$buildable"; then
for buildable_file in "${BUILD_FILTER[@]}"; do
if [[ "$buildable_file" = "$file_bin" ]]; then
buildable=true
break
fi
done
fi
# If that one is allowed to build, add it to the sources list.
if "$buildable"; then
SOURCES+=("$file")
else
printc_msg " %{YELLOW}Skipping %{MAGENTA}%s%{CLEAR}\n" "$(basename "$file_bin")"
fi
done done
if [[ "${#BUILD_FILTER[@]}" -gt 0 ]]; then
printf "\n"
fi
# ----------------------------------------------------------------------------- # -----------------------------------------------------------------------------
# Build manuals. # Build manuals.