forked from ocaml/camlp-streams
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dune
63 lines (54 loc) · 1.84 KB
/
dune
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
62
63
(* -*- tuareg -*- *)
(* camlp-streams is built in three different ways, depending on the version of
OCaml it's built for:
- 4.07 and earlier: empty library; Standard Library Stream and Genlex used
directly, since it's not possible in these versions to override the modules
- 4.08-4.14: Standard Library Stream and Genlex re-exported (without
deprecation for 4.14)
- 5.0+: modules in src/ are compiled
*)
open Jbuild_plugin.V1
let modules =
let version = Scanf.sscanf ocaml_version "%u.%u" (fun a b -> (a, b)) in
if version >= (4, 08) then ":standard" else ""
let dune_fragment_for mod_name basename =
Printf.sprintf {|
(rule
(target %s.mli)
(action (copy src/%%{target} %%{target}))
(enabled_if (>= %%{ocaml_version} 5.0)))
(rule
(target %s.ml)
(action (copy src/%%{target} %%{target}))
(enabled_if (>= %%{ocaml_version} 5.0)))
(rule
(target %s.mli)
(action (with-stdout-to %%{target}
(echo "include module type of struct include %s end")))
(enabled_if (< %%{ocaml_version} 5.0)))
(rule
(target %s.ml)
(action (with-stdout-to %%{target}
(echo "include %s")))
(enabled_if (< %%{ocaml_version} 5.0)))|}
basename basename basename mod_name basename mod_name
let () =
let stream = dune_fragment_for "Stream" "stream" in
let genlex = dune_fragment_for "Genlex" "genlex" in
Printf.ksprintf send {|
%s %s
(rule
(action (with-stdout-to flags.sexp (echo "(-w -9)")))
(enabled_if (>= %%{ocaml_version} 5.0)))
(rule
(action (with-stdout-to flags.sexp (echo "(-w -3)")))
(enabled_if (and (>= %%{ocaml_version} 4.14) (< %%{ocaml_version} 5.0))))
(rule
(action (with-stdout-to flags.sexp (echo "()")))
(enabled_if (< %%{ocaml_version} 4.14)))
(library
(name camlp_streams)
(public_name camlp-streams)
(modules %s)
(wrapped false)
(flags :standard (:include flags.sexp)))|} stream genlex modules