Compare commits

...

7 Commits

Author SHA1 Message Date
Leah Rowe 089875ac1f mk: error handling on command -v
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 11:43:58 +01:00
Leah Rowe 2dc01a93b9 mk: tidy up xbmk_sanitize_version
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 11:21:56 +01:00
Leah Rowe cebae0ed80 mk: rename autoconfargs to configureargs
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 10:58:00 +01:00
Leah Rowe d165f14a4d mk: general cleanup and awk appreciation
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 10:39:52 +01:00
Leah Rowe 5afd77433d mk: tidy up handle_defconfig
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 09:41:40 +01:00
Leah Rowe 08ec187842 wip
defconfig file test unnecessary in check_defconfig
because it's already checked in handle_defconfig

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 09:25:55 +01:00
Leah Rowe 2dc4a4d16b mk: clean up run_make_command_real
merge check_cmake with run_make_command_real

tidied up some redundant checks

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-16 07:54:16 +01:00
3 changed files with 30 additions and 65 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
bootstrapargs="--gnulib-srcdir=gnulib/ --no-git" bootstrapargs="--gnulib-srcdir=gnulib/ --no-git"
autoconfargs="--with-platform=coreboot --disable-werror" configureargs="--with-platform=coreboot --disable-werror"
makeargs="FS_PAYLOAD_MODULES=\"\"" makeargs="FS_PAYLOAD_MODULES=\"\""
buildtype="autohell" buildtype="autohell"
mkhelper="mkpayload_grub" mkhelper="mkpayload_grub"
+3 -7
View File
@@ -44,13 +44,9 @@ version()
xbmk_sanitize_version() xbmk_sanitize_version()
{ {
[ -z "$version" ] && \ [ -n "$version" ] && version="`printf '%s\n' "$version" | sed \
return 0 's/[[:space:]]//g; s/\.\.//g; s/\.\///g; s/\//-/g; s/^-//'`" \
&& [ -z "$version" ] && \
version="`printf '%s\n' "$version" | sed \
's/[[:space:]]//g; s/\.\.//g; s/\.\///g; s/\//-/g; s/^-//'`"
[ -z "$version" ] && \
err "'version' empty after sanitization" \ err "'version' empty after sanitization" \
"xbmk_sanitize_version" "$@"; : "xbmk_sanitize_version" "$@"; :
} }
+26 -57
View File
@@ -35,8 +35,8 @@ err()
( (
mk="$0" mk="$0"
[ "${mk##*/}" = "$mk" ] && \ [ "${mk##*/}" != "$mk" ] || \
mk="`command -v "$mk"`" mk="$(x_ command -v "$mk")" || exit 1
mk="$(x_ findpath "$mk")" || exit 1 mk="$(x_ findpath "$mk")" || exit 1
xbmkpwd="$(x_ dirname "$mk")" || exit 1 xbmkpwd="$(x_ dirname "$mk")" || exit 1
@@ -78,7 +78,7 @@ if_not_dry_build=""
if_single_tree=":" if_single_tree=":"
eval "`newvar autoconfargs autogenargs badhash badtghash bootstrapargs \ eval "`newvar configureargs autogenargs badhash badtghash bootstrapargs \
build_depend buildtype cleanargs cmakedir cmd defconfig dest_dir elfdir \ build_depend buildtype cleanargs cmakedir cmd defconfig dest_dir elfdir \
forcepull listfile makeargs mdir mkhelper mkhelpercfg mode postmake \ forcepull listfile makeargs mdir mkhelper mkhelpercfg mode postmake \
premake project release rev srcdir target target_dir tree xarch xgcctree \ premake project release rev srcdir target target_dir tree xarch xgcctree \
@@ -196,7 +196,7 @@ single_tree_build()
multi_tree_build() multi_tree_build()
{ {
[ ! -d "$configdir" ] && \ [ ! -d "$configdir" ] && \
err "directory '$configdir' doesn't exist" "multi_tree_build" "$@" err "dir '$configdir' doesn't exist" multi_tree_build "$@"
[ $# -lt 1 ] && \ [ $# -lt 1 ] && \
fx_ multi_tree_build find "$configdir" \ fx_ multi_tree_build find "$configdir" \
-mindepth 1 -maxdepth 1 -type d -mindepth 1 -maxdepth 1 -type d
@@ -216,7 +216,6 @@ multi_tree_build()
target="${x##*/}" target="${x##*/}"
x_ handle_defconfig x_ handle_defconfig
$if_build \ $if_build \
x_ $postmake; : x_ $postmake; :
done; : done; :
@@ -247,13 +246,8 @@ handle_defconfig()
eval defconfig="$y" eval defconfig="$y"
$if_build \ $if_build \
check_defconfig || \ prep_multi_tree_build || \
continue; : continue
for _xarch in $xarch; do
[ -n "$_xarch" ] && $if_build $if_not_dry_build \
check_cross_compiler "$_xarch"; :
done; :
handle_makefile handle_makefile
@@ -267,7 +261,7 @@ configure_project()
{ {
_tcfg="$1/target.cfg" _tcfg="$1/target.cfg"
eval "`newvar autoconfargs badhash badtghash bootstrapargs \ eval "`newvar configureargs 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`"
@@ -342,8 +336,10 @@ build_dependencies()
$if_not_dry_build \ $if_not_dry_build \
err "$project/$tree: !bd '$bd'" \ err "$project/$tree: !bd '$bd'" \
"build_dependencies" "$@" "build_dependencies" "$@"
[ "${bd##*/}" = "$bd" ] && \ [ "${bd##*/}" = "$bd" ] && \
bd_tree="" bd_tree=""
[ -n "$bd_project" ] && \ [ -n "$bd_project" ] && \
$if_not_dry_build \ $if_not_dry_build \
x_ "$mk" -b $bd_project $bd_tree; : x_ "$mk" -b $bd_project $bd_tree; :
@@ -424,7 +420,16 @@ project_up_to_date()
eval "[ \"\$$badhashvar\" = \"y\" ] && return 1"; : eval "[ \"\$$badhashvar\" = \"y\" ] && return 1"; :
} }
check_cross_compiler() prep_multi_tree_build()
{
dest_dir="$elfdir/$tree/$target/${defconfig#"$target_dir/config/"}"
$if_not_dry_build elfcheck || return 1 # skip if a build exists
$if_not_dry_build eval "$(printf '%s\n' "$xarch" | awk \
'{ for (i=1; i<=NF; i++) $i = "check_xgcc \""$i"\";"; print }')"
}
check_xgcc()
{ {
cbdir="src/coreboot/$tree" cbdir="src/coreboot/$tree"
@@ -462,22 +467,6 @@ check_cross_compiler()
x_ touch "$xgccfile" # prevent unnecessary re-build operations x_ touch "$xgccfile" # prevent unnecessary re-build operations
} }
check_defconfig()
{
[ ! -f "$defconfig" ] && \
$if_not_dry_build \
err "$project/$target: no config" check_defconfig "$@"
dest_dir="$elfdir/$tree/$target/${defconfig#"$target_dir/config/"}"
# skip build if a previous one exists:
$if_dry_build \
return 0
elfcheck || \
return 1; :
}
elfcheck() elfcheck()
{ {
# TODO: *STILL* very hacky check. do it properly (based on build.list) # TODO: *STILL* very hacky check. do it properly (based on build.list)
@@ -487,64 +476,44 @@ elfcheck()
handle_makefile() handle_makefile()
{ {
if $if_not_dry_build check_makefile "$srcdir"; then check_makefile "$srcdir" && \
$if_not_dry_build \ $if_not_dry_build \
x_ make -C "$srcdir" clean $cleanargs x_ make -C "$srcdir" clean $cleanargs
fi
[ -f "$defconfig" ] && \ [ -f "$defconfig" ] && \
x_ cp "$defconfig" "$srcdir/.config" x_ cp "$defconfig" "$srcdir/.config"
run_make_command || \ run_make_command || err "no makefile!" "handle_makefile" "$@"
err "no makefile!" "handle_makefile" "$@"
_copy=".config" _copy=".config"
[ "$mode" = "savedefconfig" ] && \ [ "$mode" = "savedefconfig" ] && \
_copy="defconfig" _copy="defconfig"
$if_make_config \ $if_make_config \
$if_not_dry_build \ x_ cp "$srcdir/$_copy" "$defconfig"; :
x_ cp "$srcdir/$_copy" "$defconfig"; :
} }
run_make_command() run_make_command()
{ {
$if_build \ $if_build \
x_ $premake x_ $premake
$if_not_dry_build \ $if_not_dry_build \
run_make_command_real || return 1 run_make_command_real || return 1
$if_build \ $if_build \
x_ $mkhelper; : x_ $mkhelper; :
} }
run_make_command_real() run_make_command_real()
{ {
$if_not_dry_build [ -z "$cmakedir" ] || \
x_ check_cmake "$srcdir" x_ cmake -B "$srcdir" "$srcdir/$cmakedir"
$if_build \ $if_build \
check_autoconf "$srcdir" check_autoconf "$srcdir"
check_makefile "$srcdir" || return 1 check_makefile "$srcdir" || return 1
x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
} }
check_cmake()
{
[ -z "$cmakedir" ] && \
return 0
check_makefile "$1" || \
cmake -B "$1" "$1/$cmakedir" || \
x_ check_makefile "$1"
x_ check_makefile "$1"; :
}
check_autoconf() check_autoconf()
{ {
( (
@@ -555,9 +524,9 @@ check_autoconf()
[ -f "autogen.sh" ] && \ [ -f "autogen.sh" ] && \
x_ ./autogen.sh $autogenargs x_ ./autogen.sh $autogenargs
[ -f "configure" ] && \ [ -f "configure" ] && \
x_ ./configure $autoconfargs; : x_ ./configure $configureargs; :
) || err "can't bootstrap project: $1" "check_autoconf" "$@"; : ) || err "can't bootstrap project: $1" check_autoconf "$@"; :
} }
check_makefile() check_makefile()