From patchwork Thu Mar 30 19:56:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sarthak Shah X-Patchwork-Id: 48825 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 1E8DD1723F; Thu, 30 Mar 2023 20:58:21 +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=-1.8 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS autolearn=ham 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 AAE8E171ED for ; Thu, 30 Mar 2023 20:58:19 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1phyPN-00059x-8V; Thu, 30 Mar 2023 15:58:05 -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 1phyPL-00059K-7H for guix-patches@gnu.org; Thu, 30 Mar 2023 15:58:04 -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 1phyPK-0001ha-VQ for guix-patches@gnu.org; Thu, 30 Mar 2023 15:58:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1phyPK-0003a3-Ca for guix-patches@gnu.org; Thu, 30 Mar 2023 15:58:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#62551] (updated with changelog formatting) References: In-Reply-To: Resent-From: Sarthak Shah Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 30 Mar 2023 19:58:02 +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: To: 62551@debbugs.gnu.org Received: via spool by 62551-submit@debbugs.gnu.org id=B62551.168020622313685 (code B ref 62551); Thu, 30 Mar 2023 19:58:02 +0000 Received: (at 62551) by debbugs.gnu.org; 30 Mar 2023 19:57:03 +0000 Received: from localhost ([127.0.0.1]:59476 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phyON-0003Yd-7h for submit@debbugs.gnu.org; Thu, 30 Mar 2023 15:57:03 -0400 Received: from mail-qt1-f182.google.com ([209.85.160.182]:36703) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1phyOK-0003Y5-No for 62551@debbugs.gnu.org; Thu, 30 Mar 2023 15:57:01 -0400 Received: by mail-qt1-f182.google.com with SMTP id hf2so19666046qtb.3 for <62551@debbugs.gnu.org>; Thu, 30 Mar 2023 12:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1680206215; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=DWIuX/3AB9if/x3TrjURV8zTwa8m+w1T63ibpt6o0lA=; b=qc+V+6CnVgSRNqf7rHWGMlT1X2v63FuUyP7abD0gjSTY0nX0F8R7axRVtjnBoTtW+2 3SaNh6x3eMgpqqBFyqWVTXdo8sTyx38yymjdb0yg57k+i8MyXvcc0x2BNOg+R7ALffno BOJmUvkX4kITZ1p91Wk/YcIooMXzKCtoOc0/rjGCXjufH9Wf+8ffsvYGwdzxZMON0c55 mGQ5a7OhhicSn+/h1yYaAFg6SCSNU7HhUy1WRC8BTJtEzCyFHcVPti+C3ptmdDPu187e Onyy9OArNR+uUe+K3v4joUh7RW8BPogGcs/SVW5I4c48DnFFAmMdjlMo6Pz5EDByaIjt 7vbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680206215; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=DWIuX/3AB9if/x3TrjURV8zTwa8m+w1T63ibpt6o0lA=; b=e88bmbSLALgALXlfR8OtP4254/Ma3mXXDz2cPM3LkEsKoUQjsUnfTjKig+34YDPQcT ovEOdn+56wr5OLzRruAbzzjiOSZsaUfjizBvcCf4ZfY0rjZcJ183qcq0sVE7fGMjBqUW umI59PMYJqfJydG1pZYDefuE0mkvkyPUqvwXqpGdb8VbsfzXdo2qXgBcag+96kyL4Njh vcZudB7+Vn1r/Fvh9maIyO7AlpTumyxbCnEMLMomlIRchKg2jbdkkHAbYPddLEnrUkIa +nYmKWhL+WOY661ld3Ez+5+yZrkGeEmxpMzE1UNQp5vnQBnGX22iZH4TpkI24KL+lswf 1iTg== X-Gm-Message-State: AO0yUKUpeMgRHBmkGi9lMIni9gkRK1LrPPC8wnwpqxlI132hot5JSi5D PFlRlzP++WNUWgvCNAteUdWFjcUz0NE90n/AdrFdUmxUBYMv+g== X-Google-Smtp-Source: AK7set/xUrbxt3X9wdiU2bUqQxOZ3yOWkHErig7agg7f2Y1fOm14TJFRN5+mIooZQYcJdsCJn5/AljPn0kHBTOHiCRA= X-Received: by 2002:a05:622a:1823:b0:3d8:c6c1:2925 with SMTP id t35-20020a05622a182300b003d8c6c12925mr8766768qtc.10.1680206214885; Thu, 30 Mar 2023 12:56:54 -0700 (PDT) MIME-Version: 1.0 From: Sarthak Shah Date: Fri, 31 Mar 2023 01:26:43 +0530 Message-ID: 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 * guix/transformations.scm (transform-package-configure-flag): New function, changes to %transformations and show-transformation-options-help/detailed --- guix/transformations.scm | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) + (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 +909,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 +980,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 +1019,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/guix/transformations.scm b/guix/transformations.scm index 8ff472ad21..8f260807dc 100644 --- a/guix/transformations.scm +++ b/guix/transformations.scm @@ -676,6 +676,70 @@ (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 '())) + ;; here extra-flag takes the form (--extra-flag) + ;; hence it must be spliced to avoid eval errors + `(cons* ,@extra-flag ,list-of-flags)))))) + + (define (coalesce-alist alist) + ;; Coalesce multiple occurrences of the same key in ALIST. + (let loop ((alist alist) + (keys '()) + (mapping vlist-null)) + (match alist + (() + (map (lambda (key) + (cons key (vhash-fold* cons '() key mapping))) + (delete-duplicates (reverse keys)))) + (((key . value) . rest) + (loop rest + (cons key keys) + (vhash-cons key value mapping)))))) + + (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. + (coalesce-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))