Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] xbps-src: new vopt_feat helper
@ 2023-06-27 16:07 cinerea0
  2023-07-01 21:57 ` Chocimier
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: cinerea0 @ 2023-06-27 16:07 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 921 bytes --]

There is a new pull request by cinerea0 against master on the void-packages repository

https://github.com/cinerea0/void-packages vopt_feat
https://github.com/void-linux/void-packages/pull/44663

xbps-src: new vopt_feat helper
#### Testing the changes
- I tested the changes in this PR: **briefly**

I didn't check this against every template where the pattern appears, but it works in the test cases I tried.

---

This helper function reduces boilerplate for [Meson's "feature" build options](https://mesonbuild.com/Build-options.html#features). Right now these are handled using the pattern `-D<property>=$(vopt_if <option> enabled disabled)`, which occurs 78 times in our templates.

Note that this does *not* allow you to set the property to "auto", but I can't think of any situation where that would be desirable.

A patch file from https://github.com/void-linux/void-packages/pull/44663.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-vopt_feat-44663.patch --]
[-- Type: text/x-diff, Size: 1751 bytes --]

From 388c51caf1dcfccfdda76a06b468841570a42131 Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Tue, 27 Jun 2023 11:05:28 -0400
Subject: [PATCH 1/2] xbps-src: new vopt_feat helper

Meson helper function like vopt_bool to reduce boilerplate for
"feature" options
---
 common/environment/setup/options.sh | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/common/environment/setup/options.sh b/common/environment/setup/options.sh
index 83e0f9420f9e..95293e222fa2 100644
--- a/common/environment/setup/options.sh
+++ b/common/environment/setup/options.sh
@@ -36,3 +36,11 @@ vopt_bool() {
     fi
     vopt_if "$1" "-D${prop}=true" "-D${prop}=false"
 }
+
+vopt_feat() {
+    local opt="$1" prop="${2:-$1}"
+    if [ "$#" -gt "2" ]; then
+        msg_error "vopt_feat $opt: $(($# - 2)) excess parameter(s)\n"
+    fi
+    vopt_if "$1" "-D${prop}=enabled" "-D${prop}=disabled"
+}

From be92a5a460904a30d53b674522f8f5d23c38de0c Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Tue, 27 Jun 2023 12:06:17 -0400
Subject: [PATCH 2/2] Manual.md: document vopt_feat

---
 Manual.md | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Manual.md b/Manual.md
index 1670863cbe54..bbd8d023ff59 100644
--- a/Manual.md
+++ b/Manual.md
@@ -1158,6 +1158,11 @@ package accordingly. Additionally, the following functions are available:
   Outputs `-D<property>=true` if the option is set, or
   `-D<property>=false` otherwise.
 
+- *vopt_feat()* `vopt_feat <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:
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-07-26 20:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-27 16:07 [PR PATCH] xbps-src: new vopt_feat helper cinerea0
2023-07-01 21:57 ` Chocimier
2023-07-02 18:17 ` eli-schwartz
2023-07-04  2:30 ` [PR PATCH] [Updated] " cinerea0
2023-07-04  2:31 ` cinerea0
2023-07-04  2:40 ` eli-schwartz
2023-07-04  2:40 ` eli-schwartz
2023-07-26 18:31 ` [PR PATCH] [Merged]: xbps-src: new vopt_feature helper Chocimier
2023-07-26 18:32 ` Chocimier
2023-07-26 20:38 ` cinerea0

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).