summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-04-25 13:15:58 -0700
committerVadim Bendebury <vbendeb@chromium.org>2015-04-28 03:13:01 +0200
commitd2cb1f93fb9c911a386d12bd9cb1a86e3b7767fa (patch)
treef820a393e9d7bfa476808db7c0a97ceeb0ecb5ea
parente46960246139fbf53e34de9288e654da900db63b (diff)
xcompile: Use local variables and make cosmetic changes
Declaring function variables local improves bash scripts' robustness. Cosmetic changes among other things include renaming variables from plural to singular and vice versa as appropriate, and replacing spaces with tabs. Tested by confirming that sorted output generated by util/xcompile/xcompile is the same before and after the change. Change-Id: I7305b3a4e45478ed3653b7d915dde4f83965f6c1 Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Reviewed-on: http://review.coreboot.org/9996 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
-rwxr-xr-xutil/xcompile/xcompile28
1 files changed, 14 insertions, 14 deletions
diff --git a/util/xcompile/xcompile b/util/xcompile/xcompile
index c4bab816b0..4a0fcf79f6 100755
--- a/util/xcompile/xcompile
+++ b/util/xcompile/xcompile
@@ -76,7 +76,7 @@ testcc() {
}
testas() {
- local gccprefixes="$1"
+ local gccprefix="$1"
local twidth="$2"
local arch="$3"
local use_dash_twidth="$4"
@@ -85,16 +85,16 @@ testas() {
rm -f "$obj_file"
[ -n "$use_dash_twidth" ] && use_dash_twidth="--$twidth"
- ${gccprefixes}as $use_dash_twidth -o "$obj_file" $TMPFILE 2>/dev/null ||
+ ${gccprefix}as $use_dash_twidth -o "$obj_file" $TMPFILE 2>/dev/null ||
return 1
# Check output content type.
- local obj_type="$(${gccprefixes}objdump -p $obj_file)"
+ local obj_type="$(${gccprefix}objdump -p $obj_file)"
local obj_arch="$(expr "$obj_type" : '.*format \(.[a-z0-9-]*\)')"
[ "$obj_arch" = "$full_arch" ] || return 1
# Architecture matched.
- GCCPREFIX="$gccprefixes"
+ GCCPREFIX="$gccprefix"
if [ -z "$use_dash_twidth" ]; then
ASFLAGS=""
@@ -146,7 +146,7 @@ detect_special_flags() {
;;
mipsel)
testcc "$CC" "$CFLAGS -mno-abicalls -fno-pic" && \
- CFLAGS+=" -mno-abicalls -fno-pic"
+ CFLAGS+=" -mno-abicalls -fno-pic"
;;
esac
}
@@ -171,8 +171,8 @@ AR_${TARCH}:=${GCCPREFIX}ar
EOF
}
-# Architecture definition
-SUPPORTED_ARCHITECTURE="x86 arm arm64 riscv mipsel"
+# Architecture definitions
+SUPPORTED_ARCHITECTURES="arm arm64 mipsel riscv x86"
arch_config_arm() {
TARCH="arm"
@@ -218,7 +218,8 @@ arch_config_mipsel() {
}
test_architecture() {
- architecture=$1
+ local architecture=$1
+ local gccprefix search
GCCPREFIX="invalid"
unset TARCH TBFDARCH TCLIST TWIDTH TSUPP TABI
@@ -244,10 +245,10 @@ test_architecture() {
# Search toolchain by checking assembler capability.
for TBFDARCH in $TBFDARCHS; do
- for gccprefixes in $search ""; do
- program_exists "${gccprefixes}as" || continue
- testas "$gccprefixes" "$TWIDTH" "$TBFDARCH" "" && break
- testas "$gccprefixes" "$TWIDTH" "$TBFDARCH" "TRUE" && break
+ for gccprefix in $search ""; do
+ program_exists "${gccprefix}as" || continue
+ testas "$gccprefix" "$TWIDTH" "$TBFDARCH" "" && break
+ testas "$gccprefix" "$TWIDTH" "$TBFDARCH" "TRUE" && break
done
[ "$GCCPREFIX" = "invalid" ] || break
done
@@ -263,7 +264,6 @@ test_architecture() {
}
# This loops over all supported architectures.
-for architecture in $SUPPORTED_ARCHITECTURE; do
+for architecture in $SUPPORTED_ARCHITECTURES; do
test_architecture $architecture
done
-