From 59dba6cfcdc6c154e4d46c14c42e7b6f0b84c7b5 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Wed, 16 Aug 2023 21:34:21 +0100 Subject: merge coreboot/u-boot download logic to one script they are fundamentally the same, in an lbmk context. they are downloaded in the same way, and compiled in the same way! (Kconfig infrastructure, board-specific code, the way submodules are used in git, etc) ~200 sloc reduction in resources/scripts the audit begins Signed-off-by: Leah Rowe --- resources/scripts/build/boot/roms_helper | 28 ++++++++++++++-------------- resources/scripts/build/clean/cbutils | 12 ++++++------ resources/scripts/build/module/cbutils | 28 ++++++++++++++-------------- resources/scripts/build/payload/u-boot | 22 +++++++++++----------- resources/scripts/build/release/roms | 12 ++++++------ resources/scripts/build/release/src | 19 ++++++++++++------- 6 files changed, 63 insertions(+), 58 deletions(-) (limited to 'resources/scripts/build') diff --git a/resources/scripts/build/boot/roms_helper b/resources/scripts/build/boot/roms_helper index 32a6e537..287d6dac 100755 --- a/resources/scripts/build/boot/roms_helper +++ b/resources/scripts/build/boot/roms_helper @@ -63,19 +63,19 @@ if [ ! -d "resources/coreboot/${board}" ]; then exit 1 fi -if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then - printf "build/roms: Missing board.cfg for target: %s\n" ${board} +if [ ! -f "resources/coreboot/${board}/target.cfg" ]; then + printf "build/roms: Missing target.cfg for target: %s\n" ${board} exit 1 fi grub_scan_disk="undefined" -cbtree="undefined" -romtype="normal" # optional parameter in board.cfg. "normal" is default +tree="undefined" +romtype="normal" # optional parameter in target.cfg. "normal" is default arch="undefined" # Disable all payloads by default. -# board.cfg files have to specifically enable [a] payload(s) +# target.cfg files have to specifically enable [a] payload(s) payload_grub="n" payload_grub_withseabios="n" # seabios chainloaded from grub payload_seabios="n" @@ -86,8 +86,8 @@ payload_uboot="n" uboot_config="undefined" # ditto option whether to compile ada in crossgcc: crossgcc_ada="y" # yes by default -# Override the above defaults using board.cfg -. "resources/coreboot/${board}/board.cfg" +# Override the above defaults using target.cfg +. "resources/coreboot/${board}/target.cfg" if [ "${grub_scan_disk}" = "undefined" ]; then printf "build/roms: Target '%s' does not define grub_scan_disk. " \ @@ -106,7 +106,7 @@ if [ "${grub_scan_disk}" != "both" ] && \ # erroring out would be silly. just use the default fi -if [ "${cbtree}" = "undefined" ]; then +if [ "${tree}" = "undefined" ]; then printf "build/roms: Target '%s' does not define a coreboot tree. " \ ${board} printf "Skipping build.\n" @@ -196,17 +196,17 @@ fi romdir="bin/${board}" cbdir="coreboot/${board}" -if [ "${board}" != "${cbtree}" ]; then - cbdir="coreboot/${cbtree}" +if [ "${board}" != "${tree}" ]; then + cbdir="coreboot/${tree}" fi -cbfstool="cbutils/${cbtree}/cbfstool" +cbfstool="cbutils/${tree}/cbfstool" corebootrom="${cbdir}/build/coreboot.rom" seavgabiosrom="payload/seabios/seavgabios.bin" -./build module cbutils ${cbtree} || exit 1 +./build module cbutils ${tree} || exit 1 if [ ! -d "${cbdir}" ]; then - ./download coreboot ${cbtree} + ./fetch_trees coreboot ${tree} fi cat version > "${cbdir}/.coreboot-version" @@ -554,7 +554,7 @@ mkGrubRom() { backgroundfile="background1280x800.png" if [ "${board}" = "x60" ] || [ "${board}" = "t60_intelgpu" ]; then - # TODO: don't hardcode this. do it in board.cfg per board + # TODO: don't hardcode this. do it in target.cfg per board backgroundfile="background1024x768.png" fi backgroundfile="resources/grub/background/${backgroundfile}" diff --git a/resources/scripts/build/clean/cbutils b/resources/scripts/build/clean/cbutils index 54659564..de9a588f 100755 --- a/resources/scripts/build/clean/cbutils +++ b/resources/scripts/build/clean/cbutils @@ -32,21 +32,21 @@ rm -Rf cbutils [ ! -d "coreboot/" ] && exit 0 -for cbtree in coreboot/*; do - if [ "${cbtree##*/}" = "coreboot" ]; then +for tree in coreboot/*; do + if [ "${tree##*/}" = "coreboot" ]; then continue fi - if [ ! -d "${cbtree}" ]; then + if [ ! -d "${tree}" ]; then continue fi # Clean coreboot, of course - make -C "${cbtree}/" distclean + make -C "${tree}/" distclean # Clean its utilities as well for util in cbfstool ifdtool nvramtool cbmem; do - make distclean -C "${cbtree}/util/${util}/" + make distclean -C "${tree}/util/${util}/" done - make distclean -C "${cbtree}/payloads/libpayload/" + make distclean -C "${tree}/payloads/libpayload/" done printf "\n\n" diff --git a/resources/scripts/build/module/cbutils b/resources/scripts/build/module/cbutils index 8d4e2f2f..45739e95 100755 --- a/resources/scripts/build/module/cbutils +++ b/resources/scripts/build/module/cbutils @@ -41,34 +41,34 @@ build_for_mainboard() { board="${1}" [ ! -d "resources/coreboot/${board}" ] && \ continue - [ ! -f "resources/coreboot/${board}/board.cfg" ] && \ + [ ! -f "resources/coreboot/${board}/target.cfg" ] && \ continue - cbtree="undefined" - . "resources/coreboot/${board}/board.cfg" # source - if [ "${cbtree}" = "undefined" ]; then - printf "build/cbutils: improper cbtree definition for '%s'" \ + tree="undefined" + . "resources/coreboot/${board}/target.cfg" # source + if [ "${tree}" = "undefined" ]; then + printf "build/cbutils: improper tree definition for '%s'" \ "${board}" return 1 fi - buildutils "${cbtree}" || return 1 + buildutils "${tree}" || return 1 } buildutils() { - cbtree="${1}" - if [ ! -d "coreboot/${cbtree}/" ]; then - ./download coreboot $cbtree || return 1 + tree="${1}" + if [ ! -d "coreboot/${tree}/" ]; then + ./fetch_trees coreboot $tree || return 1 fi for util in cbfstool ifdtool; do - [ -f "cbutils/${cbtree}/${util}" ] \ + [ -f "cbutils/${tree}/${util}" ] \ && continue - if [ ! -d "cbutils/${cbtree}" ]; then - mkdir -p "cbutils/${cbtree}" || return 1 + if [ ! -d "cbutils/${tree}" ]; then + mkdir -p "cbutils/${tree}" || return 1 fi - utildir="coreboot/${cbtree}/util/${util}" + utildir="coreboot/${tree}/util/${util}" make distclean -C "${utildir}" || return 1 make -j$(nproc) -C "${utildir}" || return 1 - mv "${utildir}/${util}" "cbutils/${cbtree}" || return 1 + mv "${utildir}/${util}" "cbutils/${tree}" || return 1 make distclean -C "${utildir}" || return 1 done } diff --git a/resources/scripts/build/payload/u-boot b/resources/scripts/build/payload/u-boot index bff41400..a98d133d 100755 --- a/resources/scripts/build/payload/u-boot +++ b/resources/scripts/build/payload/u-boot @@ -26,7 +26,7 @@ RET=0 pdir="payload/u-boot" ubdir="" arch="" -ubtree="" +tree="" config_name="" board_dir="" @@ -86,21 +86,21 @@ handle_dependencies() rm -rf "${pdir}/${board}" mkdir -p "${pdir}/${board}" - ubtree="undefined" + tree="undefined" arch="undefined" - if [ ! -f "${board_dir}/board.cfg" ]; then - printf "build/u-boot %s: Missing board.cfg.\n" \ + if [ ! -f "${board_dir}/target.cfg" ]; then + printf "build/u-boot %s: Missing target.cfg.\n" \ "${board}" RET=1 return 1 fi - # Override the above defaults using board.cfg - . "${board_dir}/board.cfg" # source + # Override the above defaults using target.cfg + . "${board_dir}/target.cfg" # source - if [ "${ubtree}" = "undefined" ]; then - printf "build/u-boot %s: ubtree undefined\n" \ + if [ "${tree}" = "undefined" ]; then + printf "build/u-boot %s: tree undefined\n" \ "${board}" RET=1 return 1 @@ -113,12 +113,12 @@ handle_dependencies() fi ubdir="u-boot/${board}" - if [ "${board}" != "${ubtree}" ]; then - ubdir="u-boot/${ubtree}" + if [ "${board}" != "${tree}" ]; then + ubdir="u-boot/${tree}" fi if [ ! -d "${ubdir}" ]; then - ./download u-boot "$board" + ./fetch_trees u-boot "$board" fi if [ ! -d "${ubdir}" ]; then diff --git a/resources/scripts/build/release/roms b/resources/scripts/build/release/roms index c60070ec..faf07af0 100755 --- a/resources/scripts/build/release/roms +++ b/resources/scripts/build/release/roms @@ -24,14 +24,14 @@ set -u -e projectname="$(cat projectname)" version="version-unknown" versiondate="version-date-unknown" -cbtree="default" +tree="default" target="" CONFIG_HAVE_MRC="" CONFIG_HAVE_ME_BIN="" CONFIG_KBC1126_FIRMWARE="" CONFIG_INCLUDE_SMSC_SCH5545_EC_FW="" -ifdtool="cbutils/${cbtree}/ifdtool" -cbfstool="cbutils/${cbtree}/cbfstool" +ifdtool="cbutils/${tree}/ifdtool" +cbfstool="cbutils/${tree}/cbfstool" main() { @@ -118,10 +118,10 @@ strip_archive() { romdir=${1} - if [ ! -d coreboot/${cbtree} ]; then - ./download coreboot ${cbtree} || exit 1 + if [ ! -d coreboot/${tree} ]; then + ./fetch_trees coreboot ${tree} || exit 1 fi - ./build module cbutils ${cbtree} || exit 1 + ./build module cbutils ${tree} || exit 1 rm -Rf "${romdir}_tmp" # dirty hack, to reduce disk io later # rather than using /tmp, which might not be tmpfs diff --git a/resources/scripts/build/release/src b/resources/scripts/build/release/src index 0e3237ab..95c0036f 100755 --- a/resources/scripts/build/release/src +++ b/resources/scripts/build/release/src @@ -23,13 +23,15 @@ set -u -e projectname="$(cat projectname)" -modlist="coreboot flashrom grub memtest86plus seabios me_cleaner u-boot" -modlist="${modlist} bios_extract biosutilities uefitool" +trees_gitclone_list="coreboot u-boot" +simple_gitclone_list="flashrom grub memtest86plus seabios me_cleaner uefitool" +simple_gitclone_list="${simple_gitclone_list} bios_extract biosutilities" dirlist="resources util" # do not add blobs directory here. it's handled below filelist="lbmk blobutil modify download build README.md COPYING Makefile update" filelist="${filelist} version versiondate projectname .gitcheck gitclone" +filelist="${filelist} fetch_trees" version="version-unknown" versiondate="version-date-unknown" @@ -75,16 +77,19 @@ create_release_directory() download_modules() { - for modname in ${modlist}; do - if [ ! -d "${modname}/" ]; then - ./download ${modname} - fi + for modname in ${trees_gitclone_list}; do + [ ! -d "${modname}" ] && \ + ./fetch_trees ${modname} + done + for modname in ${simple_gitclone_list}; do + [ ! -d "${modname}/" ] && \ + ./download ${modname} done } copy_files() { - for dir in ${modlist} ${dirlist}; do + for dir in ${simple_gitclone_list} ${dirlist}; do cp -R "${dir}/" "${srcdir}/" done -- cgit v1.2.1