Home | History | Annotate | Download | only in tools
      1 #!/usr/bin/env python
      2 #
      3 # this program is used to find source code that includes linux kernel headers directly
      4 # (e.g. with #include <linux/...> or #include <asm/...>)
      5 #
      6 # then it lists
      7 
      8 import sys, cpp, glob, os, re, getopt
      9 import kernel
     10 from utils import *
     11 from defaults import *
     12 
     13 
     14 def usage():
     15     print """\
     16   usage:  find_users.py [-v] (file|directory|@listfile)+
     17 
     18     this program is used to scan a list of files or directories for
     19     sources that include kernel headers directly. the program prints
     20     the list of said source files when it's done.
     21 
     22     when scanning directories, only files matching the following
     23     extension will be searched: .c .cpp .S .h
     24 
     25     use -v to enable verbose output
     26 """
     27     sys.exit(1)
     28 
     29 
     30 try:
     31     optlist, args = getopt.getopt( sys.argv[1:], 'v' )
     32 except:
     33     # unrecognized option
     34     print "error: unrecognized option"
     35     usage()
     36 
     37 for opt, arg in optlist:
     38     if opt == '-v':
     39         kernel.verboseSearch = 1
     40         kernel.verboseFind   = 1
     41     else:
     42         usage()
     43 
     44 if len(args) < 1:
     45     usage()
     46 
     47 # helper function used to walk the user files
     48 def parse_file(path, parser):
     49     parser.parseFile(path)
     50 
     51 
     52 # first, obtain the list of kernel files used by our clients
     53 # avoid parsing the 'kernel_headers' directory itself since we
     54 # use this program with the Android source tree by default.
     55 #
     56 fparser = kernel.HeaderScanner()
     57 walk_source_files( args, parse_file, fparser, excludes=["kernel_headers","original"] )
     58 files   = fparser.getFiles()
     59 
     60 for f in sorted(files):
     61     print f
     62 
     63 sys.exit(0)
     64