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