diff --git a/CHANGES.md b/CHANGES.md index f0a75179..4b4f9c6a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,8 @@ +# Unreleased + +- [Dune] Fix cycle dependency in `Ortac/Dune-rules` for wrapper plugin + [\#348](https://github.com/ocaml-gospel/ortac/pull/348) + # 0.7.1 - [Dune] Fix dependencies in generated library declaration for Ortac/Wrapper diff --git a/ortac-monolith.opam b/ortac-monolith.opam index 1f96880b..45bc6631 100644 --- a/ortac-monolith.opam +++ b/ortac-monolith.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.7.0" +version: "0.7.1" synopsis: "Monolith plugin for Ortac" description: """ The Monolith plugin for the Ortac command-line tool (provided by diff --git a/ortac-runtime-monolith.opam b/ortac-runtime-monolith.opam index 3ad7b90d..ed5d650e 100644 --- a/ortac-runtime-monolith.opam +++ b/ortac-runtime-monolith.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -version: "0.7.0" +version: "0.7.1" synopsis: "Runtime support library for Ortac/Monolith-generated code" description: """ The ortac-runtime-monolith library provides support for the code diff --git a/plugins/dune-rules/src/wrapper.ml b/plugins/dune-rules/src/wrapper.ml index 1e6f78a9..15341e22 100644 --- a/plugins/dune-rules/src/wrapper.ml +++ b/plugins/dune-rules/src/wrapper.ml @@ -18,6 +18,7 @@ let get_optional proj suffix config = Option.value (proj config) ~default let get_ocaml_output = get_optional (fun cfg -> cfg.ocaml_output) "wrapped.ml" +let get_lib_name cfg = Filename.(basename cfg.interface_file |> chop_extension) let get_name_output = get_optional @@ -53,7 +54,7 @@ let gen_ortac_lib ppf config = let modules ppf _ = pf ppf "(modules %s)" gen_name in let name ppf _ = pf ppf "(name %s)" gen_name in let libraries ppf config = - pf ppf "(libraries ortac-runtime %s)" (get_name_output config) + pf ppf "(libraries ortac-runtime %s)" (get_lib_name config) in let stanzas = [ name; modules; libraries ] @ package config in let library ppf = library ppf stanzas in diff --git a/plugins/dune-rules/test/test.t b/plugins/dune-rules/test/test.t index 548c06cf..7251dd30 100644 --- a/plugins/dune-rules/test/test.t +++ b/plugins/dune-rules/test/test.t @@ -134,7 +134,17 @@ Specifying a timeout causes ORTAC_QCHECK_STM_TIMEOUT to be set before running th %{test} --verbose)))) - $ ortac dune wrapper my_lib.mli --package=my_package + +The following Dune files are tested to ensure it produces correct files. + $ cat > dune-project < (lang dune 3.8) + > (package (name my_package)) + > EOF + + $ echo "(include dune.wrapper1.inc)" >> dune + $ echo '' > my_lib.mli + $ ortac dune wrapper my_lib.mli --package=my_package >> dune.wrapper1.inc + $ cat dune.wrapper1.inc ; This file is generated by ortac dune wrapper ; It contains the rules for generating a wrapper for my_lib.mli @@ -168,10 +178,15 @@ Specifying a timeout causes ORTAC_QCHECK_STM_TIMEOUT to be set before running th (library (name my_lib_wrapped) (modules my_lib_wrapped) - (libraries ortac-runtime my_lib_wrapped) + (libraries ortac-runtime my_lib) (package my_package)) - $ ortac dune wrapper my_lib.mli --package=my_package --output=named_wrapper.ml + + + $ echo "(include dune.wrapper2.inc)" >> dune + $ echo '' > my_lib.mli + $ ortac dune wrapper my_lib.mli --package=my_package --output=named_wrapper.ml >> dune.wrapper2.inc + $ cat dune.wrapper2.inc ; This file is generated by ortac dune wrapper ; It contains the rules for generating a wrapper for my_lib.mli @@ -205,5 +220,7 @@ Specifying a timeout causes ORTAC_QCHECK_STM_TIMEOUT to be set before running th (library (name named_wrapper) (modules named_wrapper) - (libraries ortac-runtime named_wrapper) + (libraries ortac-runtime my_lib) (package my_package)) + + $ dune runtest