build/coreboot/utils: simplify argument handling

Signed-off-by: Leah Rowe <leah@libreboot.org>
btrfsvols
Leah Rowe 2023-10-02 04:12:30 +01:00
parent 7ce3f93e44
commit 0a711ebc66
1 changed files with 18 additions and 25 deletions

View File

@ -6,48 +6,41 @@
set -u -e set -u -e
. "include/err.sh" . "include/err.sh"
. "include/option.sh"
main() main()
{ {
printf "Building coreboot utils\n" printf "Building coreboot utils\n"
target="${@}"
if [ $# -gt 0 ]; then [ $# -gt 0 ] || target=$(listitems config/coreboot) || err "!targets"
for board in "${@}"; do for x in ${target}; do
x_ build_for_mainboard ${board} x_ build_for_mainboard ${x}
done done
else
for boarddir in config/coreboot/*; do
[ ! -d "${boarddir}" ] && continue
x_ build_for_mainboard ${boarddir##*/}
done
fi
} }
build_for_mainboard() { build_for_mainboard() {
board="${1}" [ -d "config/coreboot/${1}" ] || \
[ -d "config/coreboot/${board}" ] || \ err "build_for_mainboard ${1}: board dir does not exist"
err "build_for_mainboard ${board}: boarddir does not exist" [ -f "config/coreboot/${1}/target.cfg" ] || \
[ -f "config/coreboot/${board}/target.cfg" ] || \ err "build_for_mainboard ${1}: target.cfg does not exist"
err "build_for_mainboard ${board}: target.cfg does not exist"
tree="undefined" tree="undefined"
. "config/coreboot/${board}/target.cfg" # source . "config/coreboot/${1}/target.cfg" # source
[ "${tree}" = "undefined" ] && \ [ "${tree}" = "undefined" ] && \
err "build_for_mainboard ${board}: improper tree definition" err "build_for_mainboard ${1}: improper tree definition"
buildutils "${tree}" buildutils "${tree}"
} }
buildutils() { buildutils() {
tree="${1}" [ -d "coreboot/${1}/" ] || \
[ -d "coreboot/${tree}/" ] || \ x_ ./update project trees coreboot ${1}
x_ ./update project trees coreboot ${tree}
for util in cbfstool ifdtool; do for util in cbfstool ifdtool; do
[ -f "cbutils/${tree}/${util}" ] && continue [ -f "cbutils/${1}/${util}" ] && continue
[ -d "cbutils/${tree}" ] || x_ mkdir -p "cbutils/${tree}" [ -d "cbutils/${1}" ] || x_ mkdir -p "cbutils/${1}"
utildir="coreboot/${tree}/util/${util}" utildir="coreboot/${1}/util/${util}"
x_ make distclean -C "${utildir}" x_ make distclean -C "${utildir}"
x_ make -j$(nproc) -C "${utildir}" x_ make -j$(nproc) -C "${utildir}"
x_ cp "${utildir}/${util}" "cbutils/${tree}" x_ cp "${utildir}/${util}" "cbutils/${1}"
x_ make distclean -C "${utildir}" x_ make distclean -C "${utildir}"
done done
} }