7

I've source code of a huge project in one directory (/my/src/) and I want the cscope files to be built in some other directory (/my/db/). How can I do that ?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
viji
  • 2,706
  • 5
  • 28
  • 34

2 Answers2

19

Try following steps:

1 . Generate cscope.files

find /my/src -name '*.c' -o -name '*.h' > /my/db/cscope.files

2 . Run cscope on the generated result

cscope -i /my/db/cscope.files

3 . Export to environment variable

CSCOPE_DB=/my/db/cscope.out; export CSCOPE_DB 
Deqing
  • 14,098
  • 15
  • 84
  • 131
  • So after creating the cscope.files, I need run cscope from /my/src and the cscope.out file will get created in /my/src ? or do I need to pass any flags. Right now, i'm passing -bqkR flags to cscope. – viji Jul 30 '12 at 12:18
  • I had updated my answer. The option `-i` is to include that file, you can add any other options if necessary. – Deqing Jul 30 '12 at 15:14
  • 1
    Answer that helps immensely! Thanks! – Chuan Yeong Oct 10 '12 at 00:52
0

If you have large number of files that are not part of git repo and if it is unnecessarily making cscope command slow. You can use below command to create cscople file (will work for java/javascript/python/c/go/c++ project).

git ls-files | grep '\.js$\|\.java$\|\.py$\|\.go$\|\.c$\|\.cpp$\|\.cc$\|\.hpp$' > /my/db/cscope.files
cscope -b -i /my/db/cscope.files
CSCOPE_DB=/my/db/cscope.out; export CSCOPE_DB 
me_astr
  • 922
  • 1
  • 14
  • 21