# HG changeset patch # User timothy.murphy@nokia.com # Date 1268668233 0 # Node ID b4baa7ca35a7054a80768eb204d8461efe48c683 # Parent 245e5b9fda514161ca6df22f136319b6bb06cac7 fix: emake log output corruption fix by using output from the annotation file. diff -r 245e5b9fda51 -r b4baa7ca35a7 sbsv2/raptor/python/raptor_make.py --- a/sbsv2/raptor/python/raptor_make.py Mon Mar 15 13:13:18 2010 +0000 +++ b/sbsv2/raptor/python/raptor_make.py Mon Mar 15 15:50:33 2010 +0000 @@ -36,6 +36,52 @@ class BadMakeEngineException(Exception): pass +def XMLEscapeLog(stream): + inRecipe = False + + for line in stream: + if line.startswith(""): + inOutput = True + yield unescape(line[8:])+'\n' + # This is make output so don't unescape it. + elif line.startswith(''): + line = line[19:] + inOutput = True + yield unescape(line)+'\n' + else: + end_output = line.find("") + + if end_output != -1: + line = line[:end_output] + inOutput = False + + yield unescape(line)+'\n' + + af.close() + + + # raptor_make module classes class MakeEngine(object): @@ -82,6 +128,24 @@ self.jobsOption = evaluator.Get("jobs") self.defaultMakeOptions = evaluator.Get("defaultoptions") + # Logging + # copylogfromannofile means, for emake, that we should ignore + # emake's console output and instead extract output from its annotation + # file. This is a workaround for a problem where some emake + # console output is lost. The annotation file has a copy of this + # output in the "parse" job and it turns out to be uncorrupted. + self.copyLogFromAnnoFile = (evaluator.Get("copylogfromannofile") == "true") + self.annoFileName = None + + if self.copyLogFromAnnoFile: + for o in self.raptor.makeOptions: + if o.startswith("--mo=--emake-annofile="): + self.annoFileName = o[22:] + + if not self.annoFileName: + self.raptor.Info("Cannot copy log from annotation file as no annotation filename was specified via the option --mo=--emake-annofile=") + self.copyLogFromAnnoFile = False + # buffering self.scrambled = (evaluator.Get("scrambled") == "true") @@ -481,7 +545,13 @@ stderrfilename = makefile+'.stderr' stdoutfilename = makefile+'.stdout' command += " 2>'%s' " % stderrfilename - command += " >'%s' " % stdoutfilename + + # Keep a copy of the stdout too in the case of using the + # annofile - so that we can trap the problem that + # makes the copy-log-from-annofile workaround necessary + # and perhaps determine when we can remove it. + if self.copyLogFromAnnoFile: + command += " >'%s' " % stdoutfilename # Substitute the makefile name for any occurrence of #MAKEFILE# command = command.replace("#MAKEFILE#", str(makefile)) @@ -519,39 +589,22 @@ universal_newlines=True, env=makeenv) stream = p.stdout - line = " " - while line: - line = stream.readline() + inRecipe = False - # should be done now - returncode = p.wait() - - # Report end-time of the build - self.raptor.InfoEndTime(object_type = "makefile", - task = "build", key = str(makefile)) + if not self.copyLogFromAnnoFile: + for l in XMLEscapeLog(stream): + self.raptor.out.write(l) - try: - e = open(stdoutfilename,"r") - inRecipe = False - for line in e: - if line.startswith(""): + inOutput = True + yield unescape(line[8:]) + # This is make output so don't unescape it. + elif line.startswith(''): + line = line[19:] + inOutput = True + yield unescape(line) + else: + end_output = line.find("") + + if end_output != -1: + line = line[:end_output] + inOutput = False + + yield unescape(line) + + af.close() + + +retcode=0 + + +annofile = sys.argv[1] +#print "File = ", annofile + +sys.stdout.write("\n") +try: + for l in XMLEscapeLog(AnnoFileParseOutput(annofile)): + sys.stdout.write(l+"\n") + +except Exception,e: + sys.stderr.write("error: " + str(e) + "\n") + retcode = 1 +sys.stdout.write("\n") + +sys.exit(retcode)