mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-13 06:49:52 +02:00
lib.sh: more unified config handling
replace it with logic that simply uses "." to load files directly. for this, "vcfg" is added as a variable in coreboot target.cfg files, referring to a directory in config/vendor/ containing a file named pkg.cfg, and this file then contains the same variables as the erstwhile config/vendor/sources config/git files are now directories, also containing pkg.cfg files each with the same variables as before, such as repository link and commit hash this change results in a noticeable reduction in code complexity within the build system. unified reading of config files: new function setcfg() added to lib.sh setcfg checks if a config exists. if a 2nd argument is passed, it is used as a return value for eval, otherwise a string calling err is passed. setcfg output is passed through eval, to set strings based on config; eval must be used, so that the variables are set within the same scope, otherwise they'd be set within setcfg which could lead to some whacky results. there's still a bit more more to do, but this single change results in a substantial reduction in code complexity. Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+13
-17
@@ -14,7 +14,7 @@ vendir="vendorfiles"
|
||||
appdir="$vendir/app"
|
||||
cbcfgsdir="config/coreboot"
|
||||
|
||||
eval "$(setvars "" _b EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe \
|
||||
eval "$(setvars "" EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe \
|
||||
E6400_VGA_DL_hash E6400_VGA_DL_url E6400_VGA_DL_url_bkup E6400_VGA_offset \
|
||||
E6400_VGA_romname CONFIG_HAVE_MRC SCH5545EC_DL_url_bkup SCH5545EC_DL_hash \
|
||||
mecleaner kbc1126_ec_dump MRC_refcode_cbtree new_mac _dl SCH5545EC_DL_url \
|
||||
@@ -24,29 +24,27 @@ eval "$(setvars "" _b EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe \
|
||||
CONFIG_VGA_BIOS_FILE CONFIG_VGA_BIOS_ID CONFIG_KBC1126_FW1 release DL_url \
|
||||
CONFIG_INCLUDE_SMSC_SCH5545_EC_FW CONFIG_SMSC_SCH5545_EC_FW_FILE nukemode \
|
||||
CONFIG_IFD_BIN_PATH CONFIG_MRC_FILE CONFIG_HAVE_REFCODE_BLOB cbfstoolref \
|
||||
CONFIG_REFCODE_BLOB_FILE)"
|
||||
CONFIG_REFCODE_BLOB_FILE vcfg)"
|
||||
|
||||
vendor_download()
|
||||
{
|
||||
export PATH="$PATH:/sbin"
|
||||
|
||||
[ $# -gt 0 ] || $err "No argument given"
|
||||
board="$1"
|
||||
_b="${board%%_*mb}" # shorthand (no duplication per rom size)
|
||||
boarddir="$cbcfgsdir/$board" && getcfg && scan_config "$_b" \
|
||||
"config/vendor" && bootstrap && getfiles; return 0
|
||||
board="$1"; boarddir="$cbcfgsdir/$board"
|
||||
getcfg && bootstrap && getfiles; return 0
|
||||
}
|
||||
|
||||
getcfg()
|
||||
{
|
||||
[ -d "$boarddir" ] || $err "Target '$board' not defined."
|
||||
eval `setcfg "$boarddir/target.cfg"`
|
||||
|
||||
[ -z "$vcfg" ] && printf "%s: vcfg unset\n" "$board" 1>&2 && return 1
|
||||
|
||||
check_defconfig "$boarddir" 1>"$tmpdir/vendorcfg.list" && return 1
|
||||
while read -r cbcfgfile; do
|
||||
set +u +e
|
||||
. "$cbcfgfile" 2>/dev/null
|
||||
set -u -e
|
||||
set +u +e; . "$cbcfgfile" 2>/dev/null; set -u -e
|
||||
done < "$tmpdir/vendorcfg.list"
|
||||
. "$boarddir/target.cfg" 2>/dev/null
|
||||
|
||||
[ -z "$tree" ] && $err "getcfg $boarddir: tree undefined"
|
||||
cbdir="src/coreboot/$tree"
|
||||
@@ -58,9 +56,10 @@ getcfg()
|
||||
for c in CONFIG_HAVE_MRC CONFIG_HAVE_ME_BIN CONFIG_KBC1126_FIRMWARE \
|
||||
CONFIG_VGA_BIOS_FILE CONFIG_INCLUDE_SMSC_SCH5545_EC_FW; do
|
||||
eval "[ \"\${$c}\" = \"/dev/null\" ] && continue"
|
||||
eval "[ -z \"\${$c}\" ] || return 0"
|
||||
eval "[ -z \"\${$c}\" ] && continue"
|
||||
eval `setcfg "config/vendor/$vcfg/pkg.cfg"`; return 0
|
||||
done
|
||||
printf "Vendor files not needed for: %s\n" "$board" 1>&2 && return 1
|
||||
printf "Vendor files not needed for: %s\n" "$board" 1>&2; return 1
|
||||
}
|
||||
|
||||
bootstrap()
|
||||
@@ -274,10 +273,7 @@ check_board()
|
||||
fi
|
||||
|
||||
boarddir="$cbcfgsdir/$board"
|
||||
[ -d "$boarddir" ] || $err "check_board: board $board missing"
|
||||
[ -f "$boarddir/target.cfg" ] || \
|
||||
$err "check_board $board: target.cfg missing"
|
||||
. "$boarddir/target.cfg" 2>/dev/null
|
||||
eval `setcfg "$boarddir/target.cfg"`
|
||||
[ -z "$tree" ] && $err "check_board $board: tree undefined"; return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user