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