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