caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dario Teixeira <dario.teixeira@nleyten.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Forcing OCamlbuild to compile a file before another
Date: Wed, 04 Feb 2015 16:15:17 +0000	[thread overview]
Message-ID: <1ee7eec964558b9bcb4f0d5650449440@nleyten.com> (raw)
In-Reply-To: <CAPFanBFs5EmPPrDP4MSQ4y31=Cjkqk-1dy24yGTUiqwcVi-xhg@mail.gmail.com>

Hi,

> I thought a bit more about this and here is a plan that seems
> reasonable (I fact-checked it with Pierre Chambart and Benoît Vaugon)
> and does not require changing ocamldep.
> 
> 1) add a notion of foo.mlalias files with content of the form
> 
>   M := Foo_M
>   Z := Bar_Z
>   ...
> 
>   with a rule .mlalias -> .cmi that generates the .ml and compiles it
> with -no-alias-deps (note that by design it never has any dependency)

This seems reasonable.  In a sense, modules like foo.ml whose contents
are just a list of aliases are already "special" in a way, and this
convention emphasises that.  Moreover, it has an added documentation
advantage: simply by listing mlalias files a newcomer may familiarise
themselves with the module aliases used in a project.


> 2) add the following rules in the code that computes dependencies from
> the output of ocamldep:
>       if the module depends on Foo (which is the name of an alias
> file) and M, and (M := Bar) is in foo.mlalias, then also add Bar as a
> dependency

And, I presume, also remove M from the module's dependency list, right?


> - I considered, instead of a .mlalias file with a specific syntax,
> allowing to tag any .ml file as an alias-giving files; that makes the
> system more complex, because the alias-giving files may contain other
> OCaml statements than alias definitions, and thus have some
> dependencies (and we don't want to get in the business of trying to
> guess which modules are just aliases or real dependencies, or having
> to inspect .cmi files after-the-fact to rebuild the aliasing map). The
> downside is that people with an existing -no-alias-deps scheme
> suddenly willing to use ocamlbuild would have to rewrite some stuff
> first. (The other direction can be made automatic by a .mlalias ->
> .ml.inferred rule)

Yeah, I see no need to overcomplicate this.


> (...)
> - It might be possible to implement this at the plugin level. The
> .mlalias rule could be proposed as a plugin. I'm less confident about
> the dependency-mangling logic, but the idea would be to overload the
> existing ".ml -> .ml.depends" rule to change the .ml.depends result
> (instead of its interpretation by ocamlbuild as I had in mind above).

It would be of course nice if all this logic made its way into 4.03
or 4.02.2 as part of OCamlbuild's builtins.  Regardless, from my
perspective of someone who's not familiar with OCamlbuild's code
base and inner workings, I think the most straightforward interim
solution will be along the lines of what I described in my previous
message: write a plugin that postprocesses OCamldep's output.  Which
leads me to the question: is it feasible to do the postprocessing
in OCamlbuild, or will I have to write an external script that does
the postprocessing and gets invoked by setting Options.ocamldep?

Kind regards,
Dario Teixeira


  reply	other threads:[~2015-02-04 16:15 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-23 15:08 Dario Teixeira
2015-01-23 16:41 ` Francois Pottier
2015-01-23 19:09   ` Dario Teixeira
2015-01-24 12:56     ` Gabriel Scherer
2015-01-25 18:16       ` Dario Teixeira
2015-01-26 12:30         ` Dario Teixeira
2015-02-03 21:13           ` Gabriel Scherer
2015-02-04 13:18             ` Dario Teixeira
2015-02-04 14:52               ` Gabriel Scherer
2015-02-04 16:15                 ` Dario Teixeira [this message]
2015-02-04 16:44                   ` Gabriel Scherer
2015-02-06 17:01                     ` Dario Teixeira
2015-02-06 17:05                       ` Gabriel Scherer
2015-02-06 18:58                         ` Dario Teixeira
2015-02-15 10:41                           ` Gabriel Scherer
2015-02-15 13:55                             ` Dario Teixeira
2015-02-15 14:42                               ` Gabriel Scherer

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=1ee7eec964558b9bcb4f0d5650449440@nleyten.com \
    --to=dario.teixeira@nleyten.com \
    --cc=caml-list@inria.fr \
    /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).