From 73d536ecd39d4d4fa0e5300cea086a6419707da0 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 12 Jan 2022 23:17:16 -0700 Subject: [PATCH 1/3] chore: 5.0 compatibility do not use deprecated Format functions Signed-off-by: Rudi Grinberg ps-id: 7DBD82E0-2A3C-4C2C-AE1D-3A0FFE042BD6 --- src/dune_lang/t.ml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/dune_lang/t.ml b/src/dune_lang/t.ml index e43193035a3..6ebcf5d81ba 100644 --- a/src/dune_lang/t.ml +++ b/src/dune_lang/t.ml @@ -77,32 +77,30 @@ module Deprecated = struct let state = ref [] in Format.pp_set_mark_tags ppf true; let ofuncs = Format.pp_get_formatter_out_functions ppf () in - let tfuncs = - (Format.pp_get_formatter_tag_functions ppf () [@warning "-3"]) - in - Format.pp_set_formatter_tag_functions ppf + let tfuncs = Format.pp_get_formatter_stag_functions ppf () in + Format.pp_set_formatter_stag_functions ppf { tfuncs with - mark_open_tag = + mark_open_stag = (function - | "atom" -> + | Format.String_tag "atom" -> state := In_atom :: !state; "" - | "makefile-action" -> + | Format.String_tag "makefile-action" -> state := In_makefile_action :: !state; "" - | "makefile-stuff" -> + | Format.String_tag "makefile-stuff" -> state := In_makefile_stuff :: !state; "" - | s -> tfuncs.mark_open_tag s) - ; mark_close_tag = + | s -> tfuncs.mark_open_stag s) + ; mark_close_stag = (function - | "atom" - | "makefile-action" - | "makefile-stuff" -> + | Format.String_tag "atom" + | Format.String_tag "makefile-action" + | Format.String_tag "makefile-stuff" -> state := List.tl !state; "" - | s -> tfuncs.mark_close_tag s) - } [@warning "-3"]; + | s -> tfuncs.mark_close_stag s) + }; Format.pp_set_formatter_out_functions ppf { ofuncs with out_newline = From 63b3dd6a7bdcfc395d2115fbb89be951b2f5d325 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Tue, 18 Jan 2022 10:10:15 +0100 Subject: [PATCH 2/3] Colors: use the stag format API It used to rely on the deprecated tag API, which is going away in 5.0. Using this patch, `make dune.exe` works with the current trunk (310541fe74dddcf05c17ae3f9d4feaace4a57287). Signed-off-by: Etienne Millon --- src/dune_rules/colors.ml | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/dune_rules/colors.ml b/src/dune_rules/colors.ml index ea7315ed758..d378b9280c7 100644 --- a/src/dune_rules/colors.ml +++ b/src/dune_rules/colors.ml @@ -33,23 +33,25 @@ module Style = struct | _ -> None end -let mark_open_tag s = - match Style.of_string s with - | Some style -> Ansi_color.Style.escape_sequence (Style.to_styles style) - | None -> - if s <> "" && s.[0] = '\027' then - s - else - "" +let mark_open_stag = function + | Format.String_tag s -> ( + match Style.of_string s with + | Some style -> Ansi_color.Style.escape_sequence (Style.to_styles style) + | None -> + if s <> "" && s.[0] = '\027' then + s + else + "") + | _ -> "" let setup_err_formatter_colors () = let open Format in if Lazy.force Ansi_color.stderr_supports_color then List.iter [ err_formatter; Dune_util.Report_error.ppf ] ~f:(fun ppf -> - let funcs = (pp_get_formatter_tag_functions ppf () [@warning "-3"]) in + let funcs = pp_get_formatter_stag_functions ppf () in pp_set_mark_tags ppf true; - pp_set_formatter_tag_functions ppf + pp_set_formatter_stag_functions ppf { funcs with - mark_close_tag = (fun _ -> Ansi_color.Style.escape_sequence []) - ; mark_open_tag - } [@warning "-3"]) + mark_close_stag = (fun _ -> Ansi_color.Style.escape_sequence []) + ; mark_open_stag + }) From f84e2d6fbcfddcc3f1b4d481eef4bfaa41994ff5 Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Tue, 18 Jan 2022 10:53:33 +0100 Subject: [PATCH 3/3] Update changelog Signed-off-by: Etienne Millon --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index a51c53db534..1b950ddd528 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,8 @@ Unreleased - No longer reference deprecated Toploop functions when using dune files in OCaml syntax. (#4834, fixes #4830, @nojb) +- Use the stag format API to be compatible with OCaml 5.0 (#5351, @emillon). + 2.9.1 (07/09/2021) ------------------