caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* ocamlbuild and c libs
@ 2007-09-30 21:52 Daniel Bünzli
  2007-10-04 14:49 ` Alan Falloon
  0 siblings, 1 reply; 5+ messages in thread
From: Daniel Bünzli @ 2007-09-30 21:52 UTC (permalink / raw)
  To: caml-list List

Hello (Nicolas),

Is it possible to specify build flags and deps in a compositional  
way ? That is I have C bindings in a libdip/ dir, I would like to  
specify the additional flags and dep there, not in the toplevel  
myocamlbuild.ml. I tried to make the toplevel plugin refer to  
external modules but it seems to be compiled in a restricted  
environement. I also tried to define a myocamlbuild.ml in libdip/ but  
it seems to be ignored. Is there something like a plugin hierarchy as  
with the _tag files ?

Best,

Daniel

P.S.

By the way I couldn't find it in the documentation but ocamlbuild  
ignores any directory starting with an underscore even if you include  
it explictly with a tag, is that right ?


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

* Re: ocamlbuild and c libs
  2007-09-30 21:52 ocamlbuild and c libs Daniel Bünzli
@ 2007-10-04 14:49 ` Alan Falloon
  2007-10-08 13:25   ` [Caml-list] " Nicolas Pouillard
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Falloon @ 2007-10-04 14:49 UTC (permalink / raw)
  To: caml-list

Daniel Bünzli wrote:
> Is it possible to specify build flags and deps in a compositional way ? 
> That is I have C bindings in a libdip/ dir, I would like to specify the 
> additional flags and dep there, not in the toplevel myocamlbuild.ml. I 
> tried to make the toplevel plugin refer to external modules but it seems 
> to be compiled in a restricted environement. I also tried to define a 
> myocamlbuild.ml in libdip/ but it seems to be ignored. Is there 
> something like a plugin hierarchy as with the _tag files ?

This is something that I am interested in as well. With this change plus 
a couple of other small changes you would be able to make a project that 
compiles on its own in ocamlbuild, or as a subdirectory of another 
project. It would be very useful when working on separate, but 
dependent, projects.

Another useful addition would be to pass the include flags when 
compiling c stubs. Right now, you need to write a plugin even if you 
only want to include the other project directories.

> By the way I couldn't find it in the documentation but ocamlbuild 
> ignores any directory starting with an underscore even if you include it 
> explictly with a tag, is that right ?

I don't know if its intended, but the code is pretty clearly doing 
exactly what you describe:

ocamlbuild/main.ml:105
(String.length name > 0 && name.[0] <> '_' && not (List.mem name 
!Options.exclude_dirs))


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

* Re: [Caml-list] Re: ocamlbuild and c libs
  2007-10-04 14:49 ` Alan Falloon
@ 2007-10-08 13:25   ` Nicolas Pouillard
  2007-10-09 14:11     ` Alan Falloon
  0 siblings, 1 reply; 5+ messages in thread
From: Nicolas Pouillard @ 2007-10-08 13:25 UTC (permalink / raw)
  To: Alan Falloon; +Cc: caml-list

Excerpts from Alan Falloon's message of Thu Oct 04 16:49:54 +0200 2007:
> Daniel Bünzli wrote:
> > Is it possible to specify build flags and deps in a compositional way ? 
> > That is I have C bindings in a libdip/ dir, I would like to specify the 
> > additional flags and dep there, not in the toplevel myocamlbuild.ml. I 
> > tried to make the toplevel plugin refer to external modules but it seems 
> > to be compiled in a restricted environement. I also tried to define a 
> > myocamlbuild.ml in libdip/ but it seems to be ignored. Is there 
> > something like a plugin hierarchy as with the _tag files ?
> 
> This is something that I am interested in as well. With this change plus 
> a couple of other small changes you would be able to make a project that 
> compiles on its own in ocamlbuild, or as a subdirectory of another 
> project. It would be very useful when working on separate, but 
> dependent, projects.

Having multiple plugins is the priority for the next version of ocamlbuild.

> Another useful addition would be to pass the include flags when 
> compiling c stubs. Right now, you need to write a plugin even if you 
> only want to include the other project directories.

You can also specify include directories using tags.

"libfoo": include

> > By the way I couldn't find it in the documentation but ocamlbuild 
> > ignores any directory starting with an underscore even if you include it 
> > explictly with a tag, is that right ?

