sbsv2/raptor/python/raptor.py
branchwip
changeset 29 ee00c00df073
parent 21 a695dd5e4c37
child 59 0f7d6c11c675
equal deleted inserted replaced
28:6983dbbe3d70 29:ee00c00df073
    32 import raptor_cli
    32 import raptor_cli
    33 import raptor_data
    33 import raptor_data
    34 import raptor_make
    34 import raptor_make
    35 import raptor_makefile
    35 import raptor_makefile
    36 import raptor_meta
    36 import raptor_meta
       
    37 import raptor_timing
    37 import raptor_utilities
    38 import raptor_utilities
    38 import raptor_version
    39 import raptor_version
    39 import raptor_xml
    40 import raptor_xml
    40 import filter_list
    41 import filter_list
    41 import sys
    42 import sys
   179 			makefile = generic_path.Path(str(makefilename_base))
   180 			makefile = generic_path.Path(str(makefilename_base))
   180 
   181 
   181 		# insert the start time into the Makefile name?
   182 		# insert the start time into the Makefile name?
   182 		makefile.path = makefile.path.replace("%TIME", build.timestring)
   183 		makefile.path = makefile.path.replace("%TIME", build.timestring)
   183 
   184 
       
   185 		build.InfoDiscovery(object_type = "layers", count = 1)
       
   186 		build.InfoStartTime(object_type = "layer", task = "parse",
       
   187 				key = str(makefile.path))
   184 		makefileset = build.maker.Write(makefile, specs, build.buildUnitsToBuild)
   188 		makefileset = build.maker.Write(makefile, specs, build.buildUnitsToBuild)
       
   189 		build.InfoEndTime(object_type = "layer", task = "parse",
       
   190 				key = str(makefile.path))
   185 
   191 
   186 		return makefileset
   192 		return makefileset
   187 		
   193 		
       
   194 
   188 
   195 
   189 	def realise(self, build):
   196 	def realise(self, build):
   190 		"""Give the spec trees to the make engine and actually 
   197 		"""Give the spec trees to the make engine and actually 
   191 		"build" the product represented by this model node"""	
   198 		"build" the product represented by this model node"""	
   192 		# Must ensure that all children are unfurled at this point
   199 		# Must ensure that all children are unfurled at this point
   196 
   203 
   197 		build.AssertBuildOK()
   204 		build.AssertBuildOK()
   198 
   205 
   199 		m = self.realise_makefile(build, sp)
   206 		m = self.realise_makefile(build, sp)
   200 
   207 
   201 		return build.Make(m)
   208 		build.InfoStartTime(object_type = "layer", task = "build",
       
   209 				key = (str(m.directory) + "/" + str(m.filenamebase)))
       
   210 		result = build.Make(m)
       
   211 		build.InfoEndTime(object_type = "layer", task = "build",
       
   212 				key = (str(m.directory) + "/" + str(m.filenamebase)))
       
   213 		
       
   214 		
       
   215 		return result
       
   216 
   202 
   217 
   203 
   218 
   204 class Project(ModelNode):
   219 class Project(ModelNode):
   205 	"""A project or, in symbian-speak, an MMP
   220 	"""A project or, in symbian-speak, an MMP
   206 	"""
   221 	"""
   305 		if build.keepGoing == True:
   320 		if build.keepGoing == True:
   306 			cli_options += " -k"
   321 			cli_options += " -k"
   307 			
   322 			
   308 		if build.quiet == True:
   323 		if build.quiet == True:
   309 			cli_options += " -q"
   324 			cli_options += " -q"
       
   325 			
       
   326 		if build.timing == True:
       
   327 			cli_options += " --timing"
   310 
   328 
   311 		
   329 		
   312 		nc = len(self.children)
   330 		nc = len(self.children)
   313 		number_blocks = build.jobs
   331 		number_blocks = build.jobs
   314 		block_size = (nc / number_blocks) + 1
   332 		block_size = (nc / number_blocks) + 1
   375 				build.Error("Can't find flm interface 'build.makefiles' ")
   393 				build.Error("Can't find flm interface 'build.makefiles' ")
   376 				
   394 				
   377 			spec_nodes.append(specNode)
   395 			spec_nodes.append(specNode)
   378 			binding_makefiles.addInclude(str(makefile_path)+"_all")
   396 			binding_makefiles.addInclude(str(makefile_path)+"_all")
   379 
   397 
   380 		ppstart = time.time()
   398 		build.InfoDiscovery(object_type = "layers", count = 1)
   381 		build.Info("Parallel Parsing: time: Start %d", int(ppstart))
   399 		build.InfoStartTime(object_type = "layer", task = "parse",
       
   400 				key = str(build.topMakefile))
   382 		m = self.realise_makefile(build, spec_nodes)
   401 		m = self.realise_makefile(build, spec_nodes)
   383 		m.close()
   402 		m.close()
   384 		gen_result = build.Make(m)
   403 		gen_result = build.Make(m)
   385 
   404 
   386 		ppfinish = time.time()
   405 		build.InfoEndTime(object_type = "layer", task = "parse",
   387 		build.Info("Parallel Parsing: time: Finish %d", int(ppfinish))
   406 				key = str(build.topMakefile))
   388 		build.Info("Parallel Parsing: time: Parse Duration %d", int(ppfinish - ppstart))
   407 		build.InfoStartTime(object_type = "layer", task = "build",
       
   408 				key = str(build.topMakefile))
   389 		build.Debug("Binding Makefile base name is %s ", binding_makefiles.filenamebase)
   409 		build.Debug("Binding Makefile base name is %s ", binding_makefiles.filenamebase)
   390 		binding_makefiles.close()
   410 		binding_makefiles.close()
   391 		b = build.Make(binding_makefiles)
   411 		b = build.Make(binding_makefiles)
   392 		buildfinish = time.time()
   412 		build.InfoEndTime(object_type = "layer", task = "build",
   393 		build.Info("Parallel Parsing: time: Build Duration %d", int(buildfinish - ppfinish))
   413 				key = str(build.topMakefile))
   394 		return b
   414 		return b
   395 
   415 
   396 
   416 
   397 
   417 
   398 
   418 
   491 		self.mission = Raptor.M_BUILD
   511 		self.mission = Raptor.M_BUILD
   492 
   512 
   493 		# what platform and filesystem are we running on?
   513 		# what platform and filesystem are we running on?
   494 		self.filesystem = raptor_utilities.getOSFileSystem()
   514 		self.filesystem = raptor_utilities.getOSFileSystem()
   495 
   515 
       
   516 		self.timing = False
   496 		self.toolset = None
   517 		self.toolset = None
   497 
   518 
   498 		self.starttime = time.time()
   519 		self.starttime = time.time()
   499 		self.timestring = time.strftime("%Y-%m-%d-%H-%M-%S")
   520 		self.timestring = time.strftime("%Y-%m-%d-%H-%M-%S")
   500 
   521 
   646 		else:
   667 		else:
   647 			self.Warn("toolcheck option must be one of: %s" % toolcheck_types)
   668 			self.Warn("toolcheck option must be one of: %s" % toolcheck_types)
   648 			return False
   669 			return False
   649 
   670 
   650 		return True
   671 		return True
       
   672 	
       
   673 	def SetTiming(self, TrueOrFalse):
       
   674 		self.timing = TrueOrFalse
       
   675 		return True
   651 
   676 
   652 	def SetParallelParsing(self, type):
   677 	def SetParallelParsing(self, type):
   653 		type = type.lower()
   678 		type = type.lower()
   654 		if type == "on":
   679 		if type == "on":
   655 			self.doParallelParsing = True
   680 			self.doParallelParsing = True
       
   681 		elif type == "slave":
       
   682 			self.isParallelParsingSlave = True
   656 		elif type == "off":
   683 		elif type == "off":
   657 			self.doParallelParsing = False
   684 			self.doParallelParsing = False
   658 		else:
   685 		else:
   659 			self.Warn(" parallel parsing option must be either 'on' or 'off' (was %s)"  % type)
   686 			self.Warn(" parallel parsing option must be either 'on' or 'off' (was %s)"  % type)
   660 			return False
   687 			return False
  1046 
  1073 
  1047 			# log header
  1074 			# log header
  1048 			self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n")
  1075 			self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n")
  1049 
  1076 
  1050 			namespace = "http://symbian.com/xml/build/log"
  1077 			namespace = "http://symbian.com/xml/build/log"
       
  1078 			progress_namespace = "http://symbian.com/xml/build/log/progress"
  1051 			schema = "http://symbian.com/xml/build/log/1_0.xsd"
  1079 			schema = "http://symbian.com/xml/build/log/1_0.xsd"
  1052 
  1080 
  1053 			self.out.write("<buildlog sbs_version=\"%s\" xmlns=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"%s %s\">\n"
  1081 			self.out.write("<buildlog sbs_version=\"%s\" xmlns=\"%s\" xmlns:progress=\"%s\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"%s %s\">\n"
  1054 						   % (raptor_version.fullversion(), namespace, namespace, schema))
  1082 						   % (raptor_version.fullversion(), namespace, progress_namespace, namespace, schema))
  1055 			self.logOpen = True
  1083 			self.logOpen = True
  1056 		except Exception,e:
  1084 		except Exception,e:
  1057 			self.out = sys.stdout # make sure that we can actually get errors out.
  1085 			self.out = sys.stdout # make sure that we can actually get errors out.
  1058 			self.logOpen = False
  1086 			self.logOpen = False
  1059 			self.FatalError("Unable to open the output logs: %s" % str(e))
  1087 			self.FatalError("Unable to open the output logs: %s" % str(e))
  1086 		"""Send an information message to the configured channel
  1114 		"""Send an information message to the configured channel
  1087 				(XML control characters will be escaped)
  1115 				(XML control characters will be escaped)
  1088 		"""
  1116 		"""
  1089 		self.out.write("<info" + self.attributeString(attributes) + ">" +
  1117 		self.out.write("<info" + self.attributeString(attributes) + ">" +
  1090 		               escape(format % extras) + "</info>\n")
  1118 		               escape(format % extras) + "</info>\n")
       
  1119 		
       
  1120 	def InfoDiscovery(self, object_type, count):
       
  1121 		if self.timing:
       
  1122 			try:
       
  1123 				self.out.write(raptor_timing.Timing.discovery_string(object_type = object_type,
       
  1124 						count = count))
       
  1125 			except Exception, exception:
       
  1126 				Error(exception.Text, function = "InfoDiscoveryTime")
       
  1127 		
       
  1128 	def InfoStartTime(self, object_type, task, key):
       
  1129 		if self.timing:
       
  1130 			try:
       
  1131 				self.out.write(raptor_timing.Timing.start_string(object_type = object_type,
       
  1132 						task = task, key = key))
       
  1133 			except Exception, exception:
       
  1134 				Error(exception.Text, function = "InfoStartTime")
       
  1135 		
       
  1136 	def InfoEndTime(self, object_type, task, key):
       
  1137 		if self.timing:
       
  1138 			try:
       
  1139 				self.out.write(raptor_timing.Timing.end_string(object_type = object_type,
       
  1140 						task = task, key = key))
       
  1141 			except Exception, exception:
       
  1142 				Error(exception.Text, function = "InfoEndTime")
  1091 
  1143 
  1092 	def Debug(self, format, *extras, **attributes):
  1144 	def Debug(self, format, *extras, **attributes):
  1093 		"Send a debugging message to the configured channel"
  1145 		"Send a debugging message to the configured channel"
  1094 
  1146 
  1095 		# the debug text is out of our control so wrap it in a CDATA
  1147 		# the debug text is out of our control so wrap it in a CDATA