sbsv2/raptor/python/raptor.py
branchfix
changeset 557 be0305eb3dc3
parent 553 7d4971eaf863
child 580 6209aeff0f73
equal deleted inserted replaced
551:b41ce675e7b2 557:be0305eb3dc3
   443 
   443 
   444 	When operated from the command-line there is a single Raptor object
   444 	When operated from the command-line there is a single Raptor object
   445 	created by the Main function. When operated by an IDE several Raptor
   445 	created by the Main function. When operated by an IDE several Raptor
   446 	objects may be created and operated at the same time."""
   446 	objects may be created and operated at the same time."""
   447 
   447 
   448 
   448 	# mission enumeration
   449 	M_BUILD = 1
   449 	M_BUILD = 1
   450 	M_VERSION = 2
   450 	M_QUERY = 2
       
   451 	M_VERSION = 3
   451 
   452 
   452 	def __init__(self, home = None):
   453 	def __init__(self, home = None):
   453 
   454 
   454 		self.DefaultSetUp(home)
   455 		self.DefaultSetUp(home)
   455 
   456 
   515 		self.doExport = True
   516 		self.doExport = True
   516 		self.noBuild = False
   517 		self.noBuild = False
   517 		self.noDependInclude = False
   518 		self.noDependInclude = False
   518 		self.noDependGenerate = False
   519 		self.noDependGenerate = False
   519 		self.projects = set()
   520 		self.projects = set()
   520 
   521 		self.queries = []
       
   522 		
   521 		self.cache = raptor_cache.Cache(self)
   523 		self.cache = raptor_cache.Cache(self)
   522 		self.override = {env: str(self.home)}
   524 		self.override = {env: str(self.home)}
   523 		self.targets = []
   525 		self.targets = []
   524 		self.defaultTargets = []
   526 		self.defaultTargets = []
   525 
   527 
   712 
   714 
   713 	def AddProject(self, projectName):
   715 	def AddProject(self, projectName):
   714 		self.projects.add(projectName.lower())
   716 		self.projects.add(projectName.lower())
   715 		return True
   717 		return True
   716 
   718 
       
   719 	def AddQuery(self, q):
       
   720 		self.queries.append(q)
       
   721 		self.mission = Raptor.M_QUERY
       
   722 		return True
       
   723 	
   717 	def FilterList(self, value):
   724 	def FilterList(self, value):
   718 		self.filterList = value
   725 		self.filterList = value
   719 		return True
   726 		return True
   720 
   727 
   721 	def IgnoreOsDetection(self, value):
   728 	def IgnoreOsDetection(self, value):
  1058 			self.pbox = pluginbox.PluginBox(str(self.systemPlugins))
  1065 			self.pbox = pluginbox.PluginBox(str(self.systemPlugins))
  1059 
  1066 
  1060 			self.raptor_params = BuildStats(self)
  1067 			self.raptor_params = BuildStats(self)
  1061 
  1068 
  1062 			# Open the requested plugins using the pluginbox
  1069 			# Open the requested plugins using the pluginbox
  1063 			self.out.open(self.raptor_params, self.filterList.split(','), self.pbox)
  1070 			self.out.open(self.raptor_params, self.filterList, self.pbox)
  1064 
  1071 
  1065 			# log header
  1072 			# log header
  1066 			self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n")
  1073 			self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n")
  1067 
  1074 
  1068 			namespace = "http://symbian.com/xml/build/log"
  1075 			namespace = "http://symbian.com/xml/build/log"
  1220 					newcg.add(c)
  1227 					newcg.add(c)
  1221 			layers = [newcg]
  1228 			layers = [newcg]
  1222 
  1229 
  1223 		return layers
  1230 		return layers
  1224 
  1231 
       
  1232 	def Query(self):
       
  1233 		"process command-line queries."
       
  1234 		
       
  1235 		if self.mission != Raptor.M_QUERY:
       
  1236 			return 0
       
  1237 		
       
  1238 		# establish an object cache based on the current settings
       
  1239 		self.LoadCache()
       
  1240 			
       
  1241 		# our "self" is a valid object for initialising an API Context
       
  1242 		import raptor_api
       
  1243 		api = raptor_api.Context(self)
       
  1244 		
       
  1245 		print "<sbs version='%s'>" % raptor_version.numericversion()
       
  1246 		
       
  1247 		for q in self.queries:
       
  1248 			try:
       
  1249 				print api.stringquery(q)
       
  1250 				
       
  1251 			except Exception, e:
       
  1252 				self.Error("exception '%s' with query '%s'", str(e), q)
       
  1253 		
       
  1254 		print "</sbs>"	
       
  1255 		return self.errorCode
       
  1256 	
  1225 	def Build(self):
  1257 	def Build(self):
  1226 
  1258 
  1227 		if self.mission != Raptor.M_BUILD: # help or version requested instead.
  1259 		if self.mission != Raptor.M_BUILD: # help or version requested instead.
  1228 			return 0
  1260 			return 0
  1229 
  1261 
  1357 	DisplayBanner()
  1389 	DisplayBanner()
  1358 
  1390 
  1359 	# object which represents a build
  1391 	# object which represents a build
  1360 	b = Raptor.CreateCommandlineBuild(argv)
  1392 	b = Raptor.CreateCommandlineBuild(argv)
  1361 
  1393 
       
  1394 	if b.mission == Raptor.M_QUERY:
       
  1395 		return b.Query()
       
  1396 	
  1362 	return b.Build()
  1397 	return b.Build()
  1363 
  1398 
  1364 
  1399 
  1365 def DisplayBanner():
  1400 def DisplayBanner():
  1366 	"""Stuff that needs printing out for every command."""
  1401 	"""Stuff that needs printing out for every command."""