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>
This commit is contained in:
Vadim Bendebury 2015-04-25 13:15:58 -07:00
parent e469602461
commit d2cb1f93fb
1 changed files with 14 additions and 14 deletions

View File

@ -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=""
@ -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