Github messages for voidlinux
 help / color / mirror / Atom feed
From: cinerea0 <cinerea0@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] xbps-src: new vopt_feat helper
Date: Tue, 27 Jun 2023 18:07:59 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-44663@inbox.vuxu.org> (raw)

[-- 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:
 

             reply	other threads:[~2023-06-27 16:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 16:07 cinerea0 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-44663@inbox.vuxu.org \
    --to=cinerea0@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).