DXR: Difference between revisions
No edit summary |
|||
Line 62: | Line 62: | ||
== Producing DXR output == | == Producing DXR output == | ||
You will need to do the following to set up your environment before building: | You will need to do the following to set up your environment before building: | ||
export DXRSRC=''dxrsrc'' # Not necessary, but it can save some typing | export DXRSRC=''dxrsrc'' # Not necessary, but it can save some typing |
Revision as of 16:14, 9 December 2011
DXR is a smart source code browser, along the lines of MXR, that uses instrumented compilers to determine information about every variable, type, and function in your code for an enhanced browsing experience. It is primarily developed by Joshua Cranmer and David Humphrey; for more information, you can check the #static channel on irc.mozilla.org or the static analysis mailing list (as a newsgroup).
Obtaining source code
The official source code for DXR can be found on github.
Prerequisites
In addition to the source code, the following programs are necessary:
- python (with python-sqlite package)
- LLVM and clang (if using clang)
- A web server capable of running python as cgi (a standard apache2 install should work)
Setting up
For the purposes of the rest of this documentation, dxrsrc refers to the directory which contains the source code for DXR, and wwwdir the directory from which the web information will be stored. These should not be the same directory.
Configuring the webserver
The following is an example configuration in use for apache2 for the webserver:
<VirtualHost *:80> DocumentRoot wwwdir # Non-root installs currently have issues AddHandler cgi-script .cgi <Directory wwwdir> Options Indexes FollowSymLinks MultiViews Options +ExecCGI AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost>
The most important thing here is that wwwdir should be readable by the web server.
Set up wwwdir
In the wwwdir, you will need to copy or symlink the following files and directory:
export DXRSRC=dxrsrc ln -s -t wwwdir $DXRSRC/www/*
Create dxr.config
The example dxr.config in dxrsrc is a guideline for how to start, but it is not immediately adaptable to all systems. I recommend you put this file in the wwwdir directory. Some notes on important values:
The [DXR] section contains files that it needs to run itself. The dxrroot variable contains dxrsrc, and templates is a list of templates, in case you want to override the default templates with your own versions.
The [Web] section contains setup information for your webserver, so that DXR knows how to generate links.
Any other section contains information on a build-tree. The sourcedir is the full path to the source root, the objdir the full path to the build root.
An example configuration is as follows:
[DXR] templates=/src/dxr/dxr-clang/templates dxrroot=/src/dxr/dxr-clang [Web] wwwdir=/src/dxr/www virtroot=/ hosturl=http://xochiquetzal [git] sourcedir=/src/dxr/git-1.7.5.3 objdir=/src/dxr/build-git
Producing DXR output
You will need to do the following to set up your environment before building:
export DXRSRC=dxrsrc # Not necessary, but it can save some typing . $DXRSRC/setup-env.sh srcdir
Now configure and build your program as you want. Most build systems should sensibly handle the exported $CC and $CXX, however some crazier build systems (tmake?) appear not to. After building, you need to generate the web-directory:
cd wwwdir python $DXRSRC/dxr-index.py
When that is done, you can then point your web browser at your DXR installation and start navigating the source code. Your source file will be located at virtroot/tree/path/to/file.c.html, e.g., http://<server>/git/ws.c.html.
Help wanted
DXR is still an infant project, and more help is always appreciated. We have a list of open bugs for DXR, as well as a list of enhancement ideas that could be fixed. Feel free to add support for more languages as well!