Compare commits

...

11 Commits

Author SHA1 Message Date
Leah Rowe 88887c0163 mk: fix check_cross_compiler call
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 22:15:16 +01:00
Leah Rowe 0c41ea82dd mk: move config back to getopt
really pointless doing it here. do it in the loop.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 22:10:37 +01:00
Leah Rowe bbc56b714b fix build error on no-makefile projects
e.g. biosutilities

the subshell screws up error handling. this
patch changes it to old behaviour.

some projects don't have makefiles. the
non-zero exit also prevents further call
to copy_elf when no binaries are created,
as in this example.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 21:17:10 +01:00
Leah Rowe 6a5b4c98d6 mk: clean up getopt flags
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 21:11:51 +01:00
Leah Rowe 50eec6d485 mk: simplify single_tree_build
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:58:40 +01:00
Leah Rowe 40b1a3e0bb Revert "init.sh: re-initialise upstream src .git"
This reverts commit cf079dbd17.

we don't need it anymore. we don't bother cleaning sources
for releases, because tehy're never dirtied. we build
using ./mk release which does everything fresh.

the git-clean feature was only used on ./mk -c, which was
removed because it's not needed for the same reason as
above. lbmk always cleans and re-builds everything when
metadata changes, otherwise storing builds out of tree
in a cache directory.

get rid of this dead code.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:42:33 +01:00
Leah Rowe 59cbc1784c mk: remove -c and -x commands (clean/xgcc-clean)
the user never runs these. it's not needed. the design
of lbmk already cleans everything, or caches everything,
between builds. everything cached out of tree.

it's not expected to ever need to clean manually, so just
remove the option. knobs are for nobs.

releases don't need it either, because we tar everything
before building, thus eliminating all build artifacts.
we do this on a fresh copy of lbmk on ./mk release

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:38:08 +01:00
Leah Rowe 6725b616f3 mk: skip build if makefile check fails
this was the previous behaviour, and prevents
single-tree builds from proceeding with
use of copy_elf

otherwise you get a bunch of build errors

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:24:08 +01:00
Leah Rowe 7507655d34 simplified make-clean handling
no point using distclean, because the context there
is providing clean sources for distribution, but we
use ./mk release which tars everything up before ever
running any build commands.

make-clean is enough

