Hello,
So I was recently tasked to update an old project, which uses dune, and I am not sure I fully grasp what is happening in one specific part.
The project was last used 2+ years ago with dune 1.8 and ocaml 4.09.0, which i updated to what I am now using; dune 3.8.0 and ocaml 5.0.0, as well as cppo 1.6.9.
When attempting to dune build, this happened:
File "dune", line 4, characters 22-54:
4 | (preprocess (action (run %{bin:cppo} %{input-file})))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: File "ast.ml", line 613, characters 0-39
Error: Cannot find included file "visitorInternalDsl.ml"
Which dissappeared after i added (preprocessor_deps visitorInternalDsl.ml)
.
I then had the same error with ast.ml not finding some of the generated.ml templates:
File "dune", line 7, characters 22-54:
7 | (preprocess (action (run %{bin:cppo} %{input-file})))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: File "ast.ml", line 616, characters 0-50
Error: Cannot find included file "templates/script.ml.generated.ml"
And I cannot seem to fix this one. So far I have tried:
Adding (source_tree _build/default/templates/)
to the preprocessor_deps.
Adding (include_subdirs unqualified)
to the dune file.
Modifying the path of the included file in ast.ml.
Using -I option in the cppo action.
My understanding is that I fail to specify to dune and/or cppo where it should look for the files, but even that may be wrong.
My dune file is:
(ocamllex lexer)
(menhir (flags ("--explain" "--dump")) (modules grammar))
(executable
(preprocessor_deps visitorInternalDsl.ml)
(preprocess (action (run %{bin:cppo} %{input-file})))
(name parser)
(libraries core))
An extract of ast.ml, where the problematic line is:
method visit_script (my:script) =
#include "visitorInternalDsl.ml"
(*INTERNAL DSL START*)
#include "templates/script.ml.generated.ml"
(*INTERNAL DSL STOP*)
ht
My project tree is as follows:
.
├── ast.ml
├── _build
│ ├── default
│ │ ├── ast.ml
│ │ ├── globals.ml
│ │ ├── globals.pp.ml
│ │ ├── grammar.mly
│ │ ├── grammar__mock.ml.mock
│ │ ├── grammar__mock.ml.pp.mock
│ │ ├── lexer.ml
│ │ ├── lexer.mll
│ │ ├── lexer.pp.ml
│ │ ├── parser.ml
│ │ ├── parser.pp.ml
│ │ ├── templates
│ │ │ ├── actions.ml
│ │ │ ├── actions.ml.generated.ml
│ │ │ └── every other template
│ │ └── visitorInternalDsl.ml
│ └── log
├── dune
├── dune-project
├── globals.ml
├── grammar.mly
├── io_externs.phaistos
├── lexer.mll
├── Makefile
├── merlin-init.sh
├── parser.ml
├── README.md
├── templates
│ ├── actions.ml
│ ├── arithmeticOp.ml
│ └── other templates
├── temp.txt
└── visitorInternalDsl.ml