Reference For Tools /
Download cscope from either the official website, or if you're using Windows get it from here.
Cscope can be used directly by calling it from a shell, but it's much easier to use it from an editor's interface, which is described in this guide (Vim is an example of an editor that comes with built-in support for Cscope).
The necessary steps for building a cscope database are:
- 1. Collect a list of filenames for the database and store the list into the file cscope.files. You should be careful not to add any non-sourcecode or version control files to the list. The source files do not need to have the full path listed in the output file.
- 2. Call Cscope from within the same directory as the file cscope.files to build the database.
- 3. Use the newly built cscope.out database file in your favourite editor/IDE that supports Cscope.
- 1. Use a good find tool to get a list of source files and output the list to a file called cscope.files. ack is a good tool for this.
- Quick ack install guide for Windows: Get and install Strawberry Perl, add the executables to the PATH, and then issue this call in a command-prompt:
- perl -MCPAN -e "CPAN::Shell->force(qw(install App::Ack));"
- The ack command to get all the C++ and D files recursively from the current directory is:
- ack -f --type-set D=.d,.di -D --cpp > cscope.files (Read the ack documentation for details on these arguments)
- 2. Build the Cscope database by calling:
- cscope -b in the same directory as cscope.files.
- 3. Use the instructions that come with your editor/IDE to add and link to the Cscope database. In Vim you can use this command:
- :cscope add %:p:h - Note that "%:p:h" expands to the current working directory in Vim. Otherwise replace this with the location of the file cscope.out, or the directory it resides in.
I've installed the Shell.vim plugin: http://peterodding.com/code/vim/shell/ , which enables calling external shell commands without blocking Vim and without popping up of the command-prompt. I have these lines in my _vimrc file: http://pastebin.com/4FUUcNLu . I also have a batch file buildcscopetags.bat in my PATH with the line:
- ack -f --type-set D=.d,.di -D --cpp > cscope.files && cscope -b
Use :h cscope in Vim for additional details on using Cscope. You might also want to try some Vim front-ends that work with Cscope (and Ctags): Vim Cscope Search