Compare commits

...

18 Commits

Author SHA1 Message Date
Leah Rowe 300f2cb434 mk: remove u-boot-specific git-clean handling
yes, make it generalised. use a new variable in
mkhelper.cfg, gitclean and gitcleanargs

not enabled by default, but u-boot enables it. i'm
considering whether to use this by default, as it
is the general policy of lbmk to clean everything
just after a build, as builds are cached out of
tree. this way, we can do re-builds safely for each
project. there are probably a lot of subtle bugs that
might be fixed if we used this

the problem is that this is currently only used on
lbmk.git, but not on libreboot release archives which
lack .git directories; the main one is initialised in
lbmk, but not in upstream sources. we could just initialise
those.

in fact, that is probably what i'm going to do.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 17:46:34 +01:00
Leah Rowe 2c94101884 mk: remove cleanargs from git-clean
totally worthless

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 17:35:19 +01:00
Leah Rowe 08f93ec812 mk: redirect readlink err to /dev/null
i had this before. forgot to add it in the new
design. oops.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 13:23:10 +01:00
Leah Rowe e99be6e5dc mk: ruthlessly simplify findpath()
i love eval, printf and awk

eval, printf and awk are the best things ever

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:47:01 +01:00
Leah Rowe e075a79867 err even louder
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:27:42 +01:00
Leah Rowe cd52750fec mk: further simplify err()
yes, just awk everything, double-quoted

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:25:35 +01:00
Leah Rowe f115bdfe37 mk: add error check on xbmkpwd init
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:19:08 +01:00
Leah Rowe 76bf71ff65 mk: simplified findpath()
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 12:08:53 +01:00
Leah Rowe c4695497f5 mk: simplified error functions
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:54:52 +01:00
Leah Rowe d9ca4265ef mk: remove xprintf
totally useless function. all it does is print
quotes. just printf the args into awk

this does literally the same thing. the output
will literally be the same.

unclear thinking == unclear code

right thinking == this patch

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:45:28 +01:00
Leah Rowe b32dd39262 move findpath and err functions to mk
otherwise, it's totally broken. i also now include
lib.sh later.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:37:34 +01:00
Leah Rowe c6900c8571 init.sh: remove redundant sha512sum init
it's done in xbmk_init. the initial value
is never used.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:33:15 +01:00
Leah Rowe c0402ef642 mk: simplify xbmkpwd initialisation
do it from mk instead. we don't need to run pwd
anymore, because we just get the path and cd
to it, setting that as the path.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:30:49 +01:00
Leah Rowe 16e04411f2 mk: include lib.sh earlier
this means we can now cd to wrkdir using findpath,
and it means the cd command can be wrapped in x_

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:11:04 +01:00
Leah Rowe b09cd4ada4 mk: call xbmk_init through x_
the function never returns 1 at the moment, but
this is a useful future trap.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:07:56 +01:00
Leah Rowe abee462f2a mk: run xbmk_init here, not from init.sh
it should be clear on first reading, what the actual
control flow is. hiding the call in init.sh obscures
first reading.

now it is absolutely clear on first reading, that
xbmk_init is called before going through everything
else in mk.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 11:07:24 +01:00
Leah Rowe cb49e77947 delete straggler
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 10:09:22 +01:00
Leah Rowe 93b49afa3f mk: remove gcc/gnat matching logic (obsolete)
coreboot has this now:

commit c421847fe2fef61586eb313206a4be0f2e491974
Author: Matt DeVillier <matt.devillier@gmail.com>
Date:   Mon Dec 29 10:12:17 2025 -0600

    util/crossgcc: Fix GNAT detection for gnat-15

this one is advisory instead, telling the user to
create such a symlink as we did. this is much less
invasive.

our own check was bad, because it basically silences
what is otherwise an error. coreboot's approach is
more correct, so we will defer to that instead.

note that this means older coreboot (for fam15h) is
no longer covered, but those trees don't use gnat
anyway as libgfxinit is unused on those targets

