From 0a0defd3256ff5e29e3b4d129a04fb7546bc31ac Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 30 Sep 2023 18:41:57 +0100 Subject: simplify initialising variables in shell scripts Signed-off-by: Leah Rowe --- script/handle/make/config | 44 ++++++++++++-------------------------------- script/handle/make/file | 3 +-- 2 files changed, 13 insertions(+), 34 deletions(-) (limited to 'script/handle/make') 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() { -- cgit v1.2.1