]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - android-sdk/platform-bionic.git/blob - libc/kernel/tools/update_all.py
auto import from //depot/cupcake/@135843
[android-sdk/platform-bionic.git] / libc / kernel / tools / update_all.py
1 #!/usr/bin/env python
2 #
3 import sys, cpp, kernel, glob, os, re, getopt, clean_header
4 from defaults import *
5 from utils import *
7 def usage():
8     print """\
9   usage: %(progname)s
11     this program is used to update all the auto-generated clean headers
12     used by the Bionic C library. it assumes the following:
14       - a set of source kernel headers is located in '../original',
15         relative to the program's directory
17       - the clean headers will be placed in '../arch-<arch>/asm',
18         '../common/linux', '../common/asm-generic', etc..
20       - if ANDROID_PRODUCT_OUT is defined in your environment, you're
21         using the Android build system, and the program will issue
22         p4 add / edit / delete commands to update the depot for you.
23         (you'll need to p4 submit manually though)
24 """ % { "progname" : os.path.basename(sys.argv[0]) }
25     sys.exit(0)
27 try:
28     optlist, args = getopt.getopt( sys.argv[1:], '' )
29 except:
30     # unrecognized option
31     sys.stderr.write( "error: unrecognized option\n" )
32     usage()
34 if len(optlist) > 0 or len(args) > 0:
35     usage()
37 progdir = find_program_dir()
38 original_dir = os.path.normpath( progdir + "/../original" )
39 if not os.path.isdir( original_dir ):
40     panic( "required directory does not exists: %s\n" % original_dir )
42 # find all source files in 'original'
43 #
44 sources = []
45 for root, dirs, files in os.walk( original_dir ):
46     for file in files:
47         base, ext = os.path.splitext(file)
48         if ext == ".h":
49             sources.append( "%s/%s" % (root,file) )
51 b = BatchFileUpdater()
53 for arch in kernel_archs:
54     b.readDir( os.path.normpath( progdir + "/../arch-%s" % arch ) )
56 b.readDir( os.path.normpath( progdir + "/../common" ) )
58 #print "OLD " + repr(b.old_files)
60 for path in sources:
61     dst_path, newdata = clean_header.cleanupFile(path)
62     if not dst_path:
63         continue
65     b.readFile( dst_path )
66     r = b.editFile( dst_path, newdata )
67     if r == 0:
68         r = "unchanged"
69     elif r == 1:
70         r = "edited"
71     else:
72         r = "added"
74     print "cleaning: %-*s -> %-*s (%s)" % ( 35, path, 35, dst_path, r )
76 usePerforce = os.environ.has_key("ANDROID_PRODUCT_OUT")
78 if usePerforce:
79     b.updateP4Files()
80 else:
81     b.updateFiles()
83 sys.exit(0)