-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-export 4.14 modules without deprecation
- Loading branch information
Showing
2 changed files
with
51 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
(* -*- tuareg -*- *) | ||
|
||
(* camlp-streams is built in three different ways, depending on the version of | ||
OCaml it's built for: | ||
- 4.13 and earlier: empty library; Standard Library Stream and Genlex used | ||
- 4.14: Standard Library Stream and Genlex re-exported without deprecation | ||
- 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, 14) 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 "[@@@ocaml.warning \"-3\"] include module type of %s"))) | ||
(enabled_if (< %%{ocaml_version} 5.0))) | ||
|
||
(rule | ||
(target %s.ml) | ||
(action (with-stdout-to %%{target} | ||
(echo "[@@@ocaml.warning \"-3\"] 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 | ||
(library | ||
(name camlp_streams) | ||
(public_name camlp-streams) | ||
(modules %s) | ||
(wrapped false) | ||
(flags :standard -w -9))|} stream genlex modules |