build/cbutils: top-down coding style, main on top
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
parent
9f58d4e481
commit
355a45b435
|
@ -18,13 +18,41 @@
|
|||
# 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
|
||||
set -u -e
|
||||
|
||||
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() {
|
||||
cbtree="${1}"
|
||||
if [ ! -d "coreboot/${cbtree}/" ]; then
|
||||
|
@ -36,45 +64,11 @@ buildutils() {
|
|||
return 1
|
||||
fi
|
||||
for util in cbfstool ifdtool; do
|
||||
(
|
||||
(
|
||||
cd "coreboot/${cbtree}/util/${util}/"
|
||||
make -j$(nproc) || return 1
|
||||
)
|
||||
)
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
buildfromboardconfig() {
|
||||
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
|
||||
main $@
|
||||
|
|
Loading…
Reference in a new issue