sbsv2/raptor/python/raptor.py
branchwip
changeset 457 9bebdb95e0de
parent 451 153129bf777e
parent 374 96629a6f26e4
child 498 564986768b79
equal deleted inserted replaced
455:6cc6d1d59188 457:9bebdb95e0de
    40 import raptor_xml
    40 import raptor_xml
    41 import filter_list
    41 import filter_list
    42 import sys
    42 import sys
    43 import types
    43 import types
    44 import time
    44 import time
    45 import re
       
    46 import traceback
    45 import traceback
    47 import pluginbox
    46 import pluginbox
    48 from xml.sax.saxutils import escape
    47 from xml.sax.saxutils import escape
    49 
    48 
    50 
    49 
   230 		self.id = self.mmp_name
   229 		self.id = self.mmp_name
   231 		self.unfurled = False
   230 		self.unfurled = False
   232 
   231 
   233 	def makefile(self, makefilename_base, engine, named = False):
   232 	def makefile(self, makefilename_base, engine, named = False):
   234 		"""Makefiles for individual mmps not feasible at the moment"""
   233 		"""Makefiles for individual mmps not feasible at the moment"""
   235 		pass # Cannot, currently, "unfurl an mmp" directly but do want
   234 		pass 
   236 		     # to be able to simulate the overall recursive unfurling of a build.
   235 		# Cannot, currently, "unfurl an mmp" directly but do want
       
   236 		# to be able to simulate the overall recursive unfurling of a build.
   237 
   237 
   238 class Component(ModelNode):
   238 class Component(ModelNode):
   239 	"""A group of projects or, in symbian-speak, a bld.inf.
   239 	"""A group of projects or, in symbian-speak, a bld.inf.
   240 	"""
   240 	"""
   241 	def __init__(self, filename, layername="", componentname=""):
   241 	def __init__(self, filename, layername="", componentname=""):
   319 		but to create a makefile that will parse it.
   319 		but to create a makefile that will parse it.
   320 		In this case it allows bld.infs to be parsed in parallel by make."""
   320 		In this case it allows bld.infs to be parsed in parallel by make."""
   321 
   321 
   322 		# insert the start time into the Makefile name?
   322 		# insert the start time into the Makefile name?
   323 
   323 
   324 		buildconfig = build.GetConfig("build").GenerateBuildUnits(build.cache)
       
   325 		self.configs = build.buildUnitsToBuild
   324 		self.configs = build.buildUnitsToBuild
   326 
   325 
   327 		# Pass certain CLI flags through to the makefile-generating sbs calls
   326 		# Pass certain CLI flags through to the makefile-generating sbs calls
   328 		cli_options = ""
   327 		cli_options = ""
   329 
   328 
   383 			configList = " ".join([c.name for c in self.configs if c.name != "build" ])
   382 			configList = " ".join([c.name for c in self.configs if c.name != "build" ])
   384 
   383 
   385 			makefile_path = str(build.topMakefile) + "_" + str(loop_number)
   384 			makefile_path = str(build.topMakefile) + "_" + str(loop_number)
   386 			try:
   385 			try:
   387 				os.unlink(makefile_path) # until we have dependencies working properly
   386 				os.unlink(makefile_path) # until we have dependencies working properly
   388 			except Exception,e:
   387 			except Exception:
   389 				# print "couldn't unlink %s: %s" %(componentMakefileName, str(e))
       
   390 				pass
   388 				pass
   391 
   389 
   392 			# add some basic data in a component-wide variant
   390 			# add some basic data in a component-wide variant
   393 			var = raptor_data.Variant()
   391 			var = raptor_data.Variant()
   394 			var.AddOperation(raptor_data.Set("COMPONENT_PATHS", componentList))
   392 			var.AddOperation(raptor_data.Set("COMPONENT_PATHS", componentList))
   857 		if not self.systemFLM.isAbsolute():
   855 		if not self.systemFLM.isAbsolute():
   858 			self.systemFLM = self.home.Append(self.systemFLM)
   856 			self.systemFLM = self.home.Append(self.systemFLM)
   859 
   857 
   860 		self.cache.Load(self.systemFLM)
   858 		self.cache.Load(self.systemFLM)
   861 
   859 
   862 	def GetConfig(self, configname):
       
   863 		names = configname.split(".")
       
   864 
       
   865 		cache = self.cache
       
   866 
       
   867 		base = names[0]
       
   868 		mods = names[1:]
       
   869 
       
   870 		if base in cache.groups:
       
   871 			x = cache.FindNamedGroup(base)
       
   872 		elif base in cache.aliases:
       
   873 			x = cache.FindNamedAlias(base)
       
   874 		elif base in cache.variants:
       
   875 			x = cache.FindNamedVariant(base)
       
   876 		else:
       
   877 			raise Exception("Unknown build configuration '%s'" % configname)
       
   878 
       
   879 		x.ClearModifiers()
       
   880 
       
   881 
       
   882 		try:
       
   883 			for m in mods: x.AddModifier( cache.FindNamedVariant(m) )
       
   884 		except KeyError:
       
   885 			raise Exception("Unknown build configuration '%s'" % configname)
       
   886 		return x
       
   887 
       
   888 	def GetBuildUnitsToBuild(self, configNames):
   860 	def GetBuildUnitsToBuild(self, configNames):
   889 		"""Return a list of the configuration objects that correspond to the
   861 		"""Return a list of the configuration objects that correspond to the
   890 		   list of configuration names in the configNames parameter.
   862 		   list of configuration names in the configNames parameter.
   891 
   863 
   892 		raptor.GetBuildUnitsToBuild(["armv5", "winscw"])
   864 		raptor.GetBuildUnitsToBuild(["armv5", "winscw"])
   898 			if len(self.defaultConfig) == 0:
   870 			if len(self.defaultConfig) == 0:
   899 				self.Warn("No default configuration name")
   871 				self.Warn("No default configuration name")
   900 			else:
   872 			else:
   901 				configNames.append(self.defaultConfig)
   873 				configNames.append(self.defaultConfig)
   902 
   874 
   903 		buildUnitsToBuild = set()
   875 		buildUnitsToBuild = raptor_data.GetBuildUnits(configNames, self.cache, self)
   904 
       
   905 
       
   906 		for c in set(configNames):
       
   907 			self.Debug("BuildUnit: %s", c)
       
   908 			try:
       
   909 				x = self.GetConfig(c)
       
   910 				gb = x.GenerateBuildUnits(self.cache)
       
   911 				buildUnitsToBuild.update( gb )
       
   912 			except Exception, e:
       
   913 				self.FatalError(str(e))
       
   914 
   876 
   915 		for b in buildUnitsToBuild:
   877 		for b in buildUnitsToBuild:
   916 			self.Info("Buildable configuration '%s'", b.name)
   878 			self.Info("Buildable configuration '%s'", b.name)
   917 
   879 
   918 		if len(buildUnitsToBuild) == 0:
   880 		if len(buildUnitsToBuild) == 0:
  1001 			dir = generic_path.CurrentDir()
   963 			dir = generic_path.CurrentDir()
  1002 		else:
   964 		else:
  1003 			dir = generic_path.Path(aDir)
   965 			dir = generic_path.Path(aDir)
  1004 
   966 
  1005 		bldInf = dir.Append(self.buildInformation)
   967 		bldInf = dir.Append(self.buildInformation)
  1006 		componentgroup = []
       
  1007 
   968 
  1008 		if bldInf.isFile():
   969 		if bldInf.isFile():
  1009 			return bldInf
   970 			return bldInf
  1010 
   971 
  1011 		return None
   972 		return None
  1148 		if self.timing:
  1109 		if self.timing:
  1149 			try:
  1110 			try:
  1150 				self.out.write(raptor_timing.Timing.discovery_string(object_type = object_type,
  1111 				self.out.write(raptor_timing.Timing.discovery_string(object_type = object_type,
  1151 						count = count))
  1112 						count = count))
  1152 			except Exception, exception:
  1113 			except Exception, exception:
  1153 				Error(exception.Text, function = "InfoDiscoveryTime")
  1114 				self.Error(exception.Text, function = "InfoDiscoveryTime")
  1154 
  1115 
  1155 	def InfoStartTime(self, object_type, task, key):
  1116 	def InfoStartTime(self, object_type, task, key):
  1156 		if self.timing:
  1117 		if self.timing:
  1157 			try:
  1118 			try:
  1158 				self.out.write(raptor_timing.Timing.start_string(object_type = object_type,
  1119 				self.out.write(raptor_timing.Timing.start_string(object_type = object_type,
  1159 						task = task, key = key))
  1120 						task = task, key = key))
  1160 			except Exception, exception:
  1121 			except Exception, exception:
  1161 				Error(exception.Text, function = "InfoStartTime")
  1122 				self.Error(exception.Text, function = "InfoStartTime")
  1162 
  1123 
  1163 	def InfoEndTime(self, object_type, task, key):
  1124 	def InfoEndTime(self, object_type, task, key):
  1164 		if self.timing:
  1125 		if self.timing:
  1165 			try:
  1126 			try:
  1166 				self.out.write(raptor_timing.Timing.end_string(object_type = object_type,
  1127 				self.out.write(raptor_timing.Timing.end_string(object_type = object_type,
  1167 						task = task, key = key))
  1128 						task = task, key = key))
  1168 			except Exception, exception:
  1129 			except Exception, exception:
  1169 				Error(exception.Text, function = "InfoEndTime")
  1130 				self.Error(exception.Text, function = "InfoEndTime")
  1170 
  1131 
  1171 	def Debug(self, format, *extras, **attributes):
  1132 	def Debug(self, format, *extras, **attributes):
  1172 		"Send a debugging message to the configured channel"
  1133 		"Send a debugging message to the configured channel"
  1173 
  1134 
  1174 		# the debug text is out of our control so wrap it in a CDATA
  1135 		# the debug text is out of our control so wrap it in a CDATA
  1278 
  1239 
  1279 			# find out what configurations to build
  1240 			# find out what configurations to build
  1280 			self.AssertBuildOK()
  1241 			self.AssertBuildOK()
  1281 			buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames)
  1242 			buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames)
  1282 
  1243 
       
  1244 			if len(buildUnitsToBuild) == 0:
       
  1245 				raise BuildCannotProgressException("No configurations to build.")
       
  1246 			
  1283 			self.buildUnitsToBuild = buildUnitsToBuild
  1247 			self.buildUnitsToBuild = buildUnitsToBuild
  1284 
  1248 
  1285 			# find out what components to build, and in what way
  1249 			# find out what components to build, and in what way
  1286 			layers = []
  1250 			layers = []
  1287 
  1251