cscope-index.py revision 3110
1#! /usr/bin/python 2 3# Generate list of files to index with cscope. 4 5# From the m5 directory, run: 6# util/cscope-find.py > cscope.files 7# cscope -b 8 9import os 10 11# absolute paths to skip 12skipdirs = [ 'src/unittest', 'src/doxygen' ] 13 14# suffixes of files to index 15suffixes = [ '.cc', '.hh', '.c', '.h' ] 16 17def oksuffix(f): 18 for s in suffixes: 19 if f.endswith(s): 20 return True 21 return False 22 23for dirpath,subdirs,files in os.walk('src'): 24 # filter out undesirable subdirectories 25 for i,dir in enumerate(subdirs): 26 if dir == 'SCCS': 27 del subdirs[i] 28 break 29 30 # filter out undesriable absolute paths 31 if dirpath in skipdirs: 32 del subdirs[:] 33 continue 34 35 # find C/C++ sources 36 okfiles = [f for f in files if oksuffix(f)] 37 if okfiles: 38 print '\n'.join([os.path.join(dirpath, f) for f in okfiles]) 39