diff --git a/CHANGELOG.md b/CHANGELOG.md index b6c0308..9355257 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,8 +15,10 @@ Breaking changes: pretty minimal. Other notable changes: -* `bashy-basics`: New utility functions `env-clean`, `env-minimize`, and - `env-names`. +* `bashy-basics`: + * New utility functions `env-clean`, `env-minimize`, and `env-names`. + * New helper library `buildy-help`, to help avoid some project-build-related + boilerplate. ### v2.7 -- 2023-10-30 diff --git a/scripts/lib/bashy-basics/buildy-help.sh b/scripts/lib/bashy-basics/buildy-help.sh new file mode 100644 index 0000000..eee1926 --- /dev/null +++ b/scripts/lib/bashy-basics/buildy-help.sh @@ -0,0 +1,37 @@ +# Copyright 2022-2023 the Bashy-lib Authors (Dan Bornstein et alia). +# SPDX-License-Identifier: Apache-2.0 + +# +# Helper library for doing builds. +# + +# Wrapper around `lib buildy out-dir` which sets up a built-output directory in +# a standard way and prints out the final path. Takes toggle option `--clean` +# and value option `--out=`. +function set-up-out-dir { + local extraOpts=() + + while (( $# > 0 )); do + case "$1" in + --clean|--clean=1) + extraOpts+=(--remove) + shift + ;; + --clean=0|--no-clean) + shift + ;; + --out=) + extraOpts+=("$1") + shift + ;; + esac + done + + if (( $# != 0 )); then + error-msg --file-line=1 "Unrecognized argument: $1" + return 1 + fi + + lib buildy out-dir \ + --out="${outDir}" --create --print "${extraOpts[@]}" +}