File: dune_file.ml

package info (click to toggle)
coq-doc 8.20.0-2
  • links: PTS, VCS
  • area: non-free
  • in suites: forky, sid, trixie
  • size: 46,708 kB
  • sloc: ml: 234,429; sh: 4,686; python: 3,359; ansic: 2,644; makefile: 842; lisp: 172; javascript: 87; xml: 24; sed: 2
file content (61 lines) | stat: -rw-r--r-- 1,729 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(************************************************************************)
(* This file is licensed under The MIT License                          *)
(* See LICENSE for more information                                     *)
(************************************************************************)

module F = Format

type 'a pp = Format.formatter -> 'a -> unit

module Rule = struct
  type t =
    { targets : string list
    ; deps : string list
    ; action : string
    ; alias : string option
    }

  let pp_sep fmt () = F.fprintf fmt "@;"
  let ppl = F.pp_print_list ~pp_sep F.pp_print_string
  let pp_alias fmt = function
    | None -> ()
    | Some alias -> F.fprintf fmt "(alias %s)@\n" alias

  let pp fmt { alias; targets; deps; action } =
    F.fprintf fmt
      "@[(rule@\n @[%a(targets @[%a@])@\n(deps @[%a@])@\n(action @[%a@])@])@]@\n"
      pp_alias alias ppl targets ppl deps F.pp_print_string action
end

module Install = struct
  type t =
    { section : string
    ; package : string
    ; files : (string * string) list
    (* (source as target) *)
    }

  let pp_install_file fmt (source, target) =
    F.fprintf fmt "(%s as %s)" source target

  let pp fmt { section; package; files } =
    F.fprintf fmt
      "@[(install@\n @[(section @[%s@])@\n(package @[%s@])@\n(files @[%a@])@])@]@\n"
      section package (F.pp_print_list pp_install_file) files

end

module Subdir = struct

  type 'a t = { subdir : string; payload : 'a }

  let pp ppf fmt { subdir; payload } =
    if String.equal subdir "" then
      ppf fmt payload
    else
      Fun.protect ~finally:(fun () -> F.fprintf fmt "@])@\n")
        (fun () ->
           F.fprintf fmt "(subdir %s@\n @[" subdir;
           ppf fmt payload)

end