From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 6JT0OIHxC2HFzwAAgWs5BA (envelope-from ) for ; Thu, 05 Aug 2021 16:11:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WGSbNIHxC2HkUQAAB5/wlQ (envelope-from ) for ; Thu, 05 Aug 2021 14:11:13 +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 683592D64 for ; Thu, 5 Aug 2021 16:11:13 +0200 (CEST) Received: from localhost ([::1]:34698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBe5Y-0004mk-CO for larch@yhetil.org; Thu, 05 Aug 2021 10:11:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50676) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBe5O-0004fm-3B for guix-patches@gnu.org; Thu, 05 Aug 2021 10:11:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36451) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mBe5N-0000sV-R8 for guix-patches@gnu.org; Thu, 05 Aug 2021 10:11:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mBe5N-00077E-Ml for guix-patches@gnu.org; Thu, 05 Aug 2021 10:11:01 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49889] [PATCH 3/5] guix: Add 'gerbil-build-system'. Resent-From: Xinglu Chen Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 05 Aug 2021 14:11:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49889 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49889@debbugs.gnu.org Received: via spool by 49889-submit@debbugs.gnu.org id=B49889.162817262327283 (code B ref 49889); Thu, 05 Aug 2021 14:11:01 +0000 Received: (at 49889) by debbugs.gnu.org; 5 Aug 2021 14:10:23 +0000 Received: from localhost ([127.0.0.1]:47991 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBe4k-00075z-Q1 for submit@debbugs.gnu.org; Thu, 05 Aug 2021 10:10:23 -0400 Received: from h87-96-130-155.cust.a3fiber.se ([87.96.130.155]:32874 helo=mail.yoctocell.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBe4i-00075k-O7 for 49889@debbugs.gnu.org; Thu, 05 Aug 2021 10:10:21 -0400 From: Xinglu Chen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yoctocell.xyz; s=mail; t=1628172613; bh=RlqoIzaOrFjoNJTbq3fypOYjKQhrMpCTSBgyuQjHV64=; h=From:To:Subject:In-Reply-To:References:Date; b=E0fLzi247XKx4uI2eIIgxMDgoc3/WMqfzvWXiGBxrEq3zbA6lqN8xjUGhMvbOAhC4 IJKFnsOcT5NSx7IXENcV/BdWfA0LV7RbrRpartPczqf5C3ds0wRhVKQ/kCQs/EIndu UhyKsSem4ksPEjABOXIMCAS97yYTDdJBLYYQPG94= In-Reply-To: References: Message-Id: <925c0e686f56bcc19b2db7ab1c38767e3bd74b9e.1628172101.git.public@yoctocell.xyz> Date: Thu, 05 Aug 2021 16:10:13 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1628172673; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=PxTd+kZBmKJYBRZu4KRTDtPGvDdOO4TBAKM0ZJSUv1w=; b=JYfI1R3m5S3PiEwPtwMT/47DyK6KgoE7KYiPAFqZpndTweuItQTEJePO/S3gdqzPfZwFdS iSq/ZtKIYnh44AzC+gqTEfwpFUI7r2vr0iO5OMcR1fVhCWfSiW/z3ZCGdlmK5lXz0U2Nl6 joL37hcPYNTnsISkLJIqEZNebU/5W8RC1lN9JgtGejVGnhyLG/VP9vDWcNhQj+gAWEtHxP JYxEgNeX7Y1Xb4mtzexNiYbQLKB266flANcu5LNdcco+lXvt3r31mWJGBRO/jBKwGz6haq u+U1D0n5MC4QVqXYszSuC3Wikj9062x4gzIf4vUeyX8LohR2gMyyKeyz1tvIgQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1628172673; a=rsa-sha256; cv=none; b=NgZ9eAsC1qcqIQ0e0auhkYDDjTR6lgP2BLI6nFXyuHqAR5eKEKmF/qo7p617N1hK3pVmyp twM/ZspME5e1/QTRsTI8W/BiBLDGh5u8Jl+oMvV8LHFu+y3Q5dmtnwEV4kVHATeHGXJHRW 2xRIv83GmY9HhhrKDce7FjYyyIgbhjUW3I5Gb9j0hMVqfq/4Hgq9edgJGd3eDBq9DBo/RY 5mt1jGF/pya4+FLqyNBUCa6Xk96DYxAX/Qj8MB8Zuo1d8Gzj8IPivwMJuqbk8J6UdSbOAX zv47CcsJmm8AO/HsM0SmNq7UW4wKPI8i0qLXQAMjo0NCZYKjfg6pJ9tlpdKIZA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=E0fLzi24; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=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-Migadu-Spam-Score: -0.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=yoctocell.xyz header.s=mail header.b=E0fLzi24; dmarc=fail reason="SPF not aligned (relaxed)" header.from=yoctocell.xyz (policy=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-Migadu-Queue-Id: 683592D64 X-Spam-Score: -0.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: a+j4RsAKqYab * guix/build/gerbil-build-system.scm: New module. * guix/build-system/gerbil.scm: Likewise. * Makefile.am (MODULES): Register them. * doc/guix.texi (Build Systems): Document it * etc/snippets/scheme-mode/guix-package: Add =E2=80=98gerbil-build-system= =E2=80=99 to list of build systems. --- Makefile.am | 2 + doc/guix.texi | 21 ++++ etc/snippets/scheme-mode/guix-package | 1 + guix/build-system/gerbil.scm | 138 ++++++++++++++++++++++++++ guix/build/gerbil-build-system.scm | 78 +++++++++++++++ 5 files changed, 240 insertions(+) create mode 100644 guix/build-system/gerbil.scm create mode 100644 guix/build/gerbil-build-system.scm diff --git a/Makefile.am b/Makefile.am index 5542aa1c56..4f773f27e5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -143,6 +143,7 @@ MODULES =3D \ guix/build-system/minify.scm \ guix/build-system/asdf.scm \ guix/build-system/copy.scm \ + guix/build-system/gerbil.scm \ guix/build-system/glib-or-gtk.scm \ guix/build-system/gnu.scm \ guix/build-system/guile.scm \ @@ -190,6 +191,7 @@ MODULES =3D \ guix/build/meson-build-system.scm \ guix/build/minify-build-system.scm \ guix/build/font-build-system.scm \ + guix/build/gerbil-build-system.scm \ guix/build/go-build-system.scm \ guix/build/android-repo.scm \ guix/build/asdf-build-system.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index a826171f34..4f2146b7ac 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -7733,6 +7733,27 @@ only one of them. This is equivalent to passing the= @code{-p} argument to @code{dune}. @end defvr =20 +@defvr {Scheme Variable} gerbil-build-system +This variable is exported by @code{(guix build-system gerbil)}. It +implements a build procedure for Gerbil packages the standard +@uref{https://cons.io/guide/package-manager.html, Gerbil build +mechanism}. + +It runs the @file{build.ss} Gerbile script, which compiles the package. +The script can also take custom commands and flags, which can be +specified by the @code{#:build-flags} parameter. + +One can also specify a custom Gerbil package to use for compiling the +package by specifying the the @code{#:gerbil} parameter. + +Gerbil projects don't have a standardized way of running tests, so not +@code{check} phase is exists by default. + +@c TODO: Should Gerbil packages be =E2=80=98inputs=E2=80=99 or =E2=80=98pr= opagated-inputs=E2=80=99? + +As of right now, cross-compilation is not supported. +@end defvr + @defvr {Scheme Variable} go-build-system This variable is exported by @code{(guix build-system go)}. It implements a build procedure for Go packages using the standard diff --git a/etc/snippets/scheme-mode/guix-package b/etc/snippets/scheme-mo= de/guix-package index 9ff6f997d1..e2d645f731 100644 --- a/etc/snippets/scheme-mode/guix-package +++ b/etc/snippets/scheme-mode/guix-package @@ -18,6 +18,7 @@ "dune-build-system" "emacs-build-system" "font-build-system" + "gerbil-build-system" "glib-or-gtk-build-system" "gnu-build-system" "go-build-system" diff --git a/guix/build-system/gerbil.scm b/guix/build-system/gerbil.scm new file mode 100644 index 0000000000..0dd61767b8 --- /dev/null +++ b/guix/build-system/gerbil.scm @@ -0,0 +1,138 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build-system gerbil) + #:use-module (guix utils) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (guix search-paths) + #:use-module (guix packages) + #:use-module (guix derivations) + #:use-module (ice-9 match) + #:export (gerbil-build-system)) + +;;; Commentary: +;;; +;;; Standard build procedure for packages using the Gerbil build system. +;;; +;;; Code: + +(define %gerbil-build-system-modules + ;; Build-side modules imported and used by default. + `((guix build gerbil-build-system) + (guix build union) + ,@%gnu-build-system-modules)) + +(define (default-gerbil) + "Return the default Gerbil package." + ;; Lazily resolve the binding to avoid circular dependency. + (let ((gerbil (resolve-interface '(gnu packages gerbil)))) + (module-ref gerbil 'gerbil))) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (gerbil (default-gerbil)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #:gerbil #:inputs #:native-inputs)) + + ;; TODO: Cross-compilation support. + (and (not target) + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs)) + (build-inputs `(("gerbil" ,gerbil) + ("libc" ,(module-ref (resolve-interface + '(gnu packages base)) + 'glibc)) + ("gcc" ,(module-ref (resolve-interface + '(gnu packages gcc)) + 'gcc)) + ("binutils" ,(module-ref (resolve-interface + '(gnu packages base)) + 'binutils)) + ,@native-inputs)) + (outputs outputs) + (build gerbil-build) + (arguments (strip-keyword-arguments private-keywords arguments)))= )) + +(define* (gerbil-build store name inputs + #:key + (phases '(@ (guix build gerbil-build-system) + %standard-phases)) + (outputs '("out")) + (search-paths '()) + (build-flags ''()) + (gerbil (default-gerbil)) + ;; Tests are disabled by default because there is no + ;; standard way to test Gerbil packages. However, = some + ;; packages might have custom test phases, so pass = the + ;; #:tests? keyword, just in case. + (tests? #f) + (system (%current-system)) + (guile #f) + (imported-modules %gerbil-build-system-modules) + (modules '((guix build gerbil-build-system) + (guix build utils)))) + (define builder + `(begin + (use-modules ,@modules) + (gerbil-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:tests? ,tests? + #:system ,system + #:phases ,phases + #:outputs %outputs + #:build-flags ,build-flags + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:inputs %build-inputs))) + + (define guile-for-build + (match guile + ((? package?) + (package-derivation store guile system #:graft? #f)) + (#f ; the default + (let* ((distro (resolve-interface '(gnu packages commencement))) + (guile (module-ref distro 'guile-final))) + (package-derivation store guile system #:graft? #f))))) + + (build-expression->derivation store name builder + #:inputs inputs + #:system system + #:modules imported-modules + #:outputs outputs + #:guile-for-build guile-for-build)) + +(define gerbil-build-system + (build-system + (name 'gerbil) + (description "The standard Gerbil build system") + (lower lower))) diff --git a/guix/build/gerbil-build-system.scm b/guix/build/gerbil-build-s= ystem.scm new file mode 100644 index 0000000000..4355d8e444 --- /dev/null +++ b/guix/build/gerbil-build-system.scm @@ -0,0 +1,78 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright =C2=A9 2021 Xinglu Chen +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix build gerbil-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build union) + #:use-module (guix build utils) + #:use-module (srfi srfi-26) + #:export (%standard-phases + gerbil-build)) + +;;; Commentary: +;;; +;;; Build-side code for building Gerbil packages. +;;; +;;; Something to note is that there is no standard way to run tests +;;; for Gerbil packages, so there is not `check' phase by default. +;;; +;;; Code: + +(define (gerbil-package? name) + "Whether NAME is a Gerbil package." + (string-prefix? "gerbil-" name)) + +(define (gerbil-load-path inputs) + "Given an alist of inputs, INPUTS, return a list of directories to add +to the GERBIL_LOADPTH environment variable." + (let* ((labels (map car inputs)) + (gerbil-packages (filter gerbil-package? labels))) + (map (cut string-append <> "/lib/gerbil") + gerbil-packages))) +=20=20 +(define* (setup-gerbil-environment #:key inputs #:allow-other-keys) + ;; This is where the compiled modules will end up. + (setenv "GERBIL_PATH" (string-append (getcwd) "/.build")) + ;; Where to look for other Gerbil modules. + (setenv "GERBIL_LOADPATH" (string-join (gerbil-load-path inputs) ":"))) +=20=20 +(define* (build #:key build-flags #:allow-other-keys) + ;; The build.ss script contians the build instructions. + (apply invoke "./build.ss" build-flags)) + +(define* (install #:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (mkdir-p (string-append out "/lib/gerbil")) + (copy-recursively ".build/lib" (string-append out "/lib/gerbil")) + (copy-recursively ".build/bin" (string-append out "/bin")))) + +(define %standard-phases + (modify-phases gnu:%standard-phases + (delete 'bootstrap) + (delete 'configure) + (add-after 'unpack 'setup-gerbil-environment setup-gerbil-environment) + (replace 'build build) + (delete 'check) + (replace 'install install))) + +(define* (gerbil-build #:key (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given Gerbil packages, applying all of PHASES in order." + (apply gnu:gnu-build #:phases phases args)) + +=20=20=20=20 --=20 2.32.0