diff options
author | David 'Digit' Turner <digit@google.com> | 2010-10-11 22:11:06 +0200 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2011-02-03 18:07:41 +0100 |
commit | fc2693110ee8a2ba22a445ad9855fbe9e118d439 (patch) | |
tree | 6bbfcf0620780f454b5c0ac2dbd5341a00cfa157 /libc/kernel/tools/find_headers.py | |
parent | 040e18f362716c0bab1d9c39a869b98d6c61584c (diff) | |
download | android_bionic-fc2693110ee8a2ba22a445ad9855fbe9e118d439.tar.gz android_bionic-fc2693110ee8a2ba22a445ad9855fbe9e118d439.tar.bz2 android_bionic-fc2693110ee8a2ba22a445ad9855fbe9e118d439.zip |
libc: Update auto-gen scripts
Make the scripts use external/kernel-headers/original by default.
clean_header.py: Document -k<path>, add -d<path>
find_headers.py: Make kernel config files optional
update_all.py: Allow setting the path to kernel headers on the command-line
update_all.py: Better formatting of output on ttys
update_all.py: Automatically perform "git add/rm" on affected files.
SYSCALLS.TXT: Fix typo in __socketcall definition.
checksyscalls.py: Add support for superH architecture in the checks.
gensyscalls.py: Automatically perform "git add/rm" on affected files.
cpp.py: Fixed a bug that prevented certain type definitions to
be kept in the generated clean header (e.g.
struct ethtool_drvinfo in <linux/ethtool.h>)
All scripts will use the content of external/kernel-headers/original by default now.
The generated code removes all empty lines and trailing whitespace. This is useful
to ensure a unified output even if we change the parser again in the future.
The top-level disclaimer has been edited with update instructions to regenerate
the headers when needed.
Also, a warning is now inserted every 8th line in the final output:
/* WARNING: DO NOT EDIT, AUTO-GENERATED CODE - SEE TOP FOR INSTRUCTIONS */
Changes under kernel/arch-arm and kernel/arch-x86 should correspond to whitespace
differences and additionnal struct definitions that were missed by the previous
parser implementation.
Change-Id: Icd1c056bacd766759f3e9b7bb5d63a246f3d656a
WARNING: If you run these script, do not submit the result to gerrit for now.
It seems there are discrepancies between the content of original headers
and those currently commited under bionic/libc/kernel/.
(This problem is the main motivation to insert the warning repeatedly).
Current list of issues:
- Missing SuperH headers (i.e. external/kernel-headers/original/asm-sh)
Diffstat (limited to 'libc/kernel/tools/find_headers.py')
-rwxr-xr-x | libc/kernel/tools/find_headers.py | 61 |
1 files changed, 28 insertions, 33 deletions
diff --git a/libc/kernel/tools/find_headers.py b/libc/kernel/tools/find_headers.py index 8e72bb603..3d622a8bc 100755 --- a/libc/kernel/tools/find_headers.py +++ b/libc/kernel/tools/find_headers.py @@ -3,7 +3,7 @@ # this program is used to find source code that includes linux kernel headers directly # (e.g. with #include <linux/...> or #include <asm/...>) # -# then it lists +# then it lists them on the standard output. import sys, cpp, glob, os, re, getopt, kernel from utils import * @@ -12,20 +12,14 @@ from defaults import * program_dir = find_program_dir() wanted_archs = kernel_archs -wanted_include = os.path.normpath(program_dir + '/../original') -wanted_config = os.path.normpath(program_dir + '/../original/config') +wanted_config = None def usage(): print """\ - usage: find_headers.py [options] (file|directory|@listfile)+ + usage: find_headers.py [options] <kernel-root> (file|directory|@listfile)+ options: - -d <include-dir> specify alternate kernel headers - 'include' directory - ('%s' by default) - - -c <file> specify alternate .config file - ('%s' by default) + -c <file> specify .config file (none by default) -a <archs> used to specify an alternative list of architectures to support @@ -37,12 +31,12 @@ def usage(): by a set of source files or directories containing them. the search is recursive to find *all* required files. -""" % ( wanted_include, wanted_config, string.join(kernel_archs,",") ) +""" % ( string.join(kernel_archs,",") ) sys.exit(1) try: - optlist, args = getopt.getopt( sys.argv[1:], 'vc:d:a:' ) + optlist, args = getopt.getopt( sys.argv[1:], 'vc:d:a:k:' ) except: # unrecognized option print "error: unrecognized option" @@ -51,8 +45,6 @@ except: for opt, arg in optlist: if opt == '-a': wanted_archs = string.split(arg,',') - elif opt == '-d': - wanted_include = arg elif opt == '-c': wanted_config = arg elif opt == '-v': @@ -62,10 +54,10 @@ for opt, arg in optlist: else: usage() -if len(args) < 1: +if len(args) < 2: usage() -kernel_root = wanted_include +kernel_root = args[0] if not os.path.exists(kernel_root): sys.stderr.write( "error: directory '%s' does not exist\n" % kernel_root ) sys.exit(1) @@ -74,26 +66,26 @@ if not os.path.isdir(kernel_root): sys.stderr.write( "error: '%s' is not a directory\n" % kernel_root ) sys.exit(1) -if not os.path.isdir(kernel_root+"/linux"): - sys.stderr.write( "error: '%s' does not have a 'linux' directory\n" % kernel_root ) +if not os.path.isdir(kernel_root+"/include/linux"): + sys.stderr.write( "error: '%s' does not have an 'include/linux' directory\n" % kernel_root ) sys.exit(1) -if not os.path.exists(wanted_config): - sys.stderr.write( "error: file '%s' does not exist\n" % wanted_config ) - sys.exit(1) +if wanted_config: + if not os.path.exists(wanted_config): + sys.stderr.write( "error: file '%s' does not exist\n" % wanted_config ) + sys.exit(1) -if not os.path.isfile(wanted_config): - sys.stderr.write( "error: '%s' is not a file\n" % wanted_config ) - sys.exit(1) + if not os.path.isfile(wanted_config): + sys.stderr.write( "error: '%s' is not a file\n" % wanted_config ) + sys.exit(1) # find all architectures in the kernel tree -re_asm_ = re.compile(r"asm-(\w+)") archs = [] -for dir in os.listdir(kernel_root): - m = re_asm_.match(dir) - if m: - if verbose: print ">> found kernel arch '%s'" % m.group(1) - archs.append(m.group(1)) +for archdir in os.listdir(kernel_root+"/arch"): + if os.path.exists("%s/arch/%s/include/asm" % (kernel_root, archdir)): + if verbose: + print "Found arch '%s'" % archdir + archs.append(archdir) # if we're using the 'kernel_headers' directory, there is only asm/ # and no other asm-<arch> directories (arm is assumed, which sucks) @@ -126,6 +118,7 @@ if wanted_archs != None: # helper function used to walk the user files def parse_file(path, parser): + #print "parse %s" % path parser.parseFile(path) @@ -136,7 +129,8 @@ def parse_file(path, parser): # try to read the config file try: cparser = kernel.ConfigParser() - cparser.parseFile( wanted_config ) + if wanted_config: + cparser.parseFile( wanted_config ) except: sys.stderr.write( "error: can't parse '%s'" % wanted_config ) sys.exit(1) @@ -145,7 +139,8 @@ kernel_config = cparser.getDefinitions() # first, obtain the list of kernel files used by our clients fparser = kernel.HeaderScanner() -walk_source_files( args, parse_file, fparser, excludes=["kernel_headers"] ) +dir_excludes=[".repo","external/kernel-headers","ndk","out","prebuilt","bionic/libc/kernel","development/ndk","external/qemu/distrib"] +walk_source_files( args[1:], parse_file, fparser, excludes=["./"+f for f in dir_excludes] ) headers = fparser.getHeaders() files = fparser.getFiles() @@ -170,6 +165,6 @@ if 0: # just for debugging sys.exit(0) for h in sorted(headers): - print h + print "%s" % h sys.exit(0) |