Skip to content

Commit

Permalink
Fix MSVC for 4.07+
Browse files Browse the repository at this point in the history
4.02-4.06 remain broken.
  • Loading branch information
dra27 committed Jun 23, 2022
1 parent 72686cc commit 35b7182
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@

(* 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
- 4.06 and earlier: empty library; Standard Library Stream and Genlex used
- 4.07-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, 14) then ":standard" else ""
if version >= (4, 07) then ":standard" else ""

let dune_fragment_for mod_name basename =
Printf.sprintf {|
Expand All @@ -28,14 +29,13 @@ let dune_fragment_for mod_name basename =
(rule
(target %s.mli)
(action (with-stdout-to %%{target}
(echo "[@@@ocaml.warning \"-3\"]\n\
include module type of struct include %s end")))
(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 "[@@@ocaml.warning \"-3\"] include %s")))
(echo "include %s")))
(enabled_if (< %%{ocaml_version} 5.0)))|}
basename basename basename mod_name basename mod_name

Expand All @@ -44,9 +44,19 @@ let () =
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 -w -9))|} stream genlex modules
(flags :standard (:include flags.sexp)))|} stream genlex modules

0 comments on commit 35b7182

Please sign in to comment.