Version française
Home     About     Download     Resources     Contact us    
Browse thread
Ocamlbuild with findlib + camlp4
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Arnaud Spiwack <Arnaud.Spiwack@l...>
Subject: Re: [Caml-list] Ocamlbuild with findlib + camlp4
Hi,

I happen to have an *almost* generic ocamlbuild plugin that calls upon 
camlp4 and findlib. Actually it is meant at compiling ulex files. But it 
is mostly the idea. However, it is still messy and need to be cleaned up 
before being put on the wiki.

The general idea is that it does *not* use ocamlfind ocamlc bar.ml 
-syntax foo. It actually proceeds in two parts. The first part consists 
in querying with ocamlfind query (using the shell, so it is not much of 
a clean part) to get the list of files to pass to the preprocessor, then 
uses camlp4 with the marshalled AST printer (there is also a target to 
build a pretty printed OCaml file from the file with syntax extension. 
This is mostly useful for debugging your own syntax extensions though). 
The second part consists in compiling this marshalled AST (using Findlib 
again to locate the .cm{i,o,a} that need to be linked or used at typing 
time).

I'll try to get that online ASAP.



Arnaud Spiwack

Dario Teixeira a écrit :
>> Nice!  Apart  the link with findlib.cma that is not supported yet and could
>> be with  the  multiple-plugins support in ocamlbuild. I think that one can
>> easily build a generic plugin for ocamlfind packages.
>>     
>
> Hi,
>
> I hope so too.  However, note that no one has managed yet to provide a solution
> to my original question, namely of integrating Ocamlbuild with findlib *and*
> camlp4.  Perhaps I should have explained better what this entails:
>
> Suppose you are using the Sexplib syntax extension.  This syntax extension
> depends on Sexplib itself and on another syntax extension, offered by the
> Type-conv package.  The META package for Sexplib should contain the following:
> (note that the version currently shipping with GODI is incomplete)
>
> ###############################################################
> name="sexplib"
> version="3.0.0"
> description="Sexplib - automated S-expression conversions"
> requires="bigarray"
> archive(byte)="sexplib.cma"
> archive(native)="sexplib.cmxa"
>
> package "statements" (
>   requires = "sexplib,type-conv.statements,camlp4"
>   version = "3.0.0"
>   description = "Syntax extension for Sexplib"
>   archive(syntax,preprocessor) = "pa_sexp_conv.cmo"
>   archive(syntax,toploop) = "pa_sexp_conv.cmo"
>   )
> ###############################################################
>
>
> To compile with Findlib a data.ml file that makes use of the Sexplib syntax
> extension is very simple.  You just have to specify the "sexplib.statements"
> package, and findlib will *automatically* take care of also loading libraries
> or even other syntax extensions needed by sexplib.statements:
>
> ocamlfind ocamlc -package sexplib.statements -syntax camlp4o -c data.ml
>
>
> Why am I insisting on this?  Because when we manage to integrate these
> three tools, we will essentially have solved the very common request of
> providing easy access to common syntax extensions (just last week there was
> an OSR on this subject).  All that will be required to compile a file such as
> data.ml using the Sexplib syntax extension will be to add a line "<data.ml>:
> use_sexplib.statements" to the _tags file.  You won't even need to create
> a custom Ocamlbuild plugin or anything, because this findlib support could
> be provided by a default plugin (living on $HOME/.ocamlbuild or something).
>
> So, Nicolas, is this altogether feasible with the current Ocamlbuild?
> (And if so, could you lent us a hand -- you are of course the most
> competent person to do so).
>
> Kind regards,
> Dario
>
>
>
>       ___________________________________________________________ 
> Rise to the challenge for Sport Relief with Yahoo! For Good  
>
> http://uk.promotions.yahoo.com/forgood/
>
> _______________________________________________
> 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
>
>