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 sAjpEpN2ZF+kRwAA0tVLHw (envelope-from ) for ; Fri, 18 Sep 2020 08:57:55 +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 mDm7DpN2ZF//AwAA1q6Kng (envelope-from ) for ; Fri, 18 Sep 2020 08:57:55 +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 9251194042A for ; Fri, 18 Sep 2020 08:57:54 +0000 (UTC) Received: from localhost ([::1]:48534 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJCDJ-00034i-0J for larch@yhetil.org; Fri, 18 Sep 2020 04:57:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38174) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kJC2o-0007hk-QM for guix-patches@gnu.org; Fri, 18 Sep 2020 04:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:57522) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kJC2o-00005k-13 for guix-patches@gnu.org; Fri, 18 Sep 2020 04:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kJC2o-0001iZ-04 for guix-patches@gnu.org; Fri, 18 Sep 2020 04:47: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, 18 Sep 2020 08:47:01 +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.16004187756538 (code B ref 42338); Fri, 18 Sep 2020 08:47:01 +0000 Received: (at 42338) by debbugs.gnu.org; 18 Sep 2020 08:46:15 +0000 Received: from localhost ([127.0.0.1]:40833 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJC22-0001hN-PR for submit@debbugs.gnu.org; Fri, 18 Sep 2020 04:46:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:59352) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kJC20-0001hA-LP for 42338@debbugs.gnu.org; Fri, 18 Sep 2020 04:46:12 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:58880) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kJC1o-0008RW-WE; Fri, 18 Sep 2020 04:46:01 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=42002 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kJC1e-0000ae-8W; Fri, 18 Sep 2020 04:45:51 -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> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: Jour du Travail de =?UTF-8?Q?l'Ann=C3=A9e?= 228 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, 18 Sep 2020 10:45:48 +0200 In-Reply-To: <20200918004403.0d755d60@tachikoma.lepiller.eu> (Julien Lepiller's message of "Fri, 18 Sep 2020 00:44:03 +0200") Message-ID: <87eemz1nib.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=none; 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.01 X-TUID: SLl4QKyppL5y Hi, Julien Lepiller skribis: > From bb5d102b6ea5e6b5c06bbf90a58927c6180e23bc Mon Sep 17 00:00:00 2001 > From: Julien Lepiller > Date: Tue, 29 Oct 2019 20:58:51 +0100 > Subject: [PATCH 03/34] guix: Add composer-build-system. > > * guix/build-system/composer.scm: New file. > * guix/build/composer-build-system.scm: New file. > * gnu/packages/aux-files/findclass.php: New file. > * Makefile.am: Add them. > * doc/guix.texi (Build Systems): Document it. [...] > --- /dev/null > +++ b/gnu/packages/aux-files/findclass.php I can=E2=80=99t believe we=E2=80=99ll have PHP in our code base. :-) > +;;; You should have received a copy of the GNU General Public License > +;;; along with GNU Guix. If not, see . > +(define-module (guix build-system composer) Missing newline. > + (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 "re= quire") > + (('@ 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"))) This is also a case for =E2=80=98define-json-mapping=E2=80=99. I suppose w= e could use Guile-JSON instead of (guix build json), no? 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 struc= tures clearer, unlike here where one has to keep in mind what the list/tree looks like so they can map car/cdr around. > + (for-each > + (lambda (input) Like for =E2=80=98map=E2=80=99, please indent on the same line: (for-each (lambda (input) > + (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)) Use (zero? x) instead of (equal? 0 x). Also, why not use =E2=80=98invoke=E2=80=99? I this because these commands = 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, whic= h will report failures more nicely. > +(define (find-php-dep inputs dependency) > + (let loop ((inputs (map cdr inputs))) > + (if (null? inputs) > + (throw 'unsatisfied-dependency "Unsatisfied dependency: required= " dependency) > + (let ((autoload (string-append (car inputs) "/share/web/" depend= ency "/vendor/autoload_conf.php"))) > + (if (file-exists? autoload) > + autoload > + (loop (cdr inputs))))))) Please use =E2=80=98match=E2=80=99 instead of car/cdr. > +(define* (create-autoload vendor composer-file inputs #:key dev-dependen= cies?) > + (with-output-to-file (string-append vendor "/autoload.php") > + (lambda _ > + (display " +// autoload.php @generated by Guix > +$map =3D $psr4map =3D $classmap =3D array(); > +") > + (format #t "require_once '~a/autoload_conf.php'~%" vendor) > + (format #t "require_once '~a/share/web/composer/ClassLoader.php'~%" > + (assoc-ref inputs "composer-classloader")) > + (display "$loader =3D new \\Composer\\Autoload\\ClassLoader(); > +foreach ($map as $namespace =3D> $path) { > + $loader->set($namespace, $path); > +} > +foreach ($psr4map as $namespace =3D> $path) { > + $loader->setPsr4($namespace, $path); > +} > +$loader->addClassMap($classmap); > +$loader->register(); > +"))) Please add a docstring explaining what=E2=80=99s happening here. Also, per= haps use =E2=80=98string-append=E2=80=99 instead of =E2=80=98format=E2=80=99 so = we don=E2=80=99t end up generating things like: require_once '#f/autoload_conf.php' :-) In short, I think we must pay attention to the style to facilitate maintainability. Could you send an updated patch? Thanks! Ludo=E2=80=99.