Compare commits

..

6 Commits

Author SHA1 Message Date
Leah Rowe 4878cec84d mk: optimise make-clean check
only check makefiles if if_not_make_clean is set

this avoids unnecessary disk usage

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 18:06:52 +01:00
Leah Rowe 04be963383 mk: remove unnecessary check
on dry builds, if_not_make_clean will also be empty

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 18:06:14 +01:00
Leah Rowe 5043b6dc97 mk: abuse an absurd number of sh macros
just the right amount of absurd

this is why i don't need to use python

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 17:08:05 +01:00
Leah Rowe a65d804f1e add dir check
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 10:37:06 +01:00
Leah Rowe cf079dbd17 init.sh: re-initialise upstream src .git
we have git-clean in use for projects, but that
only affects lbmk.git

now we re-initialise .git in upstream projects,
when .git is missing. this ensures consistent
cleaning behaviour between lbmk.git and the
libreboot releases.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 10:32:38 +01:00
Leah Rowe 828578cc57 mk: use correct elddir for coreboot xgcc
in practise, it was always correct because on projects
that used coreboot xgcc, the tree would always be called
default.

however, this is a bug. the logic uses a correct directory
name for coreboot in src/, but not elf/

this patch makes the two consistent, programattically.

this is therefore a preventative bugfix.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-15 09:16:28 +01:00
3 changed files with 122 additions and 62 deletions
+4 -4
View File
@@ -9,7 +9,7 @@ eval "`newvar url bkup_url depend loc subcurl subcurl_bkup subgit subgit_bkup \
tmpgit="$xbtmp/gitclone"
tmpgitcache="$xbtmp/tmpgit"
fetch_targets()
multi_tree_fetch()
{
[ -d "src/$project/$tree" ] && \
return 0
@@ -18,17 +18,17 @@ fetch_targets()
"src/$project/$tree" "submod"
}
fetch_project()
single_tree_fetch()
{
xgcctree=""
. "config/git/$project/pkg.cfg" || \
err "Can't read config 'config/git/$project/pkg.cfg'" \
"fetch_project" "@"
"single_tree_fetch" "@"
if [ -z "$url" ] || [ -z "$bkup_url" ]; then
err "url/bkup_url not both set 'config/git/$project/pkg.cfg'" \
"fetch_project" "$@"
"single_tree_fetch" "$@"
fi
[ -n "$xgcctree" ] && \
+36 -7
View File
@@ -356,21 +356,50 @@ git_init()
"git_init" "$@"; :
done
[ -L ".git" ] && \
git_init_src .
[ -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" "$@"
[ -e ".git" ] && \
[ -e "$gitdir/.git" ] && \
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_AUTHOR_DATE="@$versiondate +0000"
x_ git init 1>/dev/null 2>/dev/null
x_ git add -A . 1>/dev/null 2>/dev/null
x_ git -c user.name="xbmk" -c user.email="xbmk@example.com" \
commit -m "$projectname $version" \
x_ git -C "$gitdir" init 1>/dev/null 2>/dev/null
x_ git -C "$gitdir" add -A . 1>/dev/null 2>/dev/null
x_ git -C "$gitdir" -c user.name="xbmk" \
-c user.email="xbmk@example.com" \
commit -m "$projectname $version $gitdir" \
--author="xbmk <xbmk@example.com>" 1>/dev/null 2>/dev/null
x_ git -c user.name="xbmk" -c user.email="xbmk@example.com" \
x_ git -C "$gitdir" -c user.name="xbmk" \
-c user.email="xbmk@example.com" \
tag -a "$version" -m "$projectname $version" \
1>/dev/null 2>/dev/null; :
+82 -51
View File
@@ -65,11 +65,20 @@ eval "$(printf "version release download inject\n" | awk '{ for (i=1; i<=NF; \
flag=""
# macros, overridden depending on the flag
# : means false
if_do_make=""
if_dry_build=":"
if_not_do_make=":"
if_make_clean=":"
if_not_make_clean=""
if_make_config=":"
if_not_make_config=""
if_build=":" # can be false even if make is true
if_not_build=""
if_dry_build=":"
if_not_dry_build=""
if_single_tree=":"
eval "`newvar autoconfargs autogenargs badhash badtghash bootstrapargs \
build_depend buildtype cleanargs cmakedir cmd defconfig dest_dir elfdir \
forcepull listfile makeargs mdir mkhelper mkhelpercfg mode postmake \
@@ -125,6 +134,21 @@ main()
*) err "invalid option '-$option'" "trees" "$@" ;;
esac
if [ -z "$mode" ]; then
if_build=""
if_not_build=":"
fi
if [ "${mode%config}" != "$mode" ]; then
if_make_config=""
if_not_make_config=":"
fi
if [ "${mode%clean}" != "$mode" ]; then
if_make_clean=""
if_not_make_clean=":"
fi
if [ -z "${OPTARG+x}" ]; then
shift 1
break
@@ -161,9 +185,12 @@ main()
x_ touch "$mkhelpercfg"
fi
cmd="build_project"
singletree "$project" || \
cmd="build_targets"
if singletree "$project"; then
cmd="single_tree_build"
if_single_tree=""
else
cmd="multi_tree_build"
fi
remkdir "${tmpgit%/*}"
x_ touch "$mkhelpercfg"
@@ -172,7 +199,7 @@ main()
$cmd "$@"
}
build_project()
single_tree_build()
{
configure_project "$configdir" || \
return 0
@@ -181,23 +208,23 @@ build_project()
$if_not_dry_build elfcheck || \
return 0
[ "$mode" = "distclean" ] && \
mode="clean"
$if_make_clean \
eval mode="clean"
run_make_command || \
return 0
[ -z "$mode" ] && \
$if_build \
$if_not_dry_build \
copy_elf; :
}
build_targets()
multi_tree_build()
{
[ ! -d "$configdir" ] && \
err "directory '$configdir' doesn't exist" "build_targets" "$@"
err "directory '$configdir' doesn't exist" "multi_tree_build" "$@"
[ $# -lt 1 ] && \
fx_ build_targets find "$configdir" \
fx_ multi_tree_build find "$configdir" \
-mindepth 1 -maxdepth 1 -type d
[ $# -gt 0 ] && for x in "$@"
do
@@ -216,7 +243,7 @@ build_targets()
x_ handle_defconfig
[ -z "$mode" ] && \
$if_build \
x_ $postmake; :
done; :
}
@@ -226,7 +253,7 @@ handle_defconfig()
target_dir="$configdir/$target"
[ ! -f "CHANGELOG" ] && \
fetch_project "$project"
single_tree_fetch "$project"
configure_project "$target_dir" || \
return 0
@@ -236,31 +263,35 @@ handle_defconfig()
srcdir="src/$project/$tree"
[ "$mode" = "${mode%clean}" ] && [ ! -d "$srcdir" ] && \
return 0
[ ! -d "$srcdir" ] && \
$if_not_make_clean \
return 0
for y in "$target_dir/config"/*
do
[ "$flag" != "-d" ] && [ ! -f "$y" ] && \
continue
[ "$flag" != "-d" ] && \
defconfig="$y"
[ ! -f "$y" ] && \
$if_not_dry_build \
continue
if [ -z "$mode" ]; then
check_defconfig || continue; :
fi
$if_not_dry_build \
eval defconfig="$y"
[ -z "$mode" ] && \
for _xarch in $xarch; do
$if_dry_build \
break
[ -n "$_xarch" ] && \
check_cross_compiler "$_xarch"; :
done; :
$if_build \
check_defconfig || \
continue; :
for _xarch in $xarch; do
$if_not_build \
break
$if_dry_build \
break
[ -n "$_xarch" ] && \
check_cross_compiler "$_xarch"; :
done; :
handle_makefile
[ -z "$mode" ] && \
$if_build \
$if_not_dry_build \
copy_elf; :
done; :
@@ -286,7 +317,7 @@ configure_project()
fi
# override target/tree specific variables from per-target config:
while e "$_tcfg" f || [ "$cmd" != "build_project" ]
while e "$_tcfg" f || [ "$cmd" != "single_tree_build" ]
do
printf "Loading %s config: %s\n" "$project" "$_tcfg"
eval "`newvar rev tree`"
@@ -294,11 +325,11 @@ configure_project()
. "$_tcfg" || \
err "Can't read '$_tcfg'" "configure_project" "$@"
[ "$flag" = "-d" ] && \
build_depend="" # dry run
$if_dry_build \
eval build_depend=""
[ "$cmd" = "build_project" ] && \
break # single-tree, so targeting is unnecessary
$if_single_tree \
break
$if_do_make \
break
[ "${_tcfg%/*/target.cfg}" = "${_tcfg%"/$tree/target.cfg"}" ] \
@@ -309,10 +340,11 @@ configure_project()
[ "$XBMK_RELEASE" = "y" ] && [ "$release" = "n" ] && \
return 1
[ -n "$buildtype" ] && [ "${mode%config}" != "$mode" ] && \
return 1
[ -n "$buildtype" ] && \
$if_make_config \
return 1
[ -z "$mode" ] && \
$if_build \
$if_not_dry_build \
build_dependencies
@@ -323,7 +355,7 @@ configure_project()
if [ ! -f "CHANGELOG" ]; then
delete_old_project_files
$if_not_do_make \
fetch_${cmd#build_}
${cmd%_build}_fetch
fi
$if_not_do_make \
return 1
@@ -436,15 +468,17 @@ check_cross_compiler()
[ -n "$xgcctree" ] && \
cbdir="src/coreboot/$xgcctree"
cbelfdir="elf${cbdir#src}"
xfix="${1%-*}"
[ "$xfix" = "x86_64" ] && \
xfix="x64"
xgccfile="elf/coreboot/$tree/xgcc_${xfix}_was_compiled"
xgccfile="$cbelfdir/xgcc_${xfix}_was_compiled"
xgccargs="crossgcc-$xfix UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
x_ ./mk -f coreboot "${cbdir#src/coreboot/}"
x_ mkdir -p "elf/coreboot/$tree" # TODO: is this needed?
x_ mkdir -p "$cbelfdir"
# tell build systems what cross-compiler to use
export PATH="$xbmkpwd/$cbdir/util/crossgcc/xgcc/bin:$PATH"
@@ -504,24 +538,23 @@ handle_makefile()
[ "$mode" = "savedefconfig" ] && \
_copy="defconfig"
[ "${mode%config}" != "$mode" ] && \
$if_make_config \
$if_not_dry_build \
x_ cp "$srcdir/$_copy" "$defconfig"; :
[ -e "$srcdir/.git" ] && [ "$gitclean" = "y" ] && \
if [ "$mode" = "distclean" ] || [ "$mode" = "clean" ]; then
$if_make_clean \
$if_not_dry_build \
x_ git -C "$srcdir" clean $gitcleanargs; :
fi; :
}
run_make_command()
{
[ -z "$mode" ] && \
$if_build \
x_ $premake
$if_not_dry_build check_cmake "$srcdir" && \
[ -z "$mode" ] && \
$if_build \
$if_not_dry_build \
check_autoconf "$srcdir"
@@ -531,15 +564,13 @@ run_make_command()
$if_not_dry_build \
x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
[ -z "$mode" ] && \
$if_build \
x_ $mkhelper
check_makefile "$srcdir" || \
$if_not_make_clean \
return 0
[ "$mode" = "clean" ] || \
return 0
$if_dry_build \
check_makefile "$srcdir" || \
return 0
make -C "$srcdir" $cleanargs distclean || \