sbsv2/raptor/python/raptor.py
branchfix
changeset 560 245c03ee6e9c
parent 553 7d4971eaf863
child 580 6209aeff0f73
--- a/sbsv2/raptor/python/raptor.py	Mon May 17 18:27:21 2010 +0100
+++ b/sbsv2/raptor/python/raptor.py	Mon May 17 18:33:53 2010 +0100
@@ -338,9 +338,6 @@
 		if build.quiet == True:
 			cli_options += " -q"
 
-		if build.timing == True:
-			cli_options += " --timing"
-
 		if build.noDependInclude == True:
 			cli_options += " --no-depend-include"
 
@@ -448,9 +445,10 @@
 	created by the Main function. When operated by an IDE several Raptor
 	objects may be created and operated at the same time."""
 
-
+	# mission enumeration
 	M_BUILD = 1
-	M_VERSION = 2
+	M_QUERY = 2
+	M_VERSION = 3
 
 	def __init__(self, home = None):
 
@@ -520,7 +518,8 @@
 		self.noDependInclude = False
 		self.noDependGenerate = False
 		self.projects = set()
-
+		self.queries = []
+		
 		self.cache = raptor_cache.Cache(self)
 		self.override = {env: str(self.home)}
 		self.targets = []
@@ -534,7 +533,7 @@
 		# what platform and filesystem are we running on?
 		self.filesystem = raptor_utilities.getOSFileSystem()
 
-		self.timing = False
+		self.timing = True # Needed by filters such as copy_file to monitor progress
 		self.toolset = None
 
 		self.starttime = time.time()
@@ -696,7 +695,7 @@
 		return True
 
 	def SetTiming(self, TrueOrFalse):
-		self.timing = TrueOrFalse
+		self.Info("--timing switch no longer has any effect - build timing is now permanently on")
 		return True
 
 	def SetParallelParsing(self, type):
@@ -717,6 +716,11 @@
 		self.projects.add(projectName.lower())
 		return True
 
+	def AddQuery(self, q):
+		self.queries.append(q)
+		self.mission = Raptor.M_QUERY
+		return True
+	
 	def FilterList(self, value):
 		self.filterList = value
 		return True
@@ -829,6 +833,12 @@
 				self.filterList += ",filterclean"
 				if is_suspicious_clean:
 					self.Warn('CLEAN, CLEANEXPORT and a REALLYCLEAN should not be combined with other targets as the result is unpredictable.')
+			else:
+				""" Copyfile implements the <copy> tag which is primarily useful with cluster builds.
+				    It allows file copying to occur on the primary build host rather than on the cluster.
+				    This is more efficient.
+				"""
+				self.filterList += ",filtercopyfile"
 
 		if not more_to_do:
 			self.skipAll = True		# nothing else to do
@@ -1057,7 +1067,7 @@
 			self.raptor_params = BuildStats(self)
 
 			# Open the requested plugins using the pluginbox
-			self.out.open(self.raptor_params, self.filterList.split(','), self.pbox)
+			self.out.open(self.raptor_params, self.filterList, self.pbox)
 
 			# log header
 			self.out.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n")
@@ -1219,6 +1229,31 @@
 
 		return layers
 
+	def Query(self):
+		"process command-line queries."
+		
+		if self.mission != Raptor.M_QUERY:
+			return 0
+		
+		# establish an object cache based on the current settings
+		self.LoadCache()
+			
+		# our "self" is a valid object for initialising an API Context
+		import raptor_api
+		api = raptor_api.Context(self)
+		
+		print "<sbs version='%s'>" % raptor_version.numericversion()
+		
+		for q in self.queries:
+			try:
+				print api.stringquery(q)
+				
+			except Exception, e:
+				self.Error("exception '%s' with query '%s'", str(e), q)
+		
+		print "</sbs>"	
+		return self.errorCode
+	
 	def Build(self):
 
 		if self.mission != Raptor.M_BUILD: # help or version requested instead.
@@ -1356,6 +1391,9 @@
 	# object which represents a build
 	b = Raptor.CreateCommandlineBuild(argv)
 
+	if b.mission == Raptor.M_QUERY:
+		return b.Query()
+	
 	return b.Build()