Пример #1
0
def processFiles(updater, original_dir, modified_dir, src_rel_dir,
                 update_rel_dir):
    # Delete the old headers before updating to the new headers.
    update_dir = os.path.join(get_kernel_dir(), update_rel_dir)
    shutil.rmtree(update_dir)
    os.mkdir(update_dir, 0755)

    src_dir = os.path.normpath(os.path.join(original_dir, src_rel_dir))
    src_dir_len = len(src_dir) + 1
    mod_src_dir = os.path.join(modified_dir, src_rel_dir)
    update_dir = os.path.join(get_kernel_dir(), update_rel_dir)

    kernel_dir = get_kernel_dir()
    for root, _, files in os.walk(src_dir):
        for file in sorted(files):
            _, ext = os.path.splitext(file)
            if ext != ".h":
                continue
            src_file = os.path.normpath(os.path.join(root, file))
            rel_path = src_file[src_dir_len:]
            # Check to see if there is a modified header to use instead.
            if os.path.exists(os.path.join(mod_src_dir, rel_path)):
                src_file = os.path.join(mod_src_dir, rel_path)
                src_str = os.path.join("<modified>", src_rel_dir, rel_path)
            else:
                src_str = os.path.join("<original>", src_rel_dir, rel_path)
            dst_file = os.path.join(update_dir, rel_path)
            new_data = clean_header.cleanupFile(dst_file, src_file, rel_path)
            if not new_data:
                continue
            updater.readFile(dst_file)
            ret_val = updater.editFile(dst_file, new_data)
            if ret_val == 0:
                state = "unchanged"
            elif ret_val == 1:
                state = "edited"
            else:
                state = "added"
            update_path = os.path.join(update_rel_dir, rel_path)
            print "cleaning %s -> %s (%s)" % (src_str, update_path, state)
Пример #2
0
def processFiles(updater, original_dir, modified_dir, src_rel_dir, update_rel_dir):
    # Delete the old headers before updating to the new headers.
    update_dir = os.path.join(get_kernel_dir(), update_rel_dir)
    shutil.rmtree(update_dir)
    os.mkdir(update_dir, 0755)

    src_dir = os.path.normpath(os.path.join(original_dir, src_rel_dir))
    src_dir_len = len(src_dir) + 1
    mod_src_dir = os.path.join(modified_dir, src_rel_dir)
    update_dir = os.path.join(get_kernel_dir(), update_rel_dir)

    kernel_dir = get_kernel_dir()
    for root, _, files in os.walk(src_dir):
        for file in sorted(files):
            _, ext = os.path.splitext(file)
            if ext != ".h":
                continue
            src_file = os.path.normpath(os.path.join(root, file))
            rel_path = src_file[src_dir_len:]
            # Check to see if there is a modified header to use instead.
            if os.path.exists(os.path.join(mod_src_dir, rel_path)):
                src_file = os.path.join(mod_src_dir, rel_path)
                src_str = os.path.join("<modified>", src_rel_dir, rel_path)
            else:
                src_str = os.path.join("<original>", src_rel_dir, rel_path)
            dst_file = os.path.join(update_dir, rel_path)
            new_data = clean_header.cleanupFile(dst_file, src_file, rel_path)
            if not new_data:
                continue
            updater.readFile(dst_file)
            ret_val = updater.editFile(dst_file, new_data)
            if ret_val == 0:
                state = "unchanged"
            elif ret_val == 1:
                state = "edited"
            else:
                state = "added"
            update_path = os.path.join(update_rel_dir, rel_path)
            print "cleaning %s -> %s (%s)" % (src_str, update_path, state)
Пример #3
0
# Delete the old uapi headers before updating to handle headers that
# get moved/deleted.
uapi_dir = os.path.join(get_kernel_dir(), "uapi")
shutil.rmtree(uapi_dir)
os.mkdir(uapi_dir, 0755)

oldlen = 120
android_root_len = len(get_android_root()) + 1
for rel_path in sorted(sources):
    if sources[rel_path]:
        src_dir = original_dir
        src_str = "<original>/"
    else:
        src_dir = modified_dir
        src_str = "<modified>/"
    dst_path, newdata = clean_header.cleanupFile(kernel_dir, src_dir, rel_path)
    if not dst_path:
        continue

    dst_path = os.path.join(kernel_dir, dst_path)
    b.readFile(dst_path)
    r = b.editFile(dst_path, newdata)
    if r == 0:
        state = "unchanged"
    elif r == 1:
        state = "edited"
    else:
        state = "added"

    # dst_path is guaranteed to include android root.
    rel_dst_path = dst_path[android_root_len:]
Пример #4
0
    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)

for path in sources:
    dst_path, newdata = clean_header.cleanupFile(path)
    if not dst_path:
        continue

    b.readFile(dst_path)
    r = b.editFile(dst_path, newdata)
    if r == 0:
        r = "unchanged"
    elif r == 1:
        r = "edited"
    else:
        r = "added"

    print "cleaning: %-*s -> %-*s (%s)" % (35, path, 35, dst_path, r)

# We don't use Perforce anymore, but just in case, define ANDROID_USE_P4
Пример #5
0
    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)

for path in sources:
    dst_path, newdata = clean_header.cleanupFile(path)
    if not dst_path:
        continue

    b.readFile( dst_path )
    r = b.editFile( dst_path, newdata )
    if r == 0:
        r = "unchanged"
    elif r == 1:
        r = "edited"
    else:
        r = "added"

    print "cleaning: %-*s -> %-*s (%s)" % ( 35, path, 35, dst_path, r )

# We don't use Perforce anymore, but just in case, define ANDROID_USE_P4
Пример #6
0
        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)

oldlen = 120
for path in sources:
    dst_path, newdata = clean_header.cleanupFile(path, original_dir)
    if not dst_path:
        continue

    b.readFile( dst_path )
    r = b.editFile( dst_path, newdata )
    if r == 0:
        state = "unchanged"
    elif r == 1:
        state = "edited"
    else:
        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),
Пример #7
0
        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)

oldlen = 120
for path in sources:
    dst_path, newdata = clean_header.cleanupFile(path, original_dir)
    if not dst_path:
        continue

    b.readFile(dst_path)
    r = b.editFile(dst_path, newdata)
    if r == 0:
        state = "unchanged"
    elif r == 1:
        state = "edited"
    else:
        state = "added"

    str = "cleaning: %-*s -> %-*s (%s)" % (
        35, "<original>" + path[len(original_dir):], 35, dst_path, state)
    if sys.stdout.isatty():