caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Anil Madhavapeddy <anil@recoil.org>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] output-obj rule in ocamlbuild
Date: Thu, 25 Aug 2011 16:30:47 +0100	[thread overview]
Message-ID: <4F164365-2231-42EE-9410-BD4ADBD89F80@recoil.org> (raw)
In-Reply-To: <DDD109F5-B55E-48C9-A1E4-9AD11A7AA5A5@recoil.org>

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
> 



      reply	other threads:[~2011-08-25 15:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 14:09 Anil Madhavapeddy
2011-08-25 15:30 ` Anil Madhavapeddy [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F164365-2231-42EE-9410-BD4ADBD89F80@recoil.org \
    --to=anil@recoil.org \
    --cc=caml-list@yquem.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).