Does dune support glob patterns for libraries?

Viewed 44

Background

I'm trying to expose two dune libraries from the same directory - one for some interfaces, and the other for their implementations.

For example, let's say I have the following sources:

foo_api.ml
module type Foo = sig
  val foo: string
end
foo.ml
module FooImpl: Foo =
  let foo = "foo"
end

In my dune file, I want to expose these as separate libraries - an API and an implementation. I'd really like to be able to use globs here to specify the modules, as I'm planning on using this pattern for other modules, eg. Bar.ml and Bar_api.ml.

Question

Does dune support some way of globbing (or regex'ing) for modules?

(library
 (name foo_lib_api)
 (modules (glob_files "./*_api.ml")))

(library
 (name foo_lib_implementation)
 (modules (:standard \ (glob_files "./*_api.ml"))))

The above syntax does not work, and I haven't found anything that does work. Perhaps I'm trying to use dune like I would use bazel, which would let me use glob or filegroup.

1 Answers

Dune does not support glob patterns in the modules stanza.

A more idiomatic alternative would be to have one directory, which has the advantages of allowing to decouple the module and library names.

Related