summaryrefslogtreecommitdiff
path: root/script/handle/make
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-30 18:41:57 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-30 19:09:25 +0100
commit0a0defd3256ff5e29e3b4d129a04fb7546bc31ac (patch)
tree479d686f0578b506dbe3f862300e73c090ed8bcc /script/handle/make
parent49b266eb4248f87d111e9babae86a873300afa03 (diff)
simplify initialising variables in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'script/handle/make')
-rwxr-xr-xscript/handle/make/config44
-rwxr-xr-xscript/handle/make/file3
2 files changed, 13 insertions, 34 deletions
diff --git a/script/handle/make/config b/script/handle/make/config
index be6f1538..72cba193 100755
--- a/script/handle/make/config
+++ b/script/handle/make/config
@@ -15,25 +15,10 @@ read our_version < version
export LOCALVERSION="-${projectname}-${our_version}"
-arch=""
-cfgsdir=""
-codedir=""
-config=""
-config_name=""
-crossgcc_ada=""
-elfdir=""
-listfile=""
-mode=""
-project=""
-romtype=""
-target=""
-target_dir=""
-targets=""
-tree=""
-cbfstool=""
-
-tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)" || \
- fail "can't make tmpclean dir"
+eval "$(setvars "" arch cfgsdir codedir config config_name crossgcc_ada mode \
+ elfdir listfile project romtype target target_dir targets tree cbfstool)"
+
+tmpclean="$(mktemp -d -t makeclean.XXXXXXXXXX)" || fail "!mkdir tmpclean"
main()
{
@@ -115,8 +100,7 @@ handle_src_tree()
mkdir -p "${elfdir}/${target}" || \
fail "handle_src_tree: !mkdir -p ${elfdir}/${target}"
- tree="undefined"
- arch="undefined"
+ eval "$(setvars "undefined" arch tree)"
romtype="normal"
[ ! -f "${target_dir}/target.cfg" ] && \
@@ -218,10 +202,9 @@ check_config()
dest_dir="${elfdir}/${target}/${config_name}"
# TODO: very hacky check. do it properly (based on build.list)
for elftest in "${dest_dir}"/*; do
- if [ -f "${elftest}" ]; then
- printf "Build already exists, so skipping build\n" 1>&2
- return 1
- fi
+ [ -f "${elftest}" ] || continue
+ printf "Build already exists, so skipping build\n" 1>&2
+ return 1
done
mkdir -p "${dest_dir}" || \
fail "check_config: cannot mkdir: ${dest_dir}"
@@ -255,15 +238,12 @@ run_make_command()
copy_elf()
{
- if [ "${project}" = "coreboot" ]; then
- modify_coreboot_rom || \
- fail "copy_elf: cannot prepare coreboot image"
- fi
+ [ "${project}" != "coreboot" ] || modify_coreboot_rom || \
+ fail "copy_elf: cannot prepare coreboot image"
while read f; do
- [ ! -f "${codedir}/$f" ] || \
- cp "${codedir}/${f}" "${dest_dir}/" || \
- fail "copy_elf: cannot copy elf file"
+ [ ! -f "${codedir}/$f" ] || cp "${codedir}/${f}" \
+ "${dest_dir}/" || fail "copy_elf: cannot copy elf file"
done < ${listfile}
./handle make file -c "${codedir}" || \
diff --git a/script/handle/make/file b/script/handle/make/file
index 0d0d6f3c..19807425 100755
--- a/script/handle/make/file
+++ b/script/handle/make/file
@@ -7,8 +7,7 @@ set -u -e
. "include/err.sh"
-mode=""
-project=""
+eval "$(setvars "" mode project)"
main()
{