[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 2008-10-16 (08:43) |
From: | Nicolas Pouillard <nicolas.pouillard@g...> |
Subject: | Re: [Caml-list] ocamlbuild: ml -> cmx & cmi & o ? |
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