caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] oasis and thrift
@ 2011-03-18 13:22 Joel Reymont
  2011-03-18 13:31 ` [Caml-list] " Sylvain Le Gall
  0 siblings, 1 reply; 3+ messages in thread
From: Joel Reymont @ 2011-03-18 13:22 UTC (permalink / raw)
  To: caml-list

I have Thrift files like foo.thrift and need to run 'thrift -gen ocaml -o <output dir> foo.thrift' which will produce foo.ml and some other files in the output directory. 

How do I integrate this into Oasis?

	Thanks, Joel

P.S. Oasis is awesome!

--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------





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

* [Caml-list] Re: oasis and thrift
  2011-03-18 13:22 [Caml-list] oasis and thrift Joel Reymont
@ 2011-03-18 13:31 ` Sylvain Le Gall
  0 siblings, 0 replies; 3+ messages in thread
From: Sylvain Le Gall @ 2011-03-18 13:31 UTC (permalink / raw)
  To: caml-list

On 18-03-2011, Joel Reymont <joelr1@gmail.com> wrote:
> I have Thrift files like foo.thrift and need to run 'thrift -gen ocaml
> -o <output dir> foo.thrift' which will produce foo.ml and some other
> files in the output directory. 
>
> How do I integrate this into Oasis?
>

The best you can do is to integrate this into the generated
myocamlbuild.ml. As far as you write something outside the
OASIS_START/STOP section, it will be kept after regeneration of the
matching file.

See how ocamlify is integrated with myocamlbuild.ml here:
http://darcs.ocamlcore.org/cgi-bin/darcsweb.cgi?r=oasis/oasis;a=headblob;f=/myocamlbuild.ml
line 87 to 112

To trigger the generation, you'll have to depend in a way to foo.ml
(e.g. if it is a library Modules: Foo or InternalModules: Foo)

>
> P.S. Oasis is awesome!
>
Thank you

Cheers,
Sylvain Le Gall
-- 
My company: http://www.ocamlcore.com
Linkedin:   http://fr.linkedin.com/in/sylvainlegall
Start an OCaml project here: http://forge.ocamlcore.org
OCaml blogs:                 http://planet.ocamlcore.org



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

* [Caml-list] oasis and thrift
@ 2011-03-21 20:17 Joel Reymont
  0 siblings, 0 replies; 3+ messages in thread
From: Joel Reymont @ 2011-03-21 20:17 UTC (permalink / raw)
  To: caml-list

I'm trying to use Apache Thrift with Oasis. 

Suppose I have a project directory structure that looks like this:

protocol\
    message1.thrift
    message2.thrift
    ...
ocaml\
    project1
    project2
    ...

OCaml projects use Oasis and automatically generate *.ml from *.thrift using a custom rule in ocamlbuild, e.g.

    open Ocamlbuild_plugin;;
    open Command;;
    
    let thrift = A"thrift";;
    
    rule "thrift: %.thrift -> %_types.ml"
      ~prods:["%.ml";"%_consts.ml";"%_types.ml";"%_types.mli"]
      ~deps:["%.thrift"]
      begin 
        fun env build ->
          Cmd(S[thrift; A"-gen"; A"ocaml"; P(env "%.thrift")])
      end
    ;;

I'm skipping the issue of parsing dependencies by looking at Thrift "include" directives for now but do want to define path to protocol in the Oasis file for each project. This is so that I can pass -I to thrift above.

How can this be done with Oasis?

	Thanks, Joel 

--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------





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

end of thread, other threads:[~2011-03-21 20:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 13:22 [Caml-list] oasis and thrift Joel Reymont
2011-03-18 13:31 ` [Caml-list] " Sylvain Le Gall
2011-03-21 20:17 [Caml-list] " Joel Reymont

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