trees: remove project-specific hacks

move the coreboot-specific includes into mkhelper.cfg
for that project.

on some projects, we need variables from mkhelper.cfg
to be global, so I was including serprog and coreboot
mkhelper.cfg files in this script.

instead, set a new variable "mkhelpercfg" pointing to
the config file. if it doesn't exist, create and then
point to a temporary (empty) mkhelper.cfg file.

the rom.sh include has been moved to coreboot mkhelper.cfg

The only remaining project-specific logic, in this trees
script, is now the coreboot crossgcc handling, but this
needs to be there as it's also used to build U-Boot.

The way this now works, certain includes are done twice.
For example, include/rom.sh will be included once globally,
outside of main(), and then again in configure_project().

This means that certain functions will be defined twice.
I'm uncertain if shell has anything equivalent to an ifdef
guard as in C, but we actually want this here anyway, and
it shouldn't cause any problems. It's a bit of a hack, but
otherwise results in much cleaner code.

Signed-off-by: Leah Rowe <leah@libreboot.org>
audit6
Leah Rowe 2024-07-10 13:06:32 +01:00
parent e9f66ec4a8
commit 459db1cc2e
6 changed files with 24 additions and 11 deletions

View File

@ -1,3 +1,5 @@
. "include/rom.sh"
makeargs="UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
build_depend="seabios/default grub/default memtest86plus"

View File

@ -1,3 +1,5 @@
. "include/rom.sh"
bootstrapargs="--gnulib-srcdir=gnulib/ --no-git"
autoconfargs="--with-platform=coreboot --disable-werror"
makeargs="FS_PAYLOAD_MODULES=\"\""

View File

@ -1,3 +1,5 @@
. "include/rom.sh"
sersrc="src/pico-serprog"
serx="$sersrc/build/pico_serprog.uf2"
picosdk="src/pico-sdk"

View File

View File

@ -1,3 +1,5 @@
. "include/rom.sh"
sersrc="src/stm32-vserprog"
serx="$sersrc/stm32-vserprog.hex"
serdir="$sersrc/boards"

View File

@ -8,15 +8,11 @@ set -u -e
. "include/lib.sh"
. "include/git.sh"
. "include/rom.sh"
. "config/data/pico-serprog/mkhelper.cfg"
. "config/data/coreboot/mkhelper.cfg"
eval `setvars "" xarch cdir defconfig cmakedir xlang mode makeargs elfdir cmd \
project target target_dir targets xtree _f release bootstrapargs mkhelper \
autoconfargs listfile autogenargs btype tree rev tree_depend build_depend \
premake postmake`
premake postmake mkhelpercfg`
main()
{
@ -54,10 +50,16 @@ main()
listfile="$datadir/build.list" # needed on multi, optional on single
[ -f "$listfile" ] || listfile="" # optional on all projects
remkdir "${tmpgit%/*}"
mkhelpercfg="$datadir/mkhelper.cfg"
cmd="build_targets" && singletree "$project" && cmd="build_project"
$cmd $@
targets="$@"
remkdir "${tmpgit%/*}"
}
handle_project()
{
cmd="build_targets $targets" && singletree "$project" && \
cmd="build_project"; $cmd
[ -f "$listfile" ] || return 0
[ -z "$mode" ] && [ "$_f" = "-b" ] && \
@ -84,9 +86,8 @@ build_targets()
{
[ -d "$cfgsdir" ] || $err "directory, $cfgsdir, does not exist"
# Build for all targets if no argument is given
targets="$(ls -1 "$cfgsdir")" || $err "Can't get options for $cfgsdir"
[ $# -gt 0 ] && targets=$@
[ $# -gt 0 ] || \
targets="$(ls -1 "$cfgsdir")" || $err "$cfgsdir: Canot get options"
handle_targets
}
@ -288,3 +289,7 @@ copy_elf()
}
main $@
e "$mkhelpercfg" f missing && mkhelpercfg="$TMPDIR/mkhelper.cfg" && x_ \
touch "$mkhelpercfg"
. "$mkhelpercfg"
handle_project