diff -r 29df63210f13 -r 164b0547f8a5 sbsv2/raptor/python/raptor_make.py --- a/sbsv2/raptor/python/raptor_make.py Mon Nov 16 20:40:58 2009 +0000 +++ b/sbsv2/raptor/python/raptor_make.py Mon Dec 07 12:50:33 2009 +0000 @@ -20,13 +20,16 @@ import os import random import raptor -import raptor_data +import raptor_timing import raptor_utilities import raptor_version +import raptor_data import re import subprocess import time from raptor_makefile import * +import traceback +import sys # raptor_make module classes @@ -35,7 +38,6 @@ def __init__(self, Raptor): self.raptor = Raptor self.valid = True - self.makefileset = None self.descrambler = None self.descrambler_started = False @@ -53,7 +55,7 @@ # find the variant and extract the values try: - units = avar.GenerateBuildUnits() + units = avar.GenerateBuildUnits(Raptor.cache) evaluator = Raptor.GetEvaluator( None, units[0] , gathertools=True) # shell @@ -123,7 +125,7 @@ component='$$COMPONENT_NAME'\ bldinf='$$COMPONENT_META' mmp='$$PROJECT_META'\ config='$$SBS_CONFIGURATION' platform='$$PLATFORM'\ - phase='$$MAKEFILE_GROUP' source='$$SOURCE + phase='$$MAKEFILE_GROUP' source='$$SOURCE' export TALON_RECIPEATTRIBUTES TALON_SHELL TALON_TIMEOUT USE_TALON:=%s @@ -133,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 @@ -143,12 +159,13 @@ OSTYPE:=%s FLMHOME:=%s SHELL:=%s +THIS_FILENAME:=$(firstword $(MAKEFILE_LIST)) %s include %s -""" % ( raptor.name, raptor_version.Version(), +""" % ( raptor.name, raptor_version.fullversion(), " ".join(raptor.hostplatform), raptor.hostplatform_dir, self.raptor.filesystem, @@ -157,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 @@ -168,14 +195,17 @@ """Generate a set of makefiles, or one big Makefile.""" if not self.valid: - return + return None + + self.raptor.Debug("Writing Makefile '%s'" % (str(toplevel))) self.toplevel = toplevel # create the top-level makefiles + makefileset = None try: - self.makefileset = MakefileSet(directory = str(toplevel.Dir()), + makefileset = MakefileSet(directory = str(toplevel.Dir()), selectors = self.selectors, filenamebase = str(toplevel.File()), prologue = self.makefile_prologue, @@ -190,11 +220,10 @@ self.many = not self.raptor.writeSingleMakefile # add a makefile for each spec under each config - config_makefileset = self.makefileset - + config_makefileset = makefileset for c in configs: if self.many: - config_makefileset = self.makefileset.createChild(c.name) + config_makefileset = makefileset.createChild(c.name) # make sure the config_wide spec item is put out first so that it # can affect everything. @@ -207,16 +236,22 @@ ordered_specs.append(s) if config_wide_spec is not None: - config_wide_spec.Configure(c) + config_wide_spec.Configure(c, cache = self.raptor.cache) self.WriteConfiguredSpec(config_makefileset, config_wide_spec, c, True) for s in ordered_specs: - s.Configure(c) + s.Configure(c, cache = self.raptor.cache) self.WriteConfiguredSpec(config_makefileset, s, c, False) - self.makefileset.close() + makefileset.close() except Exception,e: - self.raptor.Error("Failed to write makefile '%s': %s" % (str(toplevel),str(e))) + tb = traceback.format_exc() + if not self.raptor.debugOutput: + tb="" + self.raptor.Error("Failed to write makefile '%s': %s : %s" % (str(toplevel),str(e),tb)) + makefileset = None + + return makefileset def WriteConfiguredSpec(self, parentMakefileSet, spec, config, useAllInterfaces): @@ -233,9 +268,10 @@ guard = None if hasInterface: # find the Interface (it may be a ref) - iface = spec.GetInterface() + try: + iface = spec.GetInterface(self.raptor.cache) - if iface == None: + except raptor_data.MissingInterfaceError, e: self.raptor.Error("No interface for '%s'", spec.name) return @@ -268,12 +304,12 @@ md5hash.update(value) # parameters required by the interface - for p in iface.GetParams(): + for p in iface.GetParams(self.raptor.cache): val = evaluator.Resolve(p.name) addparam(p.name,val,p.default) # Use Patterns to fetch a group of parameters - for g in iface.GetParamGroups(): + for g in iface.GetParamGroups(self.raptor.cache): for k,v in evaluator.ResolveMatching(g.patternre): addparam(k,v,g.default) @@ -301,7 +337,7 @@ # generate the call to the FLM if iface is not None: - makefileset.addCall(spec.name, config.name, iface.name, useAllInterfaces, iface.GetFLMIncludePath(), parameters, guard) + makefileset.addCall(spec.name, config.name, iface.name, useAllInterfaces, iface.GetFLMIncludePath(self.raptor.cache), parameters, guard) # recursive includes @@ -341,7 +377,7 @@ return False # Save file names to a list, to allow the order to be reversed - fileName_list = list(self.makefileset.makefileNames()) + fileName_list = list(makefileset.makefileNames()) # Iterate through args passed to raptor, searching for CLEAN or REALLYCLEAN clean_flag = False @@ -354,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): @@ -401,7 +440,7 @@ # targets go at the end, if the makefile supports them addTargets = self.raptor.targets[:] - ignoreTargets = self.makefileset.ignoreTargets(makefile) + ignoreTargets = makefileset.ignoreTargets(makefile) if addTargets and ignoreTargets: for target in self.raptor.targets: if re.match(ignoreTargets, target): @@ -410,6 +449,9 @@ if addTargets: command += " " + " ".join(addTargets) + # Substitute the makefile name for any occurrence of #MAKEFILE# + command = command.replace("#MAKEFILE#", str(makefile)) + self.raptor.Info("Executing '%s'", command) # execute the build. @@ -417,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" @@ -444,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() @@ -452,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 @@ -496,7 +548,7 @@ looking = (os.system(command) != 0) tries += 1 if looking: - self.raptor.Error("Failed to initilaise the talon shell for this build") + self.raptor.Error("Failed to initialise the talon shell for this build") self.talonctl = "" return False