sbsv2/raptor/python/raptor_make.py
branchwip
changeset 121 5e5ae3e212b3
parent 118 375b7128e900
child 122 816955f04aaa
equal deleted inserted replaced
119:f293a5f26578 121:5e5ae3e212b3
    28 import subprocess
    28 import subprocess
    29 import time
    29 import time
    30 from raptor_makefile import *
    30 from raptor_makefile import *
    31 import traceback
    31 import traceback
    32 import sys
    32 import sys
       
    33 from xml.sax.saxutils import escape
       
    34 
    33 
    35 
    34 # raptor_make module classes
    36 # raptor_make module classes
    35 
    37 
    36 class MakeEngine(object):
    38 class MakeEngine(object):
    37 
    39 
   401 			self.raptor.Info("Making %s", makefile)
   403 			self.raptor.Info("Making %s", makefile)
   402 			# assemble the build command line
   404 			# assemble the build command line
   403 			command = self.buildCommand
   405 			command = self.buildCommand
   404 
   406 
   405 			if self.makefileOption:
   407 			if self.makefileOption:
   406 				command += " " + self.makefileOption + " " + '"' + str(makefile) + '"'
   408 				command += " " + self.makefileOption + " " + ' "' + str(makefile) + '" '
   407 
   409 
   408 			if self.raptor.keepGoing and self.keepGoingOption:
   410 			if self.raptor.keepGoing and self.keepGoingOption:
   409 				command += " " + self.keepGoingOption
   411 				command += " " + self.keepGoingOption
   410 
   412 
   411 			if self.raptor.jobs > 1 and self.jobsOption:
   413 			if self.raptor.jobs > 1 and self.jobsOption:
   446 					if re.match(ignoreTargets, target):
   448 					if re.match(ignoreTargets, target):
   447 						addTargets.remove(target)
   449 						addTargets.remove(target)
   448 
   450 
   449 			if addTargets:
   451 			if addTargets:
   450 				command += " " + " ".join(addTargets)
   452 				command += " " + " ".join(addTargets)
       
   453 
       
   454 			# Send stderr to a file so that it can't mess up the log (e.g.
       
   455 			# clock skew messages from some build engines.
       
   456 			stderrfilename = makefile+'.stderr'
       
   457 			command += ' 2>"%s"' % stderrfilename
   451 
   458 
   452 			# Substitute the makefile name for any occurrence of #MAKEFILE#
   459 			# Substitute the makefile name for any occurrence of #MAKEFILE#
   453 			command = command.replace("#MAKEFILE#", str(makefile))
   460 			command = command.replace("#MAKEFILE#", str(makefile))
   454 
   461 
   455 			self.raptor.Info("Executing '%s'", command)
   462 			self.raptor.Info("Executing '%s'", command)
   467 				if self.usetalon:
   474 				if self.usetalon:
   468 					makeenv['TALON_RECIPEATTRIBUTES']="none"
   475 					makeenv['TALON_RECIPEATTRIBUTES']="none"
   469 					makeenv['TALON_SHELL']=self.talonshell
   476 					makeenv['TALON_SHELL']=self.talonshell
   470 					makeenv['TALON_BUILDID']=str(self.buildID)
   477 					makeenv['TALON_BUILDID']=str(self.buildID)
   471 					makeenv['TALON_TIMEOUT']=str(self.talontimeout)
   478 					makeenv['TALON_TIMEOUT']=str(self.talontimeout)
       
   479 
   472 				if self.raptor.filesystem == "unix":
   480 				if self.raptor.filesystem == "unix":
   473 					p = subprocess.Popen([command], bufsize=65535,
   481 					p = subprocess.Popen([command], bufsize=65535,
   474 						stdout=subprocess.PIPE,
   482 						stdout=subprocess.PIPE,
   475 						stderr=subprocess.STDOUT,
   483 						stderr=subprocess.STDOUT,
   476 						close_fds=True, env=makeenv, shell=True)
   484 						close_fds=True, env=makeenv, shell=True)
   477 				else:
   485 				else:
   478 					p = subprocess.Popen(args = 
   486 					p = subprocess.Popen(args = 
   479 						[raptor_data.ToolSet.shell, '-c', command, '2>' + makefile+'.stderr'],
   487 						[raptor_data.ToolSet.shell, '-c', command],
   480 						bufsize=65535,
   488 						bufsize=65535,
   481 						stdout=subprocess.PIPE,
   489 						stdout=subprocess.PIPE,
   482 						stderr=subprocess.STDOUT,
   490 						stderr=subprocess.STDOUT,
   483 						shell = False,
   491 						shell = False,
   484 						universal_newlines=True, env=makeenv)
   492 						universal_newlines=True, env=makeenv)
   487 
   495 
   488 				line = " "
   496 				line = " "
   489 				while line:
   497 				while line:
   490 					line = stream.readline()
   498 					line = stream.readline()
   491 					self.raptor.out.write(line)
   499 					self.raptor.out.write(line)
       
   500 
       
   501 				try:
       
   502 					e = open(stderrfilename,"r")
       
   503 					for line in e:
       
   504 						self.raptor.out.write(escape(line))
       
   505 					e.close()
       
   506 				except Exception,e:
       
   507 					self.raptor.Error("Couldn't complete stderr output for %s - '%s'", str(e), command)
   492 
   508 
   493 				# should be done now
   509 				# should be done now
   494 				returncode = p.wait()
   510 				returncode = p.wait()
   495 
   511 
   496 				# Report end-time of the build
   512 				# Report end-time of the build