mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 18:34:57 +02:00
handle/make/*: unified main() function
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -0,0 +1,30 @@
|
|||||||
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
|
||||||
|
|
||||||
|
main()
|
||||||
|
{
|
||||||
|
while getopts b:m:u:c:x: option
|
||||||
|
do
|
||||||
|
_flag="${1}"
|
||||||
|
case "${1}" in
|
||||||
|
-b) mode="all" ;;
|
||||||
|
-u) mode="oldconfig" ;;
|
||||||
|
-m) mode="menuconfig" ;;
|
||||||
|
-c) mode="distclean" ;;
|
||||||
|
-x) mode="crossgcc-clean" ;;
|
||||||
|
*) fail "Invalid option" ;;
|
||||||
|
esac
|
||||||
|
shift; project="${OPTARG}"; shift
|
||||||
|
done
|
||||||
|
[ -z "${mode}" ] && fail "mode not given (-m, -u, -b, -c or -x)"
|
||||||
|
[ -z "${project}" ] && fail "project name not specified"
|
||||||
|
|
||||||
|
handle_dependencies $@
|
||||||
|
handle_targets
|
||||||
|
}
|
||||||
|
|
||||||
|
fail()
|
||||||
|
{
|
||||||
|
[ -z "${codedir}" ] || ./handle make file -c "${codedir}" || :
|
||||||
|
err "${1}"
|
||||||
|
}
|
||||||
@@ -108,7 +108,7 @@ purge_files()
|
|||||||
done
|
done
|
||||||
x_ ./handle make file -c bios_extract flashrom grub uefitool \
|
x_ ./handle make file -c bios_extract flashrom grub uefitool \
|
||||||
util-fw/stm32-vserprog util-fw/stm32-vserprog/libopencm3 \
|
util-fw/stm32-vserprog util-fw/stm32-vserprog/libopencm3 \
|
||||||
memtest86plus/build* util/*
|
memtest86plus/build32 memtest86plus/build64 util/*
|
||||||
|
|
||||||
x_ rm -Rf .git* */.git* */*/.git* */*/*/.git* */*/*/*/.git* \
|
x_ rm -Rf .git* */.git* */*/.git* */*/*/.git* */*/*/*/.git* \
|
||||||
*/*/*/*/*/.git* */*/*/*/*/*/.git* */*/*/*/*/*/*/.git*
|
*/*/*/*/*/.git* */*/*/*/*/*/.git* */*/*/*/*/*/*/.git*
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ set -u -e
|
|||||||
|
|
||||||
. "include/err.sh"
|
. "include/err.sh"
|
||||||
. "include/option.sh"
|
. "include/option.sh"
|
||||||
|
. "include/make.sh"
|
||||||
|
|
||||||
read projectname < projectname
|
read projectname < projectname
|
||||||
read our_version < version
|
read our_version < version
|
||||||
@@ -20,26 +21,7 @@ eval "$(setvars "" arch cfgsdir codedir config config_name crossgcc_ada mode \
|
|||||||
|
|
||||||
tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)"
|
tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)"
|
||||||
|
|
||||||
main()
|
# main() is in include/make.sh
|
||||||
{
|
|
||||||
while getopts b:m:u:c:x: option
|
|
||||||
do
|
|
||||||
case "${1}" in
|
|
||||||
-b) mode="all" ;;
|
|
||||||
-u) mode="oldconfig" ;;
|
|
||||||
-m) mode="menuconfig" ;;
|
|
||||||
-c) mode="distclean" ;;
|
|
||||||
-x) mode="crossgcc-clean" ;;
|
|
||||||
*) fail "Invalid option" ;;
|
|
||||||
esac
|
|
||||||
shift; project="${OPTARG}"; shift
|
|
||||||
done
|
|
||||||
[ -z "${mode}" ] && fail "mode not given (-m, -u, -b, -c or -x)"
|
|
||||||
[ -z "${project}" ] && fail "project name not specified"
|
|
||||||
|
|
||||||
handle_dependencies $@
|
|
||||||
handle_targets
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_dependencies()
|
handle_dependencies()
|
||||||
{
|
{
|
||||||
|
|||||||
+7
-21
@@ -6,30 +6,16 @@
|
|||||||
set -u -e
|
set -u -e
|
||||||
|
|
||||||
. "include/err.sh"
|
. "include/err.sh"
|
||||||
|
. "include/make.sh"
|
||||||
|
|
||||||
eval "$(setvars "" mode project _flag)"
|
eval "$(setvars "" mode project _flag codedir)"
|
||||||
|
|
||||||
main()
|
# main() is in include/make.sh
|
||||||
{
|
|
||||||
while getopts b:c: option
|
|
||||||
do
|
|
||||||
_flag="${1}"
|
|
||||||
case "${_flag}" in
|
|
||||||
-b) : ;;
|
|
||||||
-c) mode="distclean" ;;
|
|
||||||
*) err "Invalid option" ;;
|
|
||||||
esac
|
|
||||||
shift; project="${OPTARG}"; shift
|
|
||||||
done
|
|
||||||
[ -z "${project}" ] && err "project name not specified"
|
|
||||||
[ $# -gt 0 ] && x_ ./handle make file ${_flag} ${@}
|
|
||||||
|
|
||||||
handle_dependencies
|
|
||||||
run_make_command
|
|
||||||
}
|
|
||||||
|
|
||||||
handle_dependencies()
|
handle_dependencies()
|
||||||
{
|
{
|
||||||
|
[ $# -gt 0 ] && x_ ./handle make file ${_flag} ${@}
|
||||||
|
|
||||||
[ -d "${project}" ] || x_ ./update project repo "${project%/*}"
|
[ -d "${project}" ] || x_ ./update project repo "${project%/*}"
|
||||||
[ -d "${project}" ] || \
|
[ -d "${project}" ] || \
|
||||||
err "handle_dependencies: ${project%/*} not downloaded"
|
err "handle_dependencies: ${project%/*} not downloaded"
|
||||||
@@ -42,11 +28,11 @@ handle_dependencies()
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
run_make_command()
|
handle_targets()
|
||||||
{
|
{
|
||||||
[ -f "${project}/Makefile" ] || [ -f "${project}/makefile" ] || \
|
[ -f "${project}/Makefile" ] || [ -f "${project}/makefile" ] || \
|
||||||
[ -f "${project}/GNUmakefile" ] || return 0
|
[ -f "${project}/GNUmakefile" ] || return 0
|
||||||
[ -z "${mode}" ] && x_ make -C "${project}" -j$(nproc) && return 0
|
[ "${mode}" = "all" ] && x_ make -C "${project}" -j$(nproc) && return 0
|
||||||
x_ make -C "${project}" clean
|
x_ make -C "${project}" clean
|
||||||
make -C "${project}" distclean 2>/dev/null || :
|
make -C "${project}" distclean 2>/dev/null || :
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user