Run the below script from the top level project directory.
#!/bin/bash $find -type f -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' -o -iname '*.cc' -o -iname '*.hh' -type f > ~/cscope.files $cscope -q -R -b -i ~/cscope.files -f ~/cscope.out
Add the below line to your ~/.bashrc file:
The path of the cscope database file can be customized according to your environment.
Working with Multiple directory
You can specify multiple directory to find command above. See below:
$find misc/xxxx/abc/ net/wireless/xyz/ ../../../kernel/topic/include/ -type f -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' -o -iname '*.cc' -o -iname '*.hh' -type f > ~/cscope.files
Error tag not found
By default ctrl-] doesn’t look into the cscope database rather it looks into the ctag database. So to search in cscope database add the following in your .vimrc file:
After opening a vim session do the below:
:cs add $CSCOPE_DB
Alternatively you may add it in your ~/.vimrc file as below:
:cs add $CSCOPE_DB :set cscopetag
Remember in this configuration the CSCOPE_DB will always point to ~/cscope.out. So if you were to start working with a different code base at a later point of time, you have to regenerate your cscope.out file as described above. You can place the cscope.out file anywhere you like but you have to keep in mind the CSCOPE_DB should be pointing to that location. For example if you decide to place it under /home/xyz/abc instead of ~/ then in your environment the CSCOPE_DB should be set as:
For re-generating the cscope.out you can to do:
$find -type f -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' -o -iname '*.cc' -o -iname '*.hh' -type f > /home//xyz/abc/cscope.files $cscope -q -R -b -i /home/xyz/abc/cscope.files -f /home//xyz/abc/cscope.out
Hit CTRL-D to exit Cscope.