Dune dependency computing

Hi,
I try to move a project from dune 1.6.3 to dune 1.7. This dune is used to build some embedded cmis files:

(rule
 (targets embedded_grading_cmis.ml)
 (deps (:compiler-cmis
        %{ocaml-config:standard_library}/compiler-libs/longident.cmi
        %{ocaml-config:standard_library}/compiler-libs/asttypes.cmi
        %{ocaml-config:standard_library}/compiler-libs/ast_helper.cmi
        %{ocaml-config:standard_library}/compiler-libs/ast_mapper.cmi
        %{ocaml-config:standard_library}/compiler-libs/parsetree.cmi
        %{ocaml-config:standard_library}/compiler-libs/location.cmi
        %{ocaml-config:standard_library}/compiler-libs/parse.cmi)
       (:generated-cmis
        ../ppx-metaquot/.ty.objs/ty.cmi
        ../ppx-metaquot/.fun_ty.objs/fun_ty.cmi
        .testing.objs/introspection_intf.cmi
        .learnocaml_report.objs/learnocaml_report.cmi
        .testing.objs/test_lib.cmi
        .testing.objs/mutation_test.cmi))
 (action (with-stdout-to %{targets}
           (run ocp-ocamlres -format ocamlres %{compiler-cmis} %{generated-cmis})))
)

(library
 (name grading)
 (wrapped false)
 (modes byte)
 (library_flags :standard -linkall)
 (libraries testing
            learnocaml_ppx_metaquot
            ocplib-ocamlres.runtime
            embedded_cmis
            ocplib_i18n
            learnocaml_report)
 (modules Embedded_grading_cmis
          Grading)
 (preprocess (per_module ((pps ppx_ocplib_i18n learnocaml_ppx_metaquot) Grading)))
)

With the 1.6.3 version everything works great but with the 1.7 version, I get this error and I don’t understand why:

File "src/grader/dune", line 98, characters 0-954:
 98 | (rule
 99 |  (targets embedded_grading_cmis.ml)
100 |  (deps (:compiler-cmis
.....115 |  (action (with-stdout-to %{targets}
116 |            (run ocp-ocamlres -format ocamlres %{compiler-cmis} %{generated-cmis})))
117 | )
Error: No rule found for
src/grader/.learnocaml_report.objs/learnocaml_report.cmi

Does everyone know if there is a way to fix this ?

It may be that the directory where dune places the built .cmis has changed. You could try with .<libname>.objs/byte/<modname>.cmi, eg .testing.objs/byte/test_lib.cmi (that is what is used in the current version of dune, but not sure if that is also the case for 1.7).

Having said that, two remarks:

  • The exact directory layout is an implementation detail of dune and may change in the future; if the library to which the .cmis belong is public you can use instead %{lib:<public-name>:<modname>.cmi} instead, see https://dune.readthedocs.io/en/stable/concepts.html#variables

  • Any specific reason why you are not upgrading to dune 2, which has many improvements over dune 1?

Best wishes,
Nicolás

Thanks so much for your explanations, it works perfectly.
About your two remarks:

  • Unfortunately, it’s a local library, so I can’t use this syntax…
  • The only reason why I want to move to dune 1.7 is virtual libraries. Otherwise, there isn’t any specific reason to not upgrading to dune 2.0 if it stays compatible with Ocaml 4.05.0. I will give it a try! Thanks!