Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include_subdirs + ocamllex + menhir #1372

Closed
Niols opened this issue Oct 1, 2018 · 1 comment · Fixed by ocaml/opam-repository#12774
Closed

include_subdirs + ocamllex + menhir #1372

Niols opened this issue Oct 1, 2018 · 1 comment · Fixed by ocaml/opam-repository#12774

Comments

@Niols
Copy link
Contributor

Niols commented Oct 1, 2018

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 to src/dir/dune, but this hides the modules from src/dir to the others (which is the expected behaviour, but I had to try)

  • moving the (menhir ...) stanza to src/dune using a qualified path: (menhir (modules dir/parser)). In that case, I get Error: Unbound module Parser in lexer.mll (when lexer.mll has a dependency in parser.mly, in order to use the token type for instance`).

  • moving both the stanzas in src/dune. But then, I get Error: No rule found for lexer.mll and Error: 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 getting Error: 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

@ghost
Copy link

ghost commented Oct 1, 2018

Indeed, ths is a bug in Dune.

rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Oct 4, 2018
CHANGES:

- Do not fail if the output of `ocamlc -config` doesn't include
  `standard_runtime` (ocaml/dune#1326, @diml)

- Let `Configurator.V1.C_define.import` handle negative integers
  (ocaml/dune#1334, @Chris00)

- Re-execute actions when a target is modified by the user inside
  `_build` (ocaml/dune#1343, fix ocaml/dune#1342, @diml)

- Pass `--set-switch` to opam (ocaml/dune#1341, fix ocaml/dune#1337, @diml)

- Fix bad interaction between multi-directory libraries the `menhir`
  stanza (ocaml/dune#1373, fix ocaml/dune#1372, @diml)

- Integration with automatic formatters (ocaml/dune#1252, fix ocaml/dune#1201, @emillon)

- Better error message when using `(self_build_stubs_archive ...)` and
  `(c_names ...)` or `(cxx_names ...)` simultaneously.
  (ocaml/dune#1375, fix ocaml/dune#1306, @nojb)

- Improve name detection for packages when the prefix isn't an actual package
  (ocaml/dune#1361, fix ocaml/dune#1360, @rgrinberg)

- Support for new menhir rules (ocaml/dune#863, fix ocaml/dune#305, @fpottier, @rgrinberg)

- Do not remove flags when compiling compatibility modules for wrapped mode
  (ocaml/dune#1382, fix ocaml/dune#1364, @rgrinberg)

- Fix reason support when using `staged_pps` (ocaml/dune#1384, @charlesetc)

- Add support for `enabled_if` in `rule`, `menhir`, `ocamllex`,
  `ocamlyacc` (ocaml/dune#1387, @diml)

- Exit gracefully when a signal is received (ocaml/dune#1366, @diml)

- Load all defined libraries recursively into utop (ocaml/dune#1384, fix ocaml/dune#1344,
  @rgrinberg)

- Allow to use libraries `bytes`, `result` and `uchar` without `findlib`
  installed (ocaml/dune#1391, @nojb)
rgrinberg added a commit to rgrinberg/opam-repository that referenced this issue Oct 10, 2018
CHANGES:

- Do not fail if the output of `ocamlc -config` doesn't include
  `standard_runtime` (ocaml/dune#1326, @diml)

- Let `Configurator.V1.C_define.import` handle negative integers
  (ocaml/dune#1334, @Chris00)

- Re-execute actions when a target is modified by the user inside
  `_build` (ocaml/dune#1343, fix ocaml/dune#1342, @diml)

- Pass `--set-switch` to opam (ocaml/dune#1341, fix ocaml/dune#1337, @diml)

- Fix bad interaction between multi-directory libraries the `menhir`
  stanza (ocaml/dune#1373, fix ocaml/dune#1372, @diml)

- Integration with automatic formatters (ocaml/dune#1252, fix ocaml/dune#1201, @emillon)

- Better error message when using `(self_build_stubs_archive ...)` and
  `(c_names ...)` or `(cxx_names ...)` simultaneously.
  (ocaml/dune#1375, fix ocaml/dune#1306, @nojb)

- Improve name detection for packages when the prefix isn't an actual package
  (ocaml/dune#1361, fix ocaml/dune#1360, @rgrinberg)

- Support for new menhir rules (ocaml/dune#863, fix ocaml/dune#305, @fpottier, @rgrinberg)

- Do not remove flags when compiling compatibility modules for wrapped mode
  (ocaml/dune#1382, fix ocaml/dune#1364, @rgrinberg)

- Fix reason support when using `staged_pps` (ocaml/dune#1384, @charlesetc)

- Add support for `enabled_if` in `rule`, `menhir`, `ocamllex`,
  `ocamlyacc` (ocaml/dune#1387, @diml)

- Exit gracefully when a signal is received (ocaml/dune#1366, @diml)

- Load all defined libraries recursively into utop (ocaml/dune#1384, fix ocaml/dune#1344,
  @rgrinberg)

- Allow to use libraries `bytes`, `result` and `uchar` without `findlib`
  installed (ocaml/dune#1391, @nojb)

- Take argument to self_build_stubs_archive into account. (ocaml/dune#1395, @nojb)

- Fix bad interaction between `env` customization and vendored
  projects: when a vendored project didn't have its own `env` stanza,
  the `env` stanza from the enclosing project was in effect (ocaml/dune#1408,
  @diml)

- Fix stop early bug when scanning for watermarks (ocaml/dune#1423, @diml)
shonfeder pushed a commit to shonfeder/dune that referenced this issue Dec 31, 2018
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
shonfeder pushed a commit to shonfeder/dune that referenced this issue Dec 31, 2018
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant