Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: "François Pottier" <francois.pottier@inria.fr>
Cc: caml users <caml-list@inria.fr>, github@mjambon.com
Subject: Re: [Caml-list] cppo, ocamlbuild, and dependencies
Date: Wed, 1 Feb 2017 18:10:31 +0100	[thread overview]
Message-ID: <CAPFanBEUcLqA3LcPHx+ktD9VH7JhbOX=n+yGp0uxiSQHoD2r9A@mail.gmail.com> (raw)
In-Reply-To: <d0a6f82e-1c53-b894-3af1-43fc5687d131@inria.fr>

Yes, of course, your approach would also work
(`Ocamlbuild_plugin.read_file` is you friend, followed by the parsing
technique of your choice). The only issue is that you may
over-approximate dependencies depending on how closely you approximate
cppo's grammar (and I don't know, maybe there is a way to have
computed inclusion instead of just file path literals?), so this logic
would be easier to implement correctly in cppo itself.

You may find inspiration in the part of the manual that describes how
to write rules with dynamic dependencies (the explained example is the
code of the (.itarget -> .otarget) rule):

  https://github.com/ocaml/ocamlbuild/blob/master/manual/manual.adoc#Subsec_Rules__Dynamic_dependencies

On Wed, Feb 1, 2017 at 2:40 PM, François Pottier
<francois.pottier@inria.fr> wrote:
>
> On 01/02/2017 11:19, Gabriel Scherer wrote:
>>
>> In the meantime, I implemented an amusing hack at the ocamlbuild level
>
>
> Thanks Gabriel for your quick reply.
>
> This seems amusing indeed, but does not quite work for me. Running
> ocamlbuild
> once fails, complaining that A.ml does not exist (whereas A.cppo.ml exists).
> If I immediately run ocamlbuild again, the build succeeds.
>
> I think I would prefer to use a slightly less amusing approach and just find
> out, ahead of time, what the dependencies are. In the rule that transforms
> %.cppo.ml to %.ml, could I just read the source file, looking #include
> patterns, and ask that the included files be built first?
>
>
> --
> François Pottier
> francois.pottier@inria.fr
> http://gallium.inria.fr/~fpottier/

      reply	other threads:[~2017-02-01 17:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-31 21:50 François Pottier
2017-02-01 10:19 ` Gabriel Scherer
2017-02-01 13:40   ` François Pottier
2017-02-01 17:10     ` Gabriel Scherer [this message]

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='CAPFanBEUcLqA3LcPHx+ktD9VH7JhbOX=n+yGp0uxiSQHoD2r9A@mail.gmail.com' \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=francois.pottier@inria.fr \
    --cc=github@mjambon.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