From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KMVaK+DHbV8GMgAA0tVLHw (envelope-from ) for ; Fri, 25 Sep 2020 10:35:12 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oOk/J+DHbV8aQwAA1q6Kng (envelope-from ) for ; Fri, 25 Sep 2020 10:35:12 +0000 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 23E979402AD for ; Fri, 25 Sep 2020 10:35:12 +0000 (UTC) Received: from localhost ([::1]:59258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLl4J-0003jY-3j for larch@yhetil.org; Fri, 25 Sep 2020 06:35:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kLl4A-0003eo-N4 for guix-patches@gnu.org; Fri, 25 Sep 2020 06:35:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:59471) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kLl4A-000199-Cp for guix-patches@gnu.org; Fri, 25 Sep 2020 06:35:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kLl4A-0006Te-Ag for guix-patches@gnu.org; Fri, 25 Sep 2020 06:35:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#42338] [PATCH 03/34] guix: Add composer-build-system. Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 25 Sep 2020 10:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 42338 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Julien Lepiller Cc: 42338@debbugs.gnu.org Received: via spool by 42338-submit@debbugs.gnu.org id=B42338.160103005324827 (code B ref 42338); Fri, 25 Sep 2020 10:35:02 +0000 Received: (at 42338) by debbugs.gnu.org; 25 Sep 2020 10:34:13 +0000 Received: from localhost ([127.0.0.1]:42784 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLl3N-0006SN-2a for submit@debbugs.gnu.org; Fri, 25 Sep 2020 06:34:13 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39702) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kLl3L-0006SA-K9 for 42338@debbugs.gnu.org; Fri, 25 Sep 2020 06:34:12 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:56389) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kLl3G-00012x-3v; Fri, 25 Sep 2020 06:34:06 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=60868 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kLl37-0000S9-Tj; Fri, 25 Sep 2020 06:34:04 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <20200713002055.1553f136@tachikoma.lepiller.eu> <20200712222538.18092-1-julien@lepiller.eu> <20200712222538.18092-3-julien@lepiller.eu> <87imcphe6a.fsf@gnu.org> <20200918004403.0d755d60@tachikoma.lepiller.eu> <87eemz1nib.fsf@gnu.org> <20200919012420.301201e8@tachikoma.lepiller.eu> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 4 =?UTF-8?Q?Vend=C3=A9miaire?= an 229 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Fri, 25 Sep 2020 12:33:56 +0200 In-Reply-To: <20200919012420.301201e8@tachikoma.lepiller.eu> (Julien Lepiller's message of "Sat, 19 Sep 2020 01:24:20 +0200") Message-ID: <87eemq16y3.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Spam-Score: -3.3 (---) 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" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Spam-Score: -1.51 X-TUID: kI8YL7G9L+ZQ Hi, Julien Lepiller skribis: > Le Fri, 18 Sep 2020 10:45:48 +0200, > Ludovic Court=C3=A8s a =C3=A9crit : > >> Hi, >>=20 >> Julien Lepiller skribis: >>=20 >> > + (let* ((package-data (read-package-data #:filename >> > composer-file)) >> > + (scripts (match (assoc-ref package-data "scripts") >> > + (('@ script ...) script) >> > + (#f '()))) >> > + (test-script >> > + (assoc-ref scripts test-target)) >> > + (dependencies (filter (lambda (dep) (string-contains >> > dep "/")) >> > + (map car >> > + (match (assoc-ref >> > package-data "require") >> > + (('@ dependency ...) >> > dependency) >> > + (#f '()))))) >> > + (dependencies-dev >> > + (filter (lambda (dep) (string-contains dep "/")) >> > + (map car >> > + (match (assoc-ref package-data >> > "require-dev") >> > + (('@ dependency ...) dependency) >> > + (#f '()))))) >> > + (name (assoc-ref package-data "name")))=20=20 >>=20 >> This is also a case for =E2=80=98define-json-mapping=E2=80=99. I suppos= e we could use >> Guile-JSON instead of (guix build json), no? >>=20 >> I think this code and similar occurrences would be less intimidating >> if we used =E2=80=98define-json-mapping=E2=80=99; it would make the data= structures >> clearer, unlike here where one has to keep in mind what the list/tree >> looks like so they can map car/cdr around. > > I think we already tried that with the node build system, but we had to > revert, because we were importing guile-json from the host side. I > don't remember the details though, so if you think it's OK now, I'll > gladly make the code look nicer :) Yes please. :-) I think code full of alists/dictionaries would be hard to read and to maintain since mistakes could end up being silently ignored or lead to a wrong-type-#f error far down the road. Also please remember to avoid car/cdr: https://guix.gnu.org/manual/en/html_node/Data-Types-and-Pattern-Matching.= html As for Guile-JSON: perhaps you can post a draft that we can play with to see if there=E2=80=99s anything wrong, but off the top of my head I don=E2= =80=99t see why it wouldn=E2=80=99t work. >> > + (match test-script >> > + ((? string? command) >> > + (unless (equal? (system command) 0) >> > + (throw 'failed-command command))) >> > + (('@ (? string? command) ...) >> > + (for-each >> > + (lambda (c) >> > + (unless (equal? (system c) 0) >> > + (throw 'failed-command c))) >> > + command))=20=20 >>=20 >> Use (zero? x) instead of (equal? 0 x). >>=20 >> Also, why not use =E2=80=98invoke=E2=80=99? I this because these comman= ds are really >> shell commands and expect things like glob patterns and tilde >> expansion? If these are not shell commands, I recommend =E2=80=98invoke= =E2=80=99, >> which will report failures more nicely. > > Here I have a single string that contains shell commands, so I don't > think I can use invoke. =E2=80=98system=E2=80=99 passes the string to =E2=80=9Csh -c=E2=80=9D, whic= h means the string is subject to shelly things: glob expansion, semicolon interpretation, string quotation, etc. If those strings are meant to be shell-interpreted, then passing them to =E2=80=98system=E2=80=99 is the right thing. Otherwise, it should be avoid= ed IMO. Thanks, Ludo=E2=80=99.