caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamlbuild rules generating multiple files
@ 2009-02-10 22:15 Daniel Bünzli
  2009-02-10 22:33 ` [Caml-list] " Hezekiah M. Carty
  2009-02-11 11:48 ` Romain Bardou
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Bünzli @ 2009-02-10 22:15 UTC (permalink / raw)
  To: OCaml List

Hello,

If in a rule a command generates multiple files (which don't necessary  
have the same basename as the dep), how can I make ocamlbuild  
understand that these files now exist in _build ?

Thanks,

Daniel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] ocamlbuild rules generating multiple files
  2009-02-10 22:15 ocamlbuild rules generating multiple files Daniel Bünzli
@ 2009-02-10 22:33 ` Hezekiah M. Carty
  2009-02-10 22:39   ` Daniel Bünzli
  2009-02-11 11:48 ` Romain Bardou
  1 sibling, 1 reply; 6+ messages in thread
From: Hezekiah M. Carty @ 2009-02-10 22:33 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: OCaml List

On Tue, Feb 10, 2009 at 5:15 PM, Daniel Bünzli
<daniel.buenzli@erratique.ch> wrote:
> If in a rule a command generates multiple files (which don't necessary have
> the same basename as the dep), how can I make ocamlbuild understand that
> these files now exist in _build ?

I've used the following rule under After_rules in myocamlbuild.ml for
camlidl .idl files:

      (* Handle *.idl files properly... I think *)
      rule "camlidl processing"
        ~prods:["%.mli"; "%.ml"; "%_stubs.c"]
        ~deps:["%.idl"]
        begin fun env _build ->
          let idl = env "%.idl" in
          let tags = tags_of_pathname idl++"compile"++"camlidl" in
          let cmd = Cmd(S[camlidl; T tags; P idl]) in
          Seq [cmd]
        end;

Then, given foo.idl, "ocamlbuild foo.cma" seems to work properly,
finding the relevant camlidl-output files.

Hope this helps.

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] ocamlbuild rules generating multiple files
  2009-02-10 22:33 ` [Caml-list] " Hezekiah M. Carty
@ 2009-02-10 22:39   ` Daniel Bünzli
  2009-02-10 22:51     ` Hezekiah M. Carty
  2009-02-10 22:59     ` Mikkel Fahnøe Jørgensen
  0 siblings, 2 replies; 6+ messages in thread
From: Daniel Bünzli @ 2009-02-10 22:39 UTC (permalink / raw)
  To: OCaml List


Le 10 févr. 09 à 23:33, Hezekiah M. Carty a écrit :

> I've used the following rule under After_rules in myocamlbuild.ml for

[...]

Thanks but my problem is that the generated file do not have the same  
basename as the dep i.e. I cannot specify the ~prods arg, the ~prods  
are going to be discovered while the rule is executed and without  
going through further "build" argument invocations.

Maybe a good example is tar archives. Let's say I have a rule that  
takes a .tgz and produces its files. How do I tell ocamlbuild that  
these files now exist.

Best,

Daniel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] ocamlbuild rules generating multiple files
  2009-02-10 22:39   ` Daniel Bünzli
@ 2009-02-10 22:51     ` Hezekiah M. Carty
  2009-02-10 22:59     ` Mikkel Fahnøe Jørgensen
  1 sibling, 0 replies; 6+ messages in thread
From: Hezekiah M. Carty @ 2009-02-10 22:51 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: OCaml List

On Tue, Feb 10, 2009 at 5:39 PM, Daniel Bünzli
<daniel.buenzli@erratique.ch> wrote:
>
> Le 10 févr. 09 à 23:33, Hezekiah M. Carty a écrit :
>
>> I've used the following rule under After_rules in myocamlbuild.ml for
>
> [...]
>
> Thanks but my problem is that the generated file do not have the same
> basename as the dep i.e. I cannot specify the ~prods arg, the ~prods are
> going to be discovered while the rule is executed and without going through
> further "build" argument invocations.
>
> Maybe a good example is tar archives. Let's say I have a rule that takes a
> .tgz and produces its files. How do I tell ocamlbuild that these files now
> exist.

Ah, my apologies.  I didn't read your original post carefully enough.
Would it be possible to write a function to read these files in to a
list then use "dep [foo; bar] file_list;"?  This is what I use for
included files in .idl files.  I have only done this with static,
pre-defined lists using 'dep ["compile"; "camlidl"] ["file1.inc;
file2.inc"];'.  I'm not sure how well it would work or if it would
work at all with a dynamic list of files.

Hez

-- 
Hezekiah M. Carty
Graduate Research Assistant
University of Maryland
Department of Atmospheric and Oceanic Science


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] ocamlbuild rules generating multiple files
  2009-02-10 22:39   ` Daniel Bünzli
  2009-02-10 22:51     ` Hezekiah M. Carty
@ 2009-02-10 22:59     ` Mikkel Fahnøe Jørgensen
  1 sibling, 0 replies; 6+ messages in thread
From: Mikkel Fahnøe Jørgensen @ 2009-02-10 22:59 UTC (permalink / raw)
  To: Daniel Bünzli; +Cc: OCaml List

2009/2/10 Daniel Bünzli <daniel.buenzli@erratique.ch>:
> Thanks but my problem is that the generated file do not have the same
> basename as the dep i.e. I cannot specify the ~prods arg, the ~prods are
> going to be discovered while the rule is executed and without going through
> further "build" argument invocations.

This is how dependency scanners also work.

You can see an example in

http://git.dvide.com/pub/ocamlbuild-ctools/tree/myocamlbuild_config.ml

search for:
accumulated_include_rule

Here accumulated_include_rule is used instead of rule, but it calls
rule eventually, but with its calculated prod arguments that it gets
(in this case) from reading multiple dependency files. You could
modify this function to take a list of a .tgz file.

Some care needs to be taken since each build step must produce an
actual file - especially when creating dependencies, but it is not
necessarily required in you case. Dependency scanners do need to
produce files so something else can depend on this files to ensure the
dependency is scanned.

Mikkel


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] ocamlbuild rules generating multiple files
  2009-02-10 22:15 ocamlbuild rules generating multiple files Daniel Bünzli
  2009-02-10 22:33 ` [Caml-list] " Hezekiah M. Carty
@ 2009-02-11 11:48 ` Romain Bardou
  1 sibling, 0 replies; 6+ messages in thread
From: Romain Bardou @ 2009-02-11 11:48 UTC (permalink / raw)
  To: OCaml List

Daniel Bünzli a écrit :
> Hello,
> 
> If in a rule a command generates multiple files (which don't necessary 
> have the same basename as the dep), how can I make ocamlbuild understand 
> that these files now exist in _build ?

I also encountered this problem, and AFAIK there is no support yet for 
what I would call "dynamic productions". The answer of Nicolas Pouillard 
was: "hmm good question... indeed it should be added" (roughly 
translated :) ).

-- 
Romain Bardou


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-02-11 11:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-10 22:15 ocamlbuild rules generating multiple files Daniel Bünzli
2009-02-10 22:33 ` [Caml-list] " Hezekiah M. Carty
2009-02-10 22:39   ` Daniel Bünzli
2009-02-10 22:51     ` Hezekiah M. Carty
2009-02-10 22:59     ` Mikkel Fahnøe Jørgensen
2009-02-11 11:48 ` Romain Bardou

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).