Files
lbmk/script/handle/make/file
T
Leah Rowe ad74b4c281 handle/make/file: run extra arg before, not after
The previous patch to the file was correct, except for
off by one at the end, resulting in no argument being
passed for project names.

Now the extra commands are run *before* handle_dependencies,
instead of running at the end of main. This prevents error.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2023-10-02 22:21:42 +01:00

56 lines
1.1 KiB
Bash
Executable File

#!/usr/bin/env sh
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
. "include/err.sh"
eval "$(setvars "" mode project _flag)"
main()
{
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()
{
[ -d "${project}" ] || x_ ./update project repo "${project%/*}"
[ -d "${project}" ] || \
err "handle_dependencies: ${project%/*} not downloaded"
[ "${project}" = "uefitool" ] || return 0 # TODO: remove hardcoding
(
x_ cd uefitool
cmake UEFIExtract/ || [ -f Makefile ] || \
err "handle_dependencies: !cmake UEFIExtract/"
)
}
run_make_command()
{
if [ -z "${mode}" ]; then
x_ make -C "${project}" -j$(nproc)
else
x_ make -C "${project}" clean
make -C "${project}" distclean 2>/dev/null || :
fi
}
main $@