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=1.4 required=5.0 tests=SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 00A89BC6C for ; Thu, 22 Nov 2007 00:21:44 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAGdMREdC+VyskGdsb2JhbACPMwEBAQEHAgYTEQc X-IronPort-AV: E=Sophos;i="4.21,448,1188770400"; d="scan'208";a="19551867" Received: from ug-out-1314.google.com ([66.249.92.172]) by mail4-smtp-sop.national.inria.fr with ESMTP; 22 Nov 2007 00:21:44 +0100 Received: by ug-out-1314.google.com with SMTP id m3so242270ugc for ; Wed, 21 Nov 2007 15:21:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; bh=Kf0315aCSD4lmIcEaiyvgR2UD6q6rZBE4MHrGMhuWY0=; b=mYdcTWfBS+bKEcNALZL2OY/vAhOUMZ2UgvG53L8AHUunndmg4/bQ9V+V9Vj60Bq3uiDbtl/noIgvKmFRQ/qcB2ax5UgYWKT8XmcE3eSzvQTs+n8HwdJ059cbx7b2ry4dvBIFGgyOL+SL21Th8btrqWapJG3Q+vje0lNnbZEzzHM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=t8LywZSydu+Qqx1R7OB+Zekm4ESWt+pCEdtcdP7nqRLnLG5rpoChQ0uEoT2nE5GPH8YD00fbk/pv8dz8v6QxbM2oHrjDfHDzpj4By/ULOIrtjO3Pisa/60F2EVUNcFKOcfcudk4bNI5gZ9w9v8IGBgiWPTx93OK2KBcsAl50yK4= Received: by 10.78.177.3 with SMTP id z3mr9051472hue.1195687303624; Wed, 21 Nov 2007 15:21:43 -0800 (PST) Received: by 10.78.58.19 with HTTP; Wed, 21 Nov 2007 15:21:43 -0800 (PST) Message-ID: <4b5157c30711211521g38a5d7bbg204e1283b975f38@mail.gmail.com> Date: Thu, 22 Nov 2007 00:21:43 +0100 From: "Paolo Donadeo" To: caml-list@yquem.inria.fr Subject: Using findlib and a syntax extension with ocamlbuild MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Spam: no; 0.00; findlib:01 syntax:01 wiki:01 findlib:01 syntax:01 libs:01 compilation:01 libs:01 camlp:01 camlp:01 netstring:01 ocamlfind:01 ocamlfind:01 -package:01 ocaml:01 I'm fighting again with ocamlbuild. In the (excellent!) wiki I found two useful recipes: how to use findlib with ocamlbuild and how to compile source code using a syntax extension. Now it happens that I have both these needs, and I'm not so sure how to mix the ingredients and obtain a good dish. At the moment the solution I have discovered (by trial and error) works well, but it doesn't seem very clean. The involved files in my source directory are these: ./xnuncc.ml ./myocamlbuild.ml ./ext_libs/openin-20070524/pa_openin.ml ./_tags In xnuncc.ml I use the openin extension, and xnuncc.ml is the main compilation unit. Here is the contents of _tags and the plugin for ocamlbuild: ======= 8< CUT HERE: _tags >8 ======= or or or or : include : include true : dtypes <**/pa_openin.ml> : camlp4of, use_camlp4of "xnuncc.ml" : camlp4o, use_openin ======= 8< END HERE: _tags >8 ======= ======= 8< CUT HERE: myocamlbuild.ml >8 ======= open Ocamlbuild_plugin;; open Command;; let packages = "str,netstring,oUnit,extlib";; let ocamlfind cmd = S[A"ocamlfind"; A cmd; A"-package"; A packages];; flag ["ocaml"; "link"] (A"-linkpkg");; dispatch begin function | After_options -> Options.ocamlc := ocamlfind "ocamlc"; Options.ocamlopt := ocamlfind "ocamlopt"; | After_rules -> ocaml_lib ~extern:true ~dir:"+camlp4" "camlp4of"; flag ["ocaml"; "pp"; "use_openin"] (A"ext_libs/openin-20070524/pa_openin.cmo"); dep ["ocaml"; "ocamldep"; "use_openin"] ["ext_libs/openin-20070524/pa_openin.cmo"]; | _ -> () end ======= 8< END HERE: myocamlbuild.ml >8 ======= As I wrote this works, but the aspect I don't like is why I have to specify the full path of "ext_libs/openin-20070524/pa_openin.cmo" instead of a simple "pa_openin.cmo", inside myocamlbuild.ml. Including the directory "ext_libs/openin-20070524" in the _tags file does't seem to be enough. If I use "pa_openin.cmo", indeed, the result is an absurd (for me) error message starting with: ======= 8< CUT HERE: error message >8 ======= Ocamlbuild knows of no rules that apply to a target named ext_libs/openin-20070524/xnuncc.d.ml. This can happen if you ask Ocamlbuild to build a target with the wrong extension (e.g. .opt instead of .native) or if the source files live in directories that have not been specified as include directories. Backtrace: - Failed to build the target xnuncc.d.byte - Failed to build all of these: - Building ext_libs/openin-20070524/xnuncc.d.byte: - Failed to build all of these: - Building ext_libs/openin-20070524/xnuncc.d.cmo: - Failed to build all of these: - Building ext_libs/openin-20070524/xnuncc.d.ml - Building ext_libs/openin-20070524/xnuncc.ml: - Failed to build all of these: - Building ext_libs/openin-20070524/xnuncc.mly ... ... ... ======= 8< END HERE: error message >8 ======= At the end of the story the question is: is this solution the best possible for compiling a project with findlib and a syntax extension present in a subdir of the project? TIA, -- Paolo Paolo Donadeo, Senior Software Engineer Studio Associato 4Sigma Email: p.donadeo@4sigma.it ~ ~ :wq