Tuesday, May 5, 2015

[Install] OpenGrok and Doxygen

Source tracing is a task/job that is heavily relied on good tool for software developers or programmers to fulfill their mission. My personal suggestions are OpenGrok and Doxygen. Here is not going to analysis their merits but just record my way to install them.

=== OpenGrok ===
Download Tomcat and start it up
http://ftp.mirror.tw/pub/apache/tomcat/tomcat-7/v7.0.61/bin/apache-tomcat-7.0.61.tar.gz

$ tar zxvf apache-tomcat-7.0.61.tar.gz
$ cd apache-tomcat-7.0.61
$ bin/startup.sh

Download OpenGrok binary
opengrok-0.12.1.tar.gz

I put my source code under opengrok-0.12.1/src_code and directly use another way to integrate with Tomcat server as follows:
$ OPENGROK_TOMCAT_BASE=/home/liudanny/SourceCode/apache-tomcat-7.0.61 bin/OpenGrok deploy
$ sudo OPENGROK_TOMCAT_BASE=/home/liudanny/SourceCode/apache-tomcat-7.0.61 bin/OpenGrok index /home/liudanny/SourceCode/opengrok-0.12.1/src_code

Then we can see the result in the URL:
http://127.0.0.1:8080/source/

Reference:
http://ephrain.pixnet.net/blog/post/58312758-%5Bmac%5D-%E5%AE%89%E8%A3%9D-opengrok-server
http://blog.csdn.net/weihan1314/article/details/8944291


=== Doxygen ===

sudo apt-get install doxygen graphviz

doxygen -g FILE_NAME     # generate NAME file
vim FILE_NAME     # Modify it for your own case
doxygen FILE_NAME    # generate the result


P.S: These are my modification of NAME file
PROJECT_NAME       = MyProject
PROJECT_NUMBER     = 1.0
OUTPUT_DIRECTORY   = ../docs/OpenCV2.4.9             # the output location
INPUT = /usr/local/Cellar/opencv/2.4.9                              # the input source code
CREATE_SUBDIRS     = YES
OUTPUT_LANGUAGE    = Chinese-Traditional
FULL_PATH_NAMES    = NO
EXTRACT_STATIC     = YES
FILE_PATTERNS      = *.c *.cpp *.h *.hpp
RECURSIVE          = YES
SOURCE_BROWSER         = YES
REFERENCED_BY_RELATION = YES
REFERENCES_RELATION    = YES
INLINE_SOURCE = YES
EXTRACT_ALL        = YES
HAVE_DOT = YES                    # generate dot language for Graphviz
EXTRACT_ALL = YES
UML_LOOK = YES                   #  UML Class Diagram
DOT_CLEANUP = NO              # Don't cleanup dot language for Graphviz
CALL_GRAPH = YES
CALLER_GRAPH           = YES
GENERATE_TREEVIEW      = YES


There is another example that is more efficient:
Among others, you can edit the following options in the configuration file.
# document all entities in the project.EXTRACT_ALL = YES # document all static members of a file.EXTRACT_STATIC = YES # specify the root directory that contains the project's source files.INPUT = /home/xmodulo/source # search sub-directories for all source files.RECURSIVE = YES # include the body of functions and classes in the documentation.INLINE_SOURCES = YES # generate visualization graph by using dot program (part of graphviz package).HAVE_DOT = YES


So, as a more complete example, typical "Doxyfile" options related to UML output that I tend to use are:
EXTRACT_ALL          = YES
CLASS_DIAGRAMS      = YES
HIDE_UNDOC_RELATIONS = NO
HAVE_DOT             = YES
CLASS_GRAPH          = YES
COLLABORATION_GRAPH  = YES
UML_LOOK             = YES
UML_LIMIT_NUM_FIELDS = 50
TEMPLATE_RELATIONS   = YES
DOT_GRAPH_MAX_NODES  = 100
MAX_DOT_GRAPH_DEPTH  = 0
DOT_TRANSPARENT      = YES

P.S:
I recently tried to add a new prefix file name, such as ".cu", and seemed to not work.
Here is what I found the related document:
https://github.com/OpenGrok/OpenGrok/issues/300

ERROR: You must specify: -A .extension:class or -A prefix.:class
       Ex: -A .foo:org.opensolaris.opengrok.analysis.c.CAnalyzer
           will use the C analyzer for all files ending with .foo
       Ex: -A bar.:org.opensolaris.opengrok.analysis.c.CAnalyzer
           will use the C analyzer for all files starting with bar.
       Ex: -A .c:-
           will disable the c-analyzer for for all files ending with .c

Reference:
http://blog.longwin.com.tw/2011/04/doxygen-document-generator-2011/
https://ike35.wordpress.com/2014/10/08/doxygen-install/
https://sunglint.wordpress.com/2013/03/04/doxygen-vs-graphviz/

No comments: