caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] output-obj rule in ocamlbuild
@ 2011-08-25 14:09 Anil Madhavapeddy
  2011-08-25 15:30 ` Anil Madhavapeddy
  0 siblings, 1 reply; 2+ messages in thread
From: Anil Madhavapeddy @ 2011-08-25 14:09 UTC (permalink / raw)
  To: caml-list

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

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

* Re: [Caml-list] output-obj rule in ocamlbuild
  2011-08-25 14:09 [Caml-list] output-obj rule in ocamlbuild Anil Madhavapeddy
@ 2011-08-25 15:30 ` Anil Madhavapeddy
  0 siblings, 0 replies; 2+ messages in thread
From: Anil Madhavapeddy @ 2011-08-25 15:30 UTC (permalink / raw)
  To: caml-list

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
> 



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

end of thread, other threads:[~2011-08-25 15:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-08-25 14:09 [Caml-list] output-obj rule in ocamlbuild Anil Madhavapeddy
2011-08-25 15:30 ` Anil Madhavapeddy

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