From: Sarthak Shah <shahsarthakw@gmail.com>
To: 62551@debbugs.gnu.org
Subject: [bug#62551] Updated patch - with changes, documentation and tests.
Date: Tue, 25 Apr 2023 17:52:10 +0530 [thread overview]
Message-ID: <CADBZEVn1kTD3cMs_Pj9wvEjOE=b2E2bsCqv0f49wHx4P+vjHYA@mail.gmail.com> (raw)
In-Reply-To: <CADBZEVnRLzReTO9+z0kFiwOA97V-_O4O7Bjchsr3Rdbzh0_4Xw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 6616 bytes --]
* doc/guix.texi (--with-configure-flag): Added documentation for
--with-configure-flag
* guix/transformations.scm (transform-package-configure-flag): New
function, changes to %transformations and
show-transformation-options-help/detailed
* tests/transformations.scm (test-equal "options-transformation,
with-configure-flag"): Added a test for --with-configure-flag
---
doc/guix.texi | 19 ++++++++++++++
guix/transformations.scm | 53 +++++++++++++++++++++++++++++++++++++++
tests/transformations.scm | 10 +++++++-
3 files changed, 81 insertions(+), 1 deletion(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index c49e51b72e..627a468b62 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -12859,6 +12859,25 @@ guix build coreutils
--with-patch=glibc=./glibc-frob.patch
In this example, glibc itself as well as everything that leads to
Coreutils in the dependency graph is rebuilt.
+@item --with-configure-flag=@var{package}=@var{configure-flag}
+Add @var{configure-flag} to the list of configure-flags applied to
+the arguments of @var{package}, where @var{package} is a spec such as
+@code{guile@@3.1} or @code{glibc}. The build system of @var{package}
+must support the argument @code{#:configure-flags}.
+
+For example, the command below builds GNU Hello with the
+configure-flag @code{--disable-nls}:
+
+@example
+guix build hello --with-configure-flag=hello=--disable-nls
+@end example
+
+@quotation Warning
+Currently, there is a primitive check for whether the build system
+supports the argument @code{#:configure-flags} or not, however
+users should not rely on it.
+@end quotation
+
@cindex upstream, latest version
@item --with-latest=@var{package}
@itemx --with-version=@var{package}=@var{version}
diff --git a/guix/transformations.scm b/guix/transformations.scm
index 8ff472ad21..27fb0cb646 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -676,6 +676,53 @@ (define rewrite
(rewrite obj)
obj)))
+(define (transform-package-configure-flag specs)
+ "Return a procedure that, when passed a package and a flag, adds the
flag to #:configure-flags in the package's
+'arguments' field."
+ (define (package-with-configure-flag p extra-flag)
+ (package/inherit p
+ (arguments
+ (substitute-keyword-arguments (package-arguments p)
+ ((#:configure-flags list-of-flags (quote '()))
+ #~(cons* #$extra-flag #$list-of-flags))))))
+
+
+ (define %BUILD-SYSTEMS-WITHOUT-CONFIGURE-FLAGS
+ ;; These build systems do not have a #:configure-flags parameter
+'(android-ndk asdf/sbcl asdf/ecl asdf/source cargo channel chicken clojure
copy dub dune elm emacs go guile julia linux-module maven minetest-mod
minify node perl rakudo rebar ruby scons texlive tree-sitter trivial))
+
+ (define (build-system-supports-flags? spec)
+ ;; XXX: a more sophisticated approach could be added that checks the
given build system for a configure-flags option
+ ;; if a new build system is added, it needs to be added to the
%BUILD-SYSTEMS-WITHOUT-CONFIGURE-FLAGS list manually
+ (not (member (build-system-name (package-build-system spec))
+ %BUILD-SYSTEMS-WITHOUT-CONFIGURE-FLAGS)))
+
+ (define cflags
+ ;; Spec/flag alist.
+ (map (lambda (spec)
+ (match (string-tokenize spec %not-equal)
+ ((spec flag)
+ (cons spec flag))
+ (_
+ (raise (formatted-message
+ (G_ "~a: invalid package configure-flags
specification")
+ spec)))))
+ specs))
+
+ (define rewrite
+ (package-input-rewriting/spec
+ (map (match-lambda
+ ((spec . flags)
+ (cons spec (cut package-with-configure-flag <> flags))))
+ cflags)))
+
+ (lambda (obj)
+ (if (and
+ (package? obj)
+ (build-system-supports-flags? obj))
+ (rewrite obj)
+ obj)))
+
(define (patched-source name source patches)
"Return a file-like object with the given NAME that applies PATCHES to
SOURCE. SOURCE must itself be a file-like object of any type, including
@@ -845,6 +892,7 @@ (define %transformations
(tune . ,transform-package-tuning)
(with-debug-info . ,transform-package-with-debug-info)
(without-tests . ,transform-package-tests)
+ (with-configure-flag . ,transform-package-configure-flag)
(with-patch . ,transform-package-patches)
(with-latest . ,transform-package-latest)
(with-version . ,transform-package-version)))
@@ -915,6 +963,8 @@ (define micro-architecture
(parser 'with-debug-info))
(option '("without-tests") #t #f
(parser 'without-tests))
+ (option '("with-configure-flag") #t #f
+ (parser 'with-configure-flag))
(option '("with-patch") #t #f
(parser 'with-patch))
(option '("with-latest") #t #f
@@ -952,6 +1002,9 @@ (define (show-transformation-options-help/detailed)
(display (G_ "
--with-patch=PACKAGE=FILE
add FILE to the list of patches of PACKAGE"))
+ (display (G_ "
+ --with-configure-flag=PACKAGE=FLAG
+ add FLAG to the list of #:configure-flags of
PACKAGE"))
(display (G_ "
--with-latest=PACKAGE
use the latest upstream release of PACKAGE"))
diff --git a/tests/transformations.scm b/tests/transformations.scm
index 1fa2c0bba8..31fd042d31 100644
--- a/tests/transformations.scm
+++ b/tests/transformations.scm
@@ -33,7 +33,7 @@ (define-module (test-transformations)
#:use-module ((guix gexp)
#:select (local-file? local-file-file
computed-file? computed-file-gexp
- gexp-input-thing))
+ gexp-input-thing gexp->approximate-sexp))
#:use-module (guix ui)
#:use-module (guix utils)
#:use-module (guix git)
@@ -408,6 +408,14 @@ (define (package-name* obj)
(package-full-name grep))
(package-arguments (package-replacement dep0))))))))
+(test-equal "options->transformation, with-configure-flag"
+ '(cons* "--flag" '())
+ (let* ((p (dummy-package "foo"
+ (build-system gnu-build-system)))
+ (t (options->transformation '((with-configure-flag .
"foo=--flag")))))
+ (let ((new (t p)))
+ (gexp->approximate-sexp (cadr (memq #:configure-flags
(package-arguments new)))))))
+
(test-assert "options->transformation, without-tests"
(let* ((dep (dummy-package "dep"))
(p (dummy-package "foo"
--
2.40.0
[-- Attachment #2: Type: text/html, Size: 7884 bytes --]
next prev parent reply other threads:[~2023-04-25 12:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 19:52 [bug#62551] Added new transformation option: --with-configure-flag Sarthak Shah
2023-03-30 19:56 ` [bug#62551] (updated with changelog formatting) Sarthak Shah
2023-03-31 12:34 ` [bug#62551] Added new transformation option: --with-configure-flag Ludovic Courtès
2023-04-01 0:17 ` Sarthak Shah
2023-04-25 12:22 ` Sarthak Shah [this message]
2023-05-04 14:25 ` Ludovic Courtès
2023-05-05 11:59 ` pelzflorian (Florian Pelz)
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
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CADBZEVn1kTD3cMs_Pj9wvEjOE=b2E2bsCqv0f49wHx4P+vjHYA@mail.gmail.com' \
--to=shahsarthakw@gmail.com \
--cc=62551@debbugs.gnu.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.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).