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