xbps-src: new vopt_feature helper

This commit is contained in:
cinerea0 2023-07-03 22:30:27 -04:00 committed by Chocimier
parent 65435ab244
commit 5bb9d7c856
2 changed files with 13 additions and 0 deletions

View File

@ -1204,6 +1204,11 @@ package accordingly. Additionally, the following functions are available:
Outputs `-D<property>=true` if the option is set, or
`-D<property>=false` otherwise.
- *vopt_feature()* `vopt_feature <option> <property>`
Same as `vopt_bool`, but uses `-D<property=enabled` and
`-D<property>=disabled` respectively.
The following example shows how to change a source package that uses GNU
configure to enable a new build option to support PNG images:

View File

@ -36,3 +36,11 @@ vopt_bool() {
fi
vopt_if "$1" "-D${prop}=true" "-D${prop}=false"
}
vopt_feature() {
local opt="$1" prop="${2:-$1}"
if [ "$#" -gt "2" ]; then
msg_error "vopt_feature $opt: $(($# - 2)) excess parameter(s)\n"
fi
vopt_if "$1" "-D${prop}=enabled" "-D${prop}=disabled"
}