Using Cscope on large projects(example:the Linux kernel)
Procedure:
1.Figure out where you want to put your Cscope database files.
/home/himrpei/work/cscope
2.Generate cscope.files with a list of files to be scanned.
For some projects, you may want to include every C source file in the project's directories in your Cscope database. In that case you can skip this step, and just use 'cscope -R' in the project's top-level directory to build your Cscope database. But if there's some code that you wish to exclude,and/or your project contains C++ or Java source code(by default Cscope only parses files with the .c,.h,.y,or .l extensions), you'll need to genetate a file called cscope.files, which should contain the name of all files that you wish to have Cscope scan(one file name per line).
- LNX=/home/jru/linux-2.4.18
- cd /
- find $LNX \
- -path "$LNX/arch/*" ! -path "$LNX/arch/i386*" -prune -o \
- -path "$LNX/include/asm-*" ! -path "$LNX/include/asm-i386*" -prune -o\
- -path "$LNX/tmp*" -prune -o \
- -path "$LNX/Documentation*" -prune -o \
- -path "$LNX/scripts*" -prune -o \
- -path "$LNX/drivers*" -prune -o \
- -name "*.[chxsS]" -print > /home/himrpei/cscope/cscope.files
3.Generate the Cscope database.
- cd /home/himrpei/cscope #the directory with 'cscope.files'
- cscope -b -q -k
<
The -b flag tells Cscope to just build the database, and not launch the Cscope GUI.
The -q causes an additional, 'inverted index' file to be created, which makes searches run much faster for large databases.
Finally, -k sets Cscope's 'kernel' mode--it will not look in /usr/include for any header files that are #include in your source file(this is maily useful when you are using Cscope with operating system and/or C library source code, as we are here).
>
4.Using the database.
Use Cscope to search within the editor.
Use the standalone Cscope curses-based GUI:
This tells Cscope not to regenerate the database.Otherwise you'll have to wait while Cscope checks for modified files, which can take a while for large projects, even when no files have changed.
If you accidentally run 'cscope', without any flags, you will also cause the database to be recreated from scratch without the fast index or kernel modes being used, so you'll probably need to rerun your original cscope command above to correctly recreate the database.
5.Regenerating the database when the source code changes.
If there are new files in your project, rerun your 'find' command to update cscope.files if you're using it.
Then simple invoke cscope the same way(and in the same directory)as you did to generate the database initially(i.e,cscope -b -q -k).
阅读(1807) | 评论(0) | 转发(1) |