caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Wojciech Meyer <wojciech.meyer@googlemail.com>
To: Hongbo Zhang <bobzhang1988@gmail.com>
Cc: Pierre-Etienne Meunier <pierreetienne.meunier@gmail.com>,
	O Caml <caml-list@inria.fr>
Subject: Re: [Caml-list] About ocamlbuild
Date: Fri, 16 Nov 2012 20:33:09 +0100	[thread overview]
Message-ID: <CAOg1smDhjHgSTAG_ZAidoMii31Wap7cJq8ORVVZSFY-P2karfA@mail.gmail.com> (raw)
In-Reply-To: <50A68E6E.5080704@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 8044 bytes --]

Hi,

I had the idea of fleshing out the ocamlbuild internals some time ago. On
OUD I expressed this to Nicolas P (co author of ocamlbuid) and Xavier
Clerk. I also spoke to Sylvain about turning Oasis from compiler to
interpreter, not directly generating files but instead calling ocamlbuild
API. The good start would be to be able to dynlink directly libraries with
side effects. Then we could do further and provide .build pacakges for
ocamlind for each project that uses complex build steps for instance due to
metaprogramming or several stages of compilation.

On Friday, November 16, 2012, Hongbo Zhang <bobzhang1988@gmail.com> wrote:
> On 11/16/12 6:43 AM, Pierre-Etienne Meunier wrote:
>>
>> Hi,
>>
>> My original idea was not at all to start a new ocaml-tools war, I'm
sorry if my first message was poorly formulated. Let me make myself clear,
I wrote a typesetting system in ocaml, in order to write my PhD thesis. The
way it works is a little strange, it compiles your source to ocaml source
code (our language is quite cool, because based on a dypgen grammar, but
you can use another one if you have time to write a parser and code
generator). Then it compiles this code with a library called "Typography",
that does all the document processing stuff, optimization of the page
breaks, and so on. Finally, it calls another library to output to different
formats, such as pdf, plain text, svg, opengl, or anything else.
>>
>> These are clearly "separable but not independent" projects (drivers,
document formats, font library, typesetting library, parser/code
generator). So compiling everything without duplication is not that
trivial, and I really 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 understand 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 seems difficult in ocamlbuild today. The
documentation explains how to use an internal 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 between several modules, then
calling it to compile the rest, like xmonad does, for instance.
>>
>> Also, if you are writing a document with our system, separated between
different files, you want the system to compile it automatically, without
too much recompilation. The problem is extensibility: for instance, if you
are writing a bibliography library (I wrote one, but there may be others in
the future), you certainly do not want to touch our code in order to
compile it. Instead, you want to write a dynlinkable module explaining to
our system how the documents depend on bibliography files, and how to
compile everything in what order.
>> To do this, I had to rewrite a (small) ocamlbuild-like library. My point
is that ocamlbuild exposes (or documents) a too small part of its internals
to be re-used inside another project.
>
> I fully agree with you, it would be really nice that ocamlbuild provide a
library interface instead a poor myocamlbuild.ml.
>
> Currently my situation is  that I have to copy my 2000lines
myocamlbuild.ml everywhere, and do some changes locally(probably some bug
fixes will be forgotten to sync up since it's scattered everywhere and I am
lazy), that's not the ideal case.
>
>
> Now, I completely understand Xavier's points:
>
> - about _tags, and this is also my philosophy when I write ocaml code
myself. I asked the question because I needed magic comments in the build
system of my typesetting stuff, mostly because the ocaml source code that I
compile is produced automatically, and meant to be executed only once.
Writing the correct _tags files without conflicts between the different
files, with the correct directory inclusions for instance, would be much
more complicated. This is the only case where I see the point of a mixed
system.
>
> - about the command line options of ghc: clearly, this also has to do
with the fact that ocamlopt manages to compile files of equivalent sizes
about twenty or thirty times faster than ghc in the cases I tried. The
theoretical problems solved are not the same, either.
>
> Finally, Gabriel, I would be happy to contribute code to ocaml, only my
time is a scarce resource right now. Maybe some day…
>
> Cheers,
> Pierre
>
>
> Em 16/11/2012, às 11:53, Gabriel Scherer escreveu:
>
> Regardless of the overly heated tone of the discussion, I find the
> idea of having "ocamlbuild as a library" interesting. Let me detail
> what I believe was the idea of the proposal.
>
> Currently we have a shared ocamlbuild executable that would contain
> the core logic, and be passed plugins that are invoked by the core
> logic at some point of the program. We could consider an inversion of
> control where the executable logic is exposed as a library, and users
> write scripts use this library (to invoke the ocamlbuild processing),
> the script being compiled as whole programs rather than plugins. In
> effect, you give the tool to let any project define it's own "tailored
> ocamlbuild" easily. There could be little change of usage and
> behavior, it's just a different point of view, that has the advantages
> already evoked in this thread (facility to link with other stuff,
> etc.).
>
> This idea has already been used in other projects where "configuration
> is compilation", such as the XMonad window manager (
> http://xmonad.org/ ); the xmonad.hs users write is not compiled to a
> dynamically loaded plugin, it itself invokes the "xmonad program" as a
> library function, passing it (from the language) configuration
> information.
>
> I find this idea interesting, but it will require some amount of work.
> My guess as to why Xavier Clerc's reply is a bit grumpy is that he is
> often the one tasked with implementing those changes. On the other
> hand, everyone is free to contribute to ocamlbuild, and I've been
> trying to publicly encourage people to contribute, with little success
> so far. So Pierre, if you want to have a try at implementing this
> idea, by all means, do! We'll see when someone has some working patch
> if it can be integrated upstream.
>
> Regarding in-file tags/pragmas, I find such changes should be
> considered much more cautiously, as those could mean changes to the
> OCaml tooling (or worse, language) as a whole, not simply ocamlbuild
> itself. Again, nobody's forbidden to come up with a good,
> well-specified, simple proposal that would please everyone, but that
> is a quite difficult task and any such proposal should expect to get
> rejected.
>
> On Fri, Nov 16, 2012 at 11:33 AM, Arnaud Spiwack
> <Arnaud.Spiwack@lix.polytechnique.fr> wrote:
>
> Well,
>
> I must say the sort of mafioso-like reasoning - "you really do not want to
> do that" - doesn't really make sense to me.
>
> Here are valid reasons not to include a feature X in a tool:
>
> I don't have time to do X
> I don't know how to do X
> Having X would prevent me from having Y which I'd rather
>
> Any other reason is bad.
>
> People want to have tags and compilation pragmas? Well, let them, they
> probably have valid reasons to (some options may be better seen global to
> the project and other local to files). People want to interleave compiling
> the build system and compiling the project. They have a good reason for
that
> too. Also: ocamlbuild doesn't only compile ocaml files.
>
> Related to that last point, and to the initial question: as far as I'm
> aware, an ocamlbuild plugin cannot depend on a custom library (to go
around
> that we can use a myocamlbuild.ml which compiles a mymyocamlbuild.ml (or
> something) with the appropriate linking options, th

[-- Attachment #2: Type: text/html, Size: 8988 bytes --]

  reply	other threads:[~2012-11-16 19:33 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-15 12:05 Pierre-Etienne Meunier
2012-11-15 21:48 ` Xavier Clerc
2012-11-15 22:04   ` Edgar Friendly
2012-11-15 22:36     ` Xavier Clerc
2012-11-16 10:33       ` Arnaud Spiwack
2012-11-16 10:53         ` Gabriel Scherer
2012-11-16 11:43           ` Pierre-Etienne Meunier
2012-11-16 19:05             ` [Caml-list] " Hongbo Zhang
2012-11-16 19:33               ` Wojciech Meyer [this message]
2012-11-17 17:21             ` [Caml-list] " Fabrice Le Fessant
2012-11-16 11:01         ` Daniel Bünzli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAOg1smDhjHgSTAG_ZAidoMii31Wap7cJq8ORVVZSFY-P2karfA@mail.gmail.com \
    --to=wojciech.meyer@googlemail.com \
    --cc=bobzhang1988@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=pierreetienne.meunier@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).