13110SN/A#! /usr/bin/python 23703Sstever@eecs.umich.edu# Copyright (c) 2006 The Regents of The University of Michigan 33703Sstever@eecs.umich.edu# All rights reserved. 43703Sstever@eecs.umich.edu# 53703Sstever@eecs.umich.edu# Redistribution and use in source and binary forms, with or without 63703Sstever@eecs.umich.edu# modification, are permitted provided that the following conditions are 73703Sstever@eecs.umich.edu# met: redistributions of source code must retain the above copyright 83703Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer; 93703Sstever@eecs.umich.edu# redistributions in binary form must reproduce the above copyright 103703Sstever@eecs.umich.edu# notice, this list of conditions and the following disclaimer in the 113703Sstever@eecs.umich.edu# documentation and/or other materials provided with the distribution; 123703Sstever@eecs.umich.edu# neither the name of the copyright holders nor the names of its 133703Sstever@eecs.umich.edu# contributors may be used to endorse or promote products derived from 143703Sstever@eecs.umich.edu# this software without specific prior written permission. 153703Sstever@eecs.umich.edu# 163703Sstever@eecs.umich.edu# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 173703Sstever@eecs.umich.edu# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 183703Sstever@eecs.umich.edu# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 193703Sstever@eecs.umich.edu# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 203703Sstever@eecs.umich.edu# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 213703Sstever@eecs.umich.edu# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 223703Sstever@eecs.umich.edu# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233703Sstever@eecs.umich.edu# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 243703Sstever@eecs.umich.edu# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 253703Sstever@eecs.umich.edu# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 263703Sstever@eecs.umich.edu# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 273703Sstever@eecs.umich.edu# 283703Sstever@eecs.umich.edu# Authors: Steve Reinhardt 293110SN/A 303703Sstever@eecs.umich.edu# Generate list of files to index with cscope and then generate cscope index. 313110SN/A 323703Sstever@eecs.umich.edu# Should be run from root of m5 tree (i.e. as 'util/cscope-index.py'). 333110SN/A 343110SN/Aimport os 353110SN/A 363110SN/A# absolute paths to skip 373110SN/Askipdirs = [ 'src/unittest', 'src/doxygen' ] 383110SN/A 393110SN/A# suffixes of files to index 403110SN/Asuffixes = [ '.cc', '.hh', '.c', '.h' ] 413110SN/A 423110SN/Adef oksuffix(f): 433110SN/A for s in suffixes: 443110SN/A if f.endswith(s): 453110SN/A return True 463110SN/A return False 473110SN/A 483703Sstever@eecs.umich.edufile_list = file('cscope.files', 'w') 4912043Sgedare@rtems.orgcwd = os.getcwd() 503703Sstever@eecs.umich.edu 5112043Sgedare@rtems.orgfor dirpath,subdirs,files in os.walk(os.path.join(cwd, 'src')): 523110SN/A # filter out undesirable subdirectories 533110SN/A for i,dir in enumerate(subdirs): 543110SN/A if dir == 'SCCS': 553110SN/A del subdirs[i] 563110SN/A break 573110SN/A 583703Sstever@eecs.umich.edu # filter out undesirable absolute paths 593110SN/A if dirpath in skipdirs: 603110SN/A del subdirs[:] 613110SN/A continue 623110SN/A 633110SN/A # find C/C++ sources 643110SN/A okfiles = [f for f in files if oksuffix(f)] 653110SN/A if okfiles: 663703Sstever@eecs.umich.edu print >> file_list, \ 673703Sstever@eecs.umich.edu '\n'.join([os.path.join(dirpath, f) for f in okfiles]) 683703Sstever@eecs.umich.edu 693703Sstever@eecs.umich.edufile_list.close() 703703Sstever@eecs.umich.edu 713703Sstever@eecs.umich.edu# run cscope to generate index 723703Sstever@eecs.umich.eduos.system("cscope -b") 73