mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-19 19:23:24 +02:00
handle/make/config: split up main()
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
+22
-11
@@ -27,6 +27,7 @@ project=""
|
|||||||
romtype=""
|
romtype=""
|
||||||
target=""
|
target=""
|
||||||
target_dir=""
|
target_dir=""
|
||||||
|
targets=""
|
||||||
tree=""
|
tree=""
|
||||||
cbfstool=""
|
cbfstool=""
|
||||||
|
|
||||||
@@ -47,8 +48,14 @@ main()
|
|||||||
esac
|
esac
|
||||||
shift; project="${OPTARG}"; shift
|
shift; project="${OPTARG}"; shift
|
||||||
done
|
done
|
||||||
[ -z "${mode}" ] && fail "mode not given (-m, -u or -b)"
|
[ -z "${mode}" ] && fail "mode not given (-m, -u, -b, -c or -x)"
|
||||||
|
|
||||||
|
handle_dependencies $@
|
||||||
|
handle_targets
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_dependencies()
|
||||||
|
{
|
||||||
elfdir="elf/${project}"
|
elfdir="elf/${project}"
|
||||||
|
|
||||||
cfgsdir="config/${project}"
|
cfgsdir="config/${project}"
|
||||||
@@ -58,12 +65,16 @@ main()
|
|||||||
[ -f "${listfile}" ] || fail "list file, ${listfile}, does not exist"
|
[ -f "${listfile}" ] || fail "list file, ${listfile}, does not exist"
|
||||||
|
|
||||||
# Build for all targets if no argument is given
|
# Build for all targets if no argument is given
|
||||||
targets=$(./build command options "${cfgsdir}")
|
targets=$(./build command options "${cfgsdir}") || \
|
||||||
|
fail "Cannot get options for ${cfgsdir}"
|
||||||
[ $# -gt 0 ] && targets=$@
|
[ $# -gt 0 ] && targets=$@
|
||||||
|
|
||||||
[ -d "${elfdir}" ] || [ "${mode}" != "all" ] || \
|
[ -d "${elfdir}" ] || [ "${mode}" != "all" ] || \
|
||||||
mkdir -p "${elfdir}/" || fail "can't create directory ${elfdir}"
|
mkdir -p "${elfdir}/" || fail "can't create directory ${elfdir}"
|
||||||
|
}
|
||||||
|
|
||||||
|
handle_targets()
|
||||||
|
{
|
||||||
for x in ${targets}; do
|
for x in ${targets}; do
|
||||||
target="${x}"
|
target="${x}"
|
||||||
printf "Running 'make %s' for project '%s, target '%s''\n" \
|
printf "Running 'make %s' for project '%s, target '%s''\n" \
|
||||||
@@ -80,7 +91,7 @@ main()
|
|||||||
|
|
||||||
handle_defconfig()
|
handle_defconfig()
|
||||||
{
|
{
|
||||||
handle_dependencies "${target}" || return 0
|
handle_src_tree "${target}" || return 0
|
||||||
|
|
||||||
for y in "${target_dir}/config"/*; do
|
for y in "${target_dir}/config"/*; do
|
||||||
[ -f "${y}" ] || continue
|
[ -f "${y}" ] || continue
|
||||||
@@ -96,26 +107,26 @@ handle_defconfig()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_dependencies()
|
handle_src_tree()
|
||||||
{
|
{
|
||||||
target_dir="${cfgsdir}/${target}"
|
target_dir="${cfgsdir}/${target}"
|
||||||
mkdir -p "${elfdir}/${target}" || \
|
mkdir -p "${elfdir}/${target}" || \
|
||||||
fail "handle_dependencies: !mkdir -p ${elfdir}/${target}"
|
fail "handle_src_tree: !mkdir -p ${elfdir}/${target}"
|
||||||
|
|
||||||
tree="undefined"
|
tree="undefined"
|
||||||
arch="undefined"
|
arch="undefined"
|
||||||
romtype="normal"
|
romtype="normal"
|
||||||
|
|
||||||
[ ! -f "${target_dir}/target.cfg" ] && \
|
[ ! -f "${target_dir}/target.cfg" ] && \
|
||||||
fail "handle_dependencies: ${target_dir}: missing target.cfg"
|
fail "handle_src_tree: ${target_dir}: missing target.cfg"
|
||||||
|
|
||||||
# Override the above defaults using target.cfg
|
# Override the above defaults using target.cfg
|
||||||
. "${target_dir}/target.cfg" # source
|
. "${target_dir}/target.cfg" # source
|
||||||
|
|
||||||
[ "${tree}" = "undefined" ] && \
|
[ "${tree}" = "undefined" ] && \
|
||||||
fail "handle_dependencies: ${target_dir}: tree undefined"
|
fail "handle_src_tree: ${target_dir}: tree undefined"
|
||||||
[ "${arch}" = "undefined" ] && \
|
[ "${arch}" = "undefined" ] && \
|
||||||
fail "handle_dependencies: ${target_dir}: undefined cpu type"
|
fail "handle_src_tree: ${target_dir}: undefined cpu type"
|
||||||
|
|
||||||
codedir="${project}/${tree}"
|
codedir="${project}/${tree}"
|
||||||
if [ ! -d "${codedir}" ]; then
|
if [ ! -d "${codedir}" ]; then
|
||||||
@@ -126,7 +137,7 @@ handle_dependencies()
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
./update project trees "${project}" "${target}" || \
|
./update project trees "${project}" "${target}" || \
|
||||||
fail "handle_dependencies: can't fetch ${project}/${target}"
|
fail "handle_src_tree: can't fetch ${project}/${target}"
|
||||||
elif [ "${mode}" = "distclean" ] || \
|
elif [ "${mode}" = "distclean" ] || \
|
||||||
[ "${mode}" = "crossgcc-clean" ]; then
|
[ "${mode}" = "crossgcc-clean" ]; then
|
||||||
[ -f "${tmpclean}/${tree}" ] && return 1
|
[ -f "${tmpclean}/${tree}" ] && return 1
|
||||||
@@ -136,10 +147,10 @@ handle_dependencies()
|
|||||||
# u-boot and coreboot are both compiled with coreboot's crossgcc
|
# u-boot and coreboot are both compiled with coreboot's crossgcc
|
||||||
if [ "${project}" = "coreboot" ] || [ "${project}" = "u-boot" ]; then
|
if [ "${project}" = "coreboot" ] || [ "${project}" = "u-boot" ]; then
|
||||||
[ "${mode}" != "all" ] || check_cross_compiler || \
|
[ "${mode}" != "all" ] || check_cross_compiler || \
|
||||||
fail "handle_dependencies ${project}/${target}: crossgcc"
|
fail "handle_src_tree ${project}/${target}: crossgcc"
|
||||||
cbfstool="cbutils/${tree}/cbfstool"
|
cbfstool="cbutils/${tree}/cbfstool"
|
||||||
[ -f "${cbfstool}" ] || ./build coreboot utils "${tree}" || \
|
[ -f "${cbfstool}" ] || ./build coreboot utils "${tree}" || \
|
||||||
fail "handle_dependencies: cannot build cbfstool"
|
fail "handle_src_tree: cannot build cbfstool"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user