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