Merge pull request #4054 from MilhouseVH/le10_fix_flag_enabled_var

flag_enabled(): declare is local by default - remove it
This commit is contained in:
Sascha Kühndel 2019-12-13 13:50:28 +01:00 committed by GitHub
commit ebaff1375f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -148,29 +148,20 @@ safe_remove() {
### BUILDSYSTEM HELPERS ###
# check if a flag is enabled
# $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
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
if [ -n "${PKG_BUILD_FLAGS}" ] && listcontains "${PKG_BUILD_FLAGS}" "[+]?$1"; then
if [ "${3:none}" = "only-disable" ]; then
die "ERROR: $1 cannot enable via PKG_BUILD_FLAGS (found in $PKG_NAME)"
fi
declare ${flag_name}="yes"
return 0
elif [ "$2" = "yes" ] && ! listcontains "${PKG_BUILD_FLAGS}" "-$1"; then
declare ${flag_name}="yes"
return 0
else
if [ "${3:none}" = "only-enable" ]; then
die "ERROR: $1 cannot disable via PKG_BUILD_FLAGS (found in $PKG_NAME)"
fi
declare ${flag_name}="no"
return 1
fi
}