sbsv2/raptor/python/raptor_make.py
author timothy.murphy@nokia.com
Thu, 25 Mar 2010 13:43:28 +0000
branchfix
changeset 408 a819f9223567
parent 360 77642c41e033
child 411 80ad0c7f75fe
permissions -rw-r--r--
fix: stop using "magic" numbers in string operations for the copyannofile2log feature fix: When using the copylogfromannofile workaround, extract the build ID and build duration and add to the log as these are useful for analysis. The log should now be identical to the stdout file. fix: Remove extra blank lines from output in copylogfromannofile mode.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     1
#
196
c0d1d904d868 review comments, dates, test ids
timothy.murphy@nokia.com
parents: 192
diff changeset
     2
# Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies).
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     3
# All rights reserved.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     4
# This component and the accompanying materials are made available
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     6
# which accompanies this distribution, and is available
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     8
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
     9
# Initial Contributors:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    10
# Nokia Corporation - initial contribution.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    11
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    12
# Contributors:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    13
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    14
# Description: 
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    15
# raptor_make module
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    16
# This module contains the classes that write and call Makefile wrappers.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    17
#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    18
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    19
import hashlib
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    20
import os
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    21
import random
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    22
import raptor
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
    23
import raptor_timing
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    24
import raptor_utilities
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    25
import raptor_version
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
    26
import raptor_data
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    27
import re
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    28
import subprocess
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    29
import time
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    30
from raptor_makefile import *
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
    31
import traceback
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
    32
import sys
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
    33
from xml.sax.saxutils import escape
360
77642c41e033 fix: emake log output corruption fix by using output from the annotation file. Updates.
timothy.murphy@nokia.com
parents: 357
diff changeset
    34
from xml.sax.saxutils import unescape
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
    35
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
    36
191
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
    37
class BadMakeEngineException(Exception):
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
    38
	pass
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
    39
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    40
def string_following(prefix, str):
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    41
	"""If str starts with prefix then return the rest of str, otherwise None"""
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    42
	if str.startswith(prefix):
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    43
		return str[len(prefix):]
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    44
	else:
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    45
		return None
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    46
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    47
def XMLEscapeLog(stream):
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    48
	""" A generator that reads a raptor log from a stream and performs an XML escape
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    49
	    on all text between tags, which is usually make output that could contain
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    50
	    illegal characters that upset XML-based log parsers.
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    51
	    This function yields "xml-safe" output line by line.
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    52
	"""
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    53
	inRecipe = False
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    54
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    55
	for line in stream:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    56
		if line.startswith("<recipe"):
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    57
			inRecipe = True
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    58
		elif line.startswith("</recipe"):
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    59
			inRecipe = False
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    60
			
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    61
		# unless we are inside a "recipe", any line not starting
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    62
		# with "<" is free text that must be escaped.
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    63
		if inRecipe or line.startswith("<"):
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    64
			yield line
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    65
		else:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    66
			yield escape(line)
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    67
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    68
def AnnoFileParseOutput(annofile):
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    69
	""" A generator that extracts log output from an emake annotation file, 
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    70
	    perform an XML-unescape on it and "yields" it line by line.  """
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    71
	af = open(annofile, "r")
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    72
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    73
	inOutput = False
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    74
	inParseJob = False
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    75
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    76
	buildid = ""
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    77
	for line in af:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    78
		line = line.rstrip("\n\r")
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    79
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    80
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    81
		if not inOutput:
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    82
			o = string_following("<output>", line)
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    83
			if not o:
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    84
				o = string_following('<output src="prog">', line)
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    85
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    86
			if o:
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
    87
				inOutput = True	
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    88
				yield unescape(o)+'\n'
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    89
				continue
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    90
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    91
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    92
			o = string_following('<build id="',line)
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    93
			if o:
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    94
				buildid = o[:o.find('"')]
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    95
				yield "Starting build: "+buildid+"\n"
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    96
				continue 
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    97
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    98
			o = string_following('<metric name="duration">', line)
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
    99
			if o:
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   100
				secs = int(o[:o.find('<')])
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   101
				if secs != 0:
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   102
					duration = "%d:%d" % (secs/60, secs % 60)
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   103
				else:
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   104
					duration = "0:0"
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   105
				continue 
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   106
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   107
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   108
			o = string_following('<metric name="clusterAvailability">', line)
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   109
			if o:
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   110
				availability = o[:o.find('<')]
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   111
				continue 
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   112
				
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   113
		else:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   114
			end_output = line.find("</output>")
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   115
		
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   116
			if end_output != -1:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   117
				line = line[:end_output]
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   118
				inOutput = False
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   119
			
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   120
			if line != "":	
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   121
				yield unescape(line)+'\n'
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   122
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   123
	yield "Finished build: %s   Duration: %s (m:s)   Cluster availability: %s%%\n" %(buildid,duration,availability)
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   124
	af.close()
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   125
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   126
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   127
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   128
# raptor_make module classes
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   129
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   130
class MakeEngine(object):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   131
197
dc0508fdfc44 Retain MakeEngine class API. Why not?
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 196
diff changeset
   132
	def __init__(self, Raptor, engine="make_engine"):
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   133
		self.raptor = Raptor
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   134
		self.valid = True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   135
		self.descrambler = None
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   136
		self.descrambler_started = False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   137
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   138
		# look for an alias first as this gives end-users a chance to modify
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   139
		# the shipped variant rather than completely replacing it.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   140
		if engine in Raptor.cache.aliases:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   141
			avar = Raptor.cache.FindNamedAlias(engine)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   142
		elif engine in Raptor.cache.variants:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   143
			avar = Raptor.cache.FindNamedVariant(engine)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   144
		else:
