sbsv2/raptor/python/raptor_data.py
branchwip
changeset 330 f3b3d9f9a008
parent 204 a19456c07783
child 371 2db10eac415a
equal deleted inserted replaced
329:b2c00b774e4f 330:f3b3d9f9a008
     1 #
     1 #
     2 # Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 # Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 # All rights reserved.
     3 # All rights reserved.
     4 # This component and the accompanying materials are made available
     4 # This component and the accompanying materials are made available
     5 # under the terms of the License "Eclipse Public License v1.0"
     5 # under the terms of the License "Eclipse Public License v1.0"
     6 # which accompanies this distribution, and is available
     6 # which accompanies this distribution, and is available
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
   882 		for m in self.modifiers:
   882 		for m in self.modifiers:
   883 			name = name + "." + m.name
   883 			name = name + "." + m.name
   884 			vars.append(m)
   884 			vars.append(m)
   885 		return [ BuildUnit(name=name, variants=vars) ]
   885 		return [ BuildUnit(name=name, variants=vars) ]
   886 
   886 
       
   887 	def isDerivedFrom(self, progenitor, cache):
       
   888 		if self.name == progenitor:
       
   889 			return True
       
   890 
       
   891 		pname = self.extends
       
   892 		while pname is not None and pname is not '':
       
   893 			parent = cache.FindNamedVariant(pname)
       
   894 			if parent is None:
       
   895 				break
       
   896 			if parent.name == progenitor:
       
   897 				return True
       
   898 			pname = parent.extends
       
   899 
       
   900 		return False
       
   901 
   887 	def __str__(self):
   902 	def __str__(self):
   888 		s = "<var name='%s' extends='%s'>\n" % (self.name, self.extends)
   903 		s = "<var name='%s' extends='%s'>\n" % (self.name, self.extends)
   889 		for op in self.ops:
   904 		for op in self.ops:
   890 			s +=  str(op) + '\n'
   905 			s +=  str(op) + '\n'
   891 		s += "</var>"
   906 		s += "</var>"
   934 			raise InvalidPropertyError()
   949 			raise InvalidPropertyError()
   935 
   950 
   936 	def Valid(self):
   951 	def Valid(self):
   937 		return self.name and self.meaning
   952 		return self.name and self.meaning
   938 
   953 
   939 	def GenerateBuildUnits(self, cache):
   954 	def Resolve(self, cache):
   940 		if not self.variants:
   955 		if not self.variants:
   941 			missing_variants = []
   956 			missing_variants = []
   942 			for r in self.varRefs:
   957 			for r in self.varRefs:
   943 				try:
   958 				try:
   944 					self.variants.append( r.Resolve(cache=cache) )
   959 					self.variants.append( r.Resolve(cache=cache) )
   946 					missing_variants.append(r.ref)
   961 					missing_variants.append(r.ref)
   947 				
   962 				
   948 			if len(missing_variants) > 0:
   963 			if len(missing_variants) > 0:
   949 				raise MissingVariantException("Missing variants '%s'", " ".join(missing_variants))
   964 				raise MissingVariantException("Missing variants '%s'", " ".join(missing_variants))
   950 
   965 
       
   966 	def GenerateBuildUnits(self, cache):
       
   967 		self.Resolve(cache)
       
   968 
   951 		name = self.name
   969 		name = self.name
   952 
   970 
   953 		for v in self.modifiers:
   971 		for v in self.modifiers:
   954 			name = name + "." + v.name
   972 			name = name + "." + v.name
   955 
   973 
   956 		return [ BuildUnit(name=name, variants=self.variants + self.modifiers) ]
   974 		return [ BuildUnit(name=name, variants=self.variants + self.modifiers) ]
   957 
   975 
       
   976 	def isDerivedFrom(self, progenitor, cache):
       
   977 		self.Resolve(cache)
       
   978 		for v in self.variants:
       
   979 			if v.isDerivedFrom(progenitor,cache):
       
   980 				return True
       
   981 		return False
   958 
   982 
   959 class AliasRef(Reference):
   983 class AliasRef(Reference):
   960 
   984 
   961 	def __init__(self, ref=None):
   985 	def __init__(self, ref=None):
   962 		Reference.__init__(self, ref)
   986 		Reference.__init__(self, ref)