sbsv2/raptor/python/raptor.py
branchfix
changeset 159 9758784ab2d3
parent 136 d84e89d4dde4
child 191 3bfc260b6d61
child 219 c3543adfd26e
equal deleted inserted replaced
141:dbb43cb03357 159:9758784ab2d3
     9 # Initial Contributors:
     9 # Initial Contributors:
    10 # Nokia Corporation - initial contribution.
    10 # Nokia Corporation - initial contribution.
    11 #
    11 #
    12 # Contributors:
    12 # Contributors:
    13 #
    13 #
    14 # Description: 
    14 # Description:
    15 # raptor module
    15 # raptor module
    16 # This module represents the running Raptor program. Raptor is started
    16 # This module represents the running Raptor program. Raptor is started
    17 # either by calling the Main() function, which creates an instance of
    17 # either by calling the Main() function, which creates an instance of
    18 # the raptor.Raptor class and calls its methods to perform a build based
    18 # the raptor.Raptor class and calls its methods to perform a build based
    19 # on command-line parameters, or by explicitly creating a raptor.Raptor
    19 # on command-line parameters, or by explicitly creating a raptor.Raptor
    56 hostplatform_dir = os.environ["HOSTPLATFORM_DIR"]
    56 hostplatform_dir = os.environ["HOSTPLATFORM_DIR"]
    57 
    57 
    58 # defaults can use EPOCROOT
    58 # defaults can use EPOCROOT
    59 
    59 
    60 if "EPOCROOT" in os.environ:
    60 if "EPOCROOT" in os.environ:
    61         epocroot = os.environ["EPOCROOT"].replace("\\","/")
    61 	incoming_epocroot = os.environ["EPOCROOT"]
       
    62 	epocroot = incoming_epocroot.replace("\\","/")
    62 else:
    63 else:
    63 	if 'linux' in hostplatform:
    64 	if 'win' in hostplatform:
       
    65 		incoming_epocroot = os.sep
       
    66 		epocroot = "/"
       
    67 		os.environ["EPOCROOT"] = os.sep
       
    68 	else:
    64 		epocroot=os.environ['HOME'] + os.sep + "epocroot"
    69 		epocroot=os.environ['HOME'] + os.sep + "epocroot"
    65 		os.environ["EPOCROOT"] = epocroot
    70 		os.environ["EPOCROOT"] = epocroot
    66 	else:
    71 		incoming_epocroot = epocroot
    67 		epocroot = "/"
       
    68 		os.environ["EPOCROOT"] = os.sep
       
    69 
    72 
    70 if "SBS_BUILD_DIR" in os.environ:
    73 if "SBS_BUILD_DIR" in os.environ:
    71 	sbs_build_dir = os.environ["SBS_BUILD_DIR"]
    74 	sbs_build_dir = os.environ["SBS_BUILD_DIR"]
    72 else:
    75 else:
    73 	sbs_build_dir = (epocroot + "/epoc32/build").replace("//","/")
    76 	sbs_build_dir = (epocroot + "/epoc32/build").replace("//","/")
   117 	def __init__(self, id, parent = None):
   120 	def __init__(self, id, parent = None):
   118 		self.id = id
   121 		self.id = id
   119 		self.type = type
   122 		self.type = type
   120 		self.specs = []
   123 		self.specs = []
   121 		self.deps = []
   124 		self.deps = []
   122 		self.children = set() 
   125 		self.children = set()
   123 		self.unfurled = False
   126 		self.unfurled = False
   124 		self.parent = parent
   127 		self.parent = parent
   125 
   128 
   126 	# Allow one to make a set
   129 	# Allow one to make a set
   127 	def __hash__(self):
   130 	def __hash__(self):
   161 
   164 
   162 		self.realise_exports(build) # permit communication of dependencies between children
   165 		self.realise_exports(build) # permit communication of dependencies between children
   163 
   166 
   164 		for c in self.children:
   167 		for c in self.children:
   165 			c.unfurl_all(build)
   168 			c.unfurl_all(build)
   166 		
   169 
   167 
   170 
   168 	def realise_exports(self, build):
   171 	def realise_exports(self, build):
   169 		"""Do the things that are needed such that we can fully unfurl all 
   172 		"""Do the things that are needed such that we can fully unfurl all
   170 		   sibling nodes.  i.e. this step is here to "take care" of the dependencies
   173 		   sibling nodes.  i.e. this step is here to "take care" of the dependencies
   171 		   between siblings.  
   174 		   between siblings.
   172 		"""
   175 		"""
   173 		pass
   176 		pass
   174 	
   177 
   175 	def realise_makefile(self, build, specs):
   178 	def realise_makefile(self, build, specs):
   176 		makefilename_base = build.topMakefile
   179 		makefilename_base = build.topMakefile
   177 		if self.name is not None:
   180 		if self.name is not None:
   178 			makefile = generic_path.Path(str(makefilename_base) + "_" + raptor_utilities.sanitise(self.name))
   181 			makefile = generic_path.Path(str(makefilename_base) + "_" + raptor_utilities.sanitise(self.name))
   179 		else:
   182 		else:
   188 		makefileset = build.maker.Write(makefile, specs, build.buildUnitsToBuild)
   191 		makefileset = build.maker.Write(makefile, specs, build.buildUnitsToBuild)
   189 		build.InfoEndTime(object_type = "layer", task = "parse",
   192 		build.InfoEndTime(object_type = "layer", task = "parse",
   190 				key = str(makefile.path))
   193 				key = str(makefile.path))
   191 
   194 
   192 		return makefileset
   195 		return makefileset
   193 		
   196 
   194 
   197 
   195 
   198 
   196 	def realise(self, build):
   199 	def realise(self, build):
   197 		"""Give the spec trees to the make engine and actually 
   200 		"""Give the spec trees to the make engine and actually
   198 		"build" the product represented by this model node"""	
   201 		"build" the product represented by this model node"""
   199 		# Must ensure that all children are unfurled at this point
   202 		# Must ensure that all children are unfurled at this point
   200 		self.unfurl_all(build)
   203 		self.unfurl_all(build)
   201 
   204 
   202 		sp = self.specs	
   205 		sp = self.specs
   203 
   206 
   204 		build.AssertBuildOK()
   207 		build.AssertBuildOK()
   205 
   208 
   206 		m = self.realise_makefile(build, sp)
   209 		m = self.realise_makefile(build, sp)
   207 
   210 
   208 		build.InfoStartTime(object_type = "layer", task = "build",
   211 		build.InfoStartTime(object_type = "layer", task = "build",
   209 				key = (str(m.directory) + "/" + str(m.filenamebase)))
   212 				key = (str(m.directory) + "/" + str(m.filenamebase)))
   210 		result = build.Make(m)
   213 		result = build.Make(m)
   211 		build.InfoEndTime(object_type = "layer", task = "build",
   214 		build.InfoEndTime(object_type = "layer", task = "build",
   212 				key = (str(m.directory) + "/" + str(m.filenamebase)))
   215 				key = (str(m.directory) + "/" + str(m.filenamebase)))
   213 		
   216 
   214 		
   217 
   215 		return result
   218 		return result
   216 
   219 
   217 
   220 
   218 
   221 
   219 class Project(ModelNode):
   222 class Project(ModelNode):
   227 		self.id = self.mmp_name
   230 		self.id = self.mmp_name
   228 		self.unfurled = False
   231 		self.unfurled = False
   229 
   232 
   230 	def makefile(self, makefilename_base, engine, named = False):
   233 	def makefile(self, makefilename_base, engine, named = False):
   231 		"""Makefiles for individual mmps not feasible at the moment"""
   234 		"""Makefiles for individual mmps not feasible at the moment"""
   232 		pass # Cannot, currently, "unfurl an mmp" directly but do want 
   235 		pass # Cannot, currently, "unfurl an mmp" directly but do want
   233 		     # to be able to simulate the overall recursive unfurling of a build.
   236 		     # to be able to simulate the overall recursive unfurling of a build.
   234 
   237 
   235 class Component(ModelNode):
   238 class Component(ModelNode):
   236 	"""A group of projects or, in symbian-speak, a bld.inf.
   239 	"""A group of projects or, in symbian-speak, a bld.inf.
   237 	"""
   240 	"""
   250 	def AddMMP(self, filename):
   253 	def AddMMP(self, filename):
   251 		self.children.add(Project(filename))
   254 		self.children.add(Project(filename))
   252 
   255 
   253 
   256 
   254 class Layer(ModelNode):
   257 class Layer(ModelNode):
   255 	""" 	Some components that should be built togther 
   258 	""" 	Some components that should be built togther
   256 		e.g. a Layer in the system definition. 
   259 		e.g. a Layer in the system definition.
   257 	""" 
   260 	"""
   258 	def __init__(self, name, componentlist=[]):
   261 	def __init__(self, name, componentlist=[]):
   259 		super(Layer,self).__init__(name)
   262 		super(Layer,self).__init__(name)
   260 		self.name = name
   263 		self.name = name
   261 
   264 
   262 		for c in componentlist:
   265 		for c in componentlist:
   263 			self.children.add(Component(c))
   266 			self.children.add(Component(c))
   264 
   267 
   265 	def unfurl(self, build):
   268 	def unfurl(self, build):
   266 		"""Discover the children of this layer. This involves parsing the component MetaData (bld.infs, mmps). 
   269 		"""Discover the children of this layer. This involves parsing the component MetaData (bld.infs, mmps).
   267 		Takes a raptor object as a parameter (build), together with a list of Configurations.
   270 		Takes a raptor object as a parameter (build), together with a list of Configurations.
   268 
   271 
   269 		We currently have parsers that work on collections of components/bld.infs and that cannot
   272 		We currently have parsers that work on collections of components/bld.infs and that cannot
   270 		parse at a "finer" level.  So one can't 'unfurl' an mmp at the moment.  
   273 		parse at a "finer" level.  So one can't 'unfurl' an mmp at the moment.
   271 
   274 
   272 		Returns True if the object was successfully unfurled.
   275 		Returns True if the object was successfully unfurled.
   273 		"""
   276 		"""
   274 
   277 
   275 		# setup all our components
   278 		# setup all our components
   298 
   301 
   299 
   302 
   300 	def meta_realise(self, build):
   303 	def meta_realise(self, build):
   301 		"""Generate specs that can be used to "take care of" finding out more
   304 		"""Generate specs that can be used to "take care of" finding out more
   302 		about this metaunit - i.e. one doesn't want to parse it immediately
   305 		about this metaunit - i.e. one doesn't want to parse it immediately
   303 		but to create a makefile that will parse it. 
   306 		but to create a makefile that will parse it.
   304 		In this case it allows bld.infs to be parsed in parallel by make."""
   307 		In this case it allows bld.infs to be parsed in parallel by make."""
   305 
   308 
   306 		# insert the start time into the Makefile name?
   309 		# insert the start time into the Makefile name?
   307 
   310 
   308 		buildconfig = build.GetConfig("build").GenerateBuildUnits(build.cache)
   311 		buildconfig = build.GetConfig("build").GenerateBuildUnits(build.cache)
   309 		self.configs = build.buildUnitsToBuild
   312 		self.configs = build.buildUnitsToBuild
   310 
   313 
   311 		# Pass certain CLI flags through to the makefile-generating sbs calls
   314 		# Pass certain CLI flags through to the makefile-generating sbs calls
   312 		cli_options = ""
   315 		cli_options = ""
   313 			
   316 
   314 		if build.debugOutput == True:
   317 		if build.debugOutput == True:
   315 			cli_options += " -d"
   318 			cli_options += " -d"
   316 				
   319 
   317 		if build.ignoreOsDetection == True:
   320 		if build.ignoreOsDetection == True:
   318 			cli_options += " -i"
   321 			cli_options += " -i"
   319 			
   322 
   320 		if build.keepGoing == True:
   323 		if build.keepGoing == True:
   321 			cli_options += " -k"
   324 			cli_options += " -k"
   322 			
   325 
   323 		if build.quiet == True:
   326 		if build.quiet == True:
   324 			cli_options += " -q"
   327 			cli_options += " -q"
   325 			
   328 
   326 		if build.timing == True:
   329 		if build.timing == True:
   327 			cli_options += " --timing"
   330 			cli_options += " --timing"
   328 
   331 
   329 		
   332 
   330 		nc = len(self.children)
   333 		nc = len(self.children)
   331 		number_blocks = build.jobs
   334 		number_blocks = build.jobs
   332 		block_size = (nc / number_blocks) + 1
   335 		block_size = (nc / number_blocks) + 1
   333 		component_blocks = []
   336 		component_blocks = []
   334 		spec_nodes = []
   337 		spec_nodes = []
   335 		
   338 
   336 		b = 0
   339 		b = 0
   337 		childlist = list(self.children)
   340 		childlist = list(self.children)
   338 		while b < nc:
   341 		while b < nc:
   339 			component_blocks.append(childlist[b:b+block_size])
   342 			component_blocks.append(childlist[b:b+block_size])
   340 			b += block_size
   343 			b += block_size
   341 			
   344 
   342 		while len(component_blocks[-1]) <= 0:
   345 		while len(component_blocks[-1]) <= 0:
   343 			component_blocks.pop()
   346 			component_blocks.pop()
   344 			number_blocks -= 1
   347 			number_blocks -= 1
   345 	
   348 
   346 		build.Info("Parallel Parsing: bld.infs split into %d blocks\n", number_blocks)
   349 		build.Info("Parallel Parsing: bld.infs split into %d blocks\n", number_blocks)
   347 		# Cause the binding makefiles to have the toplevel makefile's 
   350 		# Cause the binding makefiles to have the toplevel makefile's
   348 		# name.  The bindee's have __pp appended.	
   351 		# name.  The bindee's have __pp appended.
   349 		tm = build.topMakefile.Absolute()
   352 		tm = build.topMakefile.Absolute()
   350 		binding_makefiles = raptor_makefile.MakefileSet(str(tm.Dir()), build.maker.selectors, makefiles=None, filenamebase=str(tm.File()))		
   353 		binding_makefiles = raptor_makefile.MakefileSet(str(tm.Dir()), build.maker.selectors, makefiles=None, filenamebase=str(tm.File()))
   351 		build.topMakefile = generic_path.Path(str(build.topMakefile) + "_pp")
   354 		build.topMakefile = generic_path.Path(str(build.topMakefile) + "_pp")
   352 
   355 
   353 		loop_number = 0
   356 		loop_number = 0
   354 		for block in component_blocks:
   357 		for block in component_blocks:
   355 			loop_number += 1
   358 			loop_number += 1
   356 			specNode = raptor_data.Specification("metadata_" + self.name)
   359 			specNode = raptor_data.Specification("metadata_" + self.name)
   357 
   360 
   358 			componentList = " ".join([str(c.bldinf_filename) for c in block])
   361 			componentList = " ".join([str(c.bldinf_filename) for c in block])
   359 
   362 
   360 			
   363 
   361 			configList = " ".join([c.name for c in self.configs if c.name != "build" ])
   364 			configList = " ".join([c.name for c in self.configs if c.name != "build" ])
   362 			
   365 
   363 			makefile_path = str(build.topMakefile) + "_" + str(loop_number)
   366 			makefile_path = str(build.topMakefile) + "_" + str(loop_number)
   364 			try:
   367 			try:
   365 				os.unlink(makefile_path) # until we have dependencies working properly
   368 				os.unlink(makefile_path) # until we have dependencies working properly
   366 			except Exception,e:
   369 			except Exception,e:
   367 				# print "couldn't unlink %s: %s" %(componentMakefileName, str(e))
   370 				# print "couldn't unlink %s: %s" %(componentMakefileName, str(e))
   368 				pass
   371 				pass
   369 			
   372 
   370 			# add some basic data in a component-wide variant
   373 			# add some basic data in a component-wide variant
   371 			var = raptor_data.Variant()
   374 			var = raptor_data.Variant()
   372 			var.AddOperation(raptor_data.Set("COMPONENT_PATHS", componentList))
   375 			var.AddOperation(raptor_data.Set("COMPONENT_PATHS", componentList))
   373 			var.AddOperation(raptor_data.Set("MAKEFILE_PATH", makefile_path))
   376 			var.AddOperation(raptor_data.Set("MAKEFILE_PATH", makefile_path))
   374 			var.AddOperation(raptor_data.Set("CONFIGS", configList))
   377 			var.AddOperation(raptor_data.Set("CONFIGS", configList))
   383 
   386 
   384 			# Pass on '-n' (if specified) to the makefile-generating sbs calls
   387 			# Pass on '-n' (if specified) to the makefile-generating sbs calls
   385 			if build.noBuild:
   388 			if build.noBuild:
   386 				var.AddOperation(raptor_data.Set("NO_BUILD", "1"))
   389 				var.AddOperation(raptor_data.Set("NO_BUILD", "1"))
   387 			specNode.AddVariant(var)
   390 			specNode.AddVariant(var)
   388 	
   391 
   389 			try:
   392 			try:
   390 				interface = build.cache.FindNamedInterface("build.makefiles")
   393 				interface = build.cache.FindNamedInterface("build.makefiles")
   391 				specNode.SetInterface(interface)
   394 				specNode.SetInterface(interface)
   392 			except KeyError:
   395 			except KeyError:
   393 				build.Error("Can't find flm interface 'build.makefiles' ")
   396 				build.Error("Can't find flm interface 'build.makefiles' ")
   394 				
   397 
   395 			spec_nodes.append(specNode)
   398 			spec_nodes.append(specNode)
   396 			binding_makefiles.addInclude(str(makefile_path)+"_all")
   399 			binding_makefiles.addInclude(str(makefile_path)+"_all")
   397 
   400 
   398 		build.InfoDiscovery(object_type = "layers", count = 1)
   401 		build.InfoDiscovery(object_type = "layers", count = 1)
   399 		build.InfoStartTime(object_type = "layer", task = "parse",
   402 		build.InfoStartTime(object_type = "layer", task = "parse",
   428 	created by the Main function. When operated by an IDE several Raptor
   431 	created by the Main function. When operated by an IDE several Raptor
   429 	objects may be created and operated at the same time."""
   432 	objects may be created and operated at the same time."""
   430 
   433 
   431 
   434 
   432 	M_BUILD = 1
   435 	M_BUILD = 1
   433 	M_VERSION = 2	
   436 	M_VERSION = 2
   434 
   437 
   435 	def __init__(self, home = None):
   438 	def __init__(self, home = None):
   436 
   439 
   437 		self.DefaultSetUp(home)
   440 		self.DefaultSetUp(home)
   438 
   441 
   552 	def AddTarget(self, target):
   555 	def AddTarget(self, target):
   553 		if self.doCheck or self.doWhat:
   556 		if self.doCheck or self.doWhat:
   554 			self.Warn("ignoring target %s because --what or --check is specified.\n", target)
   557 			self.Warn("ignoring target %s because --what or --check is specified.\n", target)
   555 		else:
   558 		else:
   556 			self.targets.append(target)
   559 			self.targets.append(target)
   557 			
   560 
   558 	def AddSourceTarget(self, filename):
   561 	def AddSourceTarget(self, filename):
   559 		# source targets are sanitised and then added as if they were a "normal" makefile target
   562 		# source targets are sanitised and then added as if they were a "normal" makefile target
   560 		# in addition they have a default, empty, top-level target assigned in order that they can
   563 		# in addition they have a default, empty, top-level target assigned in order that they can
   561 		# be presented to any generated makefile without error
   564 		# be presented to any generated makefile without error
   562 		sourceTarget = generic_path.Path(filename).Absolute()
   565 		sourceTarget = generic_path.Path(filename).Absolute()
   613 		return True
   616 		return True
   614 
   617 
   615 	def SetNoDependInclude(self, TrueOrFalse):
   618 	def SetNoDependInclude(self, TrueOrFalse):
   616 		self.noDependInclude = TrueOrFalse
   619 		self.noDependInclude = TrueOrFalse
   617 		return True
   620 		return True
   618 		
   621 
   619 	def SetKeepGoing(self, TrueOrFalse):
   622 	def SetKeepGoing(self, TrueOrFalse):
   620 		self.keepGoing = TrueOrFalse
   623 		self.keepGoing = TrueOrFalse
   621 		return True
   624 		return True
   622 
   625 
   623 	def SetLogFileName(self, logfile):
   626 	def SetLogFileName(self, logfile):
   667 		else:
   670 		else:
   668 			self.Warn("toolcheck option must be one of: %s" % toolcheck_types)
   671 			self.Warn("toolcheck option must be one of: %s" % toolcheck_types)
   669 			return False
   672 			return False
   670 
   673 
   671 		return True
   674 		return True
   672 	
   675 
   673 	def SetTiming(self, TrueOrFalse):
   676 	def SetTiming(self, TrueOrFalse):
   674 		self.timing = TrueOrFalse
   677 		self.timing = TrueOrFalse
   675 		return True
   678 		return True
   676 
   679 
   677 	def SetParallelParsing(self, type):
   680 	def SetParallelParsing(self, type):
   715 
   718 
   716 		self.Info("%s %s", env, str(self.home))
   719 		self.Info("%s %s", env, str(self.home))
   717 		self.Info("Set-up %s", str(self.raptorXML))
   720 		self.Info("Set-up %s", str(self.raptorXML))
   718 		self.Info("Command-line-arguments %s", " ".join(self.args))
   721 		self.Info("Command-line-arguments %s", " ".join(self.args))
   719 		self.Info("Current working directory %s", os.getcwd())
   722 		self.Info("Current working directory %s", os.getcwd())
   720 		
   723 
   721 		# the inherited environment
   724 		# the inherited environment
   722 		for e, value in os.environ.items():
   725 		for e, value in sorted( os.environ.items() ):
   723 			self.Info("Environment %s=%s", e, value.replace("]]>", "]]&gt;"))
   726 			self.Info("Environment %s=%s", e, value.replace("]]>", "]]&gt;"))
   724 
   727 
   725 		# and some general debug stuff
   728 		# and some general debug stuff
   726 		self.Debug("Platform %s", "-".join(hostplatform))
   729 		self.Debug("Platform %s", "-".join(hostplatform))
   727 		self.Debug("Filesystem %s", self.filesystem)
   730 		self.Debug("Filesystem %s", self.filesystem)
   820 			absolute if required"""
   823 			absolute if required"""
   821 			if not aGenericPath.isAbsolute():
   824 			if not aGenericPath.isAbsolute():
   822 				return self.home.Append(aGenericPath)
   825 				return self.home.Append(aGenericPath)
   823 			else:
   826 			else:
   824 				return aGenericPath
   827 				return aGenericPath
   825 		
   828 
   826 		# make generic paths absolute (if required)
   829 		# make generic paths absolute (if required)
   827 		self.configPath = map(mkAbsolute, self.configPath)
   830 		self.configPath = map(mkAbsolute, self.configPath)
   828 		self.cache.Load(self.configPath)
   831 		self.cache.Load(self.configPath)
   829 
   832 
   830 		if not self.systemFLM.isAbsolute():
   833 		if not self.systemFLM.isAbsolute():
   857 		except KeyError:
   860 		except KeyError:
   858 			raise Exception("Unknown build configuration '%s'" % configname)
   861 			raise Exception("Unknown build configuration '%s'" % configname)
   859 		return x
   862 		return x
   860 
   863 
   861 	def GetBuildUnitsToBuild(self, configNames):
   864 	def GetBuildUnitsToBuild(self, configNames):
   862 		"""Return a list of the configuration objects that correspond to the 
   865 		"""Return a list of the configuration objects that correspond to the
   863 		   list of configuration names in the configNames parameter.
   866 		   list of configuration names in the configNames parameter.
   864 
   867 
   865 		raptor.GetBuildUnitsToBuild(["armv5", "winscw"])
   868 		raptor.GetBuildUnitsToBuild(["armv5", "winscw"])
   866 		>>> [ config1, config2, ... , configN ]
   869 		>>> [ config1, config2, ... , configN ]
   867 		""" 
   870 		"""
   868 
   871 
   869 		if len(configNames) == 0:
   872 		if len(configNames) == 0:
   870 			# use default config
   873 			# use default config
   871 			if len(self.defaultConfig) == 0:
   874 			if len(self.defaultConfig) == 0:
   872 				self.Warn("No default configuration name")
   875 				self.Warn("No default configuration name")
   876 		buildUnitsToBuild = set()
   879 		buildUnitsToBuild = set()
   877 
   880 
   878 
   881 
   879 		for c in set(configNames):
   882 		for c in set(configNames):
   880 			self.Debug("BuildUnit: %s", c)
   883 			self.Debug("BuildUnit: %s", c)
   881 			try:		
   884 			try:
   882 				x = self.GetConfig(c)
   885 				x = self.GetConfig(c)
   883 				gb = x.GenerateBuildUnits(self.cache) 
   886 				gb = x.GenerateBuildUnits(self.cache)
   884 				buildUnitsToBuild.update( gb )
   887 				buildUnitsToBuild.update( gb )
   885 			except Exception, e:
   888 			except Exception, e:
   886 				self.FatalError(str(e))
   889 				self.FatalError(str(e))
   887 
   890 
   888 		for b in buildUnitsToBuild:
   891 		for b in buildUnitsToBuild:
   892 			self.Error("No build configurations given")
   895 			self.Error("No build configurations given")
   893 
   896 
   894 		return buildUnitsToBuild
   897 		return buildUnitsToBuild
   895 
   898 
   896 	def CheckToolset(self, evaluator, configname):
   899 	def CheckToolset(self, evaluator, configname):
   897 		"""Check the toolset for a particular config, allow other objects access 
   900 		"""Check the toolset for a particular config, allow other objects access
   898 		to the toolset for this build (e.g. the raptor_make class)."""
   901 		to the toolset for this build (e.g. the raptor_make class)."""
   899 		if self.toolset is None:
   902 		if self.toolset is None:
   900 			if self.toolcheck == 'on':
   903 			if self.toolcheck == 'on':
   901 				self.toolset = raptor_data.ToolSet(log=self)
   904 				self.toolset = raptor_data.ToolSet(log=self)
   902 			elif self.toolcheck == 'forced' :
   905 			elif self.toolcheck == 'forced' :
   966 
   969 
   967 		return sysDef
   970 		return sysDef
   968 
   971 
   969 
   972 
   970 	def FindComponentIn(self, aDir = None):
   973 	def FindComponentIn(self, aDir = None):
   971 		# look for a bld.inf 
   974 		# look for a bld.inf
   972 
   975 
   973 		if aDir is None:
   976 		if aDir is None:
   974 			dir = generic_path.CurrentDir()
   977 			dir = generic_path.CurrentDir()
   975 		else:
   978 		else:
   976 			dir = generic_path.Path(aDir)
   979 			dir = generic_path.Path(aDir)
  1107 		"turn a dictionary into a string of XML attributes"
  1110 		"turn a dictionary into a string of XML attributes"
  1108 		atts = ""
  1111 		atts = ""
  1109 		for a,v in dictionary.items():
  1112 		for a,v in dictionary.items():
  1110 			atts += " " + a + "='" + v + "'"
  1113 			atts += " " + a + "='" + v + "'"
  1111 		return atts
  1114 		return atts
  1112 	
  1115 
  1113 	def Info(self, format, *extras, **attributes):
  1116 	def Info(self, format, *extras, **attributes):
  1114 		"""Send an information message to the configured channel
  1117 		"""Send an information message to the configured channel
  1115 				(XML control characters will be escaped)
  1118 				(XML control characters will be escaped)
  1116 		"""
  1119 		"""
  1117 		self.out.write("<info" + self.attributeString(attributes) + ">" +
  1120 		self.out.write("<info" + self.attributeString(attributes) + ">" +
  1118 		               escape(format % extras) + "</info>\n")
  1121 		               escape(format % extras) + "</info>\n")
  1119 		
  1122 
  1120 	def InfoDiscovery(self, object_type, count):
  1123 	def InfoDiscovery(self, object_type, count):
  1121 		if self.timing:
  1124 		if self.timing:
  1122 			try:
  1125 			try:
  1123 				self.out.write(raptor_timing.Timing.discovery_string(object_type = object_type,
  1126 				self.out.write(raptor_timing.Timing.discovery_string(object_type = object_type,
  1124 						count = count))
  1127 						count = count))
  1125 			except Exception, exception:
  1128 			except Exception, exception:
  1126 				Error(exception.Text, function = "InfoDiscoveryTime")
  1129 				Error(exception.Text, function = "InfoDiscoveryTime")
  1127 		
  1130 
  1128 	def InfoStartTime(self, object_type, task, key):
  1131 	def InfoStartTime(self, object_type, task, key):
  1129 		if self.timing:
  1132 		if self.timing:
  1130 			try:
  1133 			try:
  1131 				self.out.write(raptor_timing.Timing.start_string(object_type = object_type,
  1134 				self.out.write(raptor_timing.Timing.start_string(object_type = object_type,
  1132 						task = task, key = key))
  1135 						task = task, key = key))
  1133 			except Exception, exception:
  1136 			except Exception, exception:
  1134 				Error(exception.Text, function = "InfoStartTime")
  1137 				Error(exception.Text, function = "InfoStartTime")
  1135 		
  1138 
  1136 	def InfoEndTime(self, object_type, task, key):
  1139 	def InfoEndTime(self, object_type, task, key):
  1137 		if self.timing:
  1140 		if self.timing:
  1138 			try:
  1141 			try:
  1139 				self.out.write(raptor_timing.Timing.end_string(object_type = object_type,
  1142 				self.out.write(raptor_timing.Timing.end_string(object_type = object_type,
  1140 						task = task, key = key))
  1143 						task = task, key = key))
  1152 
  1155 
  1153 	def Warn(self, format, *extras, **attributes):
  1156 	def Warn(self, format, *extras, **attributes):
  1154 		"""Send a warning message to the configured channel
  1157 		"""Send a warning message to the configured channel
  1155 				(XML control characters will be escaped)
  1158 				(XML control characters will be escaped)
  1156 		"""
  1159 		"""
  1157 		self.out.write("<warning" + self.attributeString(attributes) + ">" + 
  1160 		self.out.write("<warning" + self.attributeString(attributes) + ">" +
  1158 		               escape(format % extras) + "</warning>\n")
  1161 		               escape(format % extras) + "</warning>\n")
  1159 
  1162 
  1160 	def FatalError(self, format, *extras, **attributes):
  1163 	def FatalError(self, format, *extras, **attributes):
  1161 		"""Send an error message to the configured channel. This implies such a serious
  1164 		"""Send an error message to the configured channel. This implies such a serious
  1162 		   error that the entire build must be shut down asap whilst still finishing off
  1165 		   error that the entire build must be shut down asap whilst still finishing off
  1163 		   correctly whatever housekeeping is possible e.g. producing error reports.
  1166 		   correctly whatever housekeeping is possible e.g. producing error reports.
  1164 		   Remains quiet if the raptor object is already in a fatal state since there
  1167 		   Remains quiet if the raptor object is already in a fatal state since there
  1165 		   further errors are probably triggered by the first.
  1168 		   further errors are probably triggered by the first.
  1166 		"""
  1169 		"""
  1167 		if not self.fatalErrorState:
  1170 		if not self.fatalErrorState:
  1168 			self.out.write("<error" + self.attributeString(attributes) + ">" + 
  1171 			self.out.write("<error" + self.attributeString(attributes) + ">" +
  1169 			               (format % extras) + "</error>\n")
  1172 			               (format % extras) + "</error>\n")
  1170 			self.errorCode = 1
  1173 			self.errorCode = 1
  1171 			self.fatalErrorState = True
  1174 			self.fatalErrorState = True
  1172 
  1175 
  1173 	def Error(self, format, *extras, **attributes):
  1176 	def Error(self, format, *extras, **attributes):
  1174 		"""Send an error message to the configured channel
  1177 		"""Send an error message to the configured channel
  1175 				(XML control characters will be escaped)
  1178 				(XML control characters will be escaped)
  1176 		"""
  1179 		"""
  1177 		self.out.write("<error" + self.attributeString(attributes) + ">" + 
  1180 		self.out.write("<error" + self.attributeString(attributes) + ">" +
  1178 		               escape(format % extras) + "</error>\n")
  1181 		               escape(format % extras) + "</error>\n")
  1179 		self.errorCode = 1
  1182 		self.errorCode = 1
  1180 
  1183 
  1181 
  1184 
  1182 	def PrintXML(self, format, *extras):
  1185 	def PrintXML(self, format, *extras):
  1210 
  1213 
  1211 		# If we now have a System Definition to parse then get the layers of components
  1214 		# If we now have a System Definition to parse then get the layers of components
  1212 		if self.systemDefinitionFile != None:
  1215 		if self.systemDefinitionFile != None:
  1213 			systemModel = raptor_xml.SystemModel(self, self.systemDefinitionFile, self.systemDefinitionBase)
  1216 			systemModel = raptor_xml.SystemModel(self, self.systemDefinitionFile, self.systemDefinitionBase)
  1214 			layers = self.GatherSysModelLayers(systemModel, self.systemDefinitionRequestedLayers)
  1217 			layers = self.GatherSysModelLayers(systemModel, self.systemDefinitionRequestedLayers)
  1215 			
  1218 
  1216 		# Now get components specified on a commandline - build them after any
  1219 		# Now get components specified on a commandline - build them after any
  1217 		# layers in the system definition.
  1220 		# layers in the system definition.
  1218 		if len(self.commandlineComponents) > 0:
  1221 		if len(self.commandlineComponents) > 0:
  1219 			layers.append(Layer('commandline',self.commandlineComponents))
  1222 			layers.append(Layer('commandline',self.commandlineComponents))
  1220 
  1223 
  1244 			# show the command and platform info
  1247 			# show the command and platform info
  1245 			self.AssertBuildOK()
  1248 			self.AssertBuildOK()
  1246 			self.Introduction()
  1249 			self.Introduction()
  1247 			# establish an object cache
  1250 			# establish an object cache
  1248 			self.AssertBuildOK()
  1251 			self.AssertBuildOK()
  1249 			
  1252 
  1250 			self.LoadCache()
  1253 			self.LoadCache()
  1251 
  1254 
  1252 			# find out what configurations to build
  1255 			# find out what configurations to build
  1253 			self.AssertBuildOK()
  1256 			self.AssertBuildOK()
  1254 			buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames)
  1257 			buildUnitsToBuild = self.GetBuildUnitsToBuild(self.configNames)
  1297 
  1300 
  1298 				self.AssertBuildOK()
  1301 				self.AssertBuildOK()
  1299 				for l in layers:
  1302 				for l in layers:
  1300 					# create specs for a specific group of components
  1303 					# create specs for a specific group of components
  1301 					l.realise(self)
  1304 					l.realise(self)
  1302 					
  1305 
  1303 		except BuildCannotProgressException,b:
  1306 		except BuildCannotProgressException,b:
  1304 			if str(b) != "":
  1307 			if str(b) != "":
  1305 				self.Info(str(b))
  1308 				self.Info(str(b))
  1306 
  1309 
  1307 		# final report
  1310 		# final report
  1324 		build.AssertBuildOK()
  1327 		build.AssertBuildOK()
  1325 		build.ConfigFile()
  1328 		build.ConfigFile()
  1326 		build.ProcessConfig()
  1329 		build.ProcessConfig()
  1327 		build.CommandLine(argv)
  1330 		build.CommandLine(argv)
  1328 
  1331 
  1329 		return build 
  1332 		return build
  1330 
  1333 
  1331 
  1334 
  1332 
  1335 
  1333 # Class for passing constricted parameters to filters
  1336 # Class for passing constricted parameters to filters
  1334 class BuildStats(object):
  1337 class BuildStats(object):
  1335 
  1338 
  1336 	def __init__(self, raptor_instance):
  1339 	def __init__(self, raptor_instance):
       
  1340 		self.incoming_epocroot = incoming_epocroot
       
  1341 		self.epocroot = epocroot
  1337 		self.logFileName = raptor_instance.logFileName
  1342 		self.logFileName = raptor_instance.logFileName
  1338 		self.quiet = raptor_instance.quiet
  1343 		self.quiet = raptor_instance.quiet
  1339 		self.doCheck = raptor_instance.doCheck
  1344 		self.doCheck = raptor_instance.doCheck
  1340 		self.doWhat = raptor_instance.doWhat
  1345 		self.doWhat = raptor_instance.doWhat
  1341 		self.platform = hostplatform
  1346 		self.platform = hostplatform