191
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
   145
			raise BadMakeEngineException("'%s' does not appear to be a make engine - no settings found for it" % engine)
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
   146
192
76300483f6fd fix: get make engine name validation working with aliases.
timothy.murphy@nokia.com
parents: 191
diff changeset
   147
		if not avar.isDerivedFrom("make_engine", Raptor.cache):
191
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
   148
			raise BadMakeEngineException("'%s' is not a build engine (it's a variant but it does not extend 'make_engine')" % engine)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   149
					
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   150
		# find the variant and extract the values
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   151
		try:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   152
			units = avar.GenerateBuildUnits(Raptor.cache)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   153
			evaluator = Raptor.GetEvaluator( None, units[0] , gathertools=True)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   154
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   155
			# shell
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   156
			self.shellpath = evaluator.Get("DEFAULT_SHELL")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   157
			usetalon_s = evaluator.Get("USE_TALON") 
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   158
			self.usetalon = usetalon_s is not None and usetalon_s != ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   159
			self.talonshell = str(evaluator.Get("TALON_SHELL"))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   160
			self.talontimeout = str(evaluator.Get("TALON_TIMEOUT"))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   161
			self.talonretries = str(evaluator.Get("TALON_RETRIES"))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   162
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   163
			# commands
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   164
			self.initCommand = evaluator.Get("initialise")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   165
			self.buildCommand = evaluator.Get("build")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   166
			self.shutdownCommand = evaluator.Get("shutdown")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   167
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   168
			# options
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   169
			self.makefileOption = evaluator.Get("makefile")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   170
			self.keepGoingOption = evaluator.Get("keep_going")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   171
			self.jobsOption = evaluator.Get("jobs")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   172
			self.defaultMakeOptions = evaluator.Get("defaultoptions")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   173
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   174
			# Logging
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   175
			#  copylogfromannofile means, for emake, that we should ignore 
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   176
			# emake's console output and instead extract output from its annotation
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   177
			# file.  This is a workaround for a problem where some emake
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   178
			# console output is lost.  The annotation file has a copy of this
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   179
			# output in the "parse" job and it turns out to be uncorrupted.
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   180
			self.copyLogFromAnnoFile = (evaluator.Get("copylogfromannofile") == "true")
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   181
			self.annoFileName = None
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   182
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   183
			if self.copyLogFromAnnoFile:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   184
				for o in self.raptor.makeOptions:
408
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   185
					self.annoFileName = string_following("--emake-annofile=", o)
a819f9223567 fix: stop using "magic" numbers in string operations for the copyannofile2log feature
timothy.murphy@nokia.com
parents: 360
diff changeset
   186
					if self.annoFileName:
