summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-07-10 22:14:39 +0100
committerLeah Rowe <leah@libreboot.org>2024-07-10 23:11:23 +0100
commit3263eeb6b67cf2b2290b0c4bd69b298879f1f937 (patch)
tree04f5270d5fdc8703bea3bcf30c368eba09b5a3bd
parent17f3e61a0e4fa84b78ab2951a780d6964095a052 (diff)
trees: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rw-r--r--include/git.sh2
-rw-r--r--include/lib.sh2
-rw-r--r--include/rom.sh14
-rwxr-xr-xscript/trees108
4 files changed, 53 insertions, 73 deletions
diff --git a/include/git.sh b/include/git.sh
index b0acd7dc..58f62ef3 100644
--- a/include/git.sh
+++ b/include/git.sh
@@ -12,7 +12,7 @@ fetch_targets()
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
- git_prep "$loc" "$loc" "$PWD/$cfgsdir/$tree/patches" \
+ git_prep "$loc" "$loc" "$PWD/$configdir/$tree/patches" \
"${loc%/*}/$tree" u; nuke "$project/$tree" "$project/$tree"
}
diff --git a/include/lib.sh b/include/lib.sh
index 52187734..2fb97c44 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -37,7 +37,7 @@ chkvars()
}
eval `setvars "" _nogit board xbmk_parent versiondate projectsite projectname \
- aur_notice cfgsdir datadir version relname`
+ aur_notice configdir datadir version relname`
for fv in projectname projectsite version versiondate; do
eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :"
diff --git a/include/rom.sh b/include/rom.sh
index 18770847..574b1b6c 100644
--- a/include/rom.sh
+++ b/include/rom.sh
@@ -29,13 +29,13 @@ mkpayload_grub()
eval `setvars "" grub_modules grub_install_modules`
$dry eval `setcfg "$grubdata/module/$tree"`
- $dry x_ rm -f "$cdir/grub.elf"
+ $dry x_ rm -f "$srcdir/grub.elf"
- $dry "${cdir}/grub-mkstandalone" --grub-mkimage="${cdir}/grub-mkimage" \
- -O i386-coreboot -o "${cdir}/grub.elf" -d "${cdir}/grub-core/" \
+ $dry "$srcdir/grub-mkstandalone" --grub-mkimage="$srcdir/grub-mkimage" \
+ -O i386-coreboot -o "$srcdir/grub.elf" -d "${srcdir}/grub-core/" \
--fonts= --themes= --locales= --modules="$grub_modules" \
--install-modules="$grub_install_modules" \
- "/boot/grub/grub_default.cfg=${cdir}/.config" \
+ "/boot/grub/grub_default.cfg=${srcdir}/.config" \
"/boot/grub/grub.cfg=$grubdata/memdisk.cfg" \
"/background.png=$grubdata/background/background1280x800.png" || \
$err "$tree: cannot build grub.elf"; return 0
@@ -44,8 +44,8 @@ mkpayload_grub()
mkvendorfiles()
{
check_coreboot_utils "$tree"
- printf "%s\n" "${version%%-*}" > "$cdir/.coreboot-version" || \
- $err "!mk $cdir .coreboot-version"
+ printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \
+ $err "!mk $srcdir .coreboot-version"
[ -z "$mode" ] && [ "$target" != "$tree" ] && \
x_ ./vendor download $target; return 0
}
@@ -71,7 +71,7 @@ mkcorebootbin()
{
[ "$target" = "$tree" ] && return 0
- tmprom="$cdir/build/coreboot.rom"
+ tmprom="$srcdir/build/coreboot.rom"
initmode="${defconfig##*/}"; displaymode="${initmode##*_}"
initmode="${initmode%%_*}"
[ -n "$displaymode" ] && displaymode="_$displaymode"
diff --git a/script/trees b/script/trees
index ad241172..c468a1db 100755
--- a/script/trees
+++ b/script/trees
@@ -9,10 +9,10 @@ set -u -e
. "include/lib.sh"
. "include/git.sh"
-eval `setvars "" xarch cdir defconfig cmakedir xlang mode makeargs elfdir cmd \
+eval `setvars "" xarch srcdir premake 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 mkhelpercfg dry`
+ defconfig postmake mkhelpercfg dry dest_dir`
main()
{
@@ -44,36 +44,27 @@ main()
[ -f "config/git/$project/pkg.cfg" ] || $err "'$project' not defined"
- elfdir="elf/$project"
- datadir="config/data/$project"
- cfgsdir="config/$project"
- listfile="$datadir/build.list" # needed on multi, optional on single
+ for d in "elf" "config/data" "config" "src"; do
+ eval "${d#*/}dir=\"$d/$project\""
+ done; dest_dir="$elfdir"
+ listfile="$datadir/build.list"
[ -f "$listfile" ] || listfile="" # optional on all projects
mkhelpercfg="$datadir/mkhelper.cfg"
+ e "$mkhelpercfg" f missing && mkhelpercfg="$TMPDIR/mkhelper.cfg" && \
+ x_ touch "$mkhelpercfg"
targets="$@"
- remkdir "${tmpgit%/*}"
-}
-
-handle_project()
-{
cmd="build_targets $targets" && singletree "$project" && \
- cmd="build_project"; $cmd
+ cmd="build_project"
- [ -f "$listfile" ] || return 0
- [ -z "$mode" ] && $dry printf "\n\nOK! Check %s/\n\n" "$elfdir"; :
+ remkdir "${tmpgit%/*}"
}
build_project()
{
- configure_project "$cfgsdir" || return 0
-
- dest_dir="$elfdir"
- [ ! -f "$listfile" ] || elfcheck || return 0
-
- cdir="src/${project}"
- x_ ./update trees -f "$project"
+ configure_project "$configdir" || return 0
+ [ ! -f "$listfile" ] || $dry elfcheck || return 0
[ "$mode" = "distclean" ] && mode="clean"
run_make_command || return 0
@@ -83,10 +74,8 @@ build_project()
build_targets()
{
- [ -d "$cfgsdir" ] || $err "directory, $cfgsdir, does not exist"
-
- [ $# -gt 0 ] || \
- targets="$(ls -1 "$cfgsdir")" || $err "$cfgsdir: Canot get options"
+ [ -d "$configdir" ] || $err "directory, $configdir, does not exist"
+ [ $# -gt 0 ] || targets="$(ls -1 "$configdir")" || $err "!o $configdir"
for x in $targets; do
[ "$x" = "list" ] && x_ ls -1 "config/$project" && \
@@ -101,35 +90,28 @@ build_targets()
handle_defconfig()
{
- handle_src_tree "$target" || return 0
-
- for y in "$target_dir/config"/*; do
- [ "$_f" = "-d" ] || [ -f "$y" ] || continue
- [ "$_f" = "-d" ] || defconfig="$y"
-
- [ -n "$mode" ] || check_defconfig || continue
- handle_makefile
- [ -n "$mode" ] || $dry copy_elf
- done; return 0
-}
-
-handle_src_tree()
-{
- target_dir="$cfgsdir/$target"
+ target_dir="$configdir/$target"
[ -f "CHANGELOG" ] || fetch_project "$project"
- configure_project "$target_dir" || return 1
+ configure_project "$target_dir" || return 0
x_ mkdir -p "$elfdir/$target"
chkvars tree
- cdir="src/$project/$tree"
+ srcdir="src/$project/$tree"
if [ "$mode" = "distclean" ] || [ "$mode" = "crossgcc-clean" ]; then
- [ -d "$cdir" ] || return 1
+ [ -d "$srcdir" ] || return 0
fi
- x_ ./update trees -f "$project" "$target"
+ [ -z "$mode" ] && $dry check_cross_compiler
+
+ for y in "$target_dir/config"/*; do
+ [ "$_f" = "-d" ] || [ -f "$y" ] || continue
+ [ "$_f" = "-d" ] || defconfig="$y"
- [ -z "$mode" ] && $dry check_cross_compiler; return 0
+ [ -n "$mode" ] || check_defconfig || continue
+ handle_makefile
+ [ -n "$mode" ] || $dry copy_elf
+ done; return 0
}
configure_project()
@@ -167,6 +149,7 @@ configure_project()
done
fi
+ [ "$mode" = "fetch" ] || x_ ./update trees -f "$project" $target
[ "$mode" = "fetch" ] || return 0
[ -f "CHANGELOG" ] && return 1; fetch_${cmd#build_}; return 1
}
@@ -194,10 +177,9 @@ check_cross_compiler()
check_defconfig()
{
[ -f "$defconfig" ] || $dry $err "$project/$target: missing defconfig"
-
dest_dir="$elfdir/$target/${defconfig#"$target_dir/config/"}"
- $dry elfcheck || return 1 # skip build if a previous one exists
+ $dry elfcheck || return 1 # skip build if a previous one exists
$dry x_ mkdir -p "$dest_dir"
}
@@ -211,32 +193,32 @@ elfcheck()
handle_makefile()
{
- $dry check_makefile "$cdir" && x_ make clean -C "$cdir"
- [ -f "$defconfig" ] && x_ cp "$defconfig" "$cdir/.config"
+ $dry check_makefile "$srcdir" && x_ make clean -C "$srcdir"
+ [ -f "$defconfig" ] && x_ cp "$defconfig" "$srcdir/.config"
[ -n "$mode" ] || [ -n "$btype" ] || $dry make -C \
- "$cdir" silentoldconfig || make -C "$cdir" oldconfig || :
+ "$srcdir" silentoldconfig || make -C "$srcdir" oldconfig || :
- run_make_command || $err "handle_makefile $cdir: no makefile!"
+ run_make_command || $err "handle_makefile $srcdir: no makefile!"
_copy=".config" && [ "$mode" = "savedefconfig" ] && _copy="defconfig"
- [ "${mode%config}" = "$mode" ] || $dry x_ cp "$cdir/$_copy" "$defconfig"
+ [ "${mode%config}" = "$mode" ] || \
+ $dry x_ cp "$srcdir/$_copy" "$defconfig"
- [ -e "$cdir/.git" ] && [ "$project" = "u-boot" ] && \
- [ "$mode" = "distclean" ] && $dry x_ git -C "$cdir" clean -fdx; :
+ [ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
+ [ "$mode" = "distclean" ] && $dry x_ git -C "$srcdir" clean -fdx; :
}
run_make_command()
{
[ -z "$premake" ] || [ -n "$mode" ] || $premake || $err "!$premake"
- $dry check_cmake "$cdir" && [ -z "$mode" ] && $dry check_autoconf \
- "$cdir"; $dry check_makefile "$cdir" || return 1
+ $dry check_cmake "$srcdir" && [ -z "$mode" ] && $dry check_autoconf \
+ "$srcdir"; $dry check_makefile "$srcdir" || return 1
- $dry make -C "$cdir" $mode -j$XBMK_THREADS $makeargs \
- || $err "$cdir mk$mode"
+ $dry make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs || $err "!$mode"
[ -z "$mkhelper" ] || [ -n "$mode" ] || $mkhelper || $err "!$mkhelper"
- [ "$mode" = "clean" ] && $dry make -C "$cdir" distclean || :; return 0
+ [ "$mode" = "clean" ] && $dry make -C "$srcdir" distclean || :; :
}
check_cmake()
@@ -267,12 +249,10 @@ check_makefile()
copy_elf()
{
[ -f "$listfile" ] && x_ mkdir -p "$dest_dir" && while read -r f; do
- [ -f "$cdir/$f" ] && x_ cp "$cdir/$f" "$dest_dir"
- done < "$listfile"; x_ make clean -C "$cdir"
+ [ -f "$srcdir/$f" ] && x_ cp "$srcdir/$f" "$dest_dir"
+ done < "$listfile"; x_ make clean -C "$srcdir"
}
main $@
-e "$mkhelpercfg" f missing && mkhelpercfg="$TMPDIR/mkhelper.cfg" && x_ \
- touch "$mkhelpercfg"
. "$mkhelpercfg"
-handle_project
+$cmd