From patchwork Tue Mar 12 20:19:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Efraim Flashner X-Patchwork-Id: 1398 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 8C98C16DA4; Tue, 12 Mar 2019 20:24:06 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 9505C16DA1 for ; Tue, 12 Mar 2019 20:24:05 +0000 (GMT) Received: from localhost ([127.0.0.1]:60776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3nwT-0004Gb-44 for patchwork@mira.cbaines.net; Tue, 12 Mar 2019 16:24:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h3ntn-00025a-BR for guix-patches@gnu.org; Tue, 12 Mar 2019 16:21:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h3ntd-0006Nr-3g for guix-patches@gnu.org; Tue, 12 Mar 2019 16:21:13 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:55393) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h3ntY-0006KQ-R5 for guix-patches@gnu.org; Tue, 12 Mar 2019 16:21:06 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1h3ntY-0003kF-L6 for guix-patches@gnu.org; Tue, 12 Mar 2019 16:21:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#34831] [PATCH 04/25] build: Add rakudo-build-system. Resent-From: Efraim Flashner Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 12 Mar 2019 20:21:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 34831 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 34831@debbugs.gnu.org Received: via spool by 34831-submit@debbugs.gnu.org id=B34831.155242204614141 (code B ref 34831); Tue, 12 Mar 2019 20:21:04 +0000 Received: (at 34831) by debbugs.gnu.org; 12 Mar 2019 20:20:46 +0000 Received: from localhost ([127.0.0.1]:40654 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h3ntB-0003fj-QD for submit@debbugs.gnu.org; Tue, 12 Mar 2019 16:20:46 -0400 Received: from flashner.co.il ([178.62.234.194]:49698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1h3nt1-0003eP-SS for 34831@debbugs.gnu.org; Tue, 12 Mar 2019 16:20:32 -0400 Received: from localhost (unknown [31.210.177.221]) by flashner.co.il (Postfix) with ESMTPSA id 2660140402; Tue, 12 Mar 2019 20:20:26 +0000 (UTC) From: Efraim Flashner Date: Tue, 12 Mar 2019 22:19:53 +0200 Message-Id: <20190312202014.31224-4-efraim@flashner.co.il> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312201608.30892-1-efraim@flashner.co.il> References: <20190312201608.30892-1-efraim@flashner.co.il> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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" X-getmail-retrieved-from-mailbox: Patches * guix/build-system/rakudo.scm, guix/build/rakudo-build-system.scm: New files. * Makefile.am (MODULES): Add them. * doc/guix.texi (Build System): Document it. --- Makefile.am | 3 + doc/guix.texi | 20 +++- guix/build-system/rakudo.scm | 155 +++++++++++++++++++++++++++++ guix/build/rakudo-build-system.scm | 140 ++++++++++++++++++++++++++ 4 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 guix/build-system/rakudo.scm create mode 100644 guix/build/rakudo-build-system.scm diff --git a/Makefile.am b/Makefile.am index cf35770ba7..c3d2525af3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,6 +13,7 @@ # Copyright © 2018 Julien Lepiller # Copyright © 2018 Oleg Pykhalov # Copyright © 2018 Alex Vong +# Copyright © 2019 Efraim Flashner # # This file is part of GNU Guix. # @@ -124,6 +125,7 @@ MODULES = \ guix/build-system/ocaml.scm \ guix/build-system/waf.scm \ guix/build-system/r.scm \ + guix/build-system/rakudo.scm \ guix/build-system/ruby.scm \ guix/build-system/scons.scm \ guix/build-system/texlive.scm \ @@ -164,6 +166,7 @@ MODULES = \ guix/build/python-build-system.scm \ guix/build/ocaml-build-system.scm \ guix/build/r-build-system.scm \ + guix/build/rakudo-build-system.scm \ guix/build/ruby-build-system.scm \ guix/build/scons-build-system.scm \ guix/build/texlive-build-system.scm \ diff --git a/doc/guix.texi b/doc/guix.texi index 82cf2babb2..5937c86dad 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -28,7 +28,7 @@ Copyright @copyright{} 2015, 2016, 2017 Leo Famulari@* Copyright @copyright{} 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus@* Copyright @copyright{} 2016 Ben Woodcroft@* Copyright @copyright{} 2016, 2017, 2018 Chris Marusich@* -Copyright @copyright{} 2016, 2017, 2018 Efraim Flashner@* +Copyright @copyright{} 2016, 2017, 2018, 2019 Efraim Flashner@* Copyright @copyright{} 2016 John Darrington@* Copyright @copyright{} 2016, 2017 Nils Gillmann@* Copyright @copyright{} 2016, 2017, 2018, 2019 Jan Nieuwenhuizen@* @@ -5893,6 +5893,24 @@ are run after installation using the R function @code{tools::testInstalledPackage}. @end defvr +@defvr {Scheme Variable} rakudo-build-system +This variable is exported by @code{(guix build-system rakudo)} It +implements the build procedure used by @uref{https://rakudo.org/, +Rakudo} for @uref{https://perl6.org/, Perl6} packages. It installs the +package to @code{/gnu/store/@dots{}/NAME-VERSION/share/perl6} and +installs the binaries, library files and the resources, as well as wrap +the files under the @code{bin/} directory. Tests can be skipped by +passing @code{#f} to the @code{tests?} parameter. + +Which rakudo package is used can be specified with @code{rakudo}. +Which perl6-tap-harness package used for the tests can be specified with +@code{#:prove6} or removed by passing @code{#f} to the +@code{with-prove6?} parameter. +Which perl6-zef package used for tests and installing can be specified +with @code{#:zef} or removed by passing @code{#f} to the +@code{with-zef?} parameter. +@end defvr + @defvr {Scheme Variable} texlive-build-system This variable is exported by @code{(guix build-system texlive)}. It is used to build TeX packages in batch mode with a specified engine. The diff --git a/guix/build-system/rakudo.scm b/guix/build-system/rakudo.scm new file mode 100644 index 0000000000..fd469f0bb5 --- /dev/null +++ b/guix/build-system/rakudo.scm @@ -0,0 +1,155 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Efraim Flashner +;;; +;;; 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 rakudo) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (guix packages) + #:use-module (ice-9 match) + #:export (%rakudo-build-system-modules + rakudo-build + rakudo-build-system)) + +;; Commentary: +;; +;; Standard build and install procedure for packages using the Rakudo +;; build system to be installed as system libraries. This is +;; implemented as an extension of `gnu-build-system'. +;; +;; Code: + +(define %rakudo-build-system-modules + ;; Build-side modules imported by default. + `((guix build rakudo-build-system) + ,@%gnu-build-system-modules)) + +(define (default-rakudo) + "Return the default Rakudo package." + + ;; Do not use `@' to avoid introducing circular dependencies. + (let ((module (resolve-interface '(gnu packages perl6)))) + (module-ref module 'rakudo))) + +(define (default-prove6) + "Return the default perl6-tap-harness package for tests." + (let ((module (resolve-interface '(gnu packages perl6)))) + (module-ref module 'perl6-tap-harness))) + +(define (default-zef) + "Return the default perl6-zef package." + (let ((module (resolve-interface '(gnu packages perl6)))) + (module-ref module 'perl6-zef))) + +(define* (lower name + #:key source inputs native-inputs outputs + system target + (rakudo (default-rakudo)) + (prove6 (default-prove6)) + (zef (default-zef)) + (with-prove6? #t) + (with-zef? #t) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #:rakudo #:prove6 #:zef #:inputs #:native-inputs)) + + (and (not target) ;XXX: no cross-compilation + (bag + (name name) + (system system) + (host-inputs `(,@(if source + `(("source" ,source)) + '()) + ,@inputs + + ;; Keep the standard inputs of 'gnu-build-system'. + ,@(standard-packages))) + (build-inputs `(("rakudo" ,rakudo) + ,@(if with-prove6? + `(("perl6-tap-harness" ,prove6)) + '()) + ,@(if with-zef? + `(("perl6-zef" ,zef)) + '()) + ,@native-inputs)) + (outputs outputs) + (build rakudo-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define* (rakudo-build store name inputs + #:key + (search-paths '()) + (tests? #t) + (phases '(@ (guix build rakudo-build-system) + %standard-phases)) + (outputs '("out")) + (system (%current-system)) + (guile #f) + (with-zef? #t) + (with-prove6? #t) + (imported-modules %rakudo-build-system-modules) + (modules '((guix build rakudo-build-system) + (guix build utils)))) + "Build SOURCE using PERL6, and with INPUTS." + (define builder + `(begin + (use-modules ,@modules) + (rakudo-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:search-paths ',(map search-path-specification->sexp + search-paths) + #:phases ,phases + #:system ,system + #:tests? ,tests? + #:outputs %outputs + #: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 + #:system system + #:inputs inputs + #:modules imported-modules + #:outputs outputs + #:guile-for-build guile-for-build)) + +(define rakudo-build-system + (build-system + (name 'rakudo) + (description "The standard Rakudo build system") + (lower lower))) + +;;; rakudo.scm ends here diff --git a/guix/build/rakudo-build-system.scm b/guix/build/rakudo-build-system.scm new file mode 100644 index 0000000000..bfdefa3c4e --- /dev/null +++ b/guix/build/rakudo-build-system.scm @@ -0,0 +1,140 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Efraim Flashner +;;; +;;; 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 rakudo-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:use-module (ice-9 ftw) + #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (%standard-phases + rakudo-build)) + +;; Commentary: +;; +;; Builder-side code of the standard Rakudo package build procedure. +;; +;; Code: + +(define* (check #:key tests? inputs with-prove6? #:allow-other-keys) + (if (and tests? (assoc-ref inputs "perl6-tap-harness")) + ;(if (and tests? with-prove6?) + (invoke "prove6" "-I=lib" "t/") + (format #t "test suite not run~%")) + #t) + +(define* (install #:key inputs outputs with-zef? #:allow-other-keys) + "Install a given Perl6 package." + (let* ((out (assoc-ref outputs "out")) + (perl6 (string-append out "/share/perl6"))) + (if (assoc-ref inputs "perl6-zef") + ;(if with-zef? + (begin + (let ((zef (string-append (assoc-ref inputs "perl6-zef") + "/bin/zef"))) + (setenv "HOME" (getcwd)) + (mkdir-p perl6) + (invoke zef "install" "--verbose" "." + ;; Don't install any of the following: + "--/depends" "--/build-depends" "--/test-depends" + (string-append "--install-to=" perl6)) + (delete-file (string-append perl6 "/repo.lock"))) + #t) + (begin + (let ((inst (string-append (assoc-ref inputs "rakudo") + "/share/perl6/tools/install-dist.p6"))) + (setenv "RAKUDO_RERESOLVE_DEPENDENCIES" "0") + (setenv "RAKUDO_MODULE_DEBUG" "1") ; be verbose while building + (invoke inst (string-append "--to=" perl6) "--for=site")))))) + +(define* (install-libs #:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out")) + (lock "lib/.precomp/.lock")) + (when (file-exists? lock) + (delete-file "lib/.precomp/.lock")) + (copy-recursively "lib" (string-append out "/share/perl6/lib")) + #t)) + +(define* (install-bins #:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (when (file-exists? "bin") + (for-each (lambda (file) + (install-file file (string-append out "/bin")) + (chmod (string-append out "/" file) #o555)) + (find-files "bin" ".*"))) + #t)) + +(define* (install-resources #:key outputs #:allow-other-keys) + (let ((out (assoc-ref outputs "out"))) + (when (file-exists? "resources") + (copy-recursively "resources" + (string-append out "/share/perl6/resources"))) + #t)) + +(define* (wrap #:key inputs outputs #:allow-other-keys) + (define (list-of-files dir) + (map (cut string-append dir "/" <>) + (or (scandir dir (lambda (f) + (let ((s (stat (string-append dir "/" f)))) + (eq? 'regular (stat:type s))))) + '()))) + + (define bindirs + (append-map (match-lambda + ((_ . dir) + (list (string-append dir "/bin") + (string-append dir "/sbin")))) + outputs)) + + (let* ((out (assoc-ref outputs "out")) + (var `("PERL6LIB" "," prefix + ,(cons (string-append out "/share/perl6/lib," + out "/share/perl6/site/lib," + out "/share/perl6/vendor/lib") + (search-path-as-string->list + (or (getenv "PERL6LIB") "") #\,))))) + (for-each (lambda (dir) + (let ((files (list-of-files dir))) + (for-each (cut wrap-program <> var) + files))) + bindirs) + #t)) + +(define %standard-phases + ;; No need for 'bootstrap, 'configure or 'build. + (modify-phases gnu:%standard-phases + (delete 'bootstrap) + (delete 'configure) + (delete 'build) + (replace 'check check) + (replace 'install install) + (add-before 'install 'install-lib-dir install-libs) + (add-after 'install-lib-dir 'install-resources install-resources) + (add-after 'install-resources 'install-binaries install-bins) + ;; needs to be after 'install-binaries and all 'install phases + (add-after 'install 'wrap wrap))) + +(define* (rakudo-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + "Build the given Perl6 package, applying all of PHASES in order." + (apply gnu:gnu-build + #:inputs inputs #:phases phases + args)) + +;;; rakudo-build-system.scm ends here