diff --git a/Makefile b/Makefile index 727a07ed3..8f4288172 100644 --- a/Makefile +++ b/Makefile @@ -23,12 +23,13 @@ PROGS=pfff \ scheck \ codequery \ codeslicer \ - pfff_db + pfff_db \ + codegraph PROGS+=pfff_test ifeq ($(FEATURE_VISUAL), 1) -PROGS+=codemap codegraph +PROGS+=codemap endif OPTPROGS= $(PROGS:=.opt) @@ -457,13 +458,23 @@ clean:: SYSLIBS_CG=$(SYSLIBS_CM) OBJS_CG=code_graph/lib.cma -codegraph: $(LIBS) commons/commons_gui.cma $(OBJS_CG) $(OBJS) main_codegraph.cmo +# Adds the cg and gui libraries (ocamlgtk, ocamlcairo etc.,) needed if +# feature_visual is set. Compiles without them if feature_visual is unset. +ifeq ($(FEATURE_VISUAL), 1) +VISUAL_OPTIONS=commons/commons_gui.cma $(OBJS_CG) +VISUAL_LIB=$(SYSLIBS_CG) $(GTKLOOP) + +VISUAL_OPTIONS_OPT=commons/commons_gui.cmxa $(OBJS_CG:.cma=.cmxa) +VISUAL_LIB_OPT=$(SYSLIBS_CG:.cma=.cmxa) $(GTKLOOP:.cmo=.cmx) +endif + +codegraph: $(LIBS) $(VISUAL_OPTIONS) $(OBJS) main_codegraph.cmo $(OCAMLC) -thread $(CUSTOM) -o $@ $(SYSLIBS) threads.cma \ - $(SYSLIBS_CG) $(GTKLOOP) $^ + $(VISUAL_LIB) $^ -codegraph.opt: $(LIBS:.cma=.cmxa) commons/commons_gui.cmxa $(OBJS_CG:.cma=.cmxa) $(OPTOBJS) main_codegraph.cmx +codegraph.opt: $(LIBS:.cma=.cmxa) $(VISUAL_OPTIONS_OPT) $(OPTOBJS) main_codegraph.cmx $(OCAMLOPT) -thread $(STATIC) -o $@ $(SYSLIBS:.cma=.cmxa) threads.cmxa\ - $(SYSLIBS_CG:.cma=.cmxa) $(GTKLOOP:.cmo=.cmx) $^ + $(VISUAL_LIB_OPT) $^ clean:: rm -f codegraph diff --git a/main_codegraph.ml b/main_codegraph.ml index 078562b73..0899ddeaf 100644 --- a/main_codegraph.ml +++ b/main_codegraph.ml @@ -10,8 +10,10 @@ module GC2 = Graph_code_opti module DM = Dependencies_matrix_code module DMBuild = Dependencies_matrix_build +#if FEATURE_VISUAL module Model = Model3 module View = View3 +#endif (*****************************************************************************) (* Purpose *) @@ -226,6 +228,7 @@ let constraints_of_info_txt info_txt = aux "" info_txt; h +#if FEATURE_VISUAL let set_gc () = (* only relevant in bytecode, in native the stacklimit is the os stacklimit*) Gc.set {(Gc.get ()) with Gc.stack_limit = 1000 * 1024 * 1024}; @@ -235,6 +238,7 @@ let set_gc () = Gc.set { (Gc.get()) with Gc.major_heap_increment = 8_000_000 }; Gc.set { (Gc.get()) with Gc.space_overhead = 300 }; () +#endif (*****************************************************************************) (* Model Helpers *) @@ -243,6 +247,7 @@ let set_gc () = let dep_file_of_dir dir = Filename.concat dir Graph_code.default_filename +#if FEATURE_VISUAL let build_model root = let file = dep_file_of_dir root in let g = Graph_code.load file in @@ -269,8 +274,7 @@ let dir_node xs = (Common.join "/" xs, Entity_code.Dir) let package_node xs = (Common.join "." xs, Entity_code.Package) - - +#endif (*****************************************************************************) (* Language specific, building the graph *) (*****************************************************************************) @@ -401,6 +405,8 @@ let build_stdlib lang root dst = * maybe can just cache and look if we need to recompute the code graph? * same for the dependency matrix that we can cache too. *) + +#if FEATURE_VISUAL let main_action xs = set_gc (); Logger.log Config_pfff.logger "codegraph" None; @@ -469,6 +475,8 @@ let main_action xs = let w = Model.init_world path model in View.mk_gui w + #endif + (*****************************************************************************) (* Extra Actions *) (*****************************************************************************) @@ -759,8 +767,12 @@ let main () = (* --------------------------------------------------------- *) (* main entry *) (* --------------------------------------------------------- *) + #if FEATURE_VISUAL | x::xs -> main_action (x::xs) + #else + | _::_ -> failwith ("Unsupported in non-visual mode") + #endif (* --------------------------------------------------------- *) (* empty entry *)