Skip to content

Fix cycle dependency in Ortac/Dune-rules for wrapper plugin #348

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ortac-monolith.opam
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion ortac-runtime-monolith.opam
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion plugins/dune-rules/src/wrapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
25 changes: 21 additions & 4 deletions plugins/dune-rules/test/test.t
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
> (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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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