ocaml / oasis

Cabal like system for OCaml
Other
125 stars 45 forks source link

Optional deps become mandatory in _tags #96

Open Chris00 opened 7 years ago

Chris00 commented 7 years ago

As an example, this _oasis file optionally compiles a library, making the lablgtk2 dependency optional. However, the _tag file contains

<src/*.ml{,i,y}>: package(lablgtk2)

which turns it into a compulsory dependency.

Chris00 commented 7 years ago

I think, dependencies should be managed at a module level: if a module M appears in several Library and/or Executable sections, the intersection of these sections dependencies should be used for m.ml{,i,y}.

This should allow to have optional sections, only built if the proper dependencies are present.

Chris00 commented 7 years ago

For csv-1.6, I changed <src/*.ml{,i,y}>: package(lwt) into <src/csv_lwt.ml{,i,y}>: package(lwt) in the _tag file and tests passed, showing that this is the culprit.

gildor478 commented 7 years ago

Option 1 (simple solution to the problem): Put the optional library in a different directory, e.g. src/gtk:

Library cairo2
  Path:         src

Library cairo_gtk
  Build$:   flag(lablgtk2)
  Path:         src/gtk

This will prevent dependency pollution.

Option 2 (more complex): The best way would be to tag precisely files. In order to do this, you need to be able to list the files really used. We can guess all the file names in the directory using Modules and InternalModules and then generate each precise rules.

We will need the feature source_patterns. This allows to get a precise listing.

I think the design of this thing is a bit fragile, because if we miss a single file for the compilation, we fail...