Ocamlbuild doesn't take in account the included folders

90 views Asked by At

I am trying to use ocamlbuild to build my project. It needs to take into account an external library (also compiled with ocamlbuild) that contains in the folder myfolder/ the following files (myfolder is a symlink to the good library that I create in the file myocamlbuild.ml):

$ ls _build/myfolder/
PhTools.cmi  PhTools.ml          PhTools.mli
PhTools.cmo  PhTools.ml.depends  PhTools.mli.depends

To compile my library I run the following command:

ocamlbuild -use-ocamlfind -plugin-tags "package(eliom.ocamlbuild),package(containers),package(fileutils)" -Is "myfolder" -mods "myfolder/PhTools.cmo" _server/./TestHelloServices.cmo

When I run it I have the error:

[...]
ocamlfind ocamlc -I '' -I _server -I _type -i -thread -package eliom.server -package eliom.syntax.predef -package eliom.syntax.type -syntax camlp4o _type/TestHelloServices.ml > _type/TestHelloServices.inferred.mli
+ ocamlfind ocamlc -I '' -I _server -I _type -i -thread -package eliom.server -package eliom.syntax.predef -package eliom.syntax.type -syntax camlp4o _type/TestHelloServices.ml > _type/TestHelloServices.inferred.mli
File "TestHelloServices.eliom", line 6, characters 10-17:
Error: Unbound module PhTools
Command exited with code 2.

As you can see the option -I myproject hasn't been given to the command ocamlfind ocamlc -i .... You can note that if I add by hand ocamlfind ocamlc -i -I 'myproject' this step works. I tried lot's of differents things to solve my problem : using -cflags '-I,myproject' -lflags '-I,myproject', putting in _tags the line:

myproject: include

but I always have this error.

I don't know if it's a relevant information but I use a slightly modified version of the ocsigen myocamlbuild.ml file:

let client_dir = "_client"
let server_dir = "_server"
let type_dir = "_type"
module M = Ocamlbuild_eliom.Make(struct
    let client_dir = client_dir
    let server_dir = server_dir
    let type_dir = type_dir
  end)

open Ocamlbuild_plugin;;

let () =
  dispatch begin function
    | Before_options ->
      M.dispatcher Before_options;
      (* Link root project *)
      (try
         Unix.symlink "../../../../../myfolder/" "_build/myfolder"
       with Unix.Unix_error (Unix.EEXIST, _, _)-> ());
    | hook -> M.dispatcher hook
  end;

Thank you in advance,

TobiasBora.

1

There are 1 answers

0
ygrek On

I guess ocamlbuild will not follow "external" (out of project tree) links. Maybe hardlink will work, but better yet install the library as the normal ocamlfind package.