summaryrefslogtreecommitdiff
path: root/script/build
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-12-22 11:29:36 +0000
committerLeah Rowe <leah@libreboot.org>2023-12-22 11:53:14 +0000
commitb111f4840a043a7337937c001e1f82b7af3302f2 (patch)
treed526099e98accd103a8eaa63cdb9f72f7ef792a0 /script/build
parent2f98ca6dabace3569a0ae2ee0a33d901af6547b6 (diff)
build/serprog: general code cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/build')
-rwxr-xr-xscript/build/serprog30
1 files changed, 12 insertions, 18 deletions
diff --git a/script/build/serprog b/script/build/serprog
index 74097dc5..c961161a 100755
--- a/script/build/serprog
+++ b/script/build/serprog
@@ -1,12 +1,13 @@
#!/usr/bin/env sh
# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2023 Riku Viitanen <riku.viitanen@protonmail.com>
+# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
set -u -e
. "include/err.sh"
-eval "$(setvars "" platform pico_sdk_dir pico_src_dir stm32_src_dir boards_dir)"
+eval "$(setvars "" pico_sdk_dir pico_src_dir stm32_src_dir boards_dir)"
pico_src_dir=src/pico-serprog
pico_sdk_dir=src/pico-sdk
@@ -17,31 +18,24 @@ usage="usage: ./build firmware serprog <rp2040|stm32> [board]"
main()
{
[ -z "${1+x}" ] && err "${usage}"
+ [ "${1}" != "rp2040" ] && [ "${1}" != "stm32" ] && err "${usage}"
if [ "${1}" = "rp2040" ]; then
- platform="rp2040"
boards_dir=${pico_sdk_dir}/src/boards/include/boards
- [ -d "${pico_src_dir}/" ] || \
- x_ ./update trees -f "pico-serprog"
+ [ -d "$pico_src_dir" ] || x_ ./update trees -f "pico-serprog"
elif [ "${1}" = "stm32" ]; then
- platform="stm32"
boards_dir=${stm32_src_dir}/boards
- [ -d "${stm32_src_dir}/" ] || \
- x_ ./update trees -f "stm32-vserprog"
- else
- err "${usage}"
+ [ -d "$stm32_src_dir" ] || x_ ./update trees -f "stm32-vserprog"
fi
- x_ mkdir -p "bin/serprog_${platform}"
+ x_ mkdir -p "bin/serprog_${1}"
- if [ $# -gt 1 ] ; then
- if [ "${2}" = "list" ]; then
- print_boards ${boards_dir}
- return 0
- fi
- build_${platform}_rom "${2}"
+ if [ $# -gt 1 ] && [ "${2}" = "list" ]; then
+ print_boards ${boards_dir}
+ elif [ $# -gt 1 ]; then
+ build_${1}_rom "${2}"
else
printf "Building all serprog targets\n"
- list_boards "${boards_dir}" | while read board; do
- build_${platform}_rom "${board}"
+ list_boards "${boards_dir}" | while read -r board; do
+ build_${1}_rom "${board}"
done
fi
}