diff options
author | Leah Rowe <leah@libreboot.org> | 2023-05-14 21:33:19 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-05-14 21:33:19 +0100 |
commit | 1388cccbc730bb6240ccd3f2b8e9c30996f6b864 (patch) | |
tree | 9b6a6785c5197b8582de0ba23fe1964311ffeb46 /resources | |
parent | ddad8f00c628ce9cb301fe550a2b516e6009a98e (diff) |
build/seabios: cleaner coding style
top-down logic, main() on top
moved some hardcoded strings to variables
Diffstat (limited to 'resources')
-rwxr-xr-x | resources/scripts/build/payload/seabios | 78 |
1 files changed, 50 insertions, 28 deletions
diff --git a/resources/scripts/build/payload/seabios b/resources/scripts/build/payload/seabios index 7cff55c7..c05b1b11 100755 --- a/resources/scripts/build/payload/seabios +++ b/resources/scripts/build/payload/seabios @@ -22,39 +22,61 @@ [ "x${DEBUG+set}" = 'xset' ] && set -v set -u -e -printf "Building SeaBIOS payloads and SeaVGABIOS\n" +payloaddir="payload/seabios" +seabios_elf="seabios/out/bios.bin.elf" +seavgabios="seabios/out/vgabios.bin" -if [ ! -d "payload/seabios" ]; then - mkdir -p payload/seabios/ || exit 1 -fi +main() +{ + printf "Building SeaBIOS payloads and SeaVGABIOS\n" -rm -f payload/seabios/* || exit 1 + check_dependencies + build_seabios_payloads -if [ ! -d "seabios/" ]; then - ./download seabios || exit 1 -fi + # clean it again. gotta keep it clean! + if [ -f seabios/Makefile ]; then + make distclean -BC seabios || exit 1 + fi + + printf "Done! SeaBIOS files are in %s/\n\n" ${payloaddir} +} -for x in normal vgarom libgfxinit; do - if [ ! -f seabios/Makefile ]; then - printf "SeaBIOS not properly downloaded.\n" - exit 1 +check_dependencies() +{ + if [ ! -d "${payloaddir}" ]; then + mkdir -p ${payloaddir}/ || exit 1 fi - make distclean -BC seabios || exit 1 - cp "resources/seabios/config/${x}" seabios/.config - make silentoldconfig -j$(nproc) -BC seabios || exit 1 - make -j$(nproc) -BC seabios || exit 1 - cp seabios/out/bios.bin.elf "payload/seabios/seabios_${x}.elf" \ - || exit 1 - if [ "${x}" = "libgfxinit" ]; then - cp seabios/out/vgabios.bin payload/seabios/seavgabios.bin \ - || exit 1 + + rm -f ${payloaddir}/* || exit 1 + + if [ ! -d "seabios/" ]; then + ./download seabios || exit 1 fi - rm -f seabios/.config || exit 1 -done +} + +build_seabios_payloads() +{ + for x in normal vgarom libgfxinit; do + if [ ! -f seabios/Makefile ]; then + printf "SeaBIOS not properly downloaded.\n" + exit 1 + fi + + make distclean -BC seabios || exit 1 + + cp "resources/seabios/config/${x}" seabios/.config + make silentoldconfig -j$(nproc) -BC seabios || exit 1 + make -j$(nproc) -BC seabios || exit 1 + + seabios_elf_dst="${payloaddir}/seabios_${x}.elf" + cp ${seabios_elf} "${seabios_elf_dst}" || exit 1 -# clean it again. gotta keep it clean! -if [ -f seabios/Makefile ]; then - make distclean -BC seabios || exit 1 -fi + if [ "${x}" = "libgfxinit" ]; then + cp ${seavgabios} ${payloaddir}/seavgabios.bin \ + || exit 1 + fi + rm -f seabios/.config || exit 1 + done +} -printf "Done! SeaBIOS files are in payload/seabios/\n\n" +main $@ |