Debian Codegraph @

dune

raw
1 (* -*- tuareg -*- *)
2
3 (* camlp-streams is built in three different ways, depending on the version of
4 OCaml it's built for:
5 - 4.07 and earlier: empty library; Standard Library Stream and Genlex used
6 directly, since it's not possible in these versions to override the modules
7 - 4.08-4.14: Standard Library Stream and Genlex re-exported (without
8 deprecation for 4.14)
9 - 5.0+: modules in src/ are compiled
10 *)
11
12 open Jbuild_plugin.V1
13
14 let modules =
15 let version = Scanf.sscanf ocaml_version "%u.%u" (fun a b -> (a, b)) in
16 if version >= (4, 08) then ":standard" else ""
17
18 let dune_fragment_for mod_name basename =
19 Printf.sprintf {|
20 (rule
21 (target %s.mli)
22 (action (copy src/%%{target} %%{target}))
23 (enabled_if (>= %%{ocaml_version} 5.0)))
24
25 (rule
26 (target %s.ml)
27 (action (copy src/%%{target} %%{target}))
28 (enabled_if (>= %%{ocaml_version} 5.0)))
29
30 (rule
31 (target %s.mli)
32 (action (with-stdout-to %%{target}
33 (echo "include module type of struct include %s end")))
34 (enabled_if (< %%{ocaml_version} 5.0)))
35
36 (rule
37 (target %s.ml)
38 (action (with-stdout-to %%{target}
39 (echo "include %s")))
40 (enabled_if (< %%{ocaml_version} 5.0)))|}
41 basename basename basename mod_name basename mod_name
42
43 let () =
44 let stream = dune_fragment_for "Stream" "stream" in
45 let genlex = dune_fragment_for "Genlex" "genlex" in
46 Printf.ksprintf send {|
47 %s %s
48 (rule
49 (action (with-stdout-to flags.sexp (echo "(-w -9)")))
50 (enabled_if (>= %%{ocaml_version} 5.0)))
51 (rule
52 (action (with-stdout-to flags.sexp (echo "(-w -3)")))
53 (enabled_if (and (>= %%{ocaml_version} 4.14) (< %%{ocaml_version} 5.0))))
54 (rule
55 (action (with-stdout-to flags.sexp (echo "()")))
56 (enabled_if (< %%{ocaml_version} 4.14)))
57
58 (library
59 (name camlp_streams)
60 (public_name camlp-streams)
61 (modules %s)
62 (wrapped false)
63 (flags :standard (:include flags.sexp)))|} stream genlex modules