diff options
author | Leah Rowe <leah@libreboot.org> | 2024-06-22 02:35:25 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2024-06-22 13:44:27 +0100 |
commit | fc7ae3e5903c176584cfefd6d3cf4c1549c4eaaa (patch) | |
tree | d13789beaaa3c1215607dda17fada1b322b5db49 /script | |
parent | ad1602569ebf1404c47fb8ea4b39d0f8e844b840 (diff) |
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>
Diffstat (limited to 'script')
-rwxr-xr-x | script/roms | 3 | ||||
-rwxr-xr-x | script/trees | 17 |
2 files changed, 7 insertions, 13 deletions
diff --git a/script/roms b/script/roms index 457a1baa..5cd8b66b 100755 --- a/script/roms +++ b/script/roms @@ -91,10 +91,9 @@ configure_target() board="$1" targetdir="$cfgsdir/$board" - [ -f "$targetdir/target.cfg" ] || $err "$board: target.cfg missing" # Override the above defaults using target.cfg - . "$targetdir/target.cfg" + eval `setcfg "$targetdir/target.cfg"` [ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata" diff --git a/script/trees b/script/trees index b2b1e561..6a3c1ebd 100755 --- a/script/trees +++ b/script/trees @@ -35,7 +35,7 @@ main() [ -z "$_f" ] && $err "missing flag (-m/-u/-b/-c/-x/-f/-s/-l/-n)" [ -z "$project" ] && $err "project name not specified" - [ -f "config/git/$project" ] || $err "project '$project' not defined" + [ -f "config/git/$project/pkg.cfg" ] || $err "'$project' not defined" elfdir="elf/$project" datadir="config/data/$project" @@ -154,9 +154,7 @@ load_project_config() { eval "$(setvars "" xarch xlang tree bootstrapargs autoconfargs xtree \ tree_depend makeargs)" - - [ -f "$1/target.cfg" ] || return 0 - . "$1/target.cfg" || $err "loadp $1: can't load target.cfg"; return 0 + eval `setcfg "$1/target.cfg" 0`; return 0 } check_cross_compiler() @@ -274,15 +272,12 @@ check_makefile() mkpayload_grub() { - [ -f "$grubdata/module/$tree" ] || $err "$tree: grub modules missing" - x_ rm -f "$cdir/grub.elf" - eval "$(setvars "" grub_modules grub_install_modules)" - - . "$grubdata/module/$tree" || $err "$tree: !source grub modules" - + eval `setcfg "$grubdata/module/$tree"` chkvars "grub_install_modules" "grub_modules" + x_ rm -f "$cdir/grub.elf" + "${cdir}/grub-mkstandalone" --grub-mkimage="${cdir}/grub-mkimage" \ -O i386-coreboot -o "${cdir}/grub.elf" -d "${cdir}/grub-core/" \ --fonts= --themes= --locales= --modules="$grub_modules" \ @@ -290,7 +285,7 @@ mkpayload_grub() "/boot/grub/grub_default.cfg=${cdir}/.config" \ "/boot/grub/grub.cfg=$grubdata/memdisk.cfg" \ "/background.png=$grubdata/background/background1280x800.png" || \ - $err "$tree: cannot build grub.elf" + $err "$tree: cannot build grub.elf"; return 0 } copy_elf() |