I ended up copying some of the rules out of ocamlbuild/ocaml_specific.ml and
replicating it in myocamlbuild.ml. For the archives, a rule "%.m.o" looks like:
(* Copied from ocaml/ocamlbuild/ocaml_specific.ml and modified to add
the output_obj tag *)
let native_output_obj x =
link_gen "cmx" "cmxa" !Options.ext_lib [!Options.ext_obj; "cmi"]
ocamlopt_link_prog
(fun tags -> tags++"ocaml"++"link"++"native"++"output_obj") x
let () =
(* Copied from ocaml/ocamlbuild/ocaml_specific.ml *)
let ext_obj = !Options.ext_obj in
let x_o = "%"-.-ext_obj in
(* Rule to link a module and output a standalone object file *)
rule "ocaml: cmx* & o* -> .m.o"
~tags:["ocaml"; "native"; "output_obj"]
~prod:"%.m.o"
~deps:["%.cmx"; x_o]
(native_output_obj "%.cmx" "%.m.o");
-Anil
On 25 Aug 2011, at 15:09, Anil Madhavapeddy wrote:
> Is there a built-in rule in ocamlbuild to generate the -output-obj output
> instead of a direct link?
>
> I note there are these built-in tags in the ocamlbuild source:
>
> ocaml_specific.ml:flag ["ocaml"; "link"; "native"; "output_obj"]
> (A"-output-obj");;
> ocaml_specific.ml:flag ["ocaml"; "link"; "byte"; "output_obj"]
> (A"-output-obj");;
>
> ...but I can't find a built-in target that uses these tags. Is a custom rule
> in myocamlbuild.ml needed here, or should I do something in my _tags file?
>
> cheers,
> Anil
>
> --
> Caml-list mailing list. Subscription management and archives:
> https://sympa-roc.inria.fr/wws/info/caml-list
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
Caml-list mailing list. Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs