caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Ocamlbuild: could help embedding Ocaml code into shared object?
@ 2008-06-01 11:01 Matthieu Dubuget
  2008-06-05  8:46 ` [Caml-list] " Romain Bardou
  0 siblings, 1 reply; 3+ messages in thread
From: Matthieu Dubuget @ 2008-06-01 11:01 UTC (permalink / raw)
  To: caml-list

I often deliver my work as shared objects (DLL, in fact, because I'm
stuck with Windows at work).

I would like to have ocamlbuild take care of this, but I don't know
exactly how to do it?

The idea would be to split the work in two separate rules.

The first rule generates a shared object from the Objective Caml code:

rule "mloo & cmx* -> native.oo.o"
     ~dep:"%.mloo"
     ~prod:"%.native.oo.o"
     action_for_nativecode

rule "mloo & cmo* -> byte.oo.o"
     ~dep:"%.mloo"
     ~prod:"%.byte.oo.o"
     action_for_bytecode

The actions should return commands with A "-output-obj". But I do not
know how to write them. It would need a mechanism similar to the one
used for mlpack. For example, one .mloo file listing the ocaml files to
link into the output object. Dynamic dependencies are to be generated
from the content of the .mloo file.

Unfortunately, I have no idea how to write that?

The second rule would generate a shared object from the .o files.
Maybe the current clib is enough? I have to add a flag to link
the runtime engine by adding -lasmrun -lm -ldl (-lm and -ldl being
deduced from the output of ocaml* -config).

Am I looking in the right direction?

Thanks in advance for your help

Matt


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

* Re: [Caml-list] Ocamlbuild: could help embedding Ocaml code into shared object?
  2008-06-01 11:01 Ocamlbuild: could help embedding Ocaml code into shared object? Matthieu Dubuget
@ 2008-06-05  8:46 ` Romain Bardou
  2008-06-05 19:20   ` Matthieu Dubuget
  0 siblings, 1 reply; 3+ messages in thread
From: Romain Bardou @ 2008-06-05  8:46 UTC (permalink / raw)
  To: matthieu.dubuget; +Cc: caml-list

Matthieu Dubuget a écrit :
> I often deliver my work as shared objects (DLL, in fact, because I'm
> stuck with Windows at work).
> 
> I would like to have ocamlbuild take care of this, but I don't know
> exactly how to do it?
> 
> The idea would be to split the work in two separate rules.
> 
> The first rule generates a shared object from the Objective Caml code:
> 
> rule "mloo & cmx* -> native.oo.o"
>      ~dep:"%.mloo"
>      ~prod:"%.native.oo.o"
>      action_for_nativecode
> 
> rule "mloo & cmo* -> byte.oo.o"
>      ~dep:"%.mloo"
>      ~prod:"%.byte.oo.o"
>      action_for_bytecode
> 
> The actions should return commands with A "-output-obj". But I do not
> know how to write them. It would need a mechanism similar to the one
> used for mlpack. For example, one .mloo file listing the ocaml files to
> link into the output object. Dynamic dependencies are to be generated
> from the content of the .mloo file.
> 
> Unfortunately, I have no idea how to write that?
> 
> The second rule would generate a shared object from the .o files.
> Maybe the current clib is enough? I have to add a flag to link
> the runtime engine by adding -lasmrun -lm -ldl (-lm and -ldl being
> deduced from the output of ocaml* -config).
> 
> Am I looking in the right direction?
> 
> Thanks in advance for your help
> 
> Matt

I know nothing about DLLs and OCaml but if I understand correctly, you 
need the following.

1) How to parse a file similar to a .mllib file in a plug-in. There is 
an example in the Ocamlfind plug-in on the wiki:

http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild#Source

You want to look at the find_packages function.

2) How to generate dynamic dependencies. This is done by calling the 
second argument of the function you give to the rule function. This is 
also explained in the wiki:

http://brion.inria.fr/gallium/index.php/Making_plugins#Dynamic_dependencies

I hope it helps.

-- 
Romain Bardou


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

* Re: [Caml-list] Ocamlbuild: could help embedding Ocaml code into shared object?
  2008-06-05  8:46 ` [Caml-list] " Romain Bardou
@ 2008-06-05 19:20   ` Matthieu Dubuget
  0 siblings, 0 replies; 3+ messages in thread
From: Matthieu Dubuget @ 2008-06-05 19:20 UTC (permalink / raw)
  To: Romain Bardou; +Cc: caml-list

Romain Bardou a écrit :
> Matthieu Dubuget a écrit :
>> I often deliver my work as shared objects (DLL, in fact, because I'm
>> stuck with Windows at work).
>>
>> I would like to have ocamlbuild take care of this, but I don't know
>> exactly how to do it?
>>
>> The idea would be to split the work in two separate rules.
>>
>> The first rule generates a shared object from the Objective Caml code:
>>
>> rule "mloo & cmx* -> native.oo.o"
>>      ~dep:"%.mloo"
>>      ~prod:"%.native.oo.o"
>>      action_for_nativecode
>>
>> rule "mloo & cmo* -> byte.oo.o"
>>      ~dep:"%.mloo"
>>      ~prod:"%.byte.oo.o"
>>      action_for_bytecode
>>
>> The actions should return commands with A "-output-obj". But I do not
>> know how to write them. It would need a mechanism similar to the one
>> used for mlpack. For example, one .mloo file listing the ocaml files to
>> link into the output object. Dynamic dependencies are to be generated
>> from the content of the .mloo file.
>>
>> Unfortunately, I have no idea how to write that?
>>
>> The second rule would generate a shared object from the .o files.
>> Maybe the current clib is enough? I have to add a flag to link
>> the runtime engine by adding -lasmrun -lm -ldl (-lm and -ldl being
>> deduced from the output of ocaml* -config).
>>
>> Am I looking in the right direction?
>>
>> Thanks in advance for your help
>>
>> Matt
>
> I know nothing about DLLs and OCaml but if I understand correctly, you
> need the following.
>
> 1) How to parse a file similar to a .mllib file in a plug-in. There is
> an example in the Ocamlfind plug-in on the wiki:
>
> http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild#Source
>
>
> You want to look at the find_packages function.
>
> 2) How to generate dynamic dependencies. This is done by calling the
> second argument of the function you give to the rule function. This is
> also explained in the wiki:
>
> http://brion.inria.fr/gallium/index.php/Making_plugins#Dynamic_dependencies
>
>
> I hope it helps.
>
Thanks for the links Romain. I will have a look.

Matt


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

end of thread, other threads:[~2008-06-05 19:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-01 11:01 Ocamlbuild: could help embedding Ocaml code into shared object? Matthieu Dubuget
2008-06-05  8:46 ` [Caml-list] " Romain Bardou
2008-06-05 19:20   ` Matthieu Dubuget

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