From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id AC1F0BB84 for ; Thu, 5 Jun 2008 10:43:53 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: An4BAC9ER0jAXQIniGdsb2JhbACSCAEBAQ8gnTw X-IronPort-AV: E=Sophos;i="4.27,594,1204498800"; d="scan'208";a="11588565" Received: from concorde.inria.fr ([192.93.2.39]) by mail2-smtp-roc.national.inria.fr with ESMTP; 05 Jun 2008 10:43:53 +0200 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m558hpkw025253 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 5 Jun 2008 10:43:53 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AmAAAC9ER0iBrw8Eo2dsb2JhbACSCAEBAQEBCAUIBxGdPA X-IronPort-AV: E=Sophos;i="4.27,594,1204498800"; d="scan'208";a="13262628" Received: from ext.lri.fr ([129.175.15.4]) by mail1-smtp-roc.national.inria.fr with ESMTP; 05 Jun 2008 10:43:53 +0200 Received: from localhost (localhost [127.0.0.1]) by ext.lri.fr (Postfix) with ESMTP id 238F4A47B2; Thu, 5 Jun 2008 10:43:53 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at lri.fr Received: from ext.lri.fr ([127.0.0.1]) by localhost (ext.lri.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 1sQI0WjFkFPx; Thu, 5 Jun 2008 10:43:53 +0200 (CEST) Received: from smtp.lri.fr (vhost3-23 [129.175.3.23]) by ext.lri.fr (Postfix) with ESMTP id 0BD53A41B5; Thu, 5 Jun 2008 10:43:53 +0200 (CEST) Received: from [129.175.4.107] (lri4-107 [129.175.4.107]) by smtp.lri.fr (Postfix) with ESMTP id 0652EE0546; Thu, 5 Jun 2008 10:43:53 +0200 (CEST) Message-ID: <4847A7E6.9020506@lri.fr> Date: Thu, 05 Jun 2008 10:46:30 +0200 From: Romain Bardou User-Agent: Thunderbird 2.0.0.14 (X11/20080505) MIME-Version: 1.0 To: matthieu.dubuget@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Ocamlbuild: could help embedding Ocaml code into shared object? References: <48428185.6010503@gmail.com> In-Reply-To: <48428185.6010503@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 4847A747.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; lri:01 ocaml:01 matthieu:01 dubuget:01 cmx:01 nativecode:01 cmo:01 byte:01 byte:01 bytecode:01 -output-obj:01 ocaml:01 dependencies:01 runtime:01 -lm:01 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