>From 5497df789597bedb3744af4d11d927a99dea229e Mon Sep 17 00:00:00 2001 From: Ben Woodcroft Date: Mon, 2 Jan 2017 17:11:13 +1000 Subject: [PATCH 1/5] build: Add OCaml build system. * guix/build-system/ocaml.scm: New file. * guix/build/ocaml-build-system: New file. * Makefile.am (MODULES): Add new files. * doc/guix.texi (Build Systems): Document ocaml-build-system. (TODO!!!) * gnu/packages/games.scm (laby): Use ocaml-build-system. * gnu/packages/ocaml.scm (opam, camlp4, camlp5, hevea, coq, proof-general, ocaml-menhir, lablgtk, unison, ocaml-findlib): Likewise. --- Makefile.am | 2 + gnu/packages/games.scm | 5 +- gnu/packages/ocaml.scm | 21 +++--- guix/build-system/ocaml.scm | 131 ++++++++++++++++++++++++++++++++++++++ guix/build/ocaml-build-system.scm | 41 ++++++++++++ 5 files changed, 188 insertions(+), 12 deletions(-) create mode 100644 guix/build-system/ocaml.scm create mode 100644 guix/build/ocaml-build-system.scm diff --git a/Makefile.am b/Makefile.am index fb08a004b..6338e0c4e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -74,6 +74,7 @@ MODULES = \ guix/build-system/r.scm \ guix/build-system/ruby.scm \ guix/build-system/trivial.scm \ + guix/build-system/ocaml.scm \ guix/ftp-client.scm \ guix/http-client.scm \ guix/gnupg.scm \ @@ -99,6 +100,7 @@ MODULES = \ guix/build/ruby-build-system.scm \ guix/build/waf-build-system.scm \ guix/build/haskell-build-system.scm \ + guix/build/ocaml-build-system.scm \ guix/build/store-copy.scm \ guix/build/utils.scm \ guix/build/union.scm \ diff --git a/gnu/packages/games.scm b/gnu/packages/games.scm index a3b9f04b9..814a2c77d 100644 --- a/gnu/packages/games.scm +++ b/gnu/packages/games.scm @@ -108,7 +108,8 @@ #:use-module (guix build-system haskell) #:use-module (guix build-system python) #:use-module (guix build-system cmake) - #:use-module (guix build-system trivial)) + #:use-module (guix build-system trivial) + #:use-module (guix build-system ocaml)) (define-public gnubg (package @@ -2835,7 +2836,7 @@ auto mapper with a VT100 map display.") (base32 "0gyrfa95l1qka7gbjf7l6mk7mbfvph00l0c995ia272qdw7rjhyf")) (patches (search-patches "laby-make-install.patch")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (inputs `(("lablgtk" ,lablgtk) ("ocaml" ,ocaml) diff --git a/gnu/packages/ocaml.scm b/gnu/packages/ocaml.scm index c5784db90..e1f9710e0 100644 --- a/gnu/packages/ocaml.scm +++ b/gnu/packages/ocaml.scm @@ -30,6 +30,7 @@ #:use-module (guix svn-download) #:use-module (guix utils) #:use-module (guix build-system gnu) + #:use-module (guix build-system ocaml) #:use-module (gnu packages) #:use-module (gnu packages gcc) #:use-module (gnu packages gnome) @@ -164,7 +165,7 @@ functional, imperative and object-oriented styles of programming.") (sha256 (base32 "004gwn6rbpcb53y3rpb3v23vk39rp2xmf0liyd5iy12ij8bigrhm")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (arguments '(;; Sometimes, 'make -jX' would fail right after ./configure with ;; "Fatal error: exception End_of_file". @@ -225,7 +226,7 @@ Git-friendly development workflow.") (base32 "0icdfzhsbgf89925gc8gl3fm8z2xzszzlib0v9dj5wyzkyv3a342")) (file-name (string-append name "-" version ".tar.gz")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (native-inputs `(("ocaml" ,ocaml) ("which" ,which))) (inputs `(("ocaml" ,ocaml))) @@ -266,7 +267,7 @@ syntax of OCaml.") (sha256 (base32 "1ql04iyvclpyy9805kpddc4ndjb5d0qg4shhi2fc6bixi49fvy89")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (inputs `(("ocaml" ,ocaml))) (arguments @@ -307,7 +308,7 @@ concrete syntax of the language (Quotations, Syntax Extensions).") (sha256 (base32 "14fns13wlnpiv9i05841kvi3cq4b9v2sw5x3ff6ziws28q701qnd")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (inputs `(("ocaml" ,ocaml))) (arguments @@ -338,7 +339,7 @@ written in Objective Caml.") (sha256 (base32 "0wyywia0darak2zmc5v0ra9rn0b9whwdfiahralm8v5za499s8w3")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (native-inputs `(("texlive" ,texlive) ("findlib" ,ocaml-findlib) @@ -392,7 +393,7 @@ It is developed using Objective Caml and Camlp5.") (sha256 (base32 "09qb0myq66fw17v4ziz401ilsb5xlxz1nl2wsp69d0vrfy0bcrrm")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (native-inputs `(("which" ,which) ("emacs" ,emacs-minimal) @@ -470,7 +471,7 @@ provers.") (sha256 (base32 "1j8nmcj2gq6hyyi16z27amiahplgrnk4ppchpm0v4qy80kwkf47k")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (inputs `(("ocaml" ,ocaml))) (arguments @@ -506,7 +507,7 @@ Knuth’s LR(1) parser construction technique.") (sha256 (base32 "0cyj6sfdvzx8hw7553lhgwc0krlgvlza0ph3dk9gsxy047dm3wib")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (native-inputs `(("camlp4" ,camlp4) ("ocaml" ,ocaml) @@ -612,7 +613,7 @@ libpanel, librsvg and quartz.") ;; have functioning internal hyperlinks. (substitute* "doc/Makefile" (("hevea unison") "hevea -fix unison")))))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (outputs '("out" "doc")) ; 1.9 MiB of documentation (native-inputs @@ -690,7 +691,7 @@ to the other.") (base32 "02abg1lsnwvjg3igdyb8qjgr5kv1nbwl4gaf8mdinzfii5p82721")) (patches (search-patches "ocaml-findlib-make-install.patch")))) - (build-system gnu-build-system) + (build-system ocaml-build-system) (native-inputs `(("camlp4" ,camlp4) ("m4" ,m4) diff --git a/guix/build-system/ocaml.scm b/guix/build-system/ocaml.scm new file mode 100644 index 000000000..74d336c3e --- /dev/null +++ b/guix/build-system/ocaml.scm @@ -0,0 +1,131 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Ben Woodcroft +;;; +;;; 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 ocaml) + #:use-module (guix store) + #:use-module (guix utils) + #:use-module (guix packages) + #:use-module (guix derivations) + #:use-module (guix search-paths) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) + #:use-module (ice-9 match) + #:export (%ocaml-build-system-modules + ocaml-build + ocaml-build-system)) + +(define %ocaml-build-system-modules + ;; Build-side modules imported by default. + `((guix build ocaml-build-system) + ,@%gnu-build-system-modules)) + +(define (default-ocaml) + "Return the default OCaml package." + ;; Lazily resolve the binding to avoid a circular dependency. + (let ((ocaml (resolve-interface '(gnu packages ocaml)))) + (module-ref ocaml 'ocaml))) + +(define* (lower name + #:key source inputs native-inputs outputs system target + (ocaml (default-ocaml)) + #:allow-other-keys + #:rest arguments) + "Return a bag for NAME." + (define private-keywords + '(#:source #:target #:ocaml #: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 `(("ocaml" ,ocaml) + ,@native-inputs)) + (outputs outputs) + (build ocaml-build) + (arguments (strip-keyword-arguments private-keywords arguments))))) + +(define* (ocaml-build store name inputs + #:key + (test-target "check") + (tests? #t) + (phases '(@ (guix build ocaml-build-system) + %standard-phases)) + (outputs '("out")) + (search-paths '()) + (configure-flags ''()) + (make-flags ''()) + (system (%current-system)) + (guile #f) + (parallel-build? #t) + (parallel-tests? #t) + (imported-modules %ocaml-build-system-modules) + (modules '((guix build ocaml-build-system) + (guix build utils)))) + "Build SOURCE using OCAML and INPUTS." + (define builder + `(begin + (use-modules ,@modules) + (ocaml-build #:name ,name + #:source ,(match (assoc-ref inputs "source") + (((? derivation? source)) + (derivation->output-path source)) + ((source) + source) + (source + source)) + #:system ,system + #:configure-flags ,configure-flags + #:make-flags ,make-flags + #:test-target ,test-target + #:parallel-build? ,parallel-build? + #:parallel-tests? ,parallel-tests? + #:tests? ,tests? + #:phases ,phases + #:outputs %outputs + #: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 + (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 ocaml-build-system + (build-system + (name 'ocaml) + (description "The standard OCaml build system") + (lower lower))) diff --git a/guix/build/ocaml-build-system.scm b/guix/build/ocaml-build-system.scm new file mode 100644 index 000000000..05b5cf552 --- /dev/null +++ b/guix/build/ocaml-build-system.scm @@ -0,0 +1,41 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2017 Ben Woodcroft +;;; +;;; 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 ocaml-build-system) + #:use-module ((guix build gnu-build-system) #:prefix gnu:) + #:use-module (guix build utils) + #:use-module (ice-9 match) + #:use-module (ice-9 popen) + #:use-module (ice-9 regex) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) + #:export (%standard-phases + ocaml-build)) + +;; Commentary: +;; +;; Builder-side code of the standard OCaml package build procedure. +;; +;; Code: + +(define %standard-phases + (modify-phases gnu:%standard-phases)) + +(define* (ocaml-build #:key inputs (phases %standard-phases) + #:allow-other-keys #:rest args) + (apply gnu:gnu-build #:inputs inputs #:phases phases args)) -- 2.11.0