That's intended.

> 
> I don't know if its intended, but the code is pretty clearly doing 
> exactly what you describe:
> 
> ocamlbuild/main.ml:105
> (String.length name > 0 && name.[0] <> '_' && not (List.mem name 
> !Options.exclude_dirs))

Right.
-- 
Nicolas Pouillard aka Ertai


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

* Re: [Caml-list] Re: ocamlbuild and c libs
  2007-10-08 13:25   ` [Caml-list] " Nicolas Pouillard
@ 2007-10-09 14:11     ` Alan Falloon
  2007-10-10 14:38       ` Nicolas Pouillard
  0 siblings, 1 reply; 5+ messages in thread
From: Alan Falloon @ 2007-10-09 14:11 UTC (permalink / raw)
  To: Nicolas Pouillard; +Cc: caml-list

Nicolas Pouillard wrote:
> Excerpts from Alan Falloon's message of Thu Oct 04 16:49:54 +0200 2007:
>> Another useful addition would be to pass the include flags when 
>> compiling c stubs. Right now, you need to write a plugin even if you 
>> only want to include the other project directories.
> 
> You can also specify include directories using tags.
> 
> "libfoo": include

That works for compiling ocaml ".ml -> .cmo" code, but not for c code 
".c -> .o".

I had to add this to my After_rules section:
	flag ["c"; "compile"] (
	  S( List.map
	      (fun p -> S[A"-ccopt"; A("-I../"^p)])
	      !Ocamlbuild_pack.Options.include_dirs)
	);

To get the stubs to have the project include dirs.

It is a big hack because what I really want to do is scan the C file and 
determine which header files is actually depends on and have them copied 
into the _build directory before compiling (notice the include flag has 
.. in it). However, I am having a really hard time figuring our how to 
reproduce the dependency magic implemented for the ocaml stuff, and at 
least this sort of works (as long as I don't expect the .o to rebuild 
when I touch the headers).

Maybe this would make another good example for the Wiki.


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

* Re: [Caml-list] Re: ocamlbuild and c libs
  2007-10-09 14:11     ` Alan Falloon
@ 2007-10-10 14:38       ` Nicolas Pouillard
  0 siblings, 0 replies; 5+ messages in thread
From: Nicolas Pouillard @ 2007-10-10 14:38 UTC (permalink / raw)
  To: Alan Falloon; +Cc: caml-list

Excerpts from Alan Falloon's message of Tue Oct 09 16:11:01 +0200 2007:
> Nicolas Pouillard wrote:
> > Excerpts from Alan Falloon's message of Thu Oct 04 16:49:54 +0200 2007:
> >> Another useful addition would be to pass the include flags when 
> >> compiling c stubs. Right now, you need to write a plugin even if you 
> >> only want to include the other project directories.
> > 
> > You can also specify include directories using tags.
> > 
> > "libfoo": include
> 
> That works for compiling ocaml ".ml -> .cmo" code, but not for c code 
> ".c -> .o".
> 
> I had to add this to my After_rules section:
>     flag ["c"; "compile"] (
>       S( List.map
>           (fun p -> S[A"-ccopt"; A("-I../"^p)])
>           !Ocamlbuild_pack.Options.include_dirs)
>     );

Hum, that's make sense.

[...]

> It is a big hack because what I really want to do is scan the C file and 
> determine which header files is actually depends on and have them copied 
> into the _build directory before compiling (notice the include flag has 
> .. in it). However, I am having a really hard time figuring our how to 
> reproduce the dependency magic implemented for the ocaml stuff, and at 
> least this sort of works (as long as I don't expect the .o to rebuild 
> when I touch the headers).

Have  you  tried  to  use  `gcc -MM' it's some kind of ocamldep for C code. It
returns  dependencies  in  a  makefile  syntax. But you can do almost the same
thing as for OCaml.

> Maybe this would make another good example for the Wiki.

Indeed! A volunteer... :)
-- 
Nicolas Pouillard aka Ertai


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

end of thread, other threads:[~2007-10-10 14:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-30 21:52 ocamlbuild and c libs Daniel Bünzli
2007-10-04 14:49 ` Alan Falloon
2007-10-08 13:25   ` [Caml-list] " Nicolas Pouillard
2007-10-09 14:11     ` Alan Falloon
2007-10-10 14:38       ` Nicolas Pouillard

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