sbsv2/raptor/python/raptor.py
changeset 18 de5b887c98f7
parent 13 c327db0664bb
child 28 b8fa7dfeeaa1
equal deleted inserted replaced
14:eb060913c963 18:de5b887c98f7
   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):
   793 	def CommandLine(self, args):
   797 	def CommandLine(self, args):
   794 		# remember the arguments for the log
   798 		# remember the arguments for the log
   795 		self.args = args
   799 		self.args = args
   796 
   800 
   797 		# assuming self.CLI = "raptor_cli"
   801 		# assuming self.CLI = "raptor_cli"
   798 		more_to_do = raptor_cli.GetArgs(self, args)
   802 		if not raptor_cli.GetArgs(self, args):
   799 
   803 			self.skipAll = True		# nothing else to do
       
   804 
       
   805 	def ParseCommandLineTargets(self):
   800 		# resolve inter-argument dependencies.
   806 		# resolve inter-argument dependencies.
   801 		# --what or --check implies the WHAT target and FilterWhat Filter
   807 		# --what or --check implies the WHAT target and FilterWhat Filter
   802 		if self.doWhat or self.doCheck:
   808 		if self.doWhat or self.doCheck:
   803 			self.targets = ["WHAT"]
   809 			self.targets = ["WHAT"]
   804 			self.filterList = "filterwhat"
   810 			self.filterList = "filterwhat"
   827 
   833 
   828 			if is_clean:
   834 			if is_clean:
   829 				self.filterList += ",filterclean"
   835 				self.filterList += ",filterclean"
   830 				if is_suspicious_clean:
   836 				if is_suspicious_clean:
   831 					self.Warn('CLEAN, CLEANEXPORT and a REALLYCLEAN should not be combined with other targets as the result is unpredictable.')
   837 					self.Warn('CLEAN, CLEANEXPORT and a REALLYCLEAN should not be combined with other targets as the result is unpredictable.')
   832 
   838 			else:
   833 		if not more_to_do:
   839 				""" Copyfile implements the <copy> tag which is primarily useful with cluster builds.
   834 			self.skipAll = True		# nothing else to do
   840 				    It allows file copying to occur on the primary build host rather than on the cluster.
       
   841 				    This is more efficient.
       
   842 				"""
       
   843 				self.filterList += ",filtercopyfile"
       
   844 
   835 
   845 
   836 	def ProcessConfig(self):
   846 	def ProcessConfig(self):
   837 		# this function will perform additional processing of config
   847 		# this function will perform additional processing of config
   838 
   848 
   839 		# create list of generic paths
   849 		# create list of generic paths
  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 
  1316 		build = Raptor()
  1351 		build = Raptor()
  1317 		build.AssertBuildOK()
  1352 		build.AssertBuildOK()
  1318 		build.ConfigFile()
  1353 		build.ConfigFile()
  1319 		build.ProcessConfig()
  1354 		build.ProcessConfig()
  1320 		build.CommandLine(argv)
  1355 		build.CommandLine(argv)
       
  1356 		build.ParseCommandLineTargets()
  1321 
  1357 
  1322 		return build
  1358 		return build
  1323 
  1359 	
       
  1360 	@classmethod
       
  1361 	def CreateCommandlineAnalysis(cls, argv):
       
  1362 		""" Perform an analysis run where a build is not performed. """
       
  1363 		build = Raptor()
       
  1364 		build.AssertBuildOK()
       
  1365 		build.ConfigFile()
       
  1366 		build.ProcessConfig()
       
  1367 		build.CommandLine(argv)
       
  1368 		# Don't parse command line targets - they don't make any sense if you're not doing a build
       
  1369 
       
  1370 		return build
  1324 
  1371 
  1325 
  1372 
  1326 # Class for passing constricted parameters to filters
  1373 # Class for passing constricted parameters to filters
  1327 class BuildStats(object):
  1374 class BuildStats(object):
  1328 
  1375 
  1354 	DisplayBanner()
  1401 	DisplayBanner()
  1355 
  1402 
  1356 	# object which represents a build
  1403 	# object which represents a build
  1357 	b = Raptor.CreateCommandlineBuild(argv)
  1404 	b = Raptor.CreateCommandlineBuild(argv)
  1358 
  1405 
       
  1406 	if b.mission == Raptor.M_QUERY:
       
  1407 		return b.Query()
       
  1408 	
  1359 	return b.Build()
  1409 	return b.Build()
  1360 
  1410 
  1361 
  1411 
  1362 def DisplayBanner():
  1412 def DisplayBanner():
  1363 	"""Stuff that needs printing out for every command."""
  1413 	"""Stuff that needs printing out for every command."""