sbsv2/raptor/python/raptor_make.py
branchwip
changeset 29 ee00c00df073
parent 5 593a8820b912
child 118 375b7128e900
--- a/sbsv2/raptor/python/raptor_make.py	Tue Dec 01 23:06:30 2009 +0000
+++ b/sbsv2/raptor/python/raptor_make.py	Wed Dec 02 00:21:12 2009 +0000
@@ -20,6 +20,7 @@
 import os
 import random
 import raptor
+import raptor_timing
 import raptor_utilities
 import raptor_version
 import raptor_data
@@ -27,7 +28,6 @@
 import subprocess
 import time
 from raptor_makefile import *
-import raptor_version
 import traceback
 import sys
 
@@ -135,9 +135,23 @@
 USE_TALON:=
 
 """
-		
+
+
+		timing_start = "$(info " + \
+				raptor_timing.Timing.custom_string(tag = "start",
+				object_type = "makefile", task = "parse",
+				key = "$(THIS_FILENAME)",
+				time="$(shell date +%s.%N)").rstrip("\n") + ")"
+				
+		timing_end = "$(info " + \
+				raptor_timing.Timing.custom_string(tag = "end",
+				object_type = "makefile", task = "parse",
+				key = "$(THIS_FILENAME)",
+				time="$(shell date +%s.%N)").rstrip("\n") + ")"
+
 
 		self.makefile_prologue = """
+
 # generated by %s %s
 
 HOSTPLATFORM:=%s
@@ -145,6 +159,7 @@
 OSTYPE:=%s
 FLMHOME:=%s
 SHELL:=%s
+THIS_FILENAME:=$(firstword $(MAKEFILE_LIST))
 
 %s
 
@@ -159,8 +174,18 @@
 			 talon_settings,
 			 self.raptor.systemFLM.Append('globals.mk') )
 
+		# Only output timings if requested on CLI
+		if self.raptor.timing:
+			self.makefile_prologue += "\n# Print Start-time of Makefile parsing\n" \
+					+ timing_start + "\n\n"
+	
+	
+			self.makefile_epilogue = "\n\n# Print End-time of Makefile parsing\n" \
+				+ timing_end + "\n"
+		else:
+			self.makefile_epilogue = ""
 
-		self.makefile_epilogue = """
+		self.makefile_epilogue += """
 
 include %s
 
@@ -365,6 +390,9 @@
 		if clean_flag:
 			fileName_list.reverse()
 
+		# Report number of makefiles to be built
+		self.raptor.InfoDiscovery(object_type = "makefile", count = len(fileName_list))
+
 		# Process each file in turn
 		for makefile in fileName_list:
 			if not os.path.exists(makefile):
@@ -431,6 +459,10 @@
 			# bufsize=1 means "line buffered"
 			#
 			try:
+				# Time the build
+				self.raptor.InfoStartTime(object_type = "makefile",
+						task = "build", key = str(makefile))
+				
 				makeenv=os.environ.copy()
 				if self.usetalon:
 					makeenv['TALON_RECIPEATTRIBUTES']="none"
@@ -458,6 +490,9 @@
 				# should be done now
 				returncode = p.wait()
 
+				# Report end-time of the build
+				self.raptor.InfoEndTime(object_type = "makefile",
+						task = "build", key = str(makefile))
 
 				if returncode != 0  and not self.raptor.keepGoing:
 					self.Tidy()
@@ -466,6 +501,9 @@
 			except Exception,e:
 				self.raptor.Error("Exception '%s' during '%s'", str(e), command)
 				self.Tidy()
+				# Still report end-time of the build
+				self.raptor.InfoEnd(object_type = "Building", task = "Makefile",
+						key = str(makefile))
 				return False
 
 		# run any shutdown script