Skip to content

Commit

Permalink
Re-export 4.14 modules without deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
dra27 committed Jun 23, 2022
1 parent 709a49f commit 9498a2c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 15 deletions.
51 changes: 51 additions & 0 deletions dune
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
15 changes: 0 additions & 15 deletions src/dune

This file was deleted.

0 comments on commit 9498a2c

Please sign in to comment.