ocamlocamlbuildoasis

OCaml: using Oasis with multiple-level src folders


I am trying to use oasis to compile my project, and my project is organized in this way:

_oasis
src/
    main.ml
    core_a.ml
    core_b.ml
    type.ml
    plugins/
        plugin_a.ml
        plugin_b.ml 

Note that in the plugin_a.ml, it refers to module type.ml (i.e., open Type).

When I use oasis to compile the project, it reports:

Unbound module Type

Here is the simplified version of my _oasis file:

....
BuildTools:   ocamlbuild
BuildDepends: deriving, deriving.syntax, core, batteries

Executable "main"
  Path:           src
  MainIs:         main.ml
  CompiledObject: best
  Install:        false
  BuildDepends:   deriving, deriving.syntax, core, batteries

Am I doing anything wrong here? Or what I am doing is not the best practice to organize a project like this?


Solution

  • I think your project structure is a bit strange. You have a sub directory for plugins, but you should note that there's no namespace or package hierarchy so this is not really useful in practice.

    As for whether this is possible, the answer seems to be mixed:

    As your oasis project grows, you should look into defining library sections in oasis and using those to organize inter project dependencies. E.g., in this case you could create a "plugins" library where you include plugin_a and plugin_b. But without some planning ahead here, you will quickly run into circular dependencies.