* ocamlbuild: ml -> cmx & cmi & o ?
@ 2008-10-15 11:00 Josh Berdine
2008-10-16 8:30 ` [Caml-list] " Romain Bardou
0 siblings, 1 reply; 4+ messages in thread
From: Josh Berdine @ 2008-10-15 11:00 UTC (permalink / raw)
To: caml-list
[-- Attachment #1: Type: text/plain, Size: 475 bytes --]
Hi,
I observe that ocamlbuild does not build cmx cmi and o files from a ml file (which has no associated mli) directly. Do others see different behavior? Instead it builds cmo and cmi from the ml using ocamlc, and then builds the cmx and o files from there using ocamlopt. Is there a reason I'm missing that ocamlbuild does not have a default rule for this case, using only one call to ocamlopt? If so, is there an easy way to do this with a plugin?
Cheers, Josh
[-- Attachment #2: Type: text/html, Size: 4137 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] ocamlbuild: ml -> cmx & cmi & o ?
2008-10-15 11:00 ocamlbuild: ml -> cmx & cmi & o ? Josh Berdine
@ 2008-10-16 8:30 ` Romain Bardou
2008-10-16 8:43 ` Nicolas Pouillard
0 siblings, 1 reply; 4+ messages in thread
From: Romain Bardou @ 2008-10-16 8:30 UTC (permalink / raw)
To: Josh Berdine; +Cc: caml-list
> I observe that ocamlbuild does not build cmx cmi and o files from a ml
> file (which has no associated mli) directly. Do others see different
> behavior? Instead it builds cmo and cmi from the ml using ocamlc, and
> then builds the cmx and o files from there using ocamlopt. Is there a
> reason I’m missing that ocamlbuild does not have a default rule for this
> case, using only one call to ocamlopt? If so, is there an easy way to
> do this with a plugin?
I observe the same behavior. I think it's just a matter of reordering
the rules in ocaml_specific.ml, as the following plug-in solves the
problem thanks to "~insert: `top":
open Ocamlbuild_plugin
let () = dispatch begin function
| After_rules ->
rule "ml -> cmx"
~dep: "%.ml"
~prods: ["%.cmx"; "%.o"; "%.cmi"]
~insert: `top
begin fun env _ ->
let ml = env "%.ml" in
Cmd(S[!Options.ocamlopt; A "-c"; P ml])
end
| _ -> ()
end
--
Romain Bardou
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] ocamlbuild: ml -> cmx & cmi & o ?
2008-10-16 8:30 ` [Caml-list] " Romain Bardou
@ 2008-10-16 8:43 ` Nicolas Pouillard
2008-10-16 8:53 ` Romain Bardou
0 siblings, 1 reply; 4+ messages in thread
From: Nicolas Pouillard @ 2008-10-16 8:43 UTC (permalink / raw)
To: romain.bardou; +Cc: Josh Berdine, Caml_mailing list
Excerpts from romain.bardou's message of Thu Oct 16 10:30:49 +0200 2008:
> > I observe that ocamlbuild does not build cmx cmi and o files from a ml
> > file (which has no associated mli) directly. Do others see different
> > behavior? Instead it builds cmo and cmi from the ml using ocamlc, and
> > then builds the cmx and o files from there using ocamlopt. Is there a
> > reason I’m missing that ocamlbuild does not have a default rule for this
> > case, using only one call to ocamlopt? If so, is there an easy way to
> > do this with a plugin?
There is a deep reason for this, the short answer is:
"if you want native-compilation only, then all your .ml files must have a
.mli"
Indeed ocamlbuild only generates .cmi from .ml using ocamlc, this is to avoid
conflicting defaulting rules in the engine.
> I observe the same behavior. I think it's just a matter of reordering
> the rules in ocaml_specific.ml, as the following plug-in solves the
> problem thanks to "~insert: `top":
>
> open Ocamlbuild_plugin
>
> let () = dispatch begin function
> | After_rules ->
> rule "ml -> cmx"
> ~dep: "%.ml"
> ~prods: ["%.cmx"; "%.o"; "%.cmi"]
> ~insert: `top
> begin fun env _ ->
> let ml = env "%.ml" in
> Cmd(S[!Options.ocamlopt; A "-c"; P ml])
> end
> | _ -> ()
> end
I won't recommend that.
--
Nicolas Pouillard aka Ertai
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Caml-list] ocamlbuild: ml -> cmx & cmi & o ?
2008-10-16 8:43 ` Nicolas Pouillard
@ 2008-10-16 8:53 ` Romain Bardou
0 siblings, 0 replies; 4+ messages in thread
From: Romain Bardou @ 2008-10-16 8:53 UTC (permalink / raw)
To: Nicolas Pouillard; +Cc: Caml_mailing list
> There is a deep reason for this, the short answer is:
>
> "if you want native-compilation only, then all your .ml files must have a
> .mli"
>
> Indeed ocamlbuild only generates .cmi from .ml using ocamlc, this is to avoid
> conflicting defaulting rules in the engine.
Are conflicting rules a problem?
--
Romain Bardou
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-10-16 8:53 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-15 11:00 ocamlbuild: ml -> cmx & cmi & o ? Josh Berdine
2008-10-16 8:30 ` [Caml-list] " Romain Bardou
2008-10-16 8:43 ` Nicolas Pouillard
2008-10-16 8:53 ` Romain Bardou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox