From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Woodcroft Subject: Re: [PATCH 4/4] gnu: ocaml-findlib: Update to 1.7.1. Date: Tue, 3 Jan 2017 21:03:16 +1000 Message-ID: <60005778-c62f-a3cd-e956-ad21478ef36f@uq.edu.au> References: <20170102173814.6837-1-david@craven.ch> <20170102173814.6837-4-david@craven.ch> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------40BF8A19DF400E1C50F2630F" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:35579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOMsQ-00045B-CU for guix-devel@gnu.org; Tue, 03 Jan 2017 06:03:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cOMsL-0002S3-KP for guix-devel@gnu.org; Tue, 03 Jan 2017 06:03:34 -0500 Received: from mailhub2.soe.uq.edu.au ([130.102.132.209]:40183 helo=newmailhub.uq.edu.au) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cOMsL-0002Re-10 for guix-devel@gnu.org; Tue, 03 Jan 2017 06:03:29 -0500 In-Reply-To: <20170102173814.6837-4-david@craven.ch> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: David Craven , guix-devel@gnu.org This is a multi-part message in MIME format. --------------40BF8A19DF400E1C50F2630F Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Hi David, Thanks for this. On 03/01/17 03:38, David Craven wrote: > * gnu/packages/ocaml.scm (ocaml-findlib)[arguments]: Move > ocaml-findlib-make-install.patch to phase and set ldconf="ignore" in > findlib.conf.in. > * gnu/local.mk (dist_patch_DATA): Remove old patch. The deletion of the patch file itself should also be documented. [...] > - #:phases (modify-phases %standard-phases > - (replace > - 'configure > - (lambda* (#:key inputs outputs #:allow-other-keys) > - (let ((out (assoc-ref outputs "out"))) > - (system* > - "./configure" > + #:phases > + (modify-phases %standard-phases > + (add-after 'unpack 'patch-findlib.conf.in > + (lambda _ > + (let ((port (open-file "findlib.conf.in" "w" #:encoding "utf-8"))) > + (format port "ldconf=\"ignore\"~%") > + (close-port port)) > + #t)) > + (add-after 'unpack 'patch-findlib-make-install > + (lambda _ > + (substitute* "src/findlib/Makefile" > + (("^.*topfind.*OCAML_CORE_STDLIB.*$") > + "\ttest $(INSTALL_TOPFIND) -eq 0 || cp topfind \"$(prefix)$(OCAML_SITELIB)\"\n")) > + #t)) > + (replace 'configure > + (lambda* (#:key inputs outputs #:allow-other-keys) > + (let ((out (assoc-ref outputs "out"))) > + (system* "./configure" > "-bindir" (string-append out "/bin") > "-config" (string-append out "/etc/ocamfind.conf") > "-mandir" (string-append out "/share/man") > "-sitelib" (string-append out "/lib/ocaml/site-lib") > "-with-toolbox"))))))) I had some trouble building downstream packages such as 'laby' after this patch. Do you see the same? > + (native-search-paths > + (list (search-path-specification > + (variable "OCAMLPATH") > + (files (list (string-append "lib/ocaml/site-lib")))))) This is unnecessary since this is already specified in the ocaml package definition, right? [...] On a somewhat related note, I've been getting around ocaml-findlib issues by adding this phase to downstream packages. WDYT? (add-before 'install 'setup-install (lambda* (#:key outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (destdir (string-append out "/lib/ocaml"))) (mkdir-p destdir) (setenv "OCAMLFIND_DESTDIR" destdir) (setenv "OCAMLFIND_LDCONF" (string-append destdir "/ld.conf")) #t)))))) I've been preparing a few ocaml packages, and it is getting to the point that it might be worth adding an ocaml-build-system, much like gnu-build-system except perhaps with a few tweaks such as the above (preliminary patch not adding anything ocaml/findlib-specific attached). OTOH, I'm quite cautious about my knowledge of the OCaml ecosystem, so I'm keen to hear others' opinions. Thanks, ben. --------------40BF8A19DF400E1C50F2630F Content-Type: text/x-patch; name="0001-build-Add-OCaml-build-system.patch" Content-Disposition: attachment; filename="0001-build-Add-OCaml-build-system.patch" Content-Transfer-Encoding: quoted-printable X-MIME-Autoconverted: from 8bit to quoted-printable by newmailhub.uq.edu.au id v03B3JhC042917 >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 =3D \ 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 =3D \ 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)) =20 (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 E= xtensions).") (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=E2=80=99s 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 =C2=A9 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 (a= t +;;; 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-s= ystem.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 =C2=A9 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 (a= t +;;; 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)) --=20 2.11.0 --------------40BF8A19DF400E1C50F2630F--