From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id 6B3A47EE20 for ; Sat, 17 Nov 2012 18:21:50 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of fabrissimo@gmail.com) identity=pra; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="fabrissimo@gmail.com"; x-sender="fabrissimo@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of fabrissimo@gmail.com designates 209.85.219.54 as permitted sender) identity=mailfrom; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="fabrissimo@gmail.com"; x-sender="fabrissimo@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-oa0-f54.google.com) identity=helo; client-ip=209.85.219.54; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="fabrissimo@gmail.com"; x-sender="postmaster@mail-oa0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhQCAGHHp1DRVds2m2dsb2JhbABFwyYIIwEBAQEBCAkLCRQngh4BAQVAATMFAQMMAQUFCw0uIQESAQUBHAYTh3sDD6EGjyuEWycNiU4BBQyLP2kKhQMDkkqBXYFVgRyKFoMwFimBWII6 X-IronPort-AV: E=Sophos;i="4.83,270,1352070000"; d="scan'208";a="181969745" Received: from mail-oa0-f54.google.com ([209.85.219.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 17 Nov 2012 18:21:49 +0100 Received: by mail-oa0-f54.google.com with SMTP id n9so6369133oag.27 for ; Sat, 17 Nov 2012 09:21:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=Sv+ARBEdFwJuNmDXACDNNO/JBcgLkszW0TxIZSjKjWs=; b=jilTIOEV5mzb4egAdbwlKYXf1k5QJWNuqhtaS1gihTaEV642r1AgvMJUzA4EhUUCag SbfUTZ4n/BNVkhqmyVqlDu/JUiShmsFkpKrr75zlKPj8crrzzMmWwY/zCQtfjTgbRh8K r4j8YSgMSucLSkBXvylfJ8AGGZJnJMGsLMVFmpxX6dtKjwPCF0GnlqxLWiPcQFKBgJez adY4UxKX/4j7ko4tVIoYitwDYFW34mqQJVyvc4TPIN1VzBR9KbbGOYT3JF0Rf53wamG9 qg3EnTmBm9MhdoOcjr/aT/V0e8sE/cO9CBdrtKisf0JPfAhlS6txi7+G+MzxoXPVxmoJ kfIg== MIME-Version: 1.0 Received: by 10.60.171.228 with SMTP id ax4mr6671950oec.35.1353172908229; Sat, 17 Nov 2012 09:21:48 -0800 (PST) Sender: fabrissimo@gmail.com Received: by 10.76.25.169 with HTTP; Sat, 17 Nov 2012 09:21:48 -0800 (PST) In-Reply-To: References: <50A56709.7080105@gmail.com> <331585634.4160435.1353019001535.JavaMail.root@inria.fr> Date: Sat, 17 Nov 2012 18:21:48 +0100 X-Google-Sender-Auth: LGKmeU9y5hO01BHHbkAO3gA1jVo Message-ID: From: Fabrice Le Fessant To: Pierre-Etienne Meunier Cc: O Caml Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] About ocamlbuild Hi, On Fri, Nov 16, 2012 at 12:43 PM, Pierre-Etienne Meunier wrote: > So compiling everything without duplication is not that trivial, and I re= ally would like to write an ocaml program to compile it, maybe using a more= complex build system than just one file with the ocamlbuild api. I underst= and that ocamlbuild is still in an early stage of development, this is why = I'm sending these mails. The code is split among different directories, and= using a library interface in the compilation of another library still seem= s difficult in ocamlbuild today. The documentation explains how to use an i= nternal library in program, but it forces you to use a particular layout of= your files. This is why I feel that a library would be more versatile: we = can imagine a makefile compiling the build system first, possibly split bet= ween several modules, then calling it to compile the rest, like xmonad does= , for instance. Actually, this use case is exactly the reason why I developed the "ocp-build" tool (you might have used it if you tried to compile opam). It's much less powerful than ocamlbuild, but for what it does, it is much simpler to use. The idea is to write a simple description of the package contained in each directory. The tool then scans all the sub-directories looking for these descriptions (in files with .ocp extensions), use the specified dependencies between packages to order them, and then build all of them incrementally (no unnecessary rebuild) and in parallel. Since the description is only for OCaml files, it is very simple and short, but of course, if you are doing complicated things, you won't be able to express them in such a simple language... There is currently no documentation, and 'opam install ocp-build' will install a one-year old version (but latest sources are in the typerex2 branch of typerex), so I would not advise anybody to use it curently, except for playing, but I (and some others in my team) found that it is a convenient tool for most of our needs. For example, the opam file looks like : begin comp +=3D [ "-g" "-annot" "-warn-error" "A" ] link +=3D [ "-g" ] begin library "opam-lib" subdir =3D [ "src" ] files =3D [ "opamGlobals.ml" ... "repo/opamGit.ml" "opamSolver.ml" "opamClient.ml" ] requires =3D [ "cudf" "dose" "unix" "graph" "re_glob" ] end begin program "opam" subdir =3D [ "src" ] files =3D [ "opamMain.ml" ] requires =3D [ "opam-lib" "arg" ] end begin program "opam-mk-repo" files =3D [ "src/scripts/opam_mk_repo.ml"] requires =3D [ "opam-lib" ] end begin program "opam-check" files =3D [ "src/scripts/opam_check.ml" ] requires =3D [ "opam-lib" ] end begin program "opam-repo-check" files =3D [ "src/scripts/opam_repo_check.ml" ] requires =3D [ "opam-lib" ] end end Among the current drawbacks, there is no compatibility with findlib descriptions, nor any easy way to guess the current installed packages, so you have to create a file describing your environment. For example, in opam, it comes with a file 'ocaml-libs.ocp' containing: begin generated =3D true dirname =3D [ "%{OCAMLLIB}%" ] has_byte =3D true has_asm =3D true begin library "unix" end begin library "str" requires =3D [ "unix" ] end begin library "dynlink" end begin library "camlp4fulllib" requires =3D [ "dynlink" ] has_asm =3D false end begin library "bigarray" end begin library "threads" dirname =3D [ "%{OCAMLLIB}%/threads" ] end end to describe all the default libraries. We hope that the tool, at some point, will be able to either read META files, or packages will come with an .ocp file describing them... Finally, another nice thing is the "packing" syntax. For example, to compile sexplib with ocp-build, we use : begin library "sexplib" files =3D [ pack Sexplib [ "type.ml"; "parser.mly"; "lexer.mll" "pre_sexp.ml" ( pp =3D [ "cpp"; "-undef"; "-traditional" ] = ); "sexp_intf.ml"; "sexp.ml"; "path.ml" "conv.ml" "conv_error.ml" "exn_magic.ml" "std.ml" ] ] requires =3D [ "bigarray" "nums" ] end to pack all the modules within the "Sexplib" module. --Fabrice