From patchwork Thu May 4 14:25:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 49795 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 1824C27BBEA; Thu, 4 May 2023 15:29:28 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id AA4A627BBE9 for ; Thu, 4 May 2023 15:29:25 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1puZxK-000646-3t; Thu, 04 May 2023 10:29:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1puZuF-0005aq-R9 for guix-patches@gnu.org; Thu, 04 May 2023 10:26:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1puZuF-0004Ur-JG for guix-patches@gnu.org; Thu, 04 May 2023 10:26:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1puZuF-0000HR-Ev for guix-patches@gnu.org; Thu, 04 May 2023 10:26:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62551] Added new transformation option: --with-configure-flag Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 04 May 2023 14:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62551 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Sarthak Shah Cc: 62551@debbugs.gnu.org Received: via spool by 62551-submit@debbugs.gnu.org id=B62551.16832103611051 (code B ref 62551); Thu, 04 May 2023 14:26:03 +0000 Received: (at 62551) by debbugs.gnu.org; 4 May 2023 14:26:01 +0000 Received: from localhost ([127.0.0.1]:51648 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puZuC-0000Gt-L0 for submit@debbugs.gnu.org; Thu, 04 May 2023 10:26:01 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:6075) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1puZu9-0000GW-GD for 62551@debbugs.gnu.org; Thu, 04 May 2023 10:25:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inria.fr; s=dc; h=from:to:cc:subject:references:date:in-reply-to: message-id:mime-version; bh=LNN/nECRn1DL3EN40fyk/w/3p3hU61LCX3B8bO7Jdc8=; b=cthFjw1rWasAbkbfcf51zzK3xt0MoszoZ+R/OATyJ/DSTOt+SsRzp0jW n0RRxnM50j/541unicHpxfkVBpHfsNQAUPLkcfuhwKu9Eb+gyw0ef9Iil PsgygaMzAMJhEvCACEQkxL70faiouXY2ubfLOkmNYyNCrtmoJrOOOVcZl Q=; Authentication-Results: mail3-relais-sop.national.inria.fr; dkim=none (message not signed) header.i=none; spf=SoftFail smtp.mailfrom=ludovic.courtes@inria.fr; dmarc=fail (p=none dis=none) d=inria.fr X-IronPort-AV: E=Sophos;i="5.99,249,1677538800"; d="scan'208";a="55126644" Received: from 91-160-117-201.subs.proxad.net (HELO ribbon) ([91.160.117.201]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 May 2023 16:25:51 +0200 From: Ludovic =?utf-8?q?Court=C3=A8s?= References: Date: Thu, 04 May 2023 16:25:49 +0200 In-Reply-To: (Sarthak Shah's message of "Tue, 25 Apr 2023 17:52:10 +0530") Message-ID: <87y1m4p40i.fsf_-_@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Hi Sarthak, Sarthak Shah skribis: > * 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 Nice! I made the superficial changes below, which can be summarized like this: • Allow for equal signs in the configure flag itself. • Remove build system check: we don’t do that for the other options; instead, document the limitation and leave it up to the user. • Tweak the style of the system test to avoid ‘cadr’ (info "(guix) Data Types and Pattern Matching"). • Add a CMake example in the manual and tweak wording. I’ll follow up with a news entry so people who run ‘guix pull’ can learn about the new option. Great work, thank you! Ludo’. diff --git a/doc/guix.texi b/doc/guix.texi index ff0e62053b..55221a10c3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -12919,23 +12919,33 @@ Package Transformation Options 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}. +@cindex configure flags, changing them +@item --with-configure-flag=@var{package}=@var{flag} +Append @var{flag} to the configure flags of @var{package}, where +@var{package} is a spec such as @code{guile@@3.0} or @code{glibc}. The +build system of @var{package} must support the @code{#:configure-flags} +argument. -For example, the command below builds GNU Hello with the -configure-flag @code{--disable-nls}: +For example, the command below builds GNU@tie{}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. +The following command passes an extra flag to @command{cmake} as it +builds @code{lapack}: + +@example +guix build lapack \ + --with-configure-flag=lapack=-DBUILD_COMPLEX=OFF +@end example + +@quotation Note +Under the hood, this option works by passing the +@samp{#:configure-flags} argument to the build system of the package of +interest (@pxref{Build Systems}). Most build systems support that +option but some do not. In that case, an error is raised. @end quotation @cindex upstream, latest version diff --git a/guix/transformations.scm b/guix/transformations.scm index 9cbac5df9e..943b2768c6 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -677,49 +677,42 @@ (define (transform-package-tests specs) 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." + "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)))))) + ((#:configure-flags flags #~'()) + ;; Add EXTRA-FLAG to the end so it can potentially override FLAGS. + #~(append #$flags '(#$extra-flag))))))) - - (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 + (define configure-flags ;; 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)) + (map (lambda (spec) + ;; Split SPEC on the first equal sign (the configure flag might + ;; contain equal signs, as in '-DINTSIZE=32'). + (let ((equal (string-index spec #\=))) + (match (and equal + (list (string-take spec equal) + (string-drop spec (+ 1 equal)))) + ((spec flag) + (cons spec flag)) + (_ + (raise (formatted-message + (G_ "~a: invalid package configure flag specification") + spec)))))) + specs)) (define rewrite (package-input-rewriting/spec (map (match-lambda ((spec . flags) (cons spec (cut package-with-configure-flag <> flags)))) - cflags))) + configure-flags))) (lambda (obj) - (if (and - (package? obj) - (build-system-supports-flags? obj)) + (if (package? obj) (rewrite obj) obj))) @@ -1004,7 +997,7 @@ (define (show-transformation-options-help/detailed) 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")) + append FLAG to the 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 31fd042d31..704818b9ed 100644 --- a/tests/transformations.scm +++ b/tests/transformations.scm @@ -409,12 +409,15 @@ (define* (depends-on-toolchain? p #:optional (toolchain "gcc-toolchain")) (package-arguments (package-replacement dep0)))))))) (test-equal "options->transformation, with-configure-flag" - '(cons* "--flag" '()) + '(append '() '("--flag=42")) (let* ((p (dummy-package "foo" (build-system gnu-build-system))) - (t (options->transformation '((with-configure-flag . "foo=--flag"))))) + (t (options->transformation + '((with-configure-flag . "foo=--flag=42"))))) (let ((new (t p))) - (gexp->approximate-sexp (cadr (memq #:configure-flags (package-arguments new))))))) + (match (package-arguments new) + ((#:configure-flags flags) + (gexp->approximate-sexp flags)))))) (test-assert "options->transformation, without-tests" (let* ((dep (dummy-package "dep"))