#!/usr/bin/python2 # Kernel build cleaner version 0.00000000001, or less. # Copyright 2002 Rob Landley # Released under the GNU General Public License version 2 or higher, # (the GPL is available from www.gnu.org/copyleft/gpl.html) import sys, string noenter=0 def mangle(input, output): dir="." shutup=0 leftovers=None # Repeat until spanked: while 1: result=None line=input.readline() if not line: break if shutup: output.write(".\n") continue # Reassemble split lines if leftovers: line="%s %s" % (leftovers,line) words=line.split() if words[-1]=='\\': leftovers=line continue else: leftovers=None # Stuff to just completely skip: # make: When one make file calls another, it announces the fact. # rm: Build explicitly deletes old .o file before calling linker (ld) # mv, |: Produced by make dep with modversions. Kludge. if words[0] in ("make", "rm", "|", "mv"): continue if words[0]=="gcc": action=None for i in range(len(words)): if words[i]=="-E": action="Preprocessing" elif words[i].endswith(".c"): if not action: action="Compiling" file=words[i] elif words[i].endswith(".S"): if not action: action="Assembling" file=words[i] if file: result="%s %s/%s" % (action,dir,file) elif words[0]=="ld": for i in range(len(words)): if words[i]=="-o": result="Linking %s/%s" % (dir,words[i+1]) break elif words[0]=="as": result="Assembling %s/%s" % (dir,words[-1]) elif words[0].startswith("make["): if words[2]=="directory": if words[1]=="Entering": dir=words[3][1:-1] if noenter: continue result="Entering %s" % dir else: continue # Leaving directory is not interesting. if words[1]=="Nothing": continue # Pointless error message elif words[0].endswith("/mkdep"): result="Finding dependencies in %s" % dir elif words[0]=="nm": result="Extracting symbols to %s" % words[-1] elif words[0].startswith("tmppiggy="): result="Creating compressed kernel image" shutup=1 elif words[0]=="ar": # So linker dependencies don't have to change result="Creating empty object %s" % words[2] elif words[0]=="sh" or words[0]=='.' or words[0].find("/")!=-1: if words[0]=="sh": while words[1].startswith("-"): words[1:2]=[] words[0:1]=[] if words[0].find("/")!=-1: while words[0].startswith("./"): words[0]=words[0][2:] temp=["Running %s/%s" % (dir,words[0])] else: temp=["Running %s" % words[0]] temp.extend(words[1:]) result=" ".join(temp) # That's all we understand. Now do something with it. if not result: output.write("Unknown line: %s\n" % line) else: output.write(result) if not shutup: output.write("\n") endofline="\r" if len(sys.argv)>1: if sys.argv[1].find("n")!=-1: endofline="\n" if sys.argv[1].find("c")!=-1: showcount=1 else: showcount=0 if sys.argv[1].find("e")!=-1: noenter=1 mangle(sys.stdin, sys.stdout) print