OCaml Forge

Detail: [#1050] Dependency on a library that is a syntax extension.

Bugs: Browse | Download .csv | Monitor

[#1050] Dependency on a library that is a syntax extension.

Date:
2011-11-02 10:29
Priority:
3
State:
Open
Submitted by:
Philippe Veber (pveber)
Assigned to:
Sylvain Le Gall (gildor-admin)
Product:
OASIS
Due in version:
None
Resolution:
None
Severity:
enhancement
Version:
0.2.0
Component:
OASIS
Operating System:
All
 
URL:
Summary:
Dependency on a library that is a syntax extension.

Detailed description
Let's say we define a package with a library A that is a syntax extension, and another component B (library or executable) that depends on A. It is currently not possible to use the syntax extension A in B: the compilation of B fails at ocamldep stage, because the appropriate options are not set. In contrast, if A were a regular library, there would be no problem to use it in B.

A workaround found in the LWT package (which offers several syntax extensions) is to modify myocamlbuild.ml manually (of course after the generated part so that it is kept between calls to oasis setup). Here is how I got it working (not sure this is a minimal solution, however), by adapting the ocamlbuild plugin found in LWT:

open Ocamlbuild_plugin

let () =
dispatch
(fun hook ->
dispatch_default hook;
match hook with
| Before_options ->
Options.make_links := false
| After_rules ->
(* Internal syntax extension *)
List.iter
(fun base ->
let tag = "pa_" ^ base and file = "src/syntax/pa_" ^ base ^ ".cmo" in
flag ["ocaml"; "compile"; tag] & S[A"-ppopt"; A file];
flag ["ocaml"; "ocamldep"; tag] & S[A"-ppopt"; A file];
flag ["ocaml"; "doc"; tag] & S[A"-ppopt"; A file];
dep ["ocaml"; "ocamldep"; tag] [file])
["syntax_ext1";"syntax_ext2"]; (* add your syntax extensions here *)
| _ ->
())

Followup

No Followups Have Been Posted

Attached Files:

Changes:

Field Old Value Date By
assigned_tonone2012-03-12 22:14gildor-admin