Skip to content

Commit

Permalink
refactor: Install.Entry.to_dyn (#7536)
Browse files Browse the repository at this point in the history
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
  • Loading branch information
rgrinberg authored Apr 12, 2023
1 parent 578bbb5 commit 3290a2f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/dune_rules/install.ml
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,21 @@ module Entry = struct
; dst = Dst.of_install_file ~section ~src_basename:(Path.basename src) dst
; kind = `File
}

let dyn_of_kind =
let open Dyn in
function
| `File -> variant "File" []
| `Directory -> variant "Directory" []

let to_dyn f { src; kind; dst; section } =
let open Dyn in
record
[ ("src", f src)
; ("kind", dyn_of_kind kind)
; ("dst", Dst.to_dyn dst)
; ("section", Section.to_dyn section)
]
end

module Entry_with_site = struct
Expand Down
2 changes: 2 additions & 0 deletions src/dune_rules/install.mli
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ module Entry : sig
'a t -> paths:Section.Paths.t -> prefix:Path.t -> 'a t

val compare : ('a -> 'a -> Ordering.t) -> 'a t -> 'a t -> Ordering.t

val to_dyn : ('a -> Dyn.t) -> 'a t -> Dyn.t
end

(** Same as Entry, but the destination can be in the site of a package *)
Expand Down

0 comments on commit 3290a2f

Please sign in to comment.