sbsv2/raptor/python/raptor.py
branchfix
changeset 374 96629a6f26e4
parent 372 e6d6373c0c3a
child 457 9bebdb95e0de
child 533 408bfff46ad7
equal deleted inserted replaced
373:d8868f997d1c 374:96629a6f26e4
    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 		for c in set(configNames):
       
   906 			self.Debug("BuildUnit: %s", c)
       
   907 			try:
       
   908 				x = self.GetConfig(c)
       
   909 				gb = x.GenerateBuildUnits(self.cache)
       
   910 				buildUnitsToBuild.update( gb )
       
   911 			except Exception, e:
       
   912 				self.Error(str(e))
       
   913 
   876 
   914 		for b in buildUnitsToBuild:
   877 		for b in buildUnitsToBuild:
   915 			self.Info("Buildable configuration '%s'", b.name)
   878 			self.Info("Buildable configuration '%s'", b.name)
   916 
   879 
   917 		if len(buildUnitsToBuild) == 0:
   880 		if len(buildUnitsToBuild) == 0:
  1000 			dir = generic_path.CurrentDir()
   963 			dir = generic_path.CurrentDir()
  1001 		else:
   964 		else:
  1002 			dir = generic_path.Path(aDir)
   965 			dir = generic_path.Path(aDir)
  1003 
   966 
  1004 		bldInf = dir.Append(self.buildInformation)
   967 		bldInf = dir.Append(self.buildInformation)
  1005 		componentgroup = []
       
  1006 
   968 
  1007 		if bldInf.isFile():
   969 		if bldInf.isFile():
  1008 			return bldInf
   970 			return bldInf
  1009 
   971 
  1010 		return None
   972 		return None
  1147 		if self.timing:
  1109 		if self.timing:
  1148 			try:
  1110 			try:
  1149 				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,
  1150 						count = count))
  1112 						count = count))
  1151 			except Exception, exception:
  1113 			except Exception, exception:
  1152 				Error(exception.Text, function = "InfoDiscoveryTime")
  1114 				self.Error(exception.Text, function = "InfoDiscoveryTime")
  1153 
  1115 
  1154 	def InfoStartTime(self, object_type, task, key):
  1116 	def InfoStartTime(self, object_type, task, key):
  1155 		if self.timing:
  1117 		if self.timing:
  1156 			try:
  1118 			try:
  1157 				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,
  1158 						task = task, key = key))
  1120 						task = task, key = key))
  1159 			except Exception, exception:
  1121 			except Exception, exception:
  1160 				Error(exception.Text, function = "InfoStartTime")
  1122 				self.Error(exception.Text, function = "InfoStartTime")
  1161 
  1123 
  1162 	def InfoEndTime(self, object_type, task, key):
  1124 	def InfoEndTime(self, object_type, task, key):
  1163 		if self.timing:
  1125 		if self.timing:
  1164 			try:
  1126 			try:
  1165 				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,
  1166 						task = task, key = key))
  1128 						task = task, key = key))
  1167 			except Exception, exception:
  1129 			except Exception, exception:
  1168 				Error(exception.Text, function = "InfoEndTime")
  1130 				self.Error(exception.Text, function = "InfoEndTime")
  1169 
  1131 
  1170 	def Debug(self, format, *extras, **attributes):
  1132 	def Debug(self, format, *extras, **attributes):
  1171 		"Send a debugging message to the configured channel"
  1133 		"Send a debugging message to the configured channel"
  1172 
  1134 
  1173 		# 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
  1277 
  1239 
  1278 			# find out what configurations to build
  1240 			# find out what configurations to build
  1279 			self.AssertBuildOK()
  1241 			self.AssertBuildOK()
  1280 			buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames)
  1242 			buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames)
  1281 
  1243 
       
  1244 			if len(buildUnitsToBuild) == 0:
       
  1245 				raise BuildCannotProgressException("No configurations to build.")
       
  1246 			
  1282 			self.buildUnitsToBuild = buildUnitsToBuild
  1247 			self.buildUnitsToBuild = buildUnitsToBuild
  1283 
  1248 
  1284 			# find out what components to build, and in what way
  1249 			# find out what components to build, and in what way
  1285 			layers = []
  1250 			layers = []
  1286 
  1251