sbsv2/raptor/python/raptor.py
branchfix
changeset 560 245c03ee6e9c
parent 553 7d4971eaf863
child 580 6209aeff0f73
equal deleted inserted replaced
559:3a62f88a49f8 560:245c03ee6e9c
   336 			cli_options += " -k"
   336 			cli_options += " -k"
   337 
   337 
   338 		if build.quiet == True:
   338 		if build.quiet == True:
   339 			cli_options += " -q"
   339 			cli_options += " -q"
   340 
   340 
   341 		if build.timing == True:
       
   342 			cli_options += " --timing"
       
   343 
       
   344 		if build.noDependInclude == True:
   341 		if build.noDependInclude == True:
   345 			cli_options += " --no-depend-include"
   342 			cli_options += " --no-depend-include"
   346 
   343 
   347 		if build.noDependGenerate == True:
   344 		if build.noDependGenerate == True:
   348 			cli_options += " --no-depend-generate"
   345 			cli_options += " --no-depend-generate"
   446 
   443 
   447 	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
   448 	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
   449 	objects may be created and operated at the same time."""
   446 	objects may be created and operated at the same time."""
   450 
   447 
   451 
   448 	# mission enumeration
   452 	M_BUILD = 1
   449 	M_BUILD = 1
   453 	M_VERSION = 2
   450 	M_QUERY = 2
       
   451 	M_VERSION = 3
   454 
   452 
   455 	def __init__(self, home = None):
   453 	def __init__(self, home = None):
   456 
   454 
   457 		self.DefaultSetUp(home)
   455 		self.DefaultSetUp(home)
   458 
   456 
   518 		self.doExport = True
   516 		self.doExport = True
   519 		self.noBuild = False
   517 		self.noBuild = False
   520 		self.noDependInclude = False
   518 		self.noDependInclude = False
   521 		self.noDependGenerate = False
   519 		self.noDependGenerate = False
   522 		self.projects = set()
   520 		self.projects = set()
   523 
   521 		self.queries = []
       
   522 		
   524 		self.cache = raptor_cache.Cache(self)
   523 		self.cache = raptor_cache.Cache(self)
   525 		self.override = {env: str(self.home)}
   524 		self.override = {env: str(self.home)}
   526 		self.targets = []
   525 		self.targets = []
   527 		self.defaultTargets = []
   526 		self.defaultTargets = []
   528 
   527 
   532 		self.mission = Raptor.M_BUILD
   531 		self.mission = Raptor.M_BUILD
   533 
   532 
   534 		# what platform and filesystem are we running on?
   533 		# what platform and filesystem are we running on?
   535 		self.filesystem = raptor_utilities.getOSFileSystem()
   534 		self.filesystem = raptor_utilities.getOSFileSystem()
   536 
   535 
   537 		self.timing = False
   536 		self.timing = True # Needed by filters such as copy_file to monitor progress
   538 		self.toolset = None
   537 		self.toolset = None
   539 
   538 
   540 		self.starttime = time.time()
   539 		self.starttime = time.time()
   541 		self.timestring = time.strftime("%Y-%m-%d-%H-%M-%S")
   540 		self.timestring = time.strftime("%Y-%m-%d-%H-%M-%S")
   542 
   541 
   694 			return False
   693 			return False
   695 
   694 
   696 		return True
   695 		return True
   697 
   696 
   698 	def SetTiming(self, TrueOrFalse):
   697 	def SetTiming(self, TrueOrFalse):
   699 		self.timing = TrueOrFalse
   698 		self.Info("--timing switch no longer has any effect - build timing is now permanently on")
   700 		return True
   699 		return True
   701 
   700 
   702 	def SetParallelParsing(self, type):
   701 	def SetParallelParsing(self, type):
   703 		type = type.lower()
   702 		type = type.lower()
   704 		if type == "on":
   703 		if type == "on":
   715 
   714 
   716 	def AddProject(self, projectName):
   715 	def AddProject(self, projectName):
   717 		self.projects.add(projectName.lower())
   716 		self.projects.add(projectName.lower())
   718 		return True
   717 		return True
   719 
   718 
       
   719 	def AddQuery(self, q):
       
   720 		self.queries.append(q)
       
   721 		self.mission = Raptor.M_QUERY
       
   722 		return True
       
   723 	
   720 	def FilterList(self, value):
   724 	def FilterList(self, value):
   721 		self.filterList = value
   725 		self.filterList = value
   722 		return True
   726 		return True
   723 
   727 
   724 	def IgnoreOsDetection(self, value):
   728 	def IgnoreOsDetection(self, value):
   827 
   831 
   828 			if is_clean:
   832 			if is_clean:
   829 				self.filterList += ",filterclean"
   833 				self.filterList += ",filterclean"
   830 				if is_suspicious_clean:
   834 				if is_suspicious_clean:
   831 					self.Warn('CLEAN, CLEANEXPORT and a REALLYCLEAN should not be combined with other targets as the result is unpredictable.')
   835 					self.Warn('CLEAN, CLEANEXPORT and a REALLYCLEAN should not be combined with other targets as the result is unpredictable.')
       
   836 			else:
       
   837 				""" Copyfile implements the <copy> tag which is primarily useful with cluster builds.
       
   838 				    It allows file copying to occur on the primary build host rather than on the cluster.
       
   839 				    This is more efficient.
       
   840 				"""
       
   841 				self.filterList += ",filtercopyfile"
   832 
   842 
   833 		if not more_to_do:
   843 		if not more_to_do:
   834 			self.skipAll = True		# nothing else to do
   844 			self.skipAll = True		# nothing else to do
   835 
   845 
   836 	def ProcessConfig(self):
   846 	def ProcessConfig(self):
  1055 			self.pbox = pluginbox.PluginBox(str(self.systemPlugins))
  1065 			self.pbox = pluginbox.PluginBox(str(self.systemPlugins))
  1056 
  1066 
  1057 			self.raptor_params = BuildStats(self)
  1067 			self.raptor_params = BuildStats(self)
  1058 
  1068 
  1059 			# Open the requested plugins using the pluginbox
  1069 			# Open the requested plugins using the pluginbox
  1060 			self.out.open(self.raptor_params, self.filterList.split(','), self.pbox)
  1070 			self.out.open(self.raptor_params, self.filterList, self.pbox)
  1061 
  1071 
  1062 			# log header
  1072 			# log header
  1063 			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")
  1064 
  1074 
  1065 			namespace = "http://symbian.com/xml/build/log"
  1075 			namespace = "http://symbian.com/xml/build/log"
  1217 					newcg.add(c)
  1227 					newcg.add(c)
  1218 			layers = [newcg]
  1228 			layers = [newcg]
  1219 
  1229 
  1220 		return layers
  1230 		return layers
  1221 
  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 	
  1222 	def Build(self):
  1257 	def Build(self):
  1223 
  1258 
  1224 		if self.mission != Raptor.M_BUILD: # help or version requested instead.
  1259 		if self.mission != Raptor.M_BUILD: # help or version requested instead.
  1225 			return 0
  1260 			return 0
  1226 
  1261 
  1354 	DisplayBanner()
  1389 	DisplayBanner()
  1355 
  1390 
  1356 	# object which represents a build
  1391 	# object which represents a build
  1357 	b = Raptor.CreateCommandlineBuild(argv)
  1392 	b = Raptor.CreateCommandlineBuild(argv)
  1358 
  1393 
       
  1394 	if b.mission == Raptor.M_QUERY:
       
  1395 		return b.Query()
       
  1396 	
  1359 	return b.Build()
  1397 	return b.Build()
  1360 
  1398 
  1361 
  1399 
  1362 def DisplayBanner():
  1400 def DisplayBanner():
  1363 	"""Stuff that needs printing out for every command."""
  1401 	"""Stuff that needs printing out for every command."""