this lbmk patch removes 61 sloc of dead code, which
makes me very happy.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 10:05:16 +01:00
4 changed files with 40 additions and 170 deletions
+4
View File
@@ -0,0 +1,4 @@
# SPDX-License-Identifier: GPL-3.0-or-later
gitclean="y"
gitcleanargs="-fdx"
+3 -8
View File
@@ -8,15 +8,12 @@
projectname="libreboot"
projectsite="https://libreboot.org/"
sha512sum="util/sbase/sha512sum"
eval "`newvar aur_notice basetmp board checkvarschk checkvarsxbmk configdir \
datadir is_child python pyver reinstall relname version versiondate \
xbmklock xbmkpath xbmkpwd xbmkpwd xbtmp`"
xbmklock xbmkpath xbtmp sha512sum`"
xbmk_init()
{
xbmkpwd="`pwd || err "Cannot generate PWD"`" || err "!" xbmk_init "$@"
xbmklock="$xbmkpwd/lock"
basetmp="$xbmkpwd/xbmkwd"
sha512sum="$xbmkpwd/util/sbase/sha512sum"
@@ -171,7 +168,7 @@ xbmk_parent_set_env()
xbmk_parent_set_export
xbmk_set_version
remkdir "$xbtmp" "$xbtmp/gnupath" "$xbtmp/xbmkpath"
remkdir "$xbtmp" "$xbtmp/xbmkpath"
xbmk_set_pyver
xbmk_set_mirror
@@ -216,7 +213,7 @@ xbmk_parent_set_export()
err "cachedir '$XBMK_CACHE' is a file" \
"xbmk_parent_set_export" "$@"
export PATH="$xbtmp/xbmkpath:$xbtmp/gnupath:$PATH"
export PATH="$xbtmp/xbmkpath:$PATH"
xbmkpath="$PATH"
# if "y": a coreboot target won't be built if target.cfg says release=n
@@ -391,5 +388,3 @@ xchild()
exit $xbmk_rval
}
xbmk_init "$@"
-59
View File
@@ -92,25 +92,6 @@ singletree()
-name "target.cfg" ) || return 1; :
}
findpath()
{
[ $# -lt 1 ] && \
err "findpath: No arguments provided" "findpath" "$@"
while [ $# -gt 0 ]
do
found="`readlink -f "$1" 2>/dev/null`" || return 1; :
if [ -z "$found" ]; then
found="`realpath "$1" 2>/dev/null`" || \
return 1
fi
printf "%s\n" "$found"
shift 1
done
}
pad_one_byte()
{
paddedfile="`mktemp || err "mktemp pad_one_byte"`" || \
@@ -181,16 +162,6 @@ dx_()
done < "$2" || err "cannot read '$2'" "dx_" "$@"; :
}
x_()
{
[ $# -lt 1 ] && \
return 0
[ -z "$1" ] && \
err "Empty first arg" "x_" "$@"
"$@" || err "Unhandled error" "x_" "$@"
}
xchk()
{
if [ $# -lt 3 ]; then
@@ -199,33 +170,3 @@ xchk()
err "arguments must not be empty" "xchk" "$@"
fi
}
err()
{
if [ $# -eq 1 ]; then
printf "ERROR %s: %s\n" "$0" "$1" 1>&2 || :
elif [ $# -gt 1 ]; then
printf "ERROR %s: %s: in command with args: " "$0" "$1" 1>&2
shift 1
xprintf "$@" 1>&2
else
printf "ERROR, but no arguments provided to err\n" 1>&2
fi
exit 1
}
xprintf()
{
xprintfargs=0
while [ $# -gt 0 ]; do
printf "\"%s\"" "$1"
[ $# -gt 1 ] && \
printf " "
xprintfargs=1
shift 1
done
[ $xprintfargs -gt 0 ] && \
printf "\n"; :
}
+33 -103
View File
@@ -14,19 +14,38 @@ eval "`printf "LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE \
LC_MEASUREMENT LC_IDENTIFICATION LC_ALL\n" | \
awk '{ for (i=1; i<=NF; i++) $i = "export " $i "=C.UTF-8;"; print }'`"
findpath()
{
eval "$(printf '%s\n' "$@" | awk '{printf "readlink -f \"%s\" \
2>/dev/null || realpath \"%s\" 2>/dev/null || return 1;",$0,$0}')"
}
x_()
{
[ $# -lt 1 ] || "$@" || err "UNHANDLED ERROR" "x_" "$@"; :
}
err()
{
printf '%s\n' "$@" | awk '{printf "\"%s\" ", $0}'
printf "ERROR!\n"
exit 1
}
(
xbarg0="$0"
[ "${xbarg0##*/}" = "$xbarg0" ] && \
xbarg0="`command -v "$xbarg0"`"
commandv="`readlink -f "$xbarg0" 2>/dev/null`"
[ -z "$commandv" ] && \
commandv="`realpath "$xbarg0" 2>/dev/null`"
xbmkpwd="$(x_ dirname "$(x_ findpath "$xbarg0")")" || exit 1
cd "${commandv%/*}" || exit 1
x_ cd "$xbmkpwd"
. "include/lib.sh"
. "include/env/init.sh"
x_ xbmk_init "$@"
. "include/env/get.sh"
. "include/fw/vendor.sh"
@@ -53,9 +72,9 @@ if_not_dry_build=""
eval "`newvar autoconfargs autogenargs badhash badtghash bootstrapargs \
build_depend buildtype cleanargs cmakedir cmd defconfig dest_dir elfdir \
forcepull gccdir gccfull gccver gnatdir gnatfull gnatver listfile \
makeargs mdir mkhelper mkhelpercfg mode postmake premake project release \
rev srcdir target target_dir tree xarch xgcctree xlang`"
forcepull listfile makeargs mdir mkhelper mkhelpercfg mode postmake \
premake project release rev srcdir target target_dir tree xarch xgcctree \
xlang gitclean gitcleanargs`"
main()
{
@@ -249,7 +268,7 @@ configure_project()
eval "`newvar autoconfargs badhash badtghash bootstrapargs \
build_depend buildtype cleanargs makeargs mkhelper postmake \
premake release xarch xgcctree xlang`"
premake release xarch xgcctree xlang gitclean gitcleanargs`"
[ ! -f "$_tcfg" ] && \
buildtype="auto"
@@ -433,100 +452,10 @@ check_cross_compiler()
[ -f "$xgccfile" ] && \
return 0 # build exists already, so skip building
check_gnu_path gcc gnat || x_ check_gnu_path gnat gcc
# it sometimes fails for like, no reason
make -C "$cbdir" $xgccargs || x_ make -C "$cbdir" $xgccargs
x_ touch "$xgccfile" # prevent unnecessary re-build operations
remkdir "$xbtmp/gnupath" # reset hostcc
}
# fix mismatching gcc/gnat versions on debian trixie/sid. as of december 2024,
# trixie/sid had gnat-13 as gnat and gcc-14 as gcc, but has gnat-14 in apt. in
# some cases, gcc 13+14 and gnat-13 are present; or gnat-14 and gcc-14, but
# gnat in PATH never resolves to gnat-14, because gnat-14 was "experimental"
check_gnu_path()
{
command -v "$1" 1>/dev/null || \
err "Host '$1' unavailable" "check_gnu_path" "$@"
eval "`newvar gccdir gccfull gccver gnatdir gnatfull gnatver`"
if host_gcc_gnat_match "$@"; then
return 0
elif ! match_gcc_gnat_versions "$@"; then
return 1
fi
}
# check if gcc/gnat versions already match:
host_gcc_gnat_match()
{
gnu_setver "$1" "$1" || \
err "Command '$1' unavailable." "check_gnu_path" "$@"
gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
[ "$gnatfull" != "$gccfull" ] && \
return 1; : # mismatched gcc/gnat versions
}
# find all gcc/gnat versions, matching them up in PATH:
match_gcc_gnat_versions()
{
eval "$1dir=\"$(dirname "$(command -v "$1")")\""
eval "_gnudir=\"\$$1dir\""
eval "_gnuver=\"\$$1ver\""
for _bin in "$_gnudir/$2-"*; do
if [ "${_bin#"$_gnudir/$2-"}" = "$_gnuver" ] && [ -x "$_bin" ]
then
_gnuver="${_bin#"$_gnudir/$2-"}"
break
fi
done
gnu_setver "$2" "$_gnudir/$2-$_gnuver" || \
return 1
[ "$gnatfull" != "$gccfull" ] && \
return 1
( link_gcc_gnat_versions "$@" "$_gnudir" "$_gnuver" ) || \
err "Can't link '$2-$_gnuver' '$_gnudir'" "check_gnu_path" "$@"; :
}
# create symlinks in PATH, so that the GCC/GNAT versions match:
link_gcc_gnat_versions()
{
_gnudir="$3"
_gnuver="$4"
remkdir "$xbtmp/gnupath"
x_ cd "$xbtmp/gnupath"
for _gnubin in "$_gnudir/$2"*"-$_gnuver"
do
_gnuutil="${_gnubin##*/}"
[ -e "$_gnubin" ] && \
x_ ln -s "$_gnubin" "${_gnuutil%"-$_gnuver"}"; :
done
}
# get the gcc/gnat version
# fail: return 1 if util not found
gnu_setver()
{
eval "$2 --version 1>/dev/null 2>/dev/null || return 1"
eval "$1ver=\"`"$2" --version 2>/dev/null | head -n1`\""
eval "$1ver=\"\${$1ver##* }\""
eval "$1full=\"\$$1ver\""
eval "$1ver=\"\${$1ver%%.*}\""; :
}
check_defconfig()
@@ -574,10 +503,11 @@ handle_makefile()
$if_not_dry_build \
x_ cp "$srcdir/$_copy" "$defconfig"; :
[ -e "$srcdir/.git" ] && [ "$project" = "u-boot" ] && \
[ "$mode" = "distclean" ] && \
$if_not_dry_build \
x_ git -C "$srcdir" $cleanargs clean -fdx; :
[ -e "$srcdir/.git" ] && [ "$gitclean" = "y" ] && \
if [ "$mode" = "distclean" ] || [ "$mode" = "clean" ]; then
$if_not_dry_build \
x_ git -C "$srcdir" clean $gitcleanargs; :
fi; :
}
run_make_command()