Github messages for voidlinux
 help / color / mirror / Atom feed
From: cinerea0 <cinerea0@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] xbps-src: new vopt_feat helper
Date: Tue, 04 Jul 2023 04:30:44 +0200	[thread overview]
Message-ID: <20230704023044.dN9F7bDlWC7SpVPQibbZfMUtWZ0wu-NGpmcqi89PkEo@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-44663@inbox.vuxu.org>

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

There is an updated 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: 1469 bytes --]

From fe51e16418ea1013617e880b94acba7ec268e71e Mon Sep 17 00:00:00 2001
From: cinerea0 <cinerea0@disroot.org>
Date: Mon, 3 Jul 2023 22:30:27 -0400
Subject: [PATCH] xbps-src: new vopt_feature helper

---
 Manual.md                           | 5 +++++
 common/environment/setup/options.sh | 8 ++++++++
 2 files changed, 13 insertions(+)

diff --git a/Manual.md b/Manual.md
index 63f10f354582..5a183e6c3d18 100644
--- a/Manual.md
+++ b/Manual.md
@@ -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:
 
diff --git a/common/environment/setup/options.sh b/common/environment/setup/options.sh
index 83e0f9420f9e..f75430b82cd8 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_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"
+}

  parent reply	other threads:[~2023-07-04  2:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 16:07 [PR PATCH] " cinerea0
2023-07-01 21:57 ` Chocimier
2023-07-02 18:17 ` eli-schwartz
2023-07-04  2:30 ` cinerea0 [this message]
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=20230704023044.dN9F7bDlWC7SpVPQibbZfMUtWZ0wu-NGpmcqi89PkEo@z \
    --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).