-
Notifications
You must be signed in to change notification settings - Fork 470
include_subdirs + ocamllex + menhir #1372
Description
Hello,
I was trying today to split a project in several subdirectories behaving as if they were one (Because of a dependency, we cannot split in one module per subdirectory). So I tried using the (include_subdirs unqualified) stanza.
But then I got lost trying to tell Dune how to compile my lexer and parser (ocamllex and manhir). This is basically the structure that causes the problem:
src
├── dir
│ ├── dune
│ ├── lexer.mll
│ └── parser.mly
├── dune
└── main.ml
where src/dune contains:
(include_subdirs unqualified)
(executable
(name main)
(public_name sdkjfbh)
(flags :standard -w -27-33))
and src/dir/dune contains:
(ocamllex lexer)
(menhir (modules parser))
With that architecture, I get the following error when trying to dune build:
Error: I can't determine what library/executable the files produced by this stanza are part of.
I have tried several things to solve my problem:
-
adding a
(include_subdirs unqualified)stanza tosrc/dir/dune, but this hides the modules fromsrc/dirto the others (which is the expected behaviour, but I had to try) -
moving the
(menhir ...)stanza tosrc/duneusing a qualified path:(menhir (modules dir/parser)). In that case, I getError: Unbound module Parserinlexer.mll(whenlexer.mllhas a dependency inparser.mly, in order to use thetokentype for instance`). -
moving both the stanzas in
src/dune. But then, I getError: No rule found for lexer.mllandError: No rule found for parser.mly. If I use a qualified path for the parser, I get rid of the latter but nor the former. And I can't use a qualified path for the lexer without gettingError: dir/lexer.ml does not denote a file in the current directory.
Is there something I didn't try? Is there a way to do this at all? Thank you by advance :-) and I hope I'm not just adding noise