Skip to content
This repository was archived by the owner on Jun 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
16 changes: 14 additions & 2 deletions main_codegraph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 *)
Expand Down Expand Up @@ -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};
Expand All @@ -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 *)
Expand All @@ -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
Expand All @@ -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 *)
(*****************************************************************************)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -469,6 +475,8 @@ let main_action xs =
let w = Model.init_world path model in
View.mk_gui w

#endif

(*****************************************************************************)
(* Extra Actions *)
(*****************************************************************************)
Expand Down Expand Up @@ -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 *)
Expand Down