distclean is a stupid gnuism anyway, and most makefiles
that have it will just do the same as clean anyway

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 20:20:03 +01:00
Leah Rowe 2aad50cd59 even more tidy up run_make_command
tidy it all the way up

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 19:51:55 +01:00
Leah Rowe f7b9c9e410 mk: tidy up run_make_command
yeah, this reverses the last change

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 19:03:39 +01:00
3 changed files with 35 additions and 115 deletions
-8
View File
@@ -26,11 +26,3 @@ cbfscfg=""
premake="corebootpremake" premake="corebootpremake"
mkhelper="coreboot_pad_one_byte" mkhelper="coreboot_pad_one_byte"
postmake="mkcorebootbin" postmake="mkcorebootbin"
# must confirm, but i think git-clean
# will also delete crossgcc builds in
# coreboot.git, which we do not currently
# rely on out-of-tree
gitclean="n"
# so, TODO: support out-of-tree xgcc builds
+7 -36
View File
@@ -356,50 +356,21 @@ git_init()
"git_init" "$@"; : "git_init" "$@"; :
done done
git_init_src . [ -L ".git" ] && \
[ -d "src" ] && \
fx_ git_init_src x_ find src -maxdepth 1 -mindepth 1 -type d; :
}
git_init_src()
{
gitdir="${1-}"
[ -z "$gitdir" ] && \
err "Invalid argument" git_init_src "$@"
[ -L "$gitdir/.git" ] && \
err "'$xbmkpwd/.git' is a symlink" "git_init" "$@" err "'$xbmkpwd/.git' is a symlink" "git_init" "$@"
[ -e "$gitdir/.git" ] && \ [ -e ".git" ] && \
return 0 return 0
git_projectname="${gitdir#*/}"
git_treename="${git_projectname#*/}"
[ "$git_projectname" = "${git_projectname#*/}" ] && \
git_treename=""
git_projectname="${git_projectname%%/*}"
git_treename="${git_treename%%*/}"
if ! singletree "$git_projectname"; then
if [ -z "$git_treename" ]; then
fx_ git_init_src x_ find "$gitdir" -maxdepth 1 \
-mindepth 1 -type d
return 0
fi
fi
( (
export GIT_COMMITTER_DATE="@$versiondate +0000" export GIT_COMMITTER_DATE="@$versiondate +0000"
export GIT_AUTHOR_DATE="@$versiondate +0000" export GIT_AUTHOR_DATE="@$versiondate +0000"
x_ git -C "$gitdir" init 1>/dev/null 2>/dev/null x_ git init 1>/dev/null 2>/dev/null
x_ git -C "$gitdir" add -A . 1>/dev/null 2>/dev/null x_ git add -A . 1>/dev/null 2>/dev/null
x_ git -C "$gitdir" -c user.name="xbmk" \ x_ git -c user.name="xbmk" -c user.email="xbmk@example.com" \
-c user.email="xbmk@example.com" \ commit -m "$projectname $version" \
commit -m "$projectname $version $gitdir" \
--author="xbmk <xbmk@example.com>" 1>/dev/null 2>/dev/null --author="xbmk <xbmk@example.com>" 1>/dev/null 2>/dev/null
x_ git -C "$gitdir" -c user.name="xbmk" \ x_ git -c user.name="xbmk" -c user.email="xbmk@example.com" \
-c user.email="xbmk@example.com" \
tag -a "$version" -m "$projectname $version" \ tag -a "$version" -m "$projectname $version" \
1>/dev/null 2>/dev/null; : 1>/dev/null 2>/dev/null; :
+28 -71
View File
@@ -68,8 +68,6 @@ flag=""
# : means false # : means false
if_do_make="" if_do_make=""
if_not_do_make=":" if_not_do_make=":"
if_make_clean=":"
if_not_make_clean=""
if_make_config=":" if_make_config=":"
if_not_make_config="" if_not_make_config=""
if_build=":" # can be false even if make is true if_build=":" # can be false even if make is true
@@ -85,13 +83,9 @@ eval "`newvar autoconfargs autogenargs badhash badtghash bootstrapargs \
premake project release rev srcdir target target_dir tree xarch xgcctree \ premake project release rev srcdir target target_dir tree xarch xgcctree \
xlang`" xlang`"
# can be overridden in project mkhelper.cfg
gitclean="y"
gitcleanargs="-fdx"
main() main()
{ {
flags="f:F:b:m:u:c:x:s:l:n:d:" flags="f:F:b:m:u:s:l:n:d:"
while getopts $flags option while getopts $flags option
do do
@@ -104,30 +98,21 @@ main()
# ./mk -m coreboot does: make menuconfig -C src/coreboot/tree # ./mk -m coreboot does: make menuconfig -C src/coreboot/tree
case "$flag" in case "$flag" in
-d) -b) : ;; # build a source tree
# -d is similar to -b, except that -d) # dry builds. -d is like -b but skips many build steps
# a large number of operations will be
# skipped. these are "if_not_dry_build build" scenarios
# where only a subset of build tasks are done,
# and $if_not_dry_build is prefixed to skipped commands
if_dry_build="" if_dry_build=""
if_not_dry_build=":" if_not_dry_build=":"
;; ;;
-b) : ;;
-u) mode="oldconfig" ;;
-m) mode="menuconfig" ;;
-c) mode="distclean" ;;
-x) mode="crossgcc-clean" ;;
-f|-F) # download source code for a project -f|-F) # download source code for a project
# macros. colon means false.
if_do_make=":" if_do_make=":"
if_dry_build=""
if_not_do_make="" if_not_do_make=""
if_dry_build=""
if_not_dry_build=":" if_not_dry_build=":"
[ "$flag" = "-F" ] && \ [ "$flag" = "-F" ] && \
forcepull="y"; : # never skip git fetch/pull forcepull="y"; : # never skip git fetch/pull
;; ;;
-u) mode="oldconfig" ;;
-m) mode="menuconfig" ;;
-s) mode="savedefconfig" ;; -s) mode="savedefconfig" ;;
-l) mode="olddefconfig" ;; -l) mode="olddefconfig" ;;
-n) mode="nconfig" ;; -n) mode="nconfig" ;;
@@ -138,17 +123,11 @@ main()
if_build="" if_build=""
if_not_build=":" if_not_build=":"
fi fi
if [ "${mode%config}" != "$mode" ]; then if [ "${mode%config}" != "$mode" ]; then
if_make_config="" if_make_config=""
if_not_make_config=":" if_not_make_config=":"
fi fi
if [ "${mode%clean}" != "$mode" ]; then
if_make_clean=""
if_not_make_clean=":"
fi
if [ -z "${OPTARG+x}" ]; then if [ -z "${OPTARG+x}" ]; then
shift 1 shift 1
break break
@@ -208,15 +187,9 @@ single_tree_build()
$if_not_dry_build elfcheck || \ $if_not_dry_build elfcheck || \
return 0 return 0
$if_make_clean \ run_make_command && \
eval mode="clean" $if_build $if_not_dry_build \
copy_elf; :
run_make_command || \
return 0
$if_build \
$if_not_dry_build \
copy_elf; :
} }
multi_tree_build() multi_tree_build()
@@ -263,11 +236,7 @@ handle_defconfig()
srcdir="src/$project/$tree" srcdir="src/$project/$tree"
[ ! -d "$srcdir" ] && \ [ -d "$srcdir" ] && for y in "$target_dir/config"/*
$if_not_make_clean \
return 0
for y in "$target_dir/config"/*
do do
[ ! -f "$y" ] && \ [ ! -f "$y" ] && \
$if_not_dry_build \ $if_not_dry_build \
@@ -281,11 +250,7 @@ handle_defconfig()
continue; : continue; :
for _xarch in $xarch; do for _xarch in $xarch; do
$if_not_build \ [ -n "$_xarch" ] && $if_build $if_not_dry_build \
break
$if_dry_build \
break
[ -n "$_xarch" ] && \
check_cross_compiler "$_xarch"; : check_cross_compiler "$_xarch"; :
done; : done; :
@@ -304,7 +269,6 @@ configure_project()
eval "`newvar autoconfargs badhash badtghash bootstrapargs \ eval "`newvar autoconfargs badhash badtghash bootstrapargs \
build_depend buildtype cleanargs makeargs mkhelper postmake \ build_depend buildtype cleanargs makeargs mkhelper postmake \
premake release xarch xgcctree xlang`" premake release xarch xgcctree xlang`"
gitclean="y"
[ ! -f "$_tcfg" ] && \ [ ! -f "$_tcfg" ] && \
buildtype="auto" buildtype="auto"
@@ -524,7 +488,7 @@ handle_makefile()
{ {
if $if_not_dry_build check_makefile "$srcdir"; then if $if_not_dry_build check_makefile "$srcdir"; then
$if_not_dry_build \ $if_not_dry_build \
x_ make -C "$srcdir" $cleanargs clean x_ make -C "$srcdir" clean $cleanargs
fi fi
[ -f "$defconfig" ] && \ [ -f "$defconfig" ] && \
@@ -541,11 +505,6 @@ handle_makefile()
$if_make_config \ $if_make_config \
$if_not_dry_build \ $if_not_dry_build \
x_ cp "$srcdir/$_copy" "$defconfig"; : x_ cp "$srcdir/$_copy" "$defconfig"; :
[ -e "$srcdir/.git" ] && [ "$gitclean" = "y" ] && \
$if_make_clean \
$if_not_dry_build \
x_ git -C "$srcdir" clean $gitcleanargs; :
} }
run_make_command() run_make_command()
@@ -553,35 +512,33 @@ run_make_command()
$if_build \ $if_build \
x_ $premake x_ $premake
$if_not_dry_build check_cmake "$srcdir" && \ run_make_command_real || return 1
$if_build \
$if_not_dry_build \
check_autoconf "$srcdir"
$if_not_dry_build check_makefile "$srcdir" || \
return 1
$if_not_dry_build \
x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
$if_build \ $if_build \
x_ $mkhelper x_ $mkhelper; :
}
$if_not_make_clean \ run_make_command_real()
{
$if_dry_build \
return 0 return 0
check_makefile "$srcdir" || \ x_ check_cmake "$srcdir"
return 0
make -C "$srcdir" $cleanargs distclean || \ $if_build \
x_ make -C "$srcdir" $cleanargs clean; : check_autoconf "$srcdir"
check_makefile "$srcdir" || return 1
x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
} }
check_cmake() check_cmake()
{ {
$if_dry_build \ $if_dry_build \
return 0 return 0
[ ! -n "$cmakedir" ] && \
[ -z "$cmakedir" ] && \
return 0 return 0
check_makefile "$1" || \ check_makefile "$1" || \
@@ -627,7 +584,7 @@ copy_elf()
"cannot read '$listfile'" "copy_elf" "$@"; : "cannot read '$listfile'" "copy_elf" "$@"; :
fi fi
( x_ make clean -C "$srcdir" $cleanargs ) || \ ( x_ make -C "$srcdir" clean $cleanargs ) || \
err "can't make-clean '$srcdir'" "copy_elf" "$@"; : err "can't make-clean '$srcdir'" "copy_elf" "$@"; :
} }