From 1d2c7495307ab06c7e6b01323bc0695c7fed85d4 Mon Sep 17 00:00:00 2001 From: Virgile Prevosto <virgile.prevosto@m4x.org> Date: Fri, 16 Oct 2020 14:22:01 +0200 Subject: [PATCH] [gui] accomodate for the change in module name between OCamlgraph 1.8 and 2.0 --- Makefile | 19 ++++++++++++++++--- .../{cg_viewer.ml => cg_viewer.yes.ml} | 2 +- ...{debug_manager.ml => debug_manager.yes.ml} | 4 ++-- src/plugins/gui/dgraph_helper.yes.ml | 6 ++++-- 4 files changed, 23 insertions(+), 8 deletions(-) rename src/plugins/callgraph/{cg_viewer.ml => cg_viewer.yes.ml} (99%) rename src/plugins/gui/{debug_manager.ml => debug_manager.yes.ml} (97%) diff --git a/Makefile b/Makefile index 81b8bacc777..3c5faa0f188 100644 --- a/Makefile +++ b/Makefile @@ -722,12 +722,24 @@ GENERATED+=src/plugins/gui/gtk_compat.ml ifeq ($(HAS_DGRAPH),yes) DGRAPHFILES:=debug_manager - src/plugins/gui/dgraph_helper.ml: src/plugins/gui/dgraph_helper.yes.ml - $(CP) $< $@ + GENERATED+=src/plugins/gui/debug_manager.ml + ifeq ($(HAS_OCAMLGRAPH_2), yes) + DGRAPH_MODULE=Graph_gtk + DGRAPH_ERROR=Graph_gtk.DGraphMake.DotError + else + DGRAPH_MODULE=Dgraph + DGRAPH_ERROR=Dgraph.DGraphModel.DotError + endif + src/plugins/gui/debug_manager.ml \ + src/plugins/gui/dgraph_helper.ml \ + src/plugins/callgraph/cg_viewer.ml: %.ml: %.yes.ml Makefile + $(RM) $@ + $(SED) -e 's/DGRAPH_MODULE/$(DGRAPH_MODULE)/g' \ + -e 's/DGRAPH_ERROR/$(DGRAPH_ERROR)/g' $< > $@ $(CHMOD_RO) $@ else DGRAPHFILES:= - src/plugins/gui/dgraph_helper.ml: src/plugins/gui/dgraph_helper.no.ml + src/plugins/gui/dgraph_helper.ml: src/plugins/gui/dgraph_helper.no.ml Makefile $(CP) $< $@ $(CHMOD_RO) $@ endif @@ -794,6 +806,7 @@ PLUGIN_DIR:=src/plugins/callgraph PLUGIN_CMO:= options journalize subgraph cg services uses register ifeq ($(HAS_DGRAPH),yes) PLUGIN_GUI_CMO:=cg_viewer +PLUGIN_GENERATED:=$(PLUGIN_DIR)/cg_viewer.ml else PLUGIN_GUI_CMO:= PLUGIN_DISTRIB_EXTERNAL:=cg_viewer.ml diff --git a/src/plugins/callgraph/cg_viewer.ml b/src/plugins/callgraph/cg_viewer.yes.ml similarity index 99% rename from src/plugins/callgraph/cg_viewer.ml rename to src/plugins/callgraph/cg_viewer.yes.ml index 2d314d42fa5..d29b123e0cb 100644 --- a/src/plugins/callgraph/cg_viewer.ml +++ b/src/plugins/callgraph/cg_viewer.yes.ml @@ -20,7 +20,7 @@ (* *) (**************************************************************************) -open Dgraph +open DGRAPH_MODULE let ($) f x = f x diff --git a/src/plugins/gui/debug_manager.ml b/src/plugins/gui/debug_manager.yes.ml similarity index 97% rename from src/plugins/gui/debug_manager.ml rename to src/plugins/gui/debug_manager.yes.ml index 3ae5cdd11d4..32eb2f1965f 100644 --- a/src/plugins/gui/debug_manager.ml +++ b/src/plugins/gui/debug_manager.yes.ml @@ -20,9 +20,9 @@ (* *) (**************************************************************************) -(* Require Dgraph included in Ocamlgraph, thus GnomeCanvas *) +(* Require Dgraph included in OCamlgraph/Ocamlgraph_gtk, thus GnomeCanvas *) -open Dgraph +open DGRAPH_MODULE let graph_view ~packing mk_dot = let f = diff --git a/src/plugins/gui/dgraph_helper.yes.ml b/src/plugins/gui/dgraph_helper.yes.ml index 30fa88ec14d..f547f895cb8 100644 --- a/src/plugins/gui/dgraph_helper.yes.ml +++ b/src/plugins/gui/dgraph_helper.yes.ml @@ -20,6 +20,8 @@ (* *) (**************************************************************************) +open DGRAPH_MODULE + let graph_window ~parent ~title make_view = let height = int_of_float (float parent#default_height *. 3. /. 4.) in let width = int_of_float (float parent#default_width *. 3. /. 4.) in @@ -46,13 +48,13 @@ let graph_window_through_dot ~parent ~title dot_formatter = Format.pp_print_flush fmt (); let view = snd - (Dgraph.DGraphContainer.Dot.from_dot_with_commands ~packing temp_file) + (DGraphContainer.Dot.from_dot_with_commands ~packing temp_file) in view in try graph_window ~parent ~title make_view - with Dgraph.DGraphModel.DotError _ as exn -> + with DGRAPH_ERROR _ as exn -> Gui_parameters.error "@[cannot display dot graph:@ %s@]" (Printexc.to_string exn) -- GitLab