mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-28 23:19:03 +02:00
Instead of having detailed error messages, run most commands through a function that calls err() under fault conditions. Where detail is still required, err() is still called manually. Where it isn't, the error message is simply whatever command was executed to cause the error. This results in a massive sloccount reduction for lbmk; specifically, 178 sloc reduction, or a 8.1% reduction. The total sloccount is now 2022, for shell scripts. Signed-off-by: Leah Rowe <leah@libreboot.org>
56 lines
1.4 KiB
Bash
Executable File
56 lines
1.4 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
# SPDX-FileCopyrightText: 2014-2016,2020,2021,2023 Leah Rowe <leah@libreboot.org>
|
|
|
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
|
set -u -e
|
|
|
|
. "include/err.sh"
|
|
|
|
main()
|
|
{
|
|
printf "Building coreboot utils\n"
|
|
|
|
if [ $# -gt 0 ]; then
|
|
for board in "${@}"; do
|
|
x_ build_for_mainboard ${board}
|
|
done
|
|
else
|
|
for boarddir in config/coreboot/*; do
|
|
[ ! -d "${boarddir}" ] && continue
|
|
x_ build_for_mainboard ${boarddir##*/}
|
|
done
|
|
fi
|
|
}
|
|
|
|
build_for_mainboard() {
|
|
board="${1}"
|
|
[ -d "config/coreboot/${board}" ] || \
|
|
err "build_for_mainboard ${board}: boarddir does not exist"
|
|
[ -f "config/coreboot/${board}/target.cfg" ] || \
|
|
err "build_for_mainboard ${board}: target.cfg does not exist"
|
|
tree="undefined"
|
|
. "config/coreboot/${board}/target.cfg" # source
|
|
[ "${tree}" = "undefined" ] && \
|
|
err "build_for_mainboard ${board}: improper tree definition"
|
|
buildutils "${tree}"
|
|
}
|
|
|
|
buildutils() {
|
|
tree="${1}"
|
|
[ -d "coreboot/${tree}/" ] || \
|
|
x_ ./update project trees coreboot ${tree}
|
|
for util in cbfstool ifdtool; do
|
|
[ -f "cbutils/${tree}/${util}" ] && continue
|
|
[ -d "cbutils/${tree}" ] || x_ mkdir -p "cbutils/${tree}"
|
|
|
|
utildir="coreboot/${tree}/util/${util}"
|
|
x_ make distclean -C "${utildir}"
|
|
x_ make -j$(nproc) -C "${utildir}"
|
|
x_ cp "${utildir}/${util}" "cbutils/${tree}"
|
|
x_ make distclean -C "${utildir}"
|
|
done
|
|
}
|
|
|
|
main $@
|