mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-14 23:39:33 +02:00
build/cbutils: top-down coding style, main on top
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -18,13 +18,41 @@
|
|||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
# This script assumes that the current working directory is the root
|
|
||||||
|
|
||||||
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
[ "x${DEBUG+set}" = 'xset' ] && set -v
|
||||||
set -u -e
|
set -u -e
|
||||||
|
|
||||||
printf "Building coreboot utils\n"
|
printf "Building coreboot utils\n"
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
if [ $# -gt 0 ]; then
|
||||||
|
for board in "${@}"; do
|
||||||
|
buildfromboardconfig ${board} || exit 1
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for boarddir in resources/coreboot/*; do
|
||||||
|
[ ! -d "${boarddir}" ] && continue
|
||||||
|
buildfromboardconfig ${boarddir##*/} || exit 1
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
buildfromboardconfig() {
|
||||||
|
board="${1}"
|
||||||
|
[ ! -d "resources/coreboot/${board}" ] && \
|
||||||
|
continue
|
||||||
|
[ ! -f "resources/coreboot/${board}/board.cfg" ] && \
|
||||||
|
continue
|
||||||
|
cbtree="undefined"
|
||||||
|
. "resources/coreboot/${board}/board.cfg" # source
|
||||||
|
if [ "${cbtree}" = "undefined" ]; then
|
||||||
|
printf "build/cbutils: improper cbtree definition for '%s'" \
|
||||||
|
"${board}"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
buildutils "${cbtree}" || return 1
|
||||||
|
}
|
||||||
|
|
||||||
buildutils() {
|
buildutils() {
|
||||||
cbtree="${1}"
|
cbtree="${1}"
|
||||||
if [ ! -d "coreboot/${cbtree}/" ]; then
|
if [ ! -d "coreboot/${cbtree}/" ]; then
|
||||||
@@ -36,45 +64,11 @@ buildutils() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
for util in cbfstool ifdtool; do
|
for util in cbfstool ifdtool; do
|
||||||
(
|
(
|
||||||
cd "coreboot/${cbtree}/util/${util}/"
|
cd "coreboot/${cbtree}/util/${util}/"
|
||||||
make -j$(nproc) || return 1
|
make -j$(nproc) || return 1
|
||||||
)
|
)
|
||||||
done
|
done
|
||||||
return 0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
buildfromboardconfig() {
|
main $@
|
||||||
board="${1}"
|
|
||||||
if [ ! -d "resources/coreboot/${board}" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
cbtree="undefined"
|
|
||||||
. "resources/coreboot/${board}/board.cfg" # source
|
|
||||||
if [ "${cbtree}" = "undefined" ]; then
|
|
||||||
printf "build/cbutils: improper cbtree definition for '%s'" \
|
|
||||||
"${board}"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
buildutils "${cbtree}" || return 1
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
|
||||||
for board in "${@}"; do
|
|
||||||
buildfromboardconfig ${board} || exit 1
|
|
||||||
done
|
|
||||||
else
|
|
||||||
for boarddir in resources/coreboot/*; do
|
|
||||||
if [ ! -d "${boarddir}" ]; then
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
buildfromboardconfig ${boarddir##*/} || exit 1
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n\n"
|
|
||||||
exit 0
|
|
||||||
|
|||||||
Reference in New Issue
Block a user