360
77642c41e033 fix: emake log output corruption fix by using output from the annotation file. Updates.
timothy.murphy@nokia.com
parents: 357
diff changeset
   187
						self.raptor.Info("annofile: " + o)
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   188
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   189
				if not self.annoFileName:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   190
					self.raptor.Info("Cannot copy log from annotation file as no annotation filename was specified via the option --mo=--emake-annofile=<filename>")
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   191
					self.copyLogFromAnnoFile = False
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   192
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   193
			# buffering
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   194
			self.scrambled = (evaluator.Get("scrambled") == "true")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   195
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   196
			# check tool versions
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   197
			Raptor.CheckToolset(evaluator, avar.name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   198
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   199
			# default targets (can vary per-invocation)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   200
			self.defaultTargets = Raptor.defaultTargets
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   201
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   202
			# work out how to split up makefiles
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   203
			try:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   204
				selectorNames = [ x.strip() for x in evaluator.Get("selectors").split(',') if x.strip() != "" ]
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   205
				self.selectors = []
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   206
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   207
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   208
				if len(selectorNames) > 0:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   209
					for name in selectorNames:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   210
						pattern = evaluator.Get(name.strip() + ".selector.iface")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   211
						target = evaluator.Get(name.strip() + ".selector.target")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   212
						ignoretargets = evaluator.Get(name.strip() + ".selector.ignoretargets")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   213
						self.selectors.append(MakefileSelector(name,pattern,target,ignoretargets))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   214
			except KeyError:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   215
				Raptor.Error("%s.selector.iface, %s.selector.target not found in make engine configuration", name, name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   216
				self.selectors = []
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   217
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   218
		except KeyError:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   219
			self.valid = False
191
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
   220
			raise BadMakeEngineException("Bad '%s' configuration found." % engine)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   221
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   222
		# there must at least be a build command...
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   223
		if not self.buildCommand:
191
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
   224
			self.valid = False
3bfc260b6d61 fix: better error messages when an incorrect make engine is specified. Requires that all make engine variants should extend "make_engine".
timothy.murphy@nokia.com
parents: 176
diff changeset
   225
			raise BadMakeEngineException("No build command for '%s'"% engine)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   226
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   227
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   228
		if self.usetalon:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   229
			talon_settings="""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   230
TALON_SHELL:=%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   231
TALON_TIMEOUT:=%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   232
TALON_RECIPEATTRIBUTES:=\
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   233
 name='$$RECIPE'\
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   234
 target='$$TARGET'\
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   235
 host='$$HOSTNAME'\
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   236
 layer='$$COMPONENT_LAYER'\
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   237
 component='$$COMPONENT_NAME'\
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   238
 bldinf='$$COMPONENT_META' mmp='$$PROJECT_META'\
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   239
 config='$$SBS_CONFIGURATION' platform='$$PLATFORM'\
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   240
 phase='$$MAKEFILE_GROUP' source='$$SOURCE'
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   241
export TALON_RECIPEATTRIBUTES TALON_SHELL TALON_TIMEOUT
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   242
USE_TALON:=%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   243
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   244
""" % (self.talonshell, self.talontimeout, "1")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   245
		else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   246
			talon_settings="""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   247
USE_TALON:=
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   248
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   249
"""
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   250
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   251
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   252
		timing_start = "$(info " + \
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   253
				raptor_timing.Timing.custom_string(tag = "start",
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   254
				object_type = "makefile", task = "parse",
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   255
				key = "$(THIS_FILENAME)",
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   256
				time="$(shell date +%s.%N)").rstrip("\n") + ")"
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   257
				
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   258
		timing_end = "$(info " + \
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   259
				raptor_timing.Timing.custom_string(tag = "end",
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   260
				object_type = "makefile", task = "parse",
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   261
				key = "$(THIS_FILENAME)",
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   262
				time="$(shell date +%s.%N)").rstrip("\n") + ")"
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   263
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   264
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   265
		self.makefile_prologue = """
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   266
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   267
# generated by %s %s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   268
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   269
HOSTPLATFORM:=%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   270
HOSTPLATFORM_DIR:=%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   271
OSTYPE:=%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   272
FLMHOME:=%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   273
SHELL:=%s
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   274
THIS_FILENAME:=$(firstword $(MAKEFILE_LIST))
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   275
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   276
%s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   277
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   278
include %s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   279
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   280
""" 		% (  raptor.name, raptor_version.fullversion(),
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   281
			 " ".join(raptor.hostplatform),
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   282
			 raptor.hostplatform_dir,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   283
			 self.raptor.filesystem,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   284
			 str(self.raptor.systemFLM),
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   285
			 self.shellpath,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   286
			 talon_settings,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   287
			 self.raptor.systemFLM.Append('globals.mk') )
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   288
224
c037b5dccbab Ensure that a .DEFAULT target isn't used when --no-depend-include is in play.
Jon Chatten
parents: 220
diff changeset
   289
		# Unless dependency processing has been eschewed via the CLI, use a .DEFAULT target to
219
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   290
		# trap missing dependencies (ignoring user config files that we know are usually absent)
225
d401dbd3a410 Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents: 224
diff changeset
   291
		if not (self.raptor.noDependGenerate or self.raptor.noDependInclude):
219
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   292
			self.makefile_prologue += """
225
d401dbd3a410 Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents: 224
diff changeset
   293
219
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   294
$(FLMHOME)/user/final.mk:
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   295
$(FLMHOME)/user/default.flm:
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   296
$(FLMHOME)/user/globals.mk:
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   297
225
d401dbd3a410 Ensure that parallel parsing sbs calls pass on --no-depend-generate and --no-depend-include (as these influence makefile generation).
Jon Chatten
parents: 224
diff changeset
   298
.DEFAULT::
219
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   299
	@echo "<warning>Missing dependency detected: $@</warning>"
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   300
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   301
"""
c3543adfd26e Add --no-depend-generate to the front-end CLI.
Jon Chatten
parents: 134
diff changeset
   302
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   303
		# Only output timings if requested on CLI
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   304
		if self.raptor.timing:
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   305
			self.makefile_prologue += "\n# Print Start-time of Makefile parsing\n" \
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   306
					+ timing_start + "\n\n"
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   307
	
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   308
	
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   309
			self.makefile_epilogue = "\n\n# Print End-time of Makefile parsing\n" \
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   310
				+ timing_end + "\n"
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   311
		else:
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   312
			self.makefile_epilogue = ""
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   313
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   314
		self.makefile_epilogue += """
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   315
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   316
include %s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   317
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   318
""" 			% (self.raptor.systemFLM.Append('final.mk') )
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   319
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   320
	def Write(self, toplevel, specs, configs):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   321
		"""Generate a set of makefiles, or one big Makefile."""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   322
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   323
		if not self.valid:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   324
			return None
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   325
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   326
		self.raptor.Debug("Writing Makefile '%s'" % (str(toplevel)))
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   327
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   328
		self.toplevel = toplevel
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   329
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   330
		# create the top-level makefiles
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   331
		makefileset = None
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   332
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   333
		try:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   334
			makefileset = MakefileSet(directory = str(toplevel.Dir()),
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   335
										   selectors = self.selectors,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   336
										   filenamebase = str(toplevel.File()),
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   337
										   prologue = self.makefile_prologue,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   338
										   epilogue = self.makefile_epilogue,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   339
										   defaulttargets = self.defaultTargets)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   340
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   341
			# are we pruning duplicates?
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   342
			self.prune = self.raptor.pruneDuplicateMakefiles
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   343
			self.hashes = set()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   344
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   345
			# are we writing one Makefile or lots?
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   346
			self.many = not self.raptor.writeSingleMakefile
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   347
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   348
			# add a makefile for each spec under each config
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   349
			config_makefileset = makefileset
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   350
			for c in configs:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   351
				if self.many:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   352
					config_makefileset = makefileset.createChild(c.name)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   353
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   354
				# make sure the config_wide spec item is put out first so that it
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   355
				# can affect everything.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   356
				ordered_specs=[]
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   357
				config_wide_spec = None
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   358
				for s in specs:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   359
					if s.name == "config_wide":
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   360
						config_wide_spec = s
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   361
					else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   362
						ordered_specs.append(s)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   363
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   364
				if config_wide_spec is not None:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   365
					config_wide_spec.Configure(c, cache = self.raptor.cache)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   366
					self.WriteConfiguredSpec(config_makefileset, config_wide_spec, c, True)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   367
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   368
				for s in ordered_specs:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   369
					s.Configure(c, cache = self.raptor.cache)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   370
					self.WriteConfiguredSpec(config_makefileset, s, c, False)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   371
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   372
			makefileset.close()
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   373
		except Exception,e:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   374
			tb = traceback.format_exc()
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   375
			if not self.raptor.debugOutput:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   376
				tb=""
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   377
			self.raptor.Error("Failed to write makefile '%s': %s : %s" % (str(toplevel),str(e),tb))
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   378
			makefileset = None
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   379
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   380
		return makefileset
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   381
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   382
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   383
	def WriteConfiguredSpec(self, parentMakefileSet, spec, config, useAllInterfaces):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   384
		# ignore this spec if it is empty
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   385
		hasInterface = spec.HasInterface()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   386
		childSpecs = spec.GetChildSpecs()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   387
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   388
		if not hasInterface and not childSpecs:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   389
			return
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   390
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   391
		parameters = []
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   392
		dupe = True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   393
		iface = None
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   394
		guard = None
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   395
		if hasInterface:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   396
			# find the Interface (it may be a ref)
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   397
			try:
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   398
				iface = spec.GetInterface(self.raptor.cache)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   399
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   400
			except raptor_data.MissingInterfaceError, e:	
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   401
				self.raptor.Error("No interface for '%s'", spec.name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   402
				return
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   403
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   404
			if iface.abstract:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   405
				self.raptor.Error("Abstract interface '%s' for '%s'",
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   406
								  iface.name, spec.name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   407
				return
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   408
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   409
			# we need to guard the FLM call with a hash based on all the
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   410
			# parameter values so that duplicate calls cannot be made.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   411
			# So we need to find all the values before we can write
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   412
			# anything out.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   413
			md5hash = hashlib.md5()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   414
			md5hash.update(iface.name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   415
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   416
			# we need an Evaluator to get parameter values for this
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   417
			# Specification in the context of this Configuration
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   418
			evaluator = self.raptor.GetEvaluator(spec, config)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   419
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   420
			def addparam(k, value, default):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   421
				if value == None:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   422
					if p.default != None:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   423
						value = p.default
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   424
					else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   425
						self.raptor.Error("%s undefined for '%s'",
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   426
										  k, spec.name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   427
						value = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   428
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   429
				parameters.append((k, value))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   430
				md5hash.update(value)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   431
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   432
			# parameters required by the interface
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   433
			for p in iface.GetParams(self.raptor.cache):
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   434
				val = evaluator.Resolve(p.name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   435
				addparam(p.name,val,p.default)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   436
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   437
			# Use Patterns to fetch a group of parameters
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   438
			for g in iface.GetParamGroups(self.raptor.cache):
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   439
				for k,v in evaluator.ResolveMatching(g.patternre):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   440
					addparam(k,v,g.default)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   441
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   442
			hash = md5hash.hexdigest()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   443
			dupe = hash in self.hashes
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   444
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   445
			self.hashes.add(hash)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   446
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   447
		# we only create a Makefile if we have a new FLM call to contribute,
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   448
		# OR we are not pruning duplicates (guarding instead)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   449
		# OR we have some child specs that need something to include them.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   450
		if dupe and self.prune and not childSpecs:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   451
			return
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   452
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   453
		makefileset = parentMakefileSet
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   454
		# Create a new layer of makefiles?
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   455
		if self.many:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   456
			makefileset = makefileset.createChild(spec.name)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   457
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   458
		if not (self.prune and dupe):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   459
			if self.prune:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   460
				guard = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   461
			else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   462
				guard = "guard_" + hash
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   463
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   464
		# generate the call to the FLM
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   465
		if iface is not None:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   466
			makefileset.addCall(spec.name, config.name, iface.name, useAllInterfaces, iface.GetFLMIncludePath(self.raptor.cache), parameters, guard)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   467
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   468
		# recursive includes
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   469
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   470
		for child in childSpecs:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   471
			self.WriteConfiguredSpec(makefileset, child, config, useAllInterfaces)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   472
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   473
		if self.many:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   474
			makefileset.close() # close child set of makefiles as we'll never see them again.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   475
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   476
	def Make(self, makefileset):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   477
		"run the make command"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   478
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   479
		if not self.valid:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   480
			return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   481
	
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   482
		if self.usetalon:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   483
			# Always use Talon since it does the XML not
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   484
			# just descrambling
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   485
			if not self.StartTalon() and not self.raptor.keepGoing:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   486
				self.Tidy()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   487
				return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   488
		else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   489
			# use the descrambler if we are doing a parallel build on
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   490
			# a make engine which does not buffer each agent's output
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   491
			if self.raptor.jobs > 1 and self.scrambled:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   492
				self.StartDescrambler()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   493
				if  not self.descrambler_started and not self.raptor.keepGoing:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   494
					self.Tidy()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   495
					return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   496
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   497
		# run any initialisation script
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   498
		if self.initCommand:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   499
			self.raptor.Info("Running %s", self.initCommand)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   500
			if os.system(self.initCommand) != 0:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   501
				self.raptor.Error("Failed in %s", self.initCommand)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   502
				self.Tidy()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   503
				return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   504
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   505
		# Save file names to a list, to allow the order to be reversed
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   506
		fileName_list = list(makefileset.makefileNames())
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   507
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   508
		# Iterate through args passed to raptor, searching for CLEAN or REALLYCLEAN
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   509
		clean_flag = False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   510
		for arg in self.raptor.args:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   511
			clean_flag = ("CLEAN" in self.raptor.args) or \
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   512
			            ("REALLYCLEAN" in self.raptor.args)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   513
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   514
		# Files should be deleted in the opposite order to the order
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   515
		# they were built. So reverse file order if cleaning
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   516
		if clean_flag:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   517
			fileName_list.reverse()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   518
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   519
		# Report number of makefiles to be built
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   520
		self.raptor.InfoDiscovery(object_type = "makefile", count = len(fileName_list))
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   521
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   522
		# Process each file in turn
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   523
		for makefile in fileName_list:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   524
			if not os.path.exists(makefile):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   525
				self.raptor.Info("Skipping makefile %s", makefile)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   526
				continue
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   527
			self.raptor.Info("Making %s", makefile)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   528
			# assemble the build command line
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   529
			command = self.buildCommand
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   530
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   531
			if self.makefileOption:
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
   532
				command += " " + self.makefileOption + " " + ' "' + str(makefile) + '" '
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   533
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   534
			if self.raptor.keepGoing and self.keepGoingOption:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   535
				command += " " + self.keepGoingOption
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   536
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   537
			if self.raptor.jobs > 1 and self.jobsOption:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   538
				command += " " + self.jobsOption +" "+ str(self.raptor.jobs)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   539
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   540
			# Set default options first so that they can be overridden by
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   541
			# ones set by the --mo option on the raptor commandline:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   542
			command += " " + self.defaultMakeOptions
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   543
			# Can supply options on the commandline to override default settings.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   544
			if len(self.raptor.makeOptions) > 0:
122
816955f04aaa Protect some parameters from bash, e.g. ";" and "\"
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 121
diff changeset
   545
				for o in self.raptor.makeOptions:
134
2648751b64b4 Use '' to protect backslashes in arguments rather than escaping. For parallel parsing.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 130
diff changeset
   546
					if o.find(";") != -1 or  o.find("\\") != -1:
122
816955f04aaa Protect some parameters from bash, e.g. ";" and "\"
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 121
diff changeset
   547
						command += "  " + "'" + o + "'"
816955f04aaa Protect some parameters from bash, e.g. ";" and "\"
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 121
diff changeset
   548
					else:
816955f04aaa Protect some parameters from bash, e.g. ";" and "\"
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 121
diff changeset
   549
						command += "  " + o
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   550
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   551
			# Switch off dependency file including?
220
f7d68ecb923e Add support for NO_DEPEND_GENERATE to makefile calls and respond accordingly in FLMs.
Jon Chatten
parents: 219
diff changeset
   552
			if self.raptor.noDependInclude or self.raptor.noDependGenerate:
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   553
				command += " NO_DEPEND_INCLUDE=1"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   554
			
220
f7d68ecb923e Add support for NO_DEPEND_GENERATE to makefile calls and respond accordingly in FLMs.
Jon Chatten
parents: 219
diff changeset
   555
			# Switch off dependency file generation (and, implicitly, inclusion)?
f7d68ecb923e Add support for NO_DEPEND_GENERATE to makefile calls and respond accordingly in FLMs.
Jon Chatten
parents: 219
diff changeset
   556
			if self.raptor.noDependGenerate:
f7d68ecb923e Add support for NO_DEPEND_GENERATE to makefile calls and respond accordingly in FLMs.
Jon Chatten
parents: 219
diff changeset
   557
				command += " NO_DEPEND_GENERATE=1"
f7d68ecb923e Add support for NO_DEPEND_GENERATE to makefile calls and respond accordingly in FLMs.
Jon Chatten
parents: 219
diff changeset
   558
			
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   559
			if self.usetalon:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   560
				# use the descrambler if we set it up
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   561
				command += ' TALON_DESCRAMBLE=' 
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   562
				if self.scrambled:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   563
					command += '1 '
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   564
				else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   565
					command += '0 '
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   566
			else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   567
				if self.descrambler_started:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   568
					command += ' DESCRAMBLE="' + self.descrambler + '"'
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   569
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   570
			# use the retry mechanism if requested
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   571
			if self.raptor.tries > 1:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   572
				command += ' RECIPETRIES=' + str(self.raptor.tries)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   573
				command += ' TALON_RETRIES=' + str(self.raptor.tries - 1)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   574
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   575
			# targets go at the end, if the makefile supports them
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   576
			addTargets = self.raptor.targets[:]
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   577
			ignoreTargets = makefileset.ignoreTargets(makefile)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   578
			if addTargets and ignoreTargets:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   579
				for target in self.raptor.targets:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   580
					if re.match(ignoreTargets, target):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   581
						addTargets.remove(target)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   582
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   583
			if addTargets:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   584
				command += " " + " ".join(addTargets)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   585
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
   586
			# Send stderr to a file so that it can't mess up the log (e.g.
130
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   587
			# clock skew messages from some build engines scatter their
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   588
			# output across our xml.
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
   589
			stderrfilename = makefile+'.stderr'
355
24d0baf736db test stdout to a file (debug XML problem)
timothy.murphy@nokia.com
parents: 226
diff changeset
   590
			stdoutfilename = makefile+'.stdout'
122
816955f04aaa Protect some parameters from bash, e.g. ";" and "\"
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 121
diff changeset
   591
			command += " 2>'%s' " % stderrfilename
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   592
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   593
			# Keep a copy of the stdout too in the case of using the 
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   594
			# annofile - so that we can trap the problem that
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   595
			# makes the copy-log-from-annofile workaround necessary
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   596
			# and perhaps determine when we can remove it.
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   597
			if self.copyLogFromAnnoFile:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   598
				command += " >'%s' " % stdoutfilename
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
   599
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   600
			# Substitute the makefile name for any occurrence of #MAKEFILE#
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   601
			command = command.replace("#MAKEFILE#", str(makefile))
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   602
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   603
			self.raptor.Info("Executing '%s'", command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   604
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   605
			# execute the build.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   606
			# the actual call differs between Windows and Unix.
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   607
			# bufsize=1 means "line buffered"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   608
			#
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   609
			try:
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   610
				# Time the build
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   611
				self.raptor.InfoStartTime(object_type = "makefile",
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   612
						task = "build", key = str(makefile))
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   613
				
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   614
				makeenv=os.environ.copy()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   615
				if self.usetalon:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   616
					makeenv['TALON_RECIPEATTRIBUTES']="none"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   617
					makeenv['TALON_SHELL']=self.talonshell
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   618
					makeenv['TALON_BUILDID']=str(self.buildID)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   619
					makeenv['TALON_TIMEOUT']=str(self.talontimeout)
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
   620
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   621
				if self.raptor.filesystem == "unix":
118
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   622
					p = subprocess.Popen([command], bufsize=65535,
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   623
						stdout=subprocess.PIPE,
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   624
						stderr=subprocess.STDOUT,
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   625
						close_fds=True, env=makeenv, shell=True)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   626
				else:
118
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   627
					p = subprocess.Popen(args = 
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
   628
						[raptor_data.ToolSet.shell, '-c', command],
118
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   629
						bufsize=65535,
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   630
						stdout=subprocess.PIPE,
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   631
						stderr=subprocess.STDOUT,
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   632
						shell = False,
375b7128e900 Put stderr into separate log file
timothy.murphy@nokia.com
parents: 29
diff changeset
   633
						universal_newlines=True, env=makeenv)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   634
				stream = p.stdout
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   635
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   636
				inRecipe = False
121
5e5ae3e212b3 Stderr to a file - avoid xml problems in error messages.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 118
diff changeset
   637
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   638
				if not self.copyLogFromAnnoFile:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   639
					for l in XMLEscapeLog(stream):
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   640
						self.raptor.out.write(l)
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   641
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   642
					returncode = p.wait()
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   643
				else:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   644
					returncode = p.wait()
355
24d0baf736db test stdout to a file (debug XML problem)
timothy.murphy@nokia.com
parents: 226
diff changeset
   645
360
77642c41e033 fix: emake log output corruption fix by using output from the annotation file. Updates.
timothy.murphy@nokia.com
parents: 357
diff changeset
   646
					annofilename = self.annoFileName.replace("#MAKEFILE#", makefile)
77642c41e033 fix: emake log output corruption fix by using output from the annotation file. Updates.
timothy.murphy@nokia.com
parents: 357
diff changeset
   647
					self.raptor.Info("copylogfromannofile: Copying log from annotation file %s to work around a potential problem with the console output", annofilename)
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   648
					try:
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   649
						for l in XMLEscapeLog(AnnoFileParseOutput(annofilename)):
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   650
							self.raptor.out.write(l)
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   651
					except Exception,e:
360
77642c41e033 fix: emake log output corruption fix by using output from the annotation file. Updates.
timothy.murphy@nokia.com
parents: 357
diff changeset
   652
						self.raptor.Error("Couldn't complete stdout output from annofile %s for %s - '%s'", annofilename, command, str(e))
355
24d0baf736db test stdout to a file (debug XML problem)
timothy.murphy@nokia.com
parents: 226
diff changeset
   653
24d0baf736db test stdout to a file (debug XML problem)
timothy.murphy@nokia.com
parents: 226
diff changeset
   654
130
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   655
				# Take all the stderr output that went into the .stderr file
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   656
				# and put it back into the log, but safely so it can't mess up
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   657
				# xml parsers.
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   658
				try:
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   659
					e = open(stderrfilename,"r")
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   660
					for line in e:
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   661
						self.raptor.out.write(escape(line))
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   662
					e.close()
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   663
				except Exception,e:
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   664
					self.raptor.Error("Couldn't complete stderr output for %s - '%s'", command, str(e))
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   665
				# Report end-time of the build
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   666
				self.raptor.InfoEndTime(object_type = "makefile",
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   667
						task = "build", key = str(makefile))
130
4f2ae0d78608 fix: add .stderr dumfile to log *after* make engine has exited.
raptorbot <raptorbot@systemstesthead.symbian.intra>
parents: 122
diff changeset
   668
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   669
				if returncode != 0  and not self.raptor.keepGoing:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   670
					self.Tidy()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   671
					return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   672
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   673
			except Exception,e:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   674
				self.raptor.Error("Exception '%s' during '%s'", str(e), command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   675
				self.Tidy()
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   676
				# Still report end-time of the build
360
77642c41e033 fix: emake log output corruption fix by using output from the annotation file. Updates.
timothy.murphy@nokia.com
parents: 357
diff changeset
   677
				self.raptor.InfoEndTime(object_type = "Building", task = "Makefile",
29
ee00c00df073 Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents: 5
diff changeset
   678
						key = str(makefile))
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   679
				return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   680
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   681
		# run any shutdown script
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   682
		if self.shutdownCommand != None and self.shutdownCommand != "":
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   683
			self.raptor.Info("Running %s", self.shutdownCommand)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   684
			if os.system(self.shutdownCommand) != 0:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   685
				self.raptor.Error("Failed in %s", self.shutdownCommand)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   686
				self.Tidy()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   687
				return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   688
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   689
		self.Tidy()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   690
		return True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   691
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   692
	def Tidy(self):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   693
		if self.usetalon:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   694
			self.StopTalon() 
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   695
		else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   696
			"clean up after the make command"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   697
			self.StopDescrambler()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   698
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   699
	def StartTalon(self):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   700
		# the talon command
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   701
		beginning = raptor.hostplatform_dir + "/bin"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   702
		if "win" in raptor.hostplatform:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   703
			end = ".exe"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   704
		else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   705
			end = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   706
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   707
		self.talonctl = str(self.raptor.home.Append(beginning, "talonctl"+end))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   708
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   709
		# generate a unique build number
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   710
		random.seed()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   711
		looking = True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   712
		tries = 0
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   713
		while looking and tries < 100:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   714
			self.buildID = raptor.name + str(random.getrandbits(32))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   715
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   716
			command = self.talonctl + " start"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   717
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   718
			os.environ["TALON_BUILDID"] = self.buildID
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   719
			self.raptor.Info("Running %s", command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   720
			looking = (os.system(command) != 0)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   721
			tries += 1
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   722
		if looking:
5
593a8820b912 Team Wip branch
tnmurphy@4GBL06592.nokia.com
parents: 3
diff changeset
   723
			self.raptor.Error("Failed to initialise the talon shell for this build")
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   724
			self.talonctl = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   725
			return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   726
		
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   727
		return True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   728
	
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   729
	def StopTalon(self):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   730
		if self.talonctl:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   731
			command = self.talonctl + " stop"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   732
			self.talonctl = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   733
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   734
			self.raptor.Info("Running %s", command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   735
			if os.system(command) != 0:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   736
				self.raptor.Error("Failed in %s", command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   737
				return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   738
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   739
		return True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   740
	
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   741
	def StartDescrambler(self):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   742
		# the descrambler command
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   743
		beginning = raptor.hostplatform_dir + "/bin"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   744
		if "win" in raptor.hostplatform:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   745
			end = ".exe"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   746
		else:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   747
			end = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   748
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   749
		self.descrambler = str(self.raptor.home.Append(beginning, "sbs_descramble"+end))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   750
			
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   751
		# generate a unique build number
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   752
		random.seed()
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   753
		looking = True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   754
		tries = 0
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   755
		while looking and tries < 100:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   756
			buildID = raptor.name + str(random.getrandbits(32))
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   757
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   758
			command = self.descrambler + " " + buildID + " start"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   759
			self.raptor.Info("Running %s", command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   760
			looking = (os.system(command) != 0)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   761
			tries += 1
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   762
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   763
		if looking:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   764
			self.raptor.Error("Failed to start the log descrambler")
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   765
			self.descrambler_started = True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   766
			return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   767
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   768
		self.descrambler_started = True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   769
		self.descrambler +=	" " + buildID
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   770
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   771
		return  True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   772
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   773
	def StopDescrambler(self):
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   774
		if self.descrambler_started:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   775
			command = self.descrambler + " stop"
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   776
			self.descrambler = ""
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   777
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   778
			self.raptor.Info("Running %s", command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   779
			if os.system(command) != 0:
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   780
				self.raptor.Error("Failed in %s", command)
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   781
				return False
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   782
		return True
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   783
357
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   784
b4baa7ca35a7 fix: emake log output corruption fix by using output from the annotation file.
timothy.murphy@nokia.com
parents: 355
diff changeset
   785
3
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   786
# raptor_make module functions
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   787
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   788
e1eecf4d390d Team sf branch.
tnmurphy@4GBL06592.nokia.com
parents: 0
diff changeset
   789
# end of the raptor_make module