From f3c7ca10d6f82aef62ecaab5e84a2c7fc47156cf Mon Sep 17 00:00:00 2001 From: Lucccyo Date: Mon, 21 Jul 2025 10:58:42 +0200 Subject: [PATCH 1/4] fix cycle dependency --- plugins/dune-rules/src/wrapper.ml | 3 ++- plugins/dune-rules/test/test.t | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) 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..e5904408 100644 --- a/plugins/dune-rules/test/test.t +++ b/plugins/dune-rules/test/test.t @@ -168,7 +168,7 @@ 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 @@ -205,5 +205,5 @@ 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)) From 17826dc781ac14ce6086df423c74b74c20d35c93 Mon Sep 17 00:00:00 2001 From: Lucccyo Date: Mon, 21 Jul 2025 11:11:03 +0200 Subject: [PATCH 2/4] Update Changelog --- CHANGES.md | 5 +++++ 1 file changed, 5 insertions(+) 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 From b156006565423c511b05df3f540cb050107f5d9a Mon Sep 17 00:00:00 2001 From: Lucccyo Date: Mon, 21 Jul 2025 15:14:01 +0200 Subject: [PATCH 3/4] Update versions --- ortac-monolith.opam | 2 +- ortac-runtime-monolith.opam | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 From ebbd3009a972c09b6ffc320fdd0d275729e67fcd Mon Sep 17 00:00:00 2001 From: Lucccyo Date: Mon, 21 Jul 2025 15:59:54 +0200 Subject: [PATCH 4/4] Improve cram tests to prevent dune errors --- plugins/dune-rules/test/test.t | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/plugins/dune-rules/test/test.t b/plugins/dune-rules/test/test.t index e5904408..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 @@ -171,7 +181,12 @@ Specifying a timeout causes ORTAC_QCHECK_STM_TIMEOUT to be set before running th (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 @@ -207,3 +222,5 @@ Specifying a timeout causes ORTAC_QCHECK_STM_TIMEOUT to be set before running th (modules named_wrapper) (libraries ortac-runtime my_lib) (package my_package)) + + $ dune runtest