From 1dc9e472e19acfe6dc7f41e429236e7eef7ceda1 Mon Sep 17 00:00:00 2001 From: The Android Open Source Project Date: Tue, 3 Mar 2009 19:28:35 -0800 Subject: auto import from //depot/cupcake/@135843 --- libc/kernel/tools/find_users.py | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100755 libc/kernel/tools/find_users.py (limited to 'libc/kernel/tools/find_users.py') diff --git a/libc/kernel/tools/find_users.py b/libc/kernel/tools/find_users.py new file mode 100755 index 0000000..5ee308c --- /dev/null +++ b/libc/kernel/tools/find_users.py @@ -0,0 +1,63 @@ +#!/usr/bin/env python +# +# this program is used to find source code that includes linux kernel headers directly +# (e.g. with #include or #include ) +# +# then it lists + +import sys, cpp, glob, os, re, getopt +import kernel +from utils import * +from defaults import * + + +def usage(): + print """\ + usage: find_users.py [-v] (file|directory|@listfile)+ + + this program is used to scan a list of files or directories for + sources that include kernel headers directly. the program prints + the list of said source files when it's done. + + when scanning directories, only files matching the following + extension will be searched: .c .cpp .S .h + + use -v to enable verbose output +""" + sys.exit(1) + + +try: + optlist, args = getopt.getopt( sys.argv[1:], 'v' ) +except: + # unrecognized option + print "error: unrecognized option" + usage() + +for opt, arg in optlist: + if opt == '-v': + kernel.verboseSearch = 1 + kernel.verboseFind = 1 + else: + usage() + +if len(args) < 1: + usage() + +# helper function used to walk the user files +def parse_file(path, parser): + parser.parseFile(path) + + +# first, obtain the list of kernel files used by our clients +# avoid parsing the 'kernel_headers' directory itself since we +# use this program with the Android source tree by default. +# +fparser = kernel.HeaderScanner() +walk_source_files( args, parse_file, fparser, excludes=["kernel_headers","original"] ) +files = fparser.getFiles() + +for f in sorted(files): + print f + +sys.exit(0) -- cgit v1.1