caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Dario Teixeira <dario.teixeira@nleyten.com>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] Obtaining module dependencies from within OCamlbuild plugin
Date: Tue, 3 Feb 2015 21:59:04 +0100	[thread overview]
Message-ID: <CAPFanBG-NeUzJdodH_=ChjQSDxMw6FgPciAMS8OfD=aS7Z18Tg@mail.gmail.com> (raw)
In-Reply-To: <281f21387ba38386a63301a18f46392e@nleyten.com>

In OCamlbuild, most of the dependencies are detected dynamically while
the compilation runs (typically the process of producing a target (eg.
foo.cma) will run code that will decide to recursively produce lots of
targets (eg. modules listed in foo.mllib), and those are the dynamic
dependencies). Command_deps_of_tags returns the static dependencies
that have been specified by tags, by using Command.dep and
Command.pdep to associate dependencies to specific tags.

You cannot obtain the set of dependencies of a target without actually
trying to build it. (If you were interested in this for performance
reason, a reasonable idea would be to cache the dependencies of the
last build and replay them optimistically, but I assume that's not
your point here.)


On Tue, Feb 3, 2015 at 9:01 PM, Dario Teixeira
<dario.teixeira@nleyten.com> wrote:
> Hi,
>
> I'm trying to manipulate a project's dependencies from within an OCamlbuild
> plugin, and one prerequisite is obtaining the current set of dependencies
> for a given module.  For instance, to obtain the set of dependencies for
> module "src/foo_c.ml", one could expect to invoke the following from within
> the After_rules hook of myocamlbuild.ml:
>
>   Command.deps_of_tags (tags_of_pathname "src/foo_c.ml")
>
> This always returns an empty list, however.  The same holds if one tries
> to narrow the list of tags to just the filename:
>
>   Command.deps_of_tags (Tags.of_list ["file:src/foo_c.ml"])
>
> One possible explanation for this behaviour is that the set of dependencies
> has not been computed yet when the After_rules hook is invoked.  Is that the
> case, or am I missing something altogether different?  Either way, how do I
> obtain the set of dependencies?
>
> Thanks in advance for your attention!
> Kind regards,
> Dario Teixeira
>
>
> --
> Caml-list mailing list.  Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs

  reply	other threads:[~2015-02-03 20:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-03 20:01 Dario Teixeira
2015-02-03 20:59 ` Gabriel Scherer [this message]
2015-02-04 13:17   ` Dario Teixeira

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='CAPFanBG-NeUzJdodH_=ChjQSDxMw6FgPciAMS8OfD=aS7Z18Tg@mail.gmail.com' \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dario.teixeira@nleyten.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).