2009-03-04 04:28:35 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
import sys, cpp, kernel, glob, os, re, getopt, clean_header
|
|
|
|
from defaults import *
|
|
|
|
from utils import *
|
|
|
|
|
|
|
|
def usage():
|
|
|
|
print """\
|
2010-10-11 22:11:06 +02:00
|
|
|
usage: %(progname)s [kernel-original-path]
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
this program is used to update all the auto-generated clean headers
|
|
|
|
used by the Bionic C library. it assumes the following:
|
|
|
|
|
|
|
|
- a set of source kernel headers is located in '../original',
|
|
|
|
relative to the program's directory
|
|
|
|
|
|
|
|
- the clean headers will be placed in '../arch-<arch>/asm',
|
|
|
|
'../common/linux', '../common/asm-generic', etc..
|
|
|
|
|
|
|
|
- if ANDROID_PRODUCT_OUT is defined in your environment, you're
|
|
|
|
using the Android build system, and the program will issue
|
|
|
|
p4 add / edit / delete commands to update the depot for you.
|
|
|
|
(you'll need to p4 submit manually though)
|
|
|
|
""" % { "progname" : os.path.basename(sys.argv[0]) }
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
try:
|
|
|
|
optlist, args = getopt.getopt( sys.argv[1:], '' )
|
|
|
|
except:
|
|
|
|
# unrecognized option
|
|
|
|
sys.stderr.write( "error: unrecognized option\n" )
|
|
|
|
usage()
|
|
|
|
|
2010-10-11 22:11:06 +02:00
|
|
|
if len(optlist) > 0 or len(args) > 1:
|
2009-03-04 04:28:35 +01:00
|
|
|
usage()
|
|
|
|
|
|
|
|
progdir = find_program_dir()
|
2010-10-11 22:11:06 +02:00
|
|
|
|
|
|
|
if len(args) == 1:
|
2011-12-19 20:27:50 +01:00
|
|
|
original_dir = args[0]
|
2010-10-11 22:11:06 +02:00
|
|
|
if not os.path.isdir(original_dir):
|
2011-12-19 20:27:50 +01:00
|
|
|
panic( "Not a directory: %s\n" % original_dir )
|
2010-10-11 22:11:06 +02:00
|
|
|
else:
|
|
|
|
original_dir = kernel_original_path
|
|
|
|
if not os.path.isdir(original_dir):
|
2011-12-19 20:27:50 +01:00
|
|
|
panic( "Missing directory, please specify one through command-line: %s\n" % original_dir )
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
# find all source files in 'original'
|
|
|
|
#
|
|
|
|
sources = []
|
|
|
|
for root, dirs, files in os.walk( original_dir ):
|
|
|
|
for file in files:
|
|
|
|
base, ext = os.path.splitext(file)
|
|
|
|
if ext == ".h":
|
|
|
|
sources.append( "%s/%s" % (root,file) )
|
|
|
|
|
|
|
|
b = BatchFileUpdater()
|
|
|
|
|
|
|
|
for arch in kernel_archs:
|
|
|
|
b.readDir( os.path.normpath( progdir + "/../arch-%s" % arch ) )
|
|
|
|
|
|
|
|
b.readDir( os.path.normpath( progdir + "/../common" ) )
|
|
|
|
|
|
|
|
#print "OLD " + repr(b.old_files)
|
|
|
|
|
2010-10-11 22:11:06 +02:00
|
|
|
oldlen = 120
|
2009-03-04 04:28:35 +01:00
|
|
|
for path in sources:
|
2010-10-11 22:11:06 +02:00
|
|
|
dst_path, newdata = clean_header.cleanupFile(path, original_dir)
|
2009-03-04 04:28:35 +01:00
|
|
|
if not dst_path:
|
|
|
|
continue
|
|
|
|
|
|
|
|
b.readFile( dst_path )
|
|
|
|
r = b.editFile( dst_path, newdata )
|
|
|
|
if r == 0:
|
2010-10-11 22:11:06 +02:00
|
|
|
state = "unchanged"
|
2009-03-04 04:28:35 +01:00
|
|
|
elif r == 1:
|
2010-10-11 22:11:06 +02:00
|
|
|
state = "edited"
|
2009-03-04 04:28:35 +01:00
|
|
|
else:
|
2010-10-11 22:11:06 +02:00
|
|
|
state = "added"
|
|
|
|
|
|
|
|
str = "cleaning: %-*s -> %-*s (%s)" % ( 35, "<original>" + path[len(original_dir):], 35, dst_path, state )
|
|
|
|
if sys.stdout.isatty():
|
|
|
|
print "%-*s" % (oldlen,str),
|
|
|
|
if (r == 0):
|
|
|
|
print "\r",
|
|
|
|
else:
|
|
|
|
print "\n",
|
|
|
|
oldlen = 0
|
|
|
|
else:
|
|
|
|
print str
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2010-10-11 22:11:06 +02:00
|
|
|
oldlen = len(str)
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2010-10-11 22:11:06 +02:00
|
|
|
print "%-*s" % (oldlen,"Done!")
|
2009-03-04 04:28:35 +01:00
|
|
|
|
2010-10-11 22:11:06 +02:00
|
|
|
b.updateGitFiles()
|
2009-03-04 04:28:35 +01:00
|
|
|
|
|
|
|
sys.exit(0)
|