flag_enabled(): declare is local by default - remove it

This commit is contained in:
MilhouseVH 2019-12-12 03:06:40 +00:00
parent d0f5bf579c
commit 8a7a9f3efe

View File

@ -148,29 +148,20 @@ safe_remove() {
### BUILDSYSTEM HELPERS ### ### BUILDSYSTEM HELPERS ###
# check if a flag is enabled # check if a flag is enabled
# $1: flag-name, $2: default (yes/no), $3: ingenious check (none,only-disable,only-enable) # $1: flag-name, $2: default (yes/no), $3: ingenious check (none,only-disable,only-enable)
# set variable PKG_[FLAG]_[HOST/TARGET]_ENABLED=(yes/no)
# return 0 if flag is enabled, otherwise 1 # return 0 if flag is enabled, otherwise 1
flag_enabled() { flag_enabled() {
# make flag name upper case and replace hyphen with underscore, to use as variable name
local flag_name=${1^^}
[[ $flag_name =~ : ]] || flag_name+="_TARGET"
flag_name="PKG_${flag_name//[:-]/_}_ENABLED"
# check flag # check flag
if [ -n "${PKG_BUILD_FLAGS}" ] && listcontains "${PKG_BUILD_FLAGS}" "[+]?$1"; then if [ -n "${PKG_BUILD_FLAGS}" ] && listcontains "${PKG_BUILD_FLAGS}" "[+]?$1"; then
if [ "${3:none}" = "only-disable" ]; then if [ "${3:none}" = "only-disable" ]; then
die "ERROR: $1 cannot enable via PKG_BUILD_FLAGS (found in $PKG_NAME)" die "ERROR: $1 cannot enable via PKG_BUILD_FLAGS (found in $PKG_NAME)"
fi fi
declare ${flag_name}="yes"
return 0 return 0
elif [ "$2" = "yes" ] && ! listcontains "${PKG_BUILD_FLAGS}" "-$1"; then elif [ "$2" = "yes" ] && ! listcontains "${PKG_BUILD_FLAGS}" "-$1"; then
declare ${flag_name}="yes"
return 0 return 0
else else
if [ "${3:none}" = "only-enable" ]; then if [ "${3:none}" = "only-enable" ]; then
die "ERROR: $1 cannot disable via PKG_BUILD_FLAGS (found in $PKG_NAME)" die "ERROR: $1 cannot disable via PKG_BUILD_FLAGS (found in $PKG_NAME)"
fi fi
declare ${flag_name}="no"
return 1 return 1
fi fi
} }