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