sbsv2/raptor/python/raptor_xml.py
branchfix
changeset 491 f60c4282816c
parent 333 0fe3c56ad89c
equal deleted inserted replaced
490:b60bdff41580 491:f60c4282816c
     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_xml module
    15 # raptor_xml module
    16 #
    16 #
    17 
    17 
    18 import os
    18 import os
    19 import raptor_data
    19 import raptor_data
    65 	# <build> is always the root element
    65 	# <build> is always the root element
    66 	build = dom.documentElement
    66 	build = dom.documentElement
    67 	objects = []
    67 	objects = []
    68 
    68 
    69 	fileVersion = build.getAttribute("xsi:schemaLocation")
    69 	fileVersion = build.getAttribute("xsi:schemaLocation")
    70 	
    70 
    71 	# ignore the file it matches the "invalid" schema
    71 	# ignore the file it matches the "invalid" schema
    72 	if fileVersion.endswith(xsdIgnore):
    72 	if fileVersion.endswith(xsdIgnore):
    73 		return objects
    73 		return objects
    74 		
    74 
    75 	# check that the file matches the expected schema
    75 	# check that the file matches the expected schema
    76 	if not fileVersion.endswith(xsdVersion):
    76 	if not fileVersion.endswith(xsdVersion):
    77 		Raptor.Warn("file '%s' uses schema '%s' which does not end with the expected version '%s'", filename, fileVersion, xsdVersion)
    77 		Raptor.Warn("file '%s' uses schema '%s' which does not end with the expected version '%s'", filename, fileVersion, xsdVersion)
    78 		
    78 
    79 	# create a Data Model object from each sub-element
    79 	# create a Data Model object from each sub-element
    80 	for child in build.childNodes:
    80 	for child in build.childNodes:
    81 		if child.namespaceURI == namespace \
    81 		if child.namespaceURI == namespace \
    82 		and child.nodeType == child.ELEMENT_NODE:
    82 		and child.nodeType == child.ELEMENT_NODE:
    83 			try:
    83 			try:
   181 		self.__IdAttribute = "name"
   181 		self.__IdAttribute = "name"
   182 		self.__ComponentRoot = ""
   182 		self.__ComponentRoot = ""
   183 		self.__TotalComponents = 0
   183 		self.__TotalComponents = 0
   184 		self.__LayerList = []
   184 		self.__LayerList = []
   185 		self.__LayerDetails = {}
   185 		self.__LayerDetails = {}
       
   186 		self.__MissingBldInfs = {}
   186 
   187 
   187 		self.__DOM = None
   188 		self.__DOM = None
   188 		self.__SystemDefinitionElement = None
   189 		self.__SystemDefinitionElement = None
   189 
   190 
   190 		if self.__Read():
   191 		if self.__Read():
   206 			return []
   207 			return []
   207 
   208 
   208 		return self.__LayerDetails[aLayer]
   209 		return self.__LayerDetails[aLayer]
   209 
   210 
   210 	def IsLayerBuildable(self, aLayer):
   211 	def IsLayerBuildable(self, aLayer):
       
   212 		if aLayer in self.__MissingBldInfs:
       
   213 			for missingbldinf in self.__MissingBldInfs[aLayer]:
       
   214 				self.__Logger.Error("System Definition layer \"%s\" from system definition file \"%s\" " + \
       
   215 								    "refers to non existent bld.inf file %s", aLayer, self.__SystemDefinitionFile, missingbldinf)
       
   216 
   211 		if len(self.GetLayerComponents(aLayer)):
   217 		if len(self.GetLayerComponents(aLayer)):
   212 			return True
   218 			return True
   213 		return False
   219 		return False
       
   220 
   214 
   221 
   215 	def GetAllComponents(self):
   222 	def GetAllComponents(self):
   216 		components = []
   223 		components = []
   217 
   224 
   218 		for layer in self.GetLayerNames():
   225 		for layer in self.GetLayerNames():
   273 			# explicitly overridden on the command line
   280 			# explicitly overridden on the command line
   274 			if os.environ.has_key('SRCROOT'):
   281 			if os.environ.has_key('SRCROOT'):
   275 				self.__ComponentRoot = generic_path.Path(os.environ['SRCROOT'])
   282 				self.__ComponentRoot = generic_path.Path(os.environ['SRCROOT'])
   276 			elif os.environ.has_key('SOURCEROOT'):
   283 			elif os.environ.has_key('SOURCEROOT'):
   277 				self.__ComponentRoot = generic_path.Path(os.environ['SOURCEROOT'])
   284 				self.__ComponentRoot = generic_path.Path(os.environ['SOURCEROOT'])
   278 				
   285 
   279 			if self.__SystemDefinitionBase and self.__SystemDefinitionBase != ".":
   286 			if self.__SystemDefinitionBase and self.__SystemDefinitionBase != ".":
   280 				self.__ComponentRoot = self.__SystemDefinitionBase
   287 				self.__ComponentRoot = self.__SystemDefinitionBase
   281 				if os.environ.has_key('SRCROOT'):
   288 				if os.environ.has_key('SRCROOT'):
   282 					self.__Logger.Info("Command line specified System Definition file base \'%s\' overriding environment SRCROOT \'%s\'", self.__SystemDefinitionBase, os.environ['SRCROOT'])
   289 					self.__Logger.Info("Command line specified System Definition file base \'%s\' overriding environment SRCROOT \'%s\'", self.__SystemDefinitionBase, os.environ['SRCROOT'])
   283 				elif os.environ.has_key('SOURCEROOT'):
   290 				elif os.environ.has_key('SOURCEROOT'):
   378 						group = generic_path.Join(bldInfRoot, group)
   385 						group = generic_path.Join(bldInfRoot, group)
   379 
   386 
   380 				bldinf = generic_path.Join(group, "bld.inf").FindCaseless()
   387 				bldinf = generic_path.Join(group, "bld.inf").FindCaseless()
   381 
   388 
   382 				if bldinf == None:
   389 				if bldinf == None:
   383 					self.__Logger.Error("No bld.inf found at %s in %s", group.GetLocalString(), self.__SystemDefinitionFile)
   390 					# recording layers containing non existent bld.infs
       
   391 					bldinfname = group.GetLocalString()
       
   392 					bldinfname = bldinfname + 'bld.inf'
       
   393 					layer = self.__GetEffectiveLayer(aElement)
       
   394 					if not layer in self.__MissingBldInfs:
       
   395 						self.__MissingBldInfs[layer]=[]
       
   396 					self.__MissingBldInfs[layer].append(bldinfname)
       
   397 
   384 				else:
   398 				else:
   385 					component = self.__CreateComponent(bldinf, aElement)
   399 					component = self.__CreateComponent(bldinf, aElement)
   386 					layer = component.GetLayerName()
   400 					layer = component.GetLayerName()
   387 					if layer:
   401 					if layer:
   388 						self.__LayerDetails[layer].append(component)
   402 						self.__LayerDetails[layer].append(component)