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
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
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs
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
Are conflicting rules a problem?
--
Romain Bardou