From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id qPqtE4CMSWdktgAA62LTzQ:P1 (envelope-from ) for ; Fri, 29 Nov 2024 09:42:24 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1.migadu.com with LMTPS id qPqtE4CMSWdktgAA62LTzQ (envelope-from ) for ; Fri, 29 Nov 2024 10:42:24 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b="v5B/Ogf3"; dkim=fail ("headers rsa verify failed") header.d=gnu.org header.s=fencepost-gnu-org header.b=KVu5mgcO; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 889E0769A6 for ; Fri, 29 Nov 2024 10:42:22 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tGxVo-0000fQ-EJ; Fri, 29 Nov 2024 04:42:08 -0500 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 1tGxVk-0000eI-B3 for guix-patches@gnu.org; Fri, 29 Nov 2024 04:42:05 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tGxVi-0004Wa-W2; Fri, 29 Nov 2024 04:42:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=dULSCUZc1r+OkxdLxcmQkLYesS85XPTzlxIrCobO7+A=; b=v5B/Ogf33NfLDWix+Vp+OG0I2teiqkfmb5NGSnBSz+flfJLXXLv0DXOrnL7pxXm1bPqHqZdyWpyRVk8/ag/zKSuuE3VunW64w9YNKyV4dpM6VL9rlyVw52+HZD7GvDtTE197ALqpRQEcjKOrOt6vw0XCTBIWCacoZ0/pcXQmP1JEAfTYZEhUbZDEYnjwZIBIJKcJFaNYosVcKnHhnBLXrSFv+FPYWbd7JIbCLUNgBFtCg7wEz52dqtJfz+h4G1up+LhVgpd7QBa4+I+0jH5ji0FYZxj2AtpnPi9Iion0mkNFJNITYj/tbdLky0Mn55C/fK9yX5w6N0kL6j1nYbGQ3g==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tGxVi-0005w8-P6; Fri, 29 Nov 2024 04:42:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74542] [PATCH v2 04/16] guix build: Add =?UTF-8?Q?=E2=80=98--development=E2=80=99?= option. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, maxim.cournoyer@gmail.com, zimon.toutoune@gmail.com, me@tobias.gr, guix-patches@gnu.org Resent-Date: Fri, 29 Nov 2024 09:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74542 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74542@debbugs.gnu.org Cc: Ludovic =?UTF-8?Q?Court=C3=A8s?= , Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice X-Debbugs-Original-Xcc: Christopher Baines , Josselin Poiret , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Mathieu Othacehe , Maxim Cournoyer , Simon Tournier , Tobias Geerinckx-Rice Received: via spool by 74542-submit@debbugs.gnu.org id=B74542.173287326722583 (code B ref 74542); Fri, 29 Nov 2024 09:42:02 +0000 Received: (at 74542) by debbugs.gnu.org; 29 Nov 2024 09:41:07 +0000 Received: from localhost ([127.0.0.1]:41035 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGxUm-0005rr-RL for submit@debbugs.gnu.org; Fri, 29 Nov 2024 04:41:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39582) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tGxUd-0005pc-6x for 74542@debbugs.gnu.org; Fri, 29 Nov 2024 04:40:56 -0500 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tGxUW-0003nb-1B; Fri, 29 Nov 2024 04:40:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=dULSCUZc1r+OkxdLxcmQkLYesS85XPTzlxIrCobO7+A=; b=KVu5mgcOmjQ4kNK9vSHB t+hhTFgjNRQ4lQSaJBgC8ntNlBndajbmP1IBeKMHBE0XGHkt0jNGe12nkh23MCdfHaBsDsuBPE7o5 9owdLlDLCtWI0CDX38CCd4NbJkpxmjJ8eoMwvamDzaf2yOiBSPPlVgX/MDleyOCtQScpjeNfD7l1/ 0N5b97RZ4uM6IdOnlAedTaDFk2CBw1cVJg8dpR3XGvbnJbXtVfxFFAbCd8zRapW0NrN9LbsQX4VZm M0J2fDob27FEgMGMtFbsG6Ta5rtCM5wmksLqMAYnAlMrzjWIZX3YPp5nFjlPFxWXhEYeCJup5XrtV 7VSo6oQodwKsUA==; From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Date: Fri, 29 Nov 2024 10:40:07 +0100 Message-ID: <298ce743d6908424e59c348444fa4d904935646d.1732872498.git.ludo@gnu.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -4.81 X-Spam-Score: -4.81 X-Migadu-Queue-Id: 889E0769A6 X-Migadu-Scanner: mx10.migadu.com X-TUID: Ux4TSPcUSprA * guix/scripts/build.scm (show-help, %options): Add ‘-D’. (options->things-to-build): Change ‘append-map’ to a loop. Honor ‘-D’. * tests/guix-build.sh: Add test. * doc/guix.texi (Additional Build Options): Document it. Change-Id: I99227aadfe861e43c001a4872292bd687b37f5d4 --- doc/guix.texi | 25 +++++++++ guix/scripts/build.scm | 119 ++++++++++++++++++++++++++++------------- tests/guix-build.sh | 5 ++ 3 files changed, 112 insertions(+), 37 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 26488b41c8..a9d0d044ae 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13614,6 +13614,31 @@ Additional Build Options (@pxref{The Store Monad}). The procedure must return a derivation as a monadic value, which is then passed through @code{run-with-store}. +@item --development +@itemx -D +Build the ``development environment'' (build dependencies) of the +following package. + +For example, the following command builds the inputs of @code{hello}, +but @emph{not} @code{hello} itself, and also builds @code{guile}: + +@example +guix build -D hello guile +@end example + +Notice that @option{-D} (or @option{--development}) only applies to the +immediately following package on the command line. Under the hood, it +uses @code{package->development-manifest} +(@pxref{package-development-manifest, +@code{package->development-manifest}}). + +@quotation Note +The effect of combining @option{--development} with @option{--target} +(for cross-compilation) may not be what you expect: it will +cross-compile all the dependencies of the given package when it is built +natively. +@end quotation + @item --source @itemx -S Build the source derivations of the packages, rather than the packages diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 9e05bb532b..e8384c8d2d 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -438,6 +438,8 @@ (define (show-help) -m, --manifest=FILE build the packages that the manifest given in FILE evaluates to")) (display (G_ " + -D, --development build the inputs of the following package")) + (display (G_ " -S, --source build the packages' source derivations")) (display (G_ " --sources[=TYPE] build source derivations; TYPE may optionally be one @@ -522,6 +524,9 @@ (define %options (option '(#\m "manifest") #t #f (lambda (opt name arg result) (alist-cons 'manifest arg result))) + (option '(#\D "development") #f #f + (lambda (opt name arg result) + (alist-cons 'development? #t result))) (option '(#\n "dry-run") #f #f (lambda (opt name arg result) (alist-cons 'dry-run? #t result))) @@ -581,43 +586,83 @@ (define-public my-package (for-each validate-type lst) lst)) - (append-map (match-lambda - (('argument . (? string? spec)) - (cond ((derivation-path? spec) - (catch 'system-error - (lambda () - ;; Ask for absolute file names so that .drv file - ;; names passed from the user to 'read-derivation' - ;; are absolute when it returns. - (let ((spec (canonicalize-path spec))) - (list (read-derivation-from-file spec)))) - (lambda args - ;; Non-existent .drv files can be substituted down - ;; the road, so don't error out. - (if (= ENOENT (system-error-errno args)) - '() - (apply throw args))))) - ((store-path? spec) - ;; Nothing to do; maybe for --log-file. - '()) - (else - (list (specification->package spec))))) - (('file . file) - (let ((file (or (and (string-suffix? ".json" file) - (json->scheme-file file)) - file))) - (ensure-list (load* file (make-user-module '()))))) - (('manifest . manifest) - (map manifest-entry-item - (manifest-entries - (load* manifest - (make-user-module '((guix profiles) (gnu))))))) - (('expression . str) - (ensure-list (read/eval str))) - (('argument . (? derivation? drv)) - drv) - (_ '())) - opts)) + (define system + (or (assoc-ref opts 'system) (%current-system))) + + ;; Process OPTS in "the right order", meaning that if the user typed + ;; "-D hello", arrange to see the 'development? option before the "hello" + ;; spec. + (let loop ((opts (reverse opts)) + (type 'regular) + (result '())) + (define (for-type obj) + ;; Return a list of objects corresponding to OBJ adjusted for TYPE. + (match type + ('regular + (list obj)) + ('development + (if (package? obj) + (map manifest-entry-item + (manifest-entries + (package->development-manifest obj system))) + obj)))) + + (match opts + (() + (reverse result)) + ((head . tail) + (match head + (('argument . (? string? spec)) + (cond ((derivation-path? spec) + (catch 'system-error + (lambda () + ;; Ask for absolute file names so that .drv file + ;; names passed from the user to 'read-derivation' + ;; are absolute when it returns. + (let ((spec (canonicalize-path spec))) + (loop tail 'regular + (cons (read-derivation-from-file spec) + result)))) + (lambda args + ;; Non-existent .drv files can be substituted down + ;; the road, so don't error out. + (if (= ENOENT (system-error-errno args)) + (loop tail 'regular result) + (apply throw args))))) + ((store-path? spec) + ;; Nothing to do; maybe for --log-file. + (loop tail type result)) + (else + (loop tail 'regular + (append (for-type (specification->package spec)) + result))))) + (('argument . (? derivation? drv)) + (loop tail 'regular (cons drv result))) + (('file . file) + (let ((file (or (and (string-suffix? ".json" file) + (json->scheme-file file)) + file))) + (loop tail 'regular + (append (append-map + for-type + (ensure-list (load* file (make-user-module '())))) + result)))) + (('manifest . manifest) + (loop tail 'regular + (append (map manifest-entry-item + (manifest-entries + (load* manifest + (make-user-module '((guix profiles) + (gnu)))))) + result))) + (('expression . str) + (loop tail 'regular + (append (append-map for-type (ensure-list (read/eval str))) + result))) + (('development? . #t) + (loop tail 'development result)) + (_ + (loop tail type result))))))) (define (options->derivations store opts) "Given OPTS, the result of 'args-fold', return a list of derivations to diff --git a/tests/guix-build.sh b/tests/guix-build.sh index 36eac2b7e0..3637bcdeb3 100644 --- a/tests/guix-build.sh +++ b/tests/guix-build.sh @@ -190,6 +190,11 @@ test `guix build -d --sources=transitive foo \ | grep -e 'foo\.tar\.gz' -e 'bar\.tar\.gz' -e 'bar\.dat' \ | wc -l` -eq 3 +# Building the inputs. +guix build -D hello -n +test `guix build -D hello -d \ + | grep -e 'glibc.*\.drv$' -e 'gcc.*\.drv$' -e 'binutils.*\.drv$' \ + | wc -l` -ge 3 # Unbound variable in thunked field. cat > "$module_dir/foo.scm" <