author | timothy.murphy@nokia.com |
Sat, 01 May 2010 00:09:59 +0100 | |
branch | fix |
changeset 516 | cd8318d5fb3a |
parent 460 | 1f5ab557c1d0 |
child 558 | e902bcdd2eef |
permissions | -rw-r--r-- |
3 | 1 |
# |
246
b9b473d0d6df
Release note: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
245
diff
changeset
|
2 |
# Copyright (c) 2007-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 |
# This module includes classes that process bld.inf and .mmp files to |
|
16 |
# generate Raptor build specifications |
|
17 |
# |
|
18 |
||
19 |
import copy |
|
20 |
import re |
|
21 |
import os.path |
|
22 |
import shutil |
|
23 |
import stat |
|
24 |
import hashlib |
|
25 |
import base64 |
|
26 |
||
27 |
import raptor |
|
28 |
import raptor_data |
|
29 |
import raptor_utilities |
|
30 |
import raptor_xml |
|
31 |
import generic_path |
|
32 |
import subprocess |
|
33 |
import zipfile |
|
212
18372202b584
escape filenames in <member> tags
Richard Taylor <richard.i.taylor@nokia.com>
parents:
160
diff
changeset
|
34 |
from xml.sax.saxutils import escape |
3 | 35 |
from mmpparser import * |
36 |
||
37 |
import time |
|
38 |
||
39 |
||
40 |
PiggyBackedBuildPlatforms = {'ARMV5':['GCCXML']} |
|
41 |
||
42 |
PlatformDefaultDefFileDir = {'WINSCW':'bwins', |
|
43 |
'ARMV5' :'eabi', |
|
44 |
'ARMV5SMP' :'eabi', |
|
45 |
'GCCXML':'eabi', |
|
46 |
'ARMV6':'eabi', |
|
47 |
'ARMV7' : 'eabi', |
|
48 |
'ARMV7SMP' : 'eabi'} |
|
49 |
||
50 |
def getVariantCfgDetail(aEPOCROOT, aVariantCfgFile): |
|
51 |
"""Obtain pertinent build related detail from the Symbian variant.cfg file. |
|
52 |
||
53 |
This variant.cfg file, usually located relative to $(EPOCROOT), contains: |
|
54 |
(1) The $(EPOCROOT) relative location of the primary .hrh file used to configure the specific OS variant build |
|
55 |
(2) A flag determining whether ARMV5 represents an ABIV1 or ABIV2 build (currently unused by Raptor).""" |
|
56 |
||
57 |
variantCfgDetails = {} |
|
58 |
variantCfgFile = None |
|
59 |
||
60 |
try: |
|
61 |
variantCfgFile = open(str(aVariantCfgFile)) |
|
62 |
except IOError, (number, message): |
|
63 |
raise MetaDataError("Could not read variant configuration file "+str(aVariantCfgFile)+" ("+message+")") |
|
64 |
||
65 |
for line in variantCfgFile.readlines(): |
|
66 |
if re.search('^(\s$|\s*#)', line): |
|
67 |
continue |
|
68 |
# Note that this detection of the .hrh file matches the command line build i.e. ".hrh" somewhere |
|
69 |
# in the specified line |
|
70 |
elif re.search('\.hrh', line, re.I): |
|
71 |
variantHrh = line.strip() |
|
72 |
if variantHrh.startswith('\\') or variantHrh.startswith('/'): |
|
73 |
variantHrh = variantHrh[1:] |
|
74 |
variantHrh = aEPOCROOT.Append(variantHrh) |
|
75 |
variantCfgDetails['VARIANT_HRH'] = variantHrh |
|
76 |
else: |
|
77 |
lineContent = line.split() |
|
78 |
||
79 |
if len(lineContent) == 1: |
|
80 |
variantCfgDetails[lineContent.pop(0)] = 1 |
|
81 |
else: |
|
82 |
variantCfgDetails[lineContent.pop(0)] = lineContent |
|
83 |
||
84 |
variantCfgFile.close() |
|
85 |
||
86 |
if not variantCfgDetails.has_key('VARIANT_HRH'): |
|
87 |
raise MetaDataError("No variant file specified in "+str(aVariantCfgFile)) |
|
88 |
if not variantHrh.isFile(): |
|
89 |
raise MetaDataError("Variant file "+str(variantHrh)+" does not exist") |
|
90 |
||
91 |
return variantCfgDetails |
|
92 |
||
93 |
def getOsVerFromKifXml(aPathToKifXml): |
|
94 |
"""Obtain the OS version from the kif.xml file located at $EPOCROOT/epoc32/data/kif.xml. |
|
95 |
||
96 |
If successful, the function returns a string such as "v95" to indicate 9.5; None is |
|
97 |
returned if for any reason the function cannot determine the OS version.""" |
|
98 |
||
99 |
releaseTagName = "ki:release" |
|
100 |
osVersion = None |
|
101 |
||
102 |
import xml.dom.minidom |
|
103 |
||
104 |
try: |
|
105 |
# Parsed document object |
|
106 |
kifDom = xml.dom.minidom.parse(str(aPathToKifXml)) |
|
107 |
||
108 |
# elements - the elements whose names are releaseTagName |
|
109 |
elements = kifDom.getElementsByTagName(releaseTagName) |
|
110 |
||
111 |
# There should be exactly one of the elements whose name is releaseTagName |
|
112 |
# If more than one, osVersion is left as None, since the version should be |
|
113 |
# unique to the kif.xml file |
|
114 |
if len(elements) == 1: |
|
115 |
osVersionTemp = elements[0].getAttribute("version") |
|
116 |
osVersion = "v" + osVersionTemp.replace(".", "") |
|
117 |
||
118 |
kifDom.unlink() # Clean up |
|
119 |
||
120 |
except: |
|
121 |
# There's no documentation on which exceptions are raised by these functions. |
|
122 |
# We catch everything and assume any exception means there was a failure to |
|
123 |
# determine OS version. None is returned, and the code will fall back |
|
124 |
# to looking at the buildinfo.txt file. |
|
125 |
pass |
|
126 |
||
127 |
return osVersion |
|
128 |
||
129 |
def getOsVerFromBuildInfoTxt(aPathToBuildInfoTxt): |
|
130 |
"""Obtain the OS version from the buildinfo.txt file located at $EPOCROOT/epoc32/data/buildinfo.txt. |
|
131 |
||
132 |
If successful, the function returns a string such as "v95" to indicate 9.5; None is |
|
133 |
returned if for any reason the function cannot determine the OS version. |
|
134 |
||
135 |
The file $EPOCROOT/epoc32/data/buildinfo.txt is presumed to exist. The client code should |
|
136 |
handle existance/non-existance.""" |
|
137 |
||
138 |
pathToBuildInfoTxt = str(aPathToBuildInfoTxt) # String form version of path to buildinfo.txt |
|
139 |
||
140 |
# Open the file for reading; throw an exception if it could not be read - note that |
|
141 |
# it should exist at this point. |
|
142 |
try: |
|
143 |
buildInfoTxt = open(pathToBuildInfoTxt) |
|
144 |
except IOError, (number, message): |
|
145 |
raise MetaDataError("Could not read buildinfo.txt file at" + pathToBuildInfoTxt + ": (" + message + ")") |
|
146 |
||
147 |
# Example buildinfo.txt contents: |
|
148 |
# |
|
149 |
# DeviceFamily 100 |
|
150 |
# DeviceFamilyRev 0x900 |
|
151 |
# ManufacturerSoftwareBuild M08765_Symbian_OS_v9.5 |
|
152 |
# |
|
153 |
# Regexp to match the line containing the OS version |
|
154 |
# Need to match things like M08765_Symbian_OS_v9.5 and M08765_Symbian_OS_vFuture |
|
155 |
# So for the version, match everything except whitespace after v. Whitespace |
|
156 |
# signifies the end of the regexp. |
|
157 |
osVersionMatcher = re.compile('.*_Symbian_OS_v([^\s]*)', re.I) |
|
158 |
osVersion = None |
|
159 |
||
160 |
# Search for a regexp match over all the times in the file |
|
161 |
# Note: if two or more lines match the search pattern then |
|
162 |
# the latest match will overwrite the osVersion string. |
|
163 |
for line in buildInfoTxt: |
|
164 |
matchResult = osVersionMatcher.match(line) |
|
165 |
if matchResult: |
|
166 |
result = matchResult.groups() |
|
167 |
osVersion = "v" + str(reduce(lambda x, y: x + y, result)) |
|
168 |
osVersion = osVersion.replace(".", "") |
|
169 |
||
170 |
buildInfoTxt.close() # Clean-up |
|
171 |
||
172 |
return osVersion |
|
173 |
||
174 |
def getBuildableBldInfBuildPlatforms(aBldInfBuildPlatforms, |
|
175 |
aDefaultOSBuildPlatforms, |
|
176 |
aBaseDefaultOSBuildPlatforms, |
|
177 |
aBaseUserDefaultOSBuildPlatforms): |
|
178 |
"""Obtain a set of build platform names supported by a bld.inf file |
|
179 |
||
180 |
Build platform deduction is based on both the contents of the PRJ_PLATFORMS section of |
|
181 |
a bld.inf file together with a hard-coded set of default build platforms supported by |
|
182 |
the build system itself.""" |
|
183 |
||
184 |
expandedBldInfBuildPlatforms = [] |
|
185 |
removePlatforms = set() |
|
186 |
||
187 |
for bldInfBuildPlatform in aBldInfBuildPlatforms: |
|
188 |
if bldInfBuildPlatform.upper() == "DEFAULT": |
|
189 |
expandedBldInfBuildPlatforms.extend(aDefaultOSBuildPlatforms.split()) |
|
190 |
elif bldInfBuildPlatform.upper() == "BASEDEFAULT": |
|
191 |
expandedBldInfBuildPlatforms.extend(aBaseDefaultOSBuildPlatforms.split()) |
|
192 |
elif bldInfBuildPlatform.upper() == "BASEUSERDEFAULT": |
|
193 |
expandedBldInfBuildPlatforms.extend(aBaseUserDefaultOSBuildPlatforms.split()) |
|
194 |
elif bldInfBuildPlatform.startswith("-"): |
|
195 |
removePlatforms.add(bldInfBuildPlatform.lstrip("-").upper()) |
|
196 |
else: |
|
197 |
expandedBldInfBuildPlatforms.append(bldInfBuildPlatform.upper()) |
|
198 |
||
199 |
if len(expandedBldInfBuildPlatforms) == 0: |
|
200 |
expandedBldInfBuildPlatforms.extend(aDefaultOSBuildPlatforms.split()) |
|
201 |
||
202 |
# make a set of platforms that can be built |
|
203 |
buildableBldInfBuildPlatforms = set(expandedBldInfBuildPlatforms) |
|
204 |
||
205 |
# Add platforms that are buildable by virtue of the presence of another |
|
206 |
for piggyBackedPlatform in PiggyBackedBuildPlatforms: |
|
207 |
if piggyBackedPlatform in buildableBldInfBuildPlatforms: |
|
208 |
buildableBldInfBuildPlatforms.update(PiggyBackedBuildPlatforms.get(piggyBackedPlatform)) |
|
209 |
||
210 |
# Remove platforms that were negated |
|
211 |
buildableBldInfBuildPlatforms -= removePlatforms |
|
212 |
||
213 |
return buildableBldInfBuildPlatforms |
|
214 |
||
215 |
||
216 |
def getPreProcessorCommentDetail (aPreProcessorComment): |
|
217 |
"""Takes a preprocessor comment and returns an array containing the filename and linenumber detail.""" |
|
218 |
||
219 |
commentDetail = [] |
|
220 |
commentMatch = re.search('# (?P<LINENUMBER>\d+) "(?P<FILENAME>.*)"', aPreProcessorComment) |
|
221 |
||
222 |
if commentMatch: |
|
223 |
filename = commentMatch.group('FILENAME') |
|
224 |
filename = os.path.abspath(filename) |
|
225 |
filename = re.sub(r'\\\\', r'\\', filename) |
|
226 |
filename = re.sub(r'//', r'/', filename) |
|
227 |
filename = generic_path.Path(filename) |
|
228 |
linenumber = int (commentMatch.group('LINENUMBER')) |
|
229 |
||
230 |
commentDetail.append(filename) |
|
231 |
commentDetail.append(linenumber) |
|
232 |
||
233 |
return commentDetail |
|
234 |
||
235 |
||
5 | 236 |
def getSpecName(aFileRoot, fullPath=False): |
237 |
"""Returns a build spec name: this is the file root (full path |
|
238 |
or simple file name) made safe for use as a file name.""" |
|
239 |
||
240 |
if fullPath: |
|
241 |
specName = str(aFileRoot).replace("/","_") |
|
242 |
specName = specName.replace(":","") |
|
243 |
else: |
|
244 |
specName = aFileRoot.File() |
|
245 |
||
246 |
return specName.lower() |
|
247 |
||
248 |
||
3 | 249 |
# Classes |
250 |
||
251 |
class MetaDataError(Exception): |
|
252 |
"""Fatal error wrapper, to be thrown directly back to whatever is calling.""" |
|
253 |
||
254 |
def __init__(self, aText): |
|
255 |
self.Text = aText |
|
256 |
def __str__(self): |
|
257 |
return repr(self.Text) |
|
258 |
||
259 |
||
260 |
class PreProcessedLine(str): |
|
261 |
"""Custom string class that accepts filename and line number information from |
|
262 |
a preprocessed context.""" |
|
263 |
||
264 |
def __new__(cls, value, *args, **keywargs): |
|
265 |
return str.__new__(cls, value) |
|
266 |
||
267 |
def __init__(self, value, aFilename, aLineNumber): |
|
268 |
self.filename = aFilename |
|
269 |
self.lineNumber = aLineNumber |
|
270 |
||
271 |
def getFilename (self): |
|
272 |
return self.filename |
|
273 |
||
274 |
def getLineNumber (self): |
|
275 |
return self.lineNumber |
|
276 |
||
277 |
class PreProcessor(raptor_utilities.ExternalTool): |
|
278 |
"""Preprocessor wrapper suitable for Symbian metadata file processing.""" |
|
279 |
||
280 |
def __init__(self, aPreProcessor, |
|
281 |
aStaticOptions, |
|
282 |
aIncludeOption, |
|
283 |
aMacroOption, |
|
284 |
aPreIncludeOption, |
|
285 |
aRaptor): |
|
286 |
raptor_utilities.ExternalTool.__init__(self, aPreProcessor) |
|
287 |
self.__StaticOptions = aStaticOptions |
|
288 |
self.__IncludeOption = aIncludeOption |
|
289 |
self.__MacroOption = aMacroOption |
|
290 |
self.__PreIncludeOption = aPreIncludeOption |
|
291 |
||
292 |
self.filename = "" |
|
293 |
self.__Macros = [] |
|
294 |
self.__IncludePaths = [] |
|
295 |
self.__PreIncludeFile = "" |
|
296 |
self.raptor = aRaptor |
|
297 |
||
298 |
def call(self, aArgs, sourcefilename): |
|
299 |
""" Override call so that we can do our own error handling.""" |
|
300 |
tool = self._ExternalTool__Tool |
|
32
fdfc59a2ae7e
fix for broken cpp location
Richard Taylor <richard.i.taylor@nokia.com>
parents:
29
diff
changeset
|
301 |
commandline = tool + " " + aArgs + " " + str(sourcefilename) |
3 | 302 |
try: |
303 |
# the actual call differs between Windows and Unix |
|
304 |
if raptor_utilities.getOSFileSystem() == "unix": |
|
305 |
p = subprocess.Popen(commandline, \ |
|
306 |
shell=True, bufsize=65535, \ |
|
307 |
stdin=subprocess.PIPE, \ |
|
308 |
stdout=subprocess.PIPE, \ |
|
309 |
stderr=subprocess.PIPE, \ |
|
310 |
close_fds=True) |
|
311 |
else: |
|
312 |
p = subprocess.Popen(commandline, \ |
|
313 |
bufsize=65535, \ |
|
314 |
stdin=subprocess.PIPE, \ |
|
315 |
stdout=subprocess.PIPE, \ |
|
316 |
stderr=subprocess.PIPE, \ |
|
317 |
universal_newlines=True) |
|
318 |
||
319 |
# run the command and wait for all the output |
|
320 |
(self._ExternalTool__Output, errors) = p.communicate() |
|
321 |
||
322 |
if self.raptor.debugOutput: |
|
323 |
self.raptor.Debug("Preprocessing Start %s", str(sourcefilename)) |
|
324 |
self.raptor.Debug("Output:\n%s", self._ExternalTool__Output) |
|
325 |
self.raptor.Debug("Errors:\n%s", errors) |
|
326 |
self.raptor.Debug("Preprocessing End %s", str(sourcefilename)) |
|
327 |
||
328 |
incRE = re.compile("In file included from") |
|
329 |
fromRE = re.compile(r"\s+from") |
|
330 |
warningRE = re.compile("warning:|pasting.+token|from.+:") |
|
331 |
remarkRE = re.compile("no newline at end of file|does not give a valid preprocessing token") |
|
332 |
||
333 |
actualErr = False |
|
334 |
if errors != "": |
|
335 |
for error in errors.splitlines(): |
|
336 |
if incRE.search(error) or fromRE.search(error): |
|
337 |
continue |
|
338 |
if not remarkRE.search(error): |
|
339 |
if warningRE.search(error): |
|
340 |
self.raptor.Warn("%s: %s", tool, error) |
|
341 |
else: |
|
342 |
self.raptor.Error("%s: %s", tool, error) |
|
343 |
actualErr = True |
|
344 |
if actualErr: |
|
345 |
raise MetaDataError("Errors in %s" % str(sourcefilename)) |
|
346 |
||
347 |
except Exception,e: |
|
32
fdfc59a2ae7e
fix for broken cpp location
Richard Taylor <richard.i.taylor@nokia.com>
parents:
29
diff
changeset
|
348 |
raise MetaDataError("Preprocessor exception: '%s' : in command : '%s'" % (str(e), commandline)) |
3 | 349 |
|
350 |
return 0 # all OK |
|
351 |
||
352 |
def setMacros(self, aMacros): |
|
353 |
self.__Macros = aMacros |
|
354 |
||
355 |
def addMacro(self, aMacro): |
|
356 |
self.__Macros.append(aMacro) |
|
357 |
||
358 |
def addMacros(self, aMacros): |
|
359 |
self.__Macros.extend(aMacros) |
|
360 |
||
361 |
def getMacros(self): |
|
362 |
return self.__Macros |
|
363 |
||
364 |
||
365 |
def addIncludePath(self, aIncludePath): |
|
366 |
p = str(aIncludePath) |
|
367 |
if p == "": |
|
368 |
self.raptor.Warn("attempt to set an empty preprocessor include path for %s" % str(self.filename)) |
|
369 |
else: |
|
370 |
self.__IncludePaths.append(p) |
|
371 |
||
372 |
def addIncludePaths(self, aIncludePaths): |
|
373 |
for path in aIncludePaths: |
|
374 |
self.addIncludePath(path) |
|
375 |
||
376 |
def setIncludePaths(self, aIncludePaths): |
|
377 |
self.__IncludePaths = [] |
|
378 |
self.addIncludePaths(aIncludePaths) |
|
379 |
||
380 |
def setPreIncludeFile(self, aPreIncludeFile): |
|
381 |
self.__PreIncludeFile = aPreIncludeFile |
|
382 |
||
383 |
def preprocess(self): |
|
384 |
preProcessorCall = self.__constructPreProcessorCall() |
|
385 |
returnValue = self.call(preProcessorCall, self.filename) |
|
386 |
||
387 |
return self.getOutput() |
|
388 |
||
389 |
def __constructPreProcessorCall(self): |
|
390 |
||
391 |
call = self.__StaticOptions |
|
392 |
||
393 |
if self.__PreIncludeFile: |
|
394 |
call += " " + self.__PreIncludeOption |
|
395 |
call += " " + str(self.__PreIncludeFile) |
|
396 |
||
397 |
for macro in self.__Macros: |
|
398 |
call += " " + self.__MacroOption + macro |
|
399 |
||
400 |
for includePath in self.__IncludePaths: |
|
401 |
call += " " + self.__IncludeOption |
|
402 |
call += " " + str(includePath) |
|
403 |
||
404 |
return call |
|
405 |
||
406 |
||
407 |
class MetaDataFile(object): |
|
408 |
"""A generic representation of a Symbian metadata file |
|
409 |
||
410 |
Symbian metadata files are subject to preprocessing, primarily with macros based |
|
411 |
on the selected build platform. This class provides a generic means of wrapping |
|
412 |
up the preprocessing of such files.""" |
|
413 |
||
5 | 414 |
def __init__(self, aFilename, gnucpp, depfiles, aRootLocation=None, log=None): |
3 | 415 |
""" |
416 |
@param aFilename An MMP, bld.inf or other preprocessable build spec file |
|
417 |
@param aDefaultPlatform Default preprocessed version of this file |
|
418 |
@param aCPP location of GNU CPP |
|
5 | 419 |
@param depfiles list to add dependency file tuples to |
420 |
@param aRootLocation where the file is |
|
3 | 421 |
@param log A class with Debug(<string>), Info(<string>) and Error(<string>) methods |
422 |
""" |
|
423 |
self.filename = aFilename |
|
424 |
self.__RootLocation = aRootLocation |
|
425 |
# Dictionary with key of build platform and a text string of processed output as values |
|
426 |
self.__PreProcessedContent = {} |
|
427 |
self.log = log |
|
5 | 428 |
self.depfiles = depfiles |
3 | 429 |
|
430 |
self.__gnucpp = gnucpp |
|
431 |
if gnucpp is None: |
|
432 |
raise ValueError('gnucpp must be set') |
|
433 |
||
434 |
def depspath(self, platform): |
|
435 |
""" Where does dependency information go relative to platform's SBS_BUILD_DIR? |
|
436 |
Subclasses should redefine this |
|
437 |
""" |
|
438 |
return str(platform['SBS_BUILD_DIR']) + "/" + str(self.__RootLocation) + "." + platform['key_md5'] + ".d" |
|
439 |
||
440 |
def getContent(self, aBuildPlatform): |
|
441 |
||
442 |
key = aBuildPlatform['key'] |
|
443 |
||
444 |
config_macros = [] |
|
445 |
||
446 |
adepfilename = self.depspath(aBuildPlatform) |
|
447 |
generateDepsOptions = "" |
|
448 |
if adepfilename: |
|
449 |
||
450 |
if raptor_utilities.getOSPlatform().startswith("win"): |
|
451 |
metatarget = "$(PARSETARGET)" |
|
452 |
else: |
|
453 |
metatarget = "'$(PARSETARGET)'" |
|
454 |
generateDepsOptions = "-MD -MF%s -MT%s" % (adepfilename, metatarget) |
|
5 | 455 |
self.depfiles.append((adepfilename, metatarget)) |
3 | 456 |
try: |
457 |
os.makedirs(os.path.dirname(adepfilename)) |
|
458 |
except Exception, e: |
|
459 |
self.log.Debug("Couldn't make bldinf outputpath for dependency generation") |
|
460 |
||
461 |
config_macros = (aBuildPlatform['PLATMACROS']).split() |
|
462 |
||
463 |
if not key in self.__PreProcessedContent: |
|
464 |
||
465 |
preProcessor = PreProcessor(self.__gnucpp, '-undef -nostdinc ' + generateDepsOptions + ' ', |
|
466 |
'-I', '-D', '-include', self.log) |
|
467 |
preProcessor.filename = self.filename |
|
468 |
||
469 |
# always have the current directory on the include path |
|
470 |
preProcessor.addIncludePath('.') |
|
471 |
||
472 |
# the SYSTEMINCLUDE directories defined in the build config |
|
473 |
# should be on the include path. This is added mainly to support |
|
474 |
# Feature Variation as SYSTEMINCLUDE is usually empty at this point. |
|
475 |
systemIncludes = aBuildPlatform['SYSTEMINCLUDE'] |
|
476 |
if systemIncludes: |
|
477 |
preProcessor.addIncludePaths(systemIncludes.split()) |
|
478 |
||
479 |
preInclude = aBuildPlatform['VARIANT_HRH'] |
|
480 |
||
481 |
# for non-Feature Variant builds, the directory containing the HRH should |
|
482 |
# be on the include path |
|
483 |
if not aBuildPlatform['ISFEATUREVARIANT']: |
|
484 |
preProcessor.addIncludePath(preInclude.Dir()) |
|
485 |
||
486 |
# and EPOCROOT/epoc32/include |
|
487 |
preProcessor.addIncludePath(aBuildPlatform['EPOCROOT'].Append('epoc32/include')) |
|
488 |
||
489 |
# and the directory containing the bld.inf file |
|
490 |
if self.__RootLocation is not None and str(self.__RootLocation) != "": |
|
491 |
preProcessor.addIncludePath(self.__RootLocation) |
|
492 |
||
493 |
# and the directory containing the file we are processing |
|
494 |
preProcessor.addIncludePath(self.filename.Dir()) |
|
495 |
||
496 |
# there is always a pre-include file |
|
497 |
preProcessor.setPreIncludeFile(preInclude) |
|
498 |
||
499 |
macros = ["SBSV2"] |
|
500 |
||
501 |
if config_macros: |
|
502 |
macros.extend(config_macros) |
|
503 |
||
504 |
if macros: |
|
505 |
for macro in macros: |
|
506 |
preProcessor.addMacro(macro + "=_____" +macro) |
|
507 |
||
508 |
# extra "raw" macros that do not need protecting |
|
509 |
preProcessor.addMacro("__GNUC__=3") |
|
510 |
||
511 |
preProcessorOutput = preProcessor.preprocess() |
|
512 |
||
513 |
# Resurrect preprocessing replacements |
|
514 |
pattern = r'([\\|/]| |) ?_____(('+macros[0]+')' |
|
515 |
for macro in macros[1:]: |
|
516 |
pattern += r'|('+macro+r')' |
|
517 |
||
518 |
pattern += r'\s*)' |
|
519 |
# Work on all Macros in one substitution. |
|
520 |
text = re.sub(pattern, r"\1\2", preProcessorOutput) |
|
521 |
text = re.sub(r"\n[\t ]*", r"\n", text) |
|
522 |
||
523 |
self.__PreProcessedContent[key] = text |
|
524 |
||
525 |
return self.__PreProcessedContent[key] |
|
526 |
||
527 |
class MMPFile(MetaDataFile): |
|
528 |
"""A generic representation of a Symbian metadata file |
|
529 |
||
530 |
Symbian metadata files are subject to preprocessing, primarily with macros based |
|
531 |
on the selected build platform. This class provides a generic means of wrapping |
|
532 |
up the preprocessing of such files.""" |
|
533 |
||
5 | 534 |
def __init__(self, aFilename, gnucpp, bldinf, depfiles, log=None): |
3 | 535 |
""" |
536 |
@param aFilename An MMP, bld.inf or other preprocessable build spec file |
|
537 |
@param gnucpp location of GNU CPP |
|
5 | 538 |
@param bldinf the bld.inf file this mmp was specified in |
539 |
@param depfiles list to fill with mmp dependency files |
|
540 |
@param log A class with Debug(<string>), Info(<string>) and Error(<string>) methods |
|
3 | 541 |
""" |
5 | 542 |
super(MMPFile, self).__init__(aFilename, gnucpp, depfiles, str(bldinf.filename.Dir()), log) |
3 | 543 |
self.__bldinf = bldinf |
5 | 544 |
self.depfiles = depfiles |
3 | 545 |
|
546 |
self.__gnucpp = gnucpp |
|
547 |
if gnucpp is None: |
|
548 |
raise ValueError('gnucpp must be set') |
|
549 |
||
550 |
def depspath(self, platform): |
|
551 |
""" Where does dependency information go relative to platform's SBS_BUILD_DIR? |
|
552 |
Subclasses should redefine this |
|
553 |
""" |
|
554 |
return self.__bldinf.outputpath(platform) + "/" + self.filename.File() + '.' + platform['key_md5'] + ".d" |
|
555 |
||
556 |
class Export(object): |
|
557 |
"""Single processed PRJ_EXPORTS or PRJ_TESTEXPORTS entry from a bld.inf file""" |
|
558 |
||
559 |
def getPossiblyQuotedStrings(cls,spec): |
|
560 |
""" Split a string based on whitespace |
|
561 |
but keep double quoted substrings together. |
|
562 |
""" |
|
563 |
inquotes=False |
|
564 |
intokengap=False |
|
565 |
sourcedest=[] |
|
566 |
word = 0 |
|
567 |
for c in spec: |
|
568 |
if c == '"': |
|
569 |
if inquotes: |
|
570 |
inquotes = False |
|
571 |
word += 1 |
|
572 |
intokengap = True |
|
573 |
else: |
|
574 |
inquotes = True |
|
575 |
intokengap = False |
|
576 |
pass |
|
577 |
elif c == ' ' or c == '\t': |
|
578 |
if inquotes: |
|
579 |
if len(sourcedest) == word: |
|
580 |
sourcedest.append(c) |
|
581 |
else: |
|
582 |
sourcedest[word] += c |
|
583 |
else: |
|
584 |
if intokengap: |
|
585 |
# gobble unquoted spaces |
|
586 |
pass |
|
587 |
else: |
|
588 |
word += 1 |
|
589 |
intokengap=True |
|
590 |
pass |
|
591 |
else: |
|
592 |
intokengap = False |
|
593 |
if len(sourcedest) == word: |
|
594 |
sourcedest.append(c) |
|
595 |
else: |
|
596 |
sourcedest[word] += c |
|
597 |
||
598 |
return sourcedest |
|
599 |
||
600 |
getPossiblyQuotedStrings = classmethod(getPossiblyQuotedStrings) |
|
601 |
||
602 |
||
603 |
def __init__(self, aBldInfFile, aExportsLine, aType): |
|
604 |
""" |
|
605 |
Rules from the OS library for convenience: |
|
606 |
||
607 |
For PRJ_TESTEXPORTS |
|
608 |
source_file_1 [destination_file] |
|
609 |
source_file_n [destination_file] |
|
610 |
If the source file is listed with a relative path, the path will |
|
611 |
be considered relative to the directory containing the bld.inf file. |
|
612 |
If a destination file is not specified, the source file will be copied |
|
613 |
to the directory containing the bld.inf file. |
|
614 |
If a relative path is specified with the destination file, the path |
|
615 |
will be considered relative to directory containing the bld.inf file. |
|
616 |
||
617 |
For PRJ_EXPORTS |
|
618 |
source_file_1 [destination_file] |
|
619 |
source_file_n [destination_file] |
|
620 |
:zip zip_file [destination_path] |
|
621 |
||
622 |
Note that: |
|
623 |
If a source file is listed with a relative path, the path will be |
|
624 |
considered relative to the directory containing the bld.inf file. |
|
625 |
||
626 |
If a destination file is not specified, the source file will be copied |
|
627 |
to epoc32\include\. |
|
628 |
||
629 |
If a destination file is specified with the relative path, the path will |
|
630 |
be considered relative to directory epoc32\include\. |
|
631 |
||
632 |
If a destination begins with a drive letter, then the file is copied to |
|
633 |
epoc32\data\<drive_letter>\<path>. For example, |
|
634 |
||
635 |
mydata.dat e:\appdata\mydata.dat |
|
636 |
copies mydata.dat to epoc32\data\e\appdata\mydata.dat. |
|
637 |
You can use any driveletter between A and Z. |
|
638 |
||
639 |
A line can start with the preface :zip. This instructs the build tools |
|
640 |
to unzip the specified zip file to the specified destination path. If a |
|
641 |
destination path is not specified, the source file will be unzipped in |
|
642 |
the root directory. |
|
643 |
||
644 |
||
645 |
""" |
|
646 |
||
647 |
# Work out what action is required - unzip or copy? |
|
648 |
action = "copy" |
|
649 |
typematch = re.match(r'^\s*(?P<type>:zip\s+)?(?P<spec>[^\s].*[^\s])\s*$',aExportsLine, re.I) |
|
650 |
||
651 |
spec = typematch.group('spec') |
|
652 |
if spec == None: |
|
653 |
raise ValueError('must specify at least a source file for an export') |
|
654 |
||
655 |
if typematch.group('type') is not None: |
|
656 |
action = "unzip" |
|
657 |
||
658 |
# Split the spec into source and destination but take care |
|
659 |
# to allow filenames with quoted strings. |
|
660 |
exportEntries = Export.getPossiblyQuotedStrings(spec) |
|
661 |
||
662 |
# Get the source path as specified by the bld.inf |
|
663 |
source_spec = exportEntries.pop(0).replace(' ','%20') |
|
664 |
||
665 |
# Resolve the source file |
|
666 |
sourcepath = generic_path.Path(raptor_utilities.resolveSymbianPath(str(aBldInfFile), source_spec)) |
|
667 |
||
668 |
# Find it if the case of the filename is wrong: |
|
669 |
# Carry on even if we don't find it |
|
670 |
foundfile = sourcepath.FindCaseless() |
|
671 |
if foundfile != None: |
|
672 |
source = str(foundfile).replace(' ','%20') |
|
673 |
else: |
|
674 |
source = str(sourcepath).replace(' ','%20') |
|
675 |
||
676 |
||
677 |
# Get the destination path as specified by the bld.inf |
|
678 |
if len(exportEntries) > 0: |
|
679 |
dest_spec = exportEntries.pop(0).replace(' ','%20') |
|
680 |
else: |
|
681 |
dest_spec = None |
|
682 |
# Destination list - list of destinations. For the WINSCW resource building stage, |
|
683 |
# files exported to the emulated drives and there are several locations, for example, |
|
684 |
# PRJ_[TEST]EXPORTS |
|
685 |
# 1234ABCD.SPD z:/private/10009876/policy/1234ABCD.spd |
|
686 |
# needs to end up copied in |
|
687 |
# epoc32/data/z/private/10009876/policy/1234ABCD.spd *and* in |
|
688 |
# epoc32/release/winscw/udeb/z/private/10009876/policy/1234ABCD.spd *and* in |
|
689 |
# epoc32/release/winscw/urel/z/private/10009876/policy/1234ABCD.spd |
|
690 |
dest_list = [] |
|
691 |
||
692 |
# Resolve the destination if one is specified |
|
693 |
if dest_spec: |
|
694 |
# check for troublesome characters |
|
695 |
if ':' in dest_spec and not re.search('^[a-z]:', dest_spec, re.I): |
|
696 |
raise ValueError("invalid filename " + dest_spec) |
|
697 |
||
698 |
dest_spec = dest_spec.replace(' ','%20') |
|
699 |
aSubType="" |
|
700 |
if action == "unzip": |
|
701 |
aSubType=":zip" |
|
702 |
dest_spec = dest_spec.rstrip("\\/") |
|
703 |
||
704 |
# Get the export destination(s) - note this can be a list of strings or just a string. |
|
705 |
dest_list = raptor_utilities.resolveSymbianPath(str(aBldInfFile), dest_spec, aType, aSubType) |
|
706 |
||
707 |
def process_dest(aDest): |
|
708 |
if dest_spec.endswith('/') or dest_spec.endswith('\\'): |
|
709 |
m = generic_path.Path(source) |
|
710 |
aDest += '/'+m.File() |
|
711 |
return aDest |
|
712 |
||
713 |
if isinstance(dest_list, list): |
|
714 |
# Process each file in the list |
|
715 |
dest_list = map(process_dest, dest_list) |
|
716 |
else: |
|
717 |
# Process the single destination |
|
718 |
dest_list = process_dest(dest_list) |
|
719 |
||
720 |
else: |
|
721 |
# No destination was specified so we assume an appropriate one |
|
722 |
||
723 |
dest_filename=generic_path.Path(source).File() |
|
724 |
||
725 |
if aType == "PRJ_EXPORTS": |
|
726 |
if action == "copy": |
|
727 |
destination = '$(EPOCROOT)/epoc32/include/'+dest_filename |
|
728 |
elif action == "unzip": |
|
729 |
destination = '$(EPOCROOT)' |
|
730 |
elif aType == "PRJ_TESTEXPORTS": |
|
731 |
d = aBldInfFile.Dir() |
|
732 |
if action == "copy": |
|
733 |
destination = str(d.Append(dest_filename)) |
|
734 |
elif action == "unzip": |
|
735 |
destination = "$(EPOCROOT)" |
|
736 |
else: |
|
737 |
raise ValueError("Export type should be 'PRJ_EXPORTS' or 'PRJ_TESTEXPORTS'. It was: "+str(aType)) |
|
738 |
||
739 |
||
740 |
self.__Source = source |
|
741 |
if len(dest_list) > 0: # If the list has length > 0, this means there are several export destinations. |
|
742 |
self.__Destination = dest_list |
|
743 |
else: # Otherwise the list has length zero, so there is only a single export destination. |
|
744 |
self.__Destination = destination |
|
745 |
self.__Action = action |
|
746 |
||
747 |
def getSource(self): |
|
748 |
return self.__Source |
|
749 |
||
750 |
def getDestination(self): |
|
751 |
return self.__Destination # Note that this could be either a list, or a string, depending on the export destination |
|
752 |
||
753 |
def getAction(self): |
|
754 |
return self.__Action |
|
755 |
||
756 |
class ExtensionmakefileEntry(object): |
|
757 |
def __init__(self, aGnuLine, aBldInfFile, tmp): |
|
758 |
||
759 |
self.__BldInfFile = aBldInfFile |
|
760 |
bldInfLocation = self.__BldInfFile.Dir() |
|
761 |
biloc = str(bldInfLocation) |
|
762 |
extInfLocation = tmp.filename.Dir() |
|
763 |
eiloc = str(extInfLocation) |
|
764 |
||
765 |
if eiloc is None or eiloc == "": |
|
766 |
eiloc="." # Someone building with a relative raptor path |
|
767 |
if biloc is None or biloc == "": |
|
768 |
biloc="." # Someone building with a relative raptor path |
|
769 |
||
770 |
self.__StandardVariables = {} |
|
771 |
# Relative step-down to the root - let's try ignoring this for now, as it |
|
772 |
# should amount to the same thing in a world where absolute paths are king |
|
773 |
self.__StandardVariables['TO_ROOT'] = "" |
|
774 |
# Top-level bld.inf location |
|
775 |
self.__StandardVariables['TO_BLDINF'] = biloc |
|
776 |
self.__StandardVariables['EXTENSION_ROOT'] = eiloc |
|
777 |
||
778 |
# Get the directory and filename from the full path containing the extension makefile |
|
779 |
self.__FullPath = generic_path.Join(eiloc,aGnuLine) |
|
780 |
self.__FullPath = self.__FullPath.GetLocalString() |
|
781 |
self.__Filename = os.path.split(self.__FullPath)[1] |
|
782 |
self.__Directory = os.path.split(self.__FullPath)[0] |
|
783 |
||
784 |
def getMakefileName(self): |
|
785 |
return self.__Filename |
|
786 |
||
787 |
def getMakeDirectory(self): |
|
788 |
return self.__Directory |
|
789 |
||
790 |
def getStandardVariables(self): |
|
791 |
return self.__StandardVariables |
|
792 |
||
793 |
class Extension(object): |
|
794 |
"""Single processed PRJ_EXTENSIONS or PRJ_TESTEXTENSIONS START EXTENSIONS...END block |
|
795 |
from a bld.inf file""" |
|
796 |
||
797 |
def __init__(self, aBldInfFile, aStartLine, aOptionLines, aBuildPlatform, aRaptor): |
|
798 |
self.__BldInfFile = aBldInfFile |
|
799 |
self.__Options = {} |
|
800 |
self.interface = "" |
|
801 |
self.__Raptor = aRaptor |
|
802 |
||
803 |
makefile = "" |
|
804 |
makefileMatch = re.search(r'^\s*START EXTENSION\s+(?P<MAKEFILE>\S+)\s*(?P<NAMETAG>\S*)$', aStartLine, re.I) |
|
805 |
||
806 |
self.__RawMakefile = "" |
|
807 |
||
808 |
if (makefileMatch): |
|
809 |
self.__RawMakefile = makefileMatch.group('MAKEFILE') |
|
810 |
self.nametag = makefileMatch.group('NAMETAG').lower() |
|
811 |
||
812 |
# Ensure all \'s are translated into /'s if required |
|
813 |
self.interface = self.__RawMakefile |
|
814 |
self.interface = self.interface.replace("\\", "/").replace("/", ".") |
|
815 |
||
816 |
# To support standalone testing, '$(' prefixed TEMs are assumed to start with |
|
817 |
# a makefile variable and hence be fully located in FLM operation |
|
818 |
if self.__RawMakefile.startswith("$("): |
|
819 |
self.__Makefile = self.__RawMakefile + ".mk" |
|
820 |
else: |
|
821 |
self.__Makefile = '$(MAKEFILE_TEMPLATES)/' + self.__RawMakefile + ".mk" |
|
822 |
||
823 |
for optionLine in aOptionLines: |
|
824 |
optionMatch = re.search(r'^\s*(OPTION\s+)?(?P<VARIABLE>\S+)\s+(?P<VALUE>\S+.*)$',optionLine, re.I) |
|
825 |
if optionMatch: |
|
826 |
self.__Options[optionMatch.group('VARIABLE').upper()] = optionMatch.group('VALUE') |
|
827 |
||
828 |
bldInfLocation = self.__BldInfFile.Dir() |
|
829 |
||
830 |
biloc = str(bldInfLocation) |
|
831 |
if biloc is None or biloc == "": |
|
832 |
biloc="." # Someone building with a relative raptor path |
|
833 |
||
834 |
extInfLocation = aStartLine.filename.Dir() |
|
835 |
||
836 |
eiloc = str(extInfLocation) |
|
837 |
if eiloc is None or eiloc == "": |
|
838 |
eiloc="." # Someone building with a relative raptor path |
|
839 |
||
840 |
self.__StandardVariables = {} |
|
841 |
# Relative step-down to the root - let's try ignoring this for now, as it |
|
842 |
# should amount to the same thing in a world where absolute paths are king |
|
843 |
self.__StandardVariables['TO_ROOT'] = "" |
|
844 |
# Top-level bld.inf location |
|
845 |
self.__StandardVariables['TO_BLDINF'] = biloc |
|
846 |
# Location of bld.inf file containing the current EXTENSION block |
|
847 |
self.__StandardVariables['EXTENSION_ROOT'] = eiloc |
|
848 |
||
849 |
# If the interface exists, this means it's not a Template Extension Makefile so don't look for a .meta file for it; |
|
850 |
# so do nothing if it's not a template extension makefile |
|
851 |
try: |
|
852 |
self.__Raptor.cache.FindNamedInterface(str(self.interface), aBuildPlatform['CACHEID']) |
|
853 |
except KeyError: # This means that this Raptor doesn't have the interface self.interface, so we are in a TEM |
|
854 |
# Read extension meta file and get default options from it. The use of TEM meta file is compulsory if TEM is used |
|
855 |
metaFilename = "%s/epoc32/tools/makefile_templates/%s.meta" % (aBuildPlatform['EPOCROOT'], self.__RawMakefile) |
|
856 |
metaFile = None |
|
857 |
try: |
|
858 |
metaFile = open(metaFilename, "r") |
|
859 |
except IOError, e: |
|
860 |
self.__warn("Extension: %s - cannot open Meta file: %s" % (self.__RawMakefile, metaFilename)) |
|
861 |
||
862 |
if metaFile: |
|
863 |
for line in metaFile.readlines(): |
|
864 |
defaultOptionMatch = re.search(r'^OPTION\s+(?P<VARIABLE>\S+)\s+(?P<VALUE>\S+.*)$',line, re.I) |
|
865 |
if defaultOptionMatch and defaultOptionMatch.group('VARIABLE').upper() not in self.__Options.keys(): |
|
866 |
self.__Options[defaultOptionMatch.group('VARIABLE').upper()] = defaultOptionMatch.group('VALUE') |
|
867 |
||
868 |
metaFile.close() |
|
869 |
||
870 |
def __warn(self, format, *extras): |
|
871 |
if (self.__Raptor): |
|
872 |
self.__Raptor.Warn(format, *extras) |
|
873 |
||
874 |
def getIdentifier(self): |
|
875 |
return re.sub (r'\\|\/|\$|\(|\)', '_', self.__RawMakefile) |
|
876 |
||
877 |
def getMakefile(self): |
|
878 |
return self.__Makefile |
|
879 |
||
880 |
def getOptions(self): |
|
881 |
return self.__Options |
|
882 |
||
883 |
def getStandardVariables(self): |
|
884 |
return self.__StandardVariables |
|
885 |
||
886 |
class MMPFileEntry(object): |
|
887 |
def __init__(self, aFilename, aTestOption, aARMOption): |
|
888 |
self.filename = aFilename |
|
889 |
self.testoption = aTestOption |
|
890 |
if aARMOption: |
|
891 |
self.armoption = True |
|
892 |
else: |
|
893 |
self.armoption = False |
|
894 |
||
895 |
||
896 |
class BldInfFile(MetaDataFile): |
|
897 |
"""Representation of a Symbian bld.inf file""" |
|
898 |
||
5 | 899 |
def __init__(self, aFilename, gnucpp, depfiles, log=None): |
900 |
MetaDataFile.__init__(self, aFilename, gnucpp, depfiles, None, log) |
|
3 | 901 |
self.__Raptor = log |
902 |
self.testManual = 0 |
|
903 |
self.testAuto = 0 |
|
904 |
# Generic |
|
905 |
||
906 |
def getBuildPlatforms(self, aBuildPlatform): |
|
907 |
platformList = [] |
|
908 |
||
909 |
for platformLine in self.__getSection(aBuildPlatform, 'PRJ_PLATFORMS'): |
|
910 |
for platformEntry in platformLine.split(): |
|
911 |
platformList.append(platformEntry) |
|
912 |
||
913 |
return platformList |
|
914 |
||
915 |
# Build Platform Specific |
|
916 |
def getMMPList(self, aBuildPlatform, aType="PRJ_MMPFILES"): |
|
917 |
mmpFileList=[] |
|
918 |
gnuList = [] |
|
919 |
makefileList = [] |
|
920 |
extFound = False |
|
921 |
m = None |
|
922 |
||
923 |
hashValue = {'mmpFileList': [] , 'gnuList': [], 'makefileList' : []} |
|
924 |
||
925 |
for mmpFileEntry in self.__getSection(aBuildPlatform, aType): |
|
926 |
||
927 |
actualBldInfRoot = mmpFileEntry.getFilename() |
|
928 |
n = re.match('\s*(?P<makefiletype>(GNUMAKEFILE|N?MAKEFILE))\s+(?P<extmakefile>[^ ]+)\s*(support|manual)?\s*(?P<invalid>\S+.*)?\s*$',mmpFileEntry,re.I) |
|
929 |
if n: |
|
930 |
||
931 |
if (n.groupdict()['invalid']): |
|
932 |
self.log.Error("%s (%d) : invalid .mmp file qualifier \"%s\"", mmpFileEntry.filename, mmpFileEntry.getLineNumber(), n.groupdict()['invalid']) |
|
933 |
if raptor_utilities.getOSFileSystem() == "unix": |
|
934 |
self.log.Warn("NMAKEFILE/GNUMAKEFILE/MAKEFILE keywords not supported on Linux") |
|
935 |
else: |
|
936 |
extmakefilearg = n.groupdict()['extmakefile'] |
|
937 |
bldInfDir = actualBldInfRoot.Dir() |
|
938 |
extmakefilename = bldInfDir.Append(extmakefilearg) |
|
939 |
extmakefile = ExtensionmakefileEntry(extmakefilearg, self.filename, mmpFileEntry) |
|
940 |
||
941 |
if (n.groupdict()['makefiletype']).upper() == "GNUMAKEFILE": |
|
942 |
gnuList.append(extmakefile) |
|
943 |
else: |
|
944 |
makefileList.append(extmakefile) |
|
945 |
else: |
|
946 |
# Currently there is only one possible option - build as arm. |
|
947 |
# For TESTMMPFILES, the supported options are support, tidy, ignore, manual and build as arm |
|
948 |
if aType.upper()=="PRJ_TESTMMPFILES": |
|
949 |
if re.match('\s*(?P<name>[^ ]+)\s*(?P<baa>build_as_arm)?\s*(?P<support>support)?\s*(?P<ignore>ignore)?\s*(?P<tidy>tidy)?\s*(?P<manual>manual)?\s*(?P<invalid>\S+.*)?\s*$', mmpFileEntry, re.I): |
|
950 |
m = re.match('\s*(?P<name>[^ ]+)\s*(?P<baa>build_as_arm)?\s*(?P<support>support)?\s*(?P<ignore>ignore)?\s*(?P<tidy>tidy)?\s*(?P<manual>manual)?\s*(?P<invalid>\S+.*)?\s*$', mmpFileEntry, re.I) |
|
951 |
else: |
|
952 |
if re.match('\s*(?P<name>[^ ]+)\s*(?P<baa>build_as_arm)?\s*(?P<invalid>\S+.*)?\s*$', mmpFileEntry, re.I): |
|
953 |
m = re.match('\s*(?P<name>[^ ]+)\s*(?P<baa>build_as_arm)?\s*(?P<invalid>\S+.*)?\s*$', mmpFileEntry, re.I) |
|
954 |
||
955 |
if m: |
|
956 |
if (m.groupdict()['invalid']): |
|
957 |
self.log.Error("%s (%d) : invalid .mmp file qualifier \"%s\"", mmpFileEntry.filename, mmpFileEntry.getLineNumber(), m.groupdict()['invalid']) |
|
958 |
||
959 |
mmpFileName = m.groupdict()['name'] |
|
960 |
testmmpoption = "auto" # Setup tests to be automatic by default |
|
961 |
tokens = m.groupdict() |
|
962 |
for key,item in tokens.iteritems(): |
|
963 |
if key=="manual" and item=="manual": |
|
964 |
testmmpoption = "manual" |
|
965 |
elif key=="support" and item=="support": |
|
966 |
testmmpoption = "support" |
|
967 |
elif key=="ignore" and item=="ignore": |
|
968 |
testmmpoption = "ignore" |
|
969 |
||
970 |
buildasarm = False |
|
971 |
if m.groupdict()['baa']: |
|
972 |
if m.groupdict()['baa'].lower() == 'build_as_arm': |
|
973 |
buildasarm = True |
|
974 |
||
975 |
if not mmpFileName.lower().endswith('.mmp'): |
|
976 |
mmpFileName += '.mmp' |
|
977 |
bldInfDir = actualBldInfRoot.Dir() |
|
978 |
try: |
|
979 |
mmpFileName = bldInfDir.Append(mmpFileName) |
|
980 |
mmpfe = MMPFileEntry(mmpFileName, testmmpoption, buildasarm) |
|
981 |
mmpFileList.append(mmpfe) |
|
982 |
except ValueError, e: |
|
983 |
self.log.Error("invalid .mmp file name: %s" % str(e)) |
|
984 |
||
985 |
m = None |
|
986 |
||
987 |
||
988 |
hashValue['mmpFileList'] = mmpFileList |
|
989 |
hashValue['gnuList'] = gnuList |
|
990 |
hashValue['makefileList'] = makefileList |
|
991 |
||
992 |
return hashValue |
|
993 |
||
994 |
# Return a list of gnumakefiles used in the bld.inf |
|
995 |
def getExtensionmakefileList(self, aBuildPlatform, aType="PRJ_MMPFILES",aString = ""): |
|
996 |
extMakefileList=[] |
|
997 |
m = None |
|
998 |
for extmakeFileEntry in self.__getSection(aBuildPlatform, aType): |
|
999 |
||
1000 |
actualBldInfRoot = extmakeFileEntry.filename |
|
1001 |
if aType.upper()=="PRJ_TESTMMPFILES": |
|
1002 |
m = re.match('\s*GNUMAKEFILE\s+(?P<extmakefile>[^ ]+)\s*(?P<support>support)?\s*(?P<ignore>ignore)?\s*(?P<tidy>tidy)?\s*(?P<manual>manual)?\s*(?P<invalid>\S+.*)?\s*$',extmakeFileEntry,re.I) |
|
1003 |
else: |
|
1004 |
if aString == "gnumakefile": |
|
1005 |
m = re.match('\s*GNUMAKEFILE\s+(?P<extmakefile>[^ ]+)\s*(?P<invalid>\S+.*)?\s*$',extmakeFileEntry,re.I) |
|
1006 |
elif aString == "nmakefile": |
|
1007 |
m = re.match('\s*NMAKEFILE\s+(?P<extmakefile>[^ ]+)\s*(?P<invalid>\S+.*)?\s*$',extmakeFileEntry,re.I) |
|
1008 |
elif aString == "makefile": |
|
1009 |
m = re.match('\s*MAKEFILE\s+(?P<extmakefile>[^ ]+)\s*(?P<invalid>\S+.*)?\s*$',extmakeFileEntry,re.I) |
|
1010 |
if m: |
|
1011 |
if (m.groupdict()['invalid']): |
|
1012 |
self.log.Error("%s (%d) : invalid extension makefile qualifier \"%s\"", extmakeFileEntry.filename, extmakeFileEntry.getLineNumber(), m.groupdict()['invalid']) |
|
1013 |
||
1014 |
extmakefilearg = m.groupdict()['extmakefile'] |
|
1015 |
bldInfDir = actualBldInfRoot.Dir() |
|
1016 |
extmakefilename = bldInfDir.Append(extmakefilearg) |
|
1017 |
extmakefile = ExtensionmakefileEntry(extmakefilearg, self.filename, extmakeFileEntry) |
|
1018 |
extMakefileList.append(extmakefile) |
|
1019 |
m = None |
|
1020 |
||
1021 |
return extMakefileList |
|
1022 |
||
1023 |
def getTestExtensionmakefileList(self,aBuildPlatform,aString=""): |
|
1024 |
return self.getExtensionmakefileList(aBuildPlatform,"PRJ_TESTMMPFILES",aString) |
|
1025 |
||
1026 |
def getTestMMPList(self, aBuildPlatform): |
|
1027 |
return self.getMMPList(aBuildPlatform, "PRJ_TESTMMPFILES") |
|
1028 |
||
1029 |
def getRomTestType(self, aBuildPlatform): |
|
1030 |
testMMPList = self.getTestMMPList(aBuildPlatform) |
|
1031 |
for testMMPFileEntry in testMMPList['mmpFileList']: |
|
1032 |
if aBuildPlatform["TESTCODE"]: |
|
1033 |
# Calculate test type (manual or auto) |
|
1034 |
if testMMPFileEntry.testoption == "manual": |
|
1035 |
self.testManual += 1 |
|
1036 |
if not (testMMPFileEntry.testoption == "support" or testMMPFileEntry.testoption == "manual" or testMMPFileEntry.testoption == "ignore"): |
|
1037 |
self.testAuto += 1 |
|
1038 |
if self.testManual and self.testAuto: |
|
1039 |
return 'BOTH' |
|
1040 |
elif self.testAuto: |
|
1041 |
return 'AUTO' |
|
1042 |
elif self.testManual: |
|
1043 |
return 'MANUAL' |
|
1044 |
else: |
|
1045 |
return 'NONE' |
|
1046 |
||
1047 |
def getExports(self, aBuildPlatform, aType="PRJ_EXPORTS"): |
|
1048 |
exportList = [] |
|
1049 |
||
1050 |
for exportLine in self.__getSection(aBuildPlatform, aType): |
|
1051 |
||
1052 |
if not re.match(r'\S+', exportLine): |
|
1053 |
continue |
|
1054 |
||
1055 |
try: |
|
1056 |
exportList.append(Export(exportLine.getFilename(), exportLine, aType)) |
|
1057 |
except ValueError,e: |
|
1058 |
self.log.Error(str(e)) |
|
1059 |
||
1060 |
return exportList |
|
1061 |
||
1062 |
def getTestExports(self, aBuildPlatform): |
|
1063 |
return self.getExports(aBuildPlatform, "PRJ_TESTEXPORTS") |
|
1064 |
||
1065 |
def getExtensions(self, aBuildPlatform, aType="PRJ_EXTENSIONS"): |
|
1066 |
extensionObjects = [] |
|
1067 |
start = "" |
|
1068 |
options = [] |
|
1069 |
||
1070 |
for extensionLine in self.__getSection(aBuildPlatform, aType): |
|
1071 |
if (re.search(r'^\s*START ',extensionLine, re.I)): |
|
1072 |
start = extensionLine |
|
1073 |
elif re.search(r'^\s*END\s*$',extensionLine, re.I): |
|
458
79718b9711e8
fix for bug 2297 : traceback on unmatched END in a bld.inf
Richard Taylor <richard.i.taylor@nokia.com>
parents:
422
diff
changeset
|
1074 |
if start == "": |
79718b9711e8
fix for bug 2297 : traceback on unmatched END in a bld.inf
Richard Taylor <richard.i.taylor@nokia.com>
parents:
422
diff
changeset
|
1075 |
self.log.Error("unmatched END statement in %s section", aType, bldinf=str(self.filename)) |
79718b9711e8
fix for bug 2297 : traceback on unmatched END in a bld.inf
Richard Taylor <richard.i.taylor@nokia.com>
parents:
422
diff
changeset
|
1076 |
else: |
79718b9711e8
fix for bug 2297 : traceback on unmatched END in a bld.inf
Richard Taylor <richard.i.taylor@nokia.com>
parents:
422
diff
changeset
|
1077 |
extensionObjects.append(Extension(self.filename, start, options, aBuildPlatform, self.__Raptor)) |
79718b9711e8
fix for bug 2297 : traceback on unmatched END in a bld.inf
Richard Taylor <richard.i.taylor@nokia.com>
parents:
422
diff
changeset
|
1078 |
start = "" |
79718b9711e8
fix for bug 2297 : traceback on unmatched END in a bld.inf
Richard Taylor <richard.i.taylor@nokia.com>
parents:
422
diff
changeset
|
1079 |
options = [] |
3 | 1080 |
elif re.search(r'^\s*$',extensionLine, re.I): |
1081 |
continue |
|
1082 |
elif start: |
|
1083 |
options.append(extensionLine) |
|
1084 |
||
1085 |
return extensionObjects |
|
1086 |
||
1087 |
def getTestExtensions(self, aBuildPlatform): |
|
1088 |
return self.getExtensions(aBuildPlatform, "PRJ_TESTEXTENSIONS") |
|
1089 |
||
1090 |
def __getSection(self, aBuildPlatform, aSection): |
|
1091 |
||
1092 |
activeSection = False |
|
1093 |
sectionContent = [] |
|
1094 |
lineContent = re.split(r'\n', self.getContent(aBuildPlatform)); |
|
1095 |
||
1096 |
currentBldInfFile = self.filename |
|
1097 |
currentLineNumber = 0 |
|
1098 |
||
1099 |
for line in lineContent: |
|
1100 |
if line.startswith("#"): |
|
1101 |
commentDetail = getPreProcessorCommentDetail(line) |
|
1102 |
currentBldInfFile = commentDetail[0] |
|
1103 |
currentLineNumber = commentDetail[1]-1 |
|
1104 |
continue |
|
1105 |
||
1106 |
currentLineNumber += 1 |
|
1107 |
||
1108 |
if not re.match(r'.*\S+', line): |
|
1109 |
continue |
|
1110 |
elif re.match(r'\s*' + aSection + r'\s*$', line, re.I): |
|
1111 |
activeSection = True |
|
1112 |
elif re.match(r'\s*PRJ_\w+\s*$', line, re.I): |
|
1113 |
activeSection = False |
|
1114 |
elif activeSection: |
|
1115 |
sectionContent.append(PreProcessedLine(line, currentBldInfFile, currentLineNumber)) |
|
1116 |
||
1117 |
return sectionContent |
|
1118 |
||
1119 |
@staticmethod |
|
1120 |
def outputPathFragment(bldinfpath): |
|
1121 |
"""Return a relative path that uniquely identifies this bldinf file |
|
1122 |
whilst being short so that it can be appended to epoc32/build. |
|
1123 |
The build product of a particular bld.inf may be placed in here. |
|
1124 |
This affects its TEMs and its MMPs""" |
|
1125 |
||
1126 |
absroot_str = os.path.abspath(str(bldinfpath)).lower().replace("\\","/") |
|
1127 |
||
1128 |
uniqueid = hashlib.md5() |
|
1129 |
uniqueid.update(absroot_str) |
|
1130 |
||
1131 |
specnamecomponents = (re.sub("^[A-Za-z]:", "", absroot_str)).split('/') # split, removing any drive identifier (if present) |
|
1132 |
||
1133 |
pathlist=[] |
|
1134 |
while len(specnamecomponents) > 0: |
|
1135 |
top = specnamecomponents.pop() |
|
1136 |
if top.endswith('.inf'): |
|
1137 |
continue |
|
1138 |
elif top == 'group': |
|
1139 |
continue |
|
1140 |
else: |
|
1141 |
pathlist = [top] |
|
1142 |
break |
|
1143 |
||
1144 |
pathlist.append("c_"+uniqueid.hexdigest()[:16]) |
|
1145 |
return "/".join(pathlist) |
|
1146 |
||
1147 |
def outputpath(self, platform): |
|
1148 |
""" The full path where product from this bldinf is created.""" |
|
1149 |
return str(platform['SBS_BUILD_DIR']) + "/" + BldInfFile.outputPathFragment(self.filename) |
|
1150 |
||
1151 |
def depspath(self, platform): |
|
1152 |
""" Where does dependency information go relative to platform's SBS_BUILD_DIR? |
|
1153 |
Subclasses should redefine this |
|
1154 |
""" |
|
1155 |
return self.outputpath(platform) + "/bldinf." + platform['key_md5'] + ".d" |
|
1156 |
||
1157 |
||
1158 |
||
1159 |
class MMPRaptorBackend(MMPBackend): |
|
1160 |
"""A parser "backend" for the MMP language |
|
1161 |
||
1162 |
This is used to map recognised MMP syntax onto a buildspec """ |
|
1163 |
||
1164 |
# Support priorities, with case-fixed mappings for use |
|
1165 |
epoc32priorities = { |
|
1166 |
'low':'Low', |
|
1167 |
'background':'Background', |
|
1168 |
'foreground':'Foreground', |
|
1169 |
'high':'High', |
|
1170 |
'windowserver':'WindowServer', |
|
1171 |
'fileserver':'FileServer', |
|
1172 |
'realtimeserver':'RealTimeServer', |
|
1173 |
'supervisor':'SuperVisor' |
|
1174 |
} |
|
1175 |
||
1176 |
# Known capability flags with associated bitwise operations |
|
1177 |
supportedCapabilities = { |
|
1178 |
'tcb':(1<<0), |
|
1179 |
'commdd':(1<<1), |
|
1180 |
'powermgmt':(1<<2), |
|
1181 |
'multimediadd':(1<<3), |
|
1182 |
'readdevicedata':(1<<4), |
|
1183 |
'writedevicedata':(1<<5), |
|
1184 |
'drm':(1<<6), |
|
1185 |
'trustedui':(1<<7), |
|
1186 |
'protserv':(1<<8), |
|
1187 |
'diskadmin':(1<<9), |
|
1188 |
'networkcontrol':(1<<10), |
|
1189 |
'allfiles':(1<<11), |
|
1190 |
'swevent':(1<<12), |
|
1191 |
'networkservices':(1<<13), |
|
1192 |
'localservices':(1<<14), |
|
1193 |
'readuserdata':(1<<15), |
|
1194 |
'writeuserdata':(1<<16), |
|
1195 |
'location':(1<<17), |
|
1196 |
'surroundingsdd':(1<<18), |
|
1197 |
'userenvironment':(1<<19), |
|
1198 |
# Old capability names have zero value |
|
1199 |
'root':0, |
|
1200 |
'mediadd':0, |
|
1201 |
'readsystemdata':0, |
|
1202 |
'writesystemdata':0, |
|
1203 |
'sounddd':0, |
|
1204 |
'uidd':0, |
|
1205 |
'killanyprocess':0, |
|
1206 |
'devman':0, |
|
1207 |
'phonenetwork':0, |
|
1208 |
'localnetwork':0 |
|
1209 |
} |
|
1210 |
||
1211 |
library_re = re.compile(r"^(?P<name>[^{]+?)(?P<version>{(?P<major>[0-9]+)\.(?P<minor>[0-9]+)})?(\.(lib|dso))?$",re.I) |
|
1212 |
||
1213 |
||
1214 |
def __init__(self, aRaptor, aMmpfilename, aBldInfFilename): |
|
1215 |
super(MMPRaptorBackend,self).__init__() |
|
1216 |
self.platformblock = None |
|
1217 |
self.__Raptor = aRaptor |
|
5 | 1218 |
self.__debug("-----+++++ %s " % aMmpfilename) |
1219 |
self.BuildVariant = raptor_data.Variant(name = "mmp") |
|
9 | 1220 |
self.ApplyVariants = [] |
3 | 1221 |
self.ResourceVariants = [] |
1222 |
self.BitmapVariants = [] |
|
1223 |
self.StringTableVariants = [] |
|
1224 |
self.__bldInfFilename = aBldInfFilename |
|
1225 |
self.__targettype = "UNKNOWN" |
|
1226 |
self.__currentMmpFile = aMmpfilename |
|
1227 |
self.__defFileRoot = self.__currentMmpFile |
|
1228 |
self.__currentLineNumber = 0 |
|
1229 |
self.__sourcepath = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, "") |
|
1230 |
self.__userinclude = "" |
|
1231 |
self.__systeminclude = "" |
|
1232 |
self.__bitmapSourcepath = self.__sourcepath |
|
1233 |
self.__current_resource = "" |
|
9 | 1234 |
self.__resourceFiles = [] |
3 | 1235 |
self.__pageConflict = [] |
1236 |
self.__debuggable = "" |
|
9 | 1237 |
self.__compressionKeyword = "" |
3 | 1238 |
self.sources = [] |
5 | 1239 |
self.capabilities = [] |
3 | 1240 |
|
1241 |
self.__TARGET = "" |
|
1242 |
self.__TARGETEXT = "" |
|
1243 |
self.deffile = "" |
|
1244 |
self.__LINKAS = "" |
|
1245 |
self.nostrictdef = False |
|
1246 |
self.featureVariant = False |
|
1247 |
||
1248 |
self.__currentResourceVariant = None |
|
1249 |
self.__currentStringTableVariant = None |
|
1250 |
self.__explicitversion = False |
|
1251 |
self.__versionhex = "" |
|
1252 |
||
1253 |
# "ALL" capability calculated based on the total capabilities currently supported |
|
1254 |
allCapabilities = 0 |
|
1255 |
for supportedCapability in MMPRaptorBackend.supportedCapabilities.keys(): |
|
1256 |
allCapabilities = allCapabilities | MMPRaptorBackend.supportedCapabilities[supportedCapability] |
|
1257 |
MMPRaptorBackend.supportedCapabilities['all'] = allCapabilities |
|
1258 |
||
1259 |
# Permit unit-testing output without a Raptor context |
|
1260 |
def __debug(self, format, *extras): |
|
1261 |
if (self.__Raptor): |
|
1262 |
self.__Raptor.Debug(format, *extras) |
|
1263 |
||
1264 |
def __warn(self, format, *extras): |
|
1265 |
if (self.__Raptor): |
|
1266 |
self.__Raptor.Warn(format, *extras) |
|
1267 |
||
1268 |
def doPreProcessorComment(self,s,loc,toks): |
|
1269 |
commentDetail = getPreProcessorCommentDetail(toks[0]) |
|
1270 |
self.__currentMmpFile = commentDetail[0].GetLocalString() |
|
1271 |
self.__currentLineNumber = commentDetail[1] |
|
1272 |
self.__debug("Current file %s, line number %s\n" % (self.__currentMmpFile,str(self.__currentLineNumber))) |
|
1273 |
return "OK" |
|
1274 |
||
1275 |
def doBlankLine(self,s,loc,toks): |
|
1276 |
self.__currentLineNumber += 1 |
|
1277 |
||
1278 |
def doStartPlatform(self,s,loc,toks): |
|
1279 |
self.__currentLineNumber += 1 |
|
1280 |
self.__debug( "Start Platform block "+toks[0]) |
|
1281 |
self.platformblock = toks[0] |
|
1282 |
return "OK" |
|
1283 |
||
1284 |
def doEndPlatform(self,s,loc,toks): |
|
1285 |
self.__currentLineNumber += 1 |
|
1286 |
self.__debug( "Finalise platform " + self.platformblock) |
|
1287 |
return "OK" |
|
1288 |
||
1289 |
def doSetSwitch(self,s,loc,toks): |
|
1290 |
self.__currentLineNumber += 1 |
|
1291 |
prefix="" |
|
1292 |
varname = toks[0].upper() |
|
1293 |
||
1294 |
# A bright spark made the optionname the same as |
|
1295 |
# the env variable. One will override the other if we pass this |
|
1296 |
# on to make. Add a prefix to prevent the clash. |
|
1297 |
if varname=='ARMINC': |
|
1298 |
prefix="SET_" |
|
1299 |
self.__debug( "Set switch "+toks[0]+" ON") |
|
1300 |
self.BuildVariant.AddOperation(raptor_data.Set(prefix+varname, "1")) |
|
1301 |
||
1302 |
elif varname=='NOSTRICTDEF': |
|
1303 |
self.nostrictdef = True |
|
1304 |
self.__debug( "Set switch "+toks[0]+" ON") |
|
1305 |
self.BuildVariant.AddOperation(raptor_data.Set(prefix+varname, "1")) |
|
1306 |
||
1307 |
elif varname == 'PAGED': |
|
1308 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, "1")) |
|
1309 |
self.__debug( "Set switch PAGE ON") |
|
414
fdf44dc5eff3
PAGED means PAGEDCODE
Richard Taylor <richard.i.taylor@nokia.com>
parents:
392
diff
changeset
|
1310 |
# PAGED is equivalent to PAGEDCODE |
3 | 1311 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGEDCODE_OPTION", "paged")) |
1312 |
self.__debug( "Set switch PAGEDCODE ON") |
|
1313 |
self.__pageConflict.append("PAGEDCODE") |
|
1314 |
||
1315 |
elif varname == 'UNPAGED': |
|
1316 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGED", "0")) |
|
1317 |
self.__debug( "Set switch PAGED OFF") |
|
414
fdf44dc5eff3
PAGED means PAGEDCODE
Richard Taylor <richard.i.taylor@nokia.com>
parents:
392
diff
changeset
|
1318 |
# UNPAGED is equivalent to UNPAGEDCODE *and* UNPAGEDDATA |
3 | 1319 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGEDCODE_OPTION", "unpaged")) |
1320 |
self.__debug( "Set switch PAGEDCODE OFF") |
|
1321 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGEDDATA_OPTION", "unpaged")) |
|
1322 |
self.__debug( "Set data PAGEDDATA OFF") |
|
1323 |
self.__pageConflict.append("UNPAGEDCODE") |
|
1324 |
self.__pageConflict.append("UNPAGEDDATA") |
|
1325 |
||
1326 |
elif varname == 'PAGEDCODE': |
|
1327 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGEDCODE_OPTION", "paged")) |
|
1328 |
self.__debug( "Set switch " + varname + " ON") |
|
1329 |
self.__pageConflict.append(varname) |
|
1330 |
||
1331 |
elif varname == 'PAGEDDATA': |
|
1332 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGEDDATA_OPTION", "paged")) |
|
1333 |
self.__debug( "Set switch " + varname + " ON") |
|
1334 |
self.__pageConflict.append(varname) |
|
1335 |
||
1336 |
elif varname == 'UNPAGEDCODE': |
|
1337 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGEDCODE_OPTION", "unpaged")) |
|
1338 |
self.__debug( "Set switch " + varname + " ON") |
|
1339 |
self.__pageConflict.append(varname) |
|
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
1340 |
|
3 | 1341 |
elif varname == 'UNPAGEDDATA': |
1342 |
self.BuildVariant.AddOperation(raptor_data.Set("PAGEDDATA_OPTION", "unpaged")) |
|
1343 |
self.__debug( "Set switch " + varname + " ON") |
|
1344 |
self.__pageConflict.append(varname) |
|
1345 |
||
1346 |
elif varname == 'NOLINKTIMECODEGENERATION': |
|
1347 |
self.BuildVariant.AddOperation(raptor_data.Set("LTCG","")) |
|
1348 |
self.__debug( "Set switch " + varname + " OFF") |
|
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
1349 |
|
3 | 1350 |
elif varname == 'NOMULTIFILECOMPILATION': |
1351 |
self.BuildVariant.AddOperation(raptor_data.Set("MULTIFILE_ENABLED","")) |
|
1352 |
self.__debug( "Set switch " + varname + " OFF") |
|
1353 |
||
1354 |
elif varname == 'DEBUGGABLE': |
|
1355 |
if self.__debuggable != "udeb": |
|
1356 |
self.__debuggable = "udeb urel" |
|
1357 |
else: |
|
1358 |
self.__Raptor.Warn("DEBUGGABLE keyword ignored as DEBUGGABLE_UDEBONLY is already specified") |
|
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
1359 |
|
3 | 1360 |
elif varname == 'DEBUGGABLE_UDEBONLY': |
1361 |
if self.__debuggable != "": |
|
1362 |
self.__Raptor.Warn("DEBUGGABLE keyword has no effect as DEBUGGABLE or DEBUGGABLE_UDEBONLY is already set") |
|
1363 |
self.__debuggable = "udeb" |
|
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
1364 |
|
3 | 1365 |
elif varname == 'FEATUREVARIANT': |
1366 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,"1")) |
|
1367 |
self.featureVariant = True |
|
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
1368 |
|
9 | 1369 |
elif varname in ['COMPRESSTARGET', 'NOCOMPRESSTARGET', 'INFLATECOMPRESSTARGET', 'BYTEPAIRCOMPRESSTARGET']: |
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
1370 |
self.resolveCompressionKeyword(varname) |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
1371 |
|
3 | 1372 |
else: |
1373 |
self.__debug( "Set switch "+toks[0]+" ON") |
|
1374 |
self.BuildVariant.AddOperation(raptor_data.Set(prefix+varname, "1")) |
|
1375 |
||
1376 |
return "OK" |
|
1377 |
||
1378 |
def doAssignment(self,s,loc,toks): |
|
1379 |
self.__currentLineNumber += 1 |
|
1380 |
varname = toks[0].upper() |
|
1381 |
if varname=='TARGET': |
|
1382 |
(self.__TARGET, self.__TARGETEXT) = os.path.splitext(toks[1]) |
|
1383 |
self.__TARGETEXT = self.__TARGETEXT.lstrip('.') |
|
1384 |
||
1385 |
self.BuildVariant.AddOperation(raptor_data.Set("REQUESTEDTARGETEXT", self.__TARGETEXT.lower())) |
|
1386 |
||
1387 |
lowercase_TARGET = self.__TARGET.lower() |
|
1388 |
self.__debug("Set "+toks[0]+" to " + lowercase_TARGET) |
|
1389 |
self.__debug("Set REQUESTEDTARGETEXT to " + self.__TARGETEXT.lower()) |
|
1390 |
||
1391 |
self.BuildVariant.AddOperation(raptor_data.Set("TARGET", self.__TARGET)) |
|
1392 |
self.BuildVariant.AddOperation(raptor_data.Set("TARGET_lower", lowercase_TARGET)) |
|
1393 |
if lowercase_TARGET != self.__TARGET: |
|
1394 |
self.__debug("TARGET is not lowercase: '%s' - might cause BC problems." % self.__TARGET) |
|
1395 |
elif varname=='TARGETTYPE': |
|
1396 |
self.__debug("Set "+toks[0]+" to " + str(toks[1])) |
|
1397 |
self.__targettype=toks[1] |
|
1398 |
if self.__targettype.lower() == "none": |
|
1399 |
self.BuildVariant.AddOperation(raptor_data.Set("TARGET", "")) |
|
1400 |
self.BuildVariant.AddOperation(raptor_data.Set("TARGET_lower","")) |
|
1401 |
self.BuildVariant.AddOperation(raptor_data.Set("REQUESTEDTARGETEXT", "")) |
|
1402 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,toks[1].lower())) |
|
1403 |
||
1404 |
elif varname=='TARGETPATH': |
|
1405 |
value = toks[1].lower().replace('\\','/') |
|
1406 |
self.__debug("Set "+varname+" to " + value) |
|
1407 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, value)) |
|
1408 |
||
1409 |
elif varname=='OPTION' or varname=='LINKEROPTION': |
|
1410 |
self.__debug("Set "+toks[1]+varname+" to " + str(toks[2])) |
|
1411 |
self.BuildVariant.AddOperation(raptor_data.Append(varname+"_"+toks[1].upper()," ".join(toks[2]))) |
|
1412 |
||
1413 |
# Warn about OPTION ARMASM |
|
1414 |
if "armasm" in toks[1].lower(): |
|
1415 |
self.__Raptor.Warn(varname+" ARMASM has no effect (use OPTION ARMCC).") |
|
1416 |
||
1417 |
elif varname=='OPTION_REPLACE': |
|
1418 |
# Warn about OPTION_REPLACE ARMASM |
|
1419 |
if "armasm" in toks[1].lower(): |
|
1420 |
self.__Raptor.Warn("OPTION_REPLACE ARMASM has no effect (use OPTION_REPLACE ARMCC).") |
|
1421 |
else: |
|
1422 |
args = " ".join(toks[2]) |
|
1423 |
||
1424 |
searchReplacePairs = self.resolveOptionReplace(args) |
|
1425 |
||
1426 |
for searchReplacePair in searchReplacePairs: |
|
1427 |
self.__debug("Append %s to OPTION_REPLACE_%s", searchReplacePair, toks[1].upper()) |
|
1428 |
self.BuildVariant.AddOperation(raptor_data.Append(varname+"_"+toks[1].upper(),searchReplacePair)) |
|
1429 |
||
1430 |
elif varname=='SYSTEMINCLUDE' or varname=='USERINCLUDE': |
|
1431 |
for path in toks[1]: |
|
1432 |
resolved = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, path) |
|
1433 |
self.BuildVariant.AddOperation(raptor_data.Append(varname,resolved)) |
|
1434 |
||
1435 |
if varname=='SYSTEMINCLUDE': |
|
1436 |
self.__systeminclude += ' ' + resolved |
|
1437 |
self.__debug(" %s = %s",varname, self.__systeminclude) |
|
1438 |
else: |
|
1439 |
self.__userinclude += ' ' + resolved |
|
1440 |
self.__debug(" %s = %s",varname, self.__userinclude) |
|
1441 |
||
1442 |
self.__debug("Appending %s to %s",resolved, varname) |
|
1443 |
||
1444 |
self.__systeminclude = self.__systeminclude.strip() |
|
1445 |
self.__systeminclude = self.__systeminclude.rstrip('\/') |
|
1446 |
self.__userinclude = self.__userinclude.strip() |
|
1447 |
self.__userinclude = self.__userinclude.rstrip('\/') |
|
1448 |
||
1449 |
elif varname=='EXPORTLIBRARY': |
|
1450 |
# Remove extension from the EXPORTLIBRARY name |
|
1451 |
libName = toks[1].rsplit(".", 1)[0] |
|
1452 |
self.__debug("Set "+varname+" to " + libName) |
|
1453 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,"".join(libName))) |
|
1454 |
||
1455 |
elif varname=='CAPABILITY': |
|
1456 |
for cap in toks[1]: |
|
151
d4605037b3b2
set file format of raptor_meta.py to unix when on unix
timothy.murphy@nokia.com
parents:
144
diff
changeset
|
1457 |
cap = cap.lower() |
3 | 1458 |
self.__debug("Setting "+toks[0]+": " + cap) |
160 | 1459 |
if not cap.startswith("-"): |
1460 |
if not cap.startswith("+"): |
|
1461 |
cap = "+" + cap |
|
5 | 1462 |
self.capabilities.append(cap) |
3 | 1463 |
elif varname=='DEFFILE': |
1464 |
self.__defFileRoot = self.__currentMmpFile |
|
1465 |
self.deffile = toks[1] |
|
1466 |
elif varname=='LINKAS': |
|
1467 |
self.__debug("Set "+toks[0]+" OPTION to " + str(toks[1])) |
|
1468 |
self.__LINKAS = toks[1] |
|
1469 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, toks[1])) |
|
1470 |
elif varname=='SECUREID' or varname=='VENDORID': |
|
1471 |
hexoutput = MMPRaptorBackend.canonicalUID(toks[1]) |
|
1472 |
self.__debug("Set "+toks[0]+" OPTION to " + hexoutput) |
|
1473 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, hexoutput)) |
|
1474 |
elif varname=='VERSION': |
|
1475 |
if toks[-1] == "EXPLICIT": |
|
1476 |
self.__explicitversion = True |
|
1477 |
self.BuildVariant.AddOperation(raptor_data.Set("EXPLICITVERSION", "1")) |
|
1478 |
||
1479 |
vm = re.match(r'^(\d+)(\.(\d+))?$', toks[1]) |
|
1480 |
if vm is not None: |
|
1481 |
version = vm.groups() |
|
1482 |
# the major version number |
|
1483 |
major = int(version[0],10) |
|
1484 |
||
1485 |
# add in the minor number |
|
1486 |
minor = 0 |
|
1487 |
if version[1] is not None: |
|
1488 |
minor = int(version[2],10) |
|
1489 |
else: |
|
1490 |
self.__Raptor.Warn("VERSION (%s) missing '.minor' in %s, using '.0'" % (toks[1],self.__currentMmpFile)) |
|
1491 |
||
1492 |
self.__versionhex = "%04x%04x" % (major, minor) |
|
1493 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, "%d.%d" %(major, minor))) |
|
1494 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"HEX", self.__versionhex)) |
|
1495 |
self.__debug("Set "+toks[0]+" OPTION to " + toks[1]) |
|
1496 |
self.__debug("Set "+toks[0]+"HEX OPTION to " + "%04x%04x" % (major,minor)) |
|
1497 |
||
1498 |
else: |
|
1499 |
self.__Raptor.Warn("Invalid version supplied to VERSION (%s), using default value" % toks[1]) |
|
1500 |
||
1501 |
elif varname=='EPOCHEAPSIZE': |
|
1502 |
# Standardise on sending hex numbers to the FLMS. |
|
1503 |
||
1504 |
if toks[1].lower().startswith('0x'): |
|
1505 |
min = long(toks[1],16) |
|
1506 |
else: |
|
1507 |
min = long(toks[1],10) |
|
1508 |
||
1509 |
if toks[2].lower().startswith('0x'): |
|
1510 |
max = long(toks[2],16) |
|
1511 |
else: |
|
1512 |
max = long(toks[2],10) |
|
1513 |
||
1514 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MIN", "%x" % min)) |
|
1515 |
self.__debug("Set "+varname+"MIN OPTION to '%x' (hex)" % min ) |
|
1516 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MAX", "%x" % max)) |
|
1517 |
self.__debug("Set "+varname+"MAX OPTION to '%x' (hex)" % max ) |
|
1518 |
||
1519 |
# Some toolchains require decimal versions of the min/max values, converted to KB and |
|
1520 |
# rounded up to the next 1KB boundary |
|
1521 |
min_dec_kb = (int(min) + 1023) / 1024 |
|
1522 |
max_dec_kb = (int(max) + 1023) / 1024 |
|
1523 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MIN_DEC_KB", "%d" % min_dec_kb)) |
|
1524 |
self.__debug("Set "+varname+"MIN OPTION KB to '%d' (dec)" % min_dec_kb ) |
|
1525 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MAX_DEC_KB", "%d" % max_dec_kb)) |
|
1526 |
self.__debug("Set "+varname+"MAX OPTION KB to '%d' (dec)" % max_dec_kb ) |
|
1527 |
||
1528 |
elif varname=='EPOCSTACKSIZE': |
|
1529 |
if toks[1].lower().startswith('0x'): |
|
1530 |
stack = long(toks[1],16) |
|
1531 |
else: |
|
1532 |
stack = long(toks[1],10) |
|
1533 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, "%x" % stack)) |
|
1534 |
self.__debug("Set "+varname+" OPTION to '%x' (hex)" % stack ) |
|
1535 |
elif varname=='EPOCPROCESSPRIORITY': |
|
1536 |
# low, background, foreground, high, windowserver, fileserver, realtimeserver or supervisor |
|
1537 |
# These are case insensitive in metadata entries, but must be mapped to a static case pattern for use |
|
1538 |
prio = toks[1].lower() |
|
1539 |
||
1540 |
# NOTE: Original validation here didn't actually work. This has been corrected to provide an error, but probably needs re-examination. |
|
1541 |
if not MMPRaptorBackend.epoc32priorities.has_key(prio): |
|
1542 |
self.__Raptor.Error("Priority setting '%s' is not a valid priority - should be one of %s.", prio, MMPRaptorBackend.epoc32priorities.values()) |
|
1543 |
else: |
|
1544 |
self.__debug("Set "+toks[0]+" to " + MMPRaptorBackend.epoc32priorities[prio]) |
|
1545 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,MMPRaptorBackend.epoc32priorities[prio])) |
|
1546 |
elif varname=='ROMTARGET' or varname=='RAMTARGET': |
|
1547 |
if len(toks) == 1: |
|
1548 |
self.__debug("Set "+toks[0]+" to <none>" ) |
|
1549 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,"<none>")) |
|
1550 |
else: |
|
1551 |
toks1 = str(toks[1]).replace("\\","/") |
|
1552 |
if toks1.find(","): |
|
1553 |
toks1 = re.sub("[,'\[\]]", "", toks1).replace("//","/") |
|
1554 |
self.__debug("Set "+toks[0]+" to " + toks1) |
|
1555 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,toks1)) |
|
9 | 1556 |
elif varname=='APPLY': |
1557 |
self.ApplyVariants.append(toks[1]) |
|
3 | 1558 |
else: |
1559 |
self.__debug("Set "+toks[0]+" to " + str(toks[1])) |
|
1560 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,"".join(toks[1]))) |
|
1561 |
||
1562 |
if varname=='LINKAS': |
|
1563 |
self.__LINKAS = toks[1] |
|
1564 |
||
1565 |
return "OK" |
|
1566 |
||
1567 |
def doAppend(self,s,loc,toks): |
|
1568 |
self.__currentLineNumber += 1 |
|
1569 |
"""MMP command |
|
1570 |
""" |
|
1571 |
name=toks[0].upper() |
|
1572 |
if len(toks) == 1: |
|
1573 |
# list can be empty e.g. MACRO _FRED_ when fred it defined in the HRH |
|
1574 |
# causes us to see just "MACRO" in the input - it is valid to ignore this |
|
1575 |
self.__debug("Empty append list for " + name) |
|
1576 |
return "OK" |
|
1577 |
self.__debug("Append to "+name+" the values: " +str(toks[1])) |
|
1578 |
||
1579 |
if name=='MACRO': |
|
1580 |
name='MMPDEFS' |
|
1581 |
elif name=='LANG': |
|
1582 |
# don't break the environment variable |
|
1583 |
name='LANGUAGES' |
|
1584 |
||
1585 |
for item in toks[1]: |
|
1586 |
if name=='MMPDEFS': |
|
1587 |
# Unquote any macros since the FLM does it anyhow |
|
1588 |
if item.startswith('"') and item.endswith('"') \ |
|
1589 |
or item.startswith("'") and item.endswith("'"): |
|
1590 |
item = item.strip("'\"") |
|
1591 |
if name=='LIBRARY' or name=='DEBUGLIBRARY': |
|
1592 |
im = MMPRaptorBackend.library_re.match(item) |
|
1593 |
if not im: |
|
1594 |
self.__error("LIBRARY: %s Seems to have an invalid name.\nExpected xxxx.lib or xxxx.dso\n where xxxx might be\n\tname or \n\tname(n,m) where n is a major version number and m is a minor version number\n" %item) |
|
1595 |
d = im.groupdict() |
|
1596 |
||
1597 |
item = d['name'] |
|
1598 |
if d['version'] is not None: |
|
1599 |
item += "{%04x%04x}" % (int(d['major']), int(d['minor'])) |
|
1600 |
item += ".dso" |
|
1601 |
elif name=='STATICLIBRARY': |
|
1602 |
# the FLM will decide on the ending appropriate to the platform |
|
1603 |
item = re.sub(r"^(.*)\.[Ll][Ii][Bb]$",r"\1", item) |
|
1604 |
elif name=="LANGUAGES": |
|
1605 |
item = item.lower() |
|
1606 |
elif (name=="WIN32_LIBRARY" and (item.startswith(".") or re.search(r'[\\|/]',item))) \ |
|
1607 |
or (name=="WIN32_RESOURCE"): |
|
1608 |
# Relatively pathed win32 libraries, and all win32 resources, are resolved in relation |
|
1609 |
# to the wrapper bld.inf file in which their .mmp file is specified. This equates to |
|
1610 |
# the current working directory in ABLD operation. |
|
1611 |
item = raptor_utilities.resolveSymbianPath(self.__bldInfFilename, item) |
|
1612 |
||
1613 |
self.BuildVariant.AddOperation(raptor_data.Append(name,item," ")) |
|
1614 |
||
1615 |
# maintain a debug library list, the same as LIBRARY but with DEBUGLIBRARY values |
|
1616 |
# appended as they are encountered |
|
1617 |
if name=='LIBRARY' or name=='DEBUGLIBRARY': |
|
1618 |
self.BuildVariant.AddOperation(raptor_data.Append("LIBRARY_DEBUG",item," ")) |
|
1619 |
||
1620 |
return "OK" |
|
1621 |
||
1622 |
def canonicalUID(number): |
|
1623 |
""" convert a UID string into an 8 digit hexadecimal string without leading 0x """ |
|
1624 |
if number.lower().startswith("0x"): |
|
1625 |
n = int(number,16) |
|
1626 |
else: |
|
1627 |
n = int(number,10) |
|
1628 |
||
1629 |
return "%08x" % n |
|
1630 |
||
1631 |
canonicalUID = staticmethod(canonicalUID) |
|
1632 |
||
1633 |
def doUIDAssignment(self,s,loc,toks): |
|
1634 |
"""A single UID command results in a number of spec variables""" |
|
1635 |
self.__currentLineNumber += 1 |
|
1636 |
||
1637 |
hexoutput = MMPRaptorBackend.canonicalUID(toks[1][0]) |
|
1638 |
self.__debug( "Set UID2 to %s" % hexoutput ) |
|
1639 |
self.BuildVariant.AddOperation(raptor_data.Set("UID2", hexoutput)) |
|
1640 |
||
1641 |
if len(toks[1]) > 1: |
|
1642 |
hexoutput = MMPRaptorBackend.canonicalUID(toks[1][1]) |
|
1643 |
self.__debug( "Set UID3 to %s" % hexoutput) |
|
1644 |
self.BuildVariant.AddOperation(raptor_data.Set("UID3", hexoutput)) |
|
1645 |
||
1646 |
self.__debug( "done set UID") |
|
1647 |
return "OK" |
|
1648 |
||
1649 |
def doSourcePathAssignment(self,s,loc,toks): |
|
1650 |
self.__currentLineNumber += 1 |
|
1651 |
self.__sourcepath = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, toks[1]) |
|
1652 |
self.__debug( "Remembering self.sourcepath state: "+str(toks[0])+" is now " + self.__sourcepath) |
|
1653 |
self.__debug("selfcurrentMmpFile: " + self.__currentMmpFile) |
|
1654 |
return "OK" |
|
1655 |
||
1656 |
||
1657 |
def doSourceAssignment(self,s,loc,toks): |
|
1658 |
self.__currentLineNumber += 1 |
|
1659 |
self.__debug( "Setting "+toks[0]+" to " + str(toks[1])) |
|
1660 |
for file in toks[1]: |
|
1661 |
# file is always relative to sourcepath but some MMP files |
|
1662 |
# have items that begin with a slash... |
|
1663 |
file = file.lstrip("/") |
|
1664 |
source = generic_path.Join(self.__sourcepath, file) |
|
1665 |
||
1666 |
# If the SOURCEPATH itself begins with a '/', then dont look up the caseless version, since |
|
1667 |
# we don't know at this time what $(EPOCROOT) will evaluate to. |
|
1668 |
if source.GetLocalString().startswith('$(EPOCROOT)'): |
|
1669 |
self.sources.append(str(source)) |
|
1670 |
self.__debug("Append SOURCE " + str(source)) |
|
1671 |
||
1672 |
else: |
|
1673 |
foundsource = source.FindCaseless() |
|
1674 |
if foundsource == None: |
|
1675 |
# Hope that the file will be generated later |
|
1676 |
self.__debug("Sourcefile not found: %s" % source) |
|
1677 |
foundsource = source |
|
1678 |
||
1679 |
self.sources.append(str(foundsource)) |
|
1680 |
self.__debug("Append SOURCE " + str(foundsource)) |
|
1681 |
||
1682 |
||
1683 |
self.__debug(" sourcepath: " + self.__sourcepath) |
|
1684 |
return "OK" |
|
1685 |
||
1686 |
# Resource |
|
1687 |
||
1688 |
def doOldResourceAssignment(self,s,loc,toks): |
|
1689 |
# Technically deprecated, but still used, so... |
|
1690 |
self.__currentLineNumber += 1 |
|
1691 |
self.__debug("Processing old-style "+toks[0]+" "+str(toks[1])) |
|
1692 |
||
1693 |
sysRes = (toks[0].lower() == "systemresource") |
|
1694 |
||
1695 |
for rss in toks[1]: |
|
1696 |
variant = raptor_data.Variant() |
|
1697 |
||
1698 |
source = generic_path.Join(self.__sourcepath, rss) |
|
1699 |
variant.AddOperation(raptor_data.Set("SOURCE", str(source))) |
|
1700 |
self.__resourceFiles.append(str(source)) |
|
1701 |
||
1702 |
target = source.File().rsplit(".", 1)[0] # remove the extension |
|
1703 |
variant.AddOperation(raptor_data.Set("TARGET", target)) |
|
1704 |
variant.AddOperation(raptor_data.Set("TARGET_lower", target.lower())) |
|
1705 |
||
1706 |
header = target.lower() + ".rsg" # filename policy |
|
1707 |
variant.AddOperation(raptor_data.Set("HEADER", header)) |
|
1708 |
||
1709 |
if sysRes: |
|
1710 |
dsrtp = self.getDefaultSystemResourceTargetPath() |
|
1711 |
variant.AddOperation(raptor_data.Set("TARGETPATH", dsrtp)) |
|
1712 |
||
1713 |
self.ResourceVariants.append(variant) |
|
1714 |
||
1715 |
return "OK" |
|
1716 |
||
1717 |
def getDefaultSystemResourceTargetPath(self): |
|
1718 |
# the default systemresource TARGETPATH value should come from the |
|
1719 |
# configuration rather than being hard-coded here. Then again, this |
|
1720 |
# should really be deprecated away into oblivion... |
|
1721 |
return "system/data" |
|
1722 |
||
1723 |
||
1724 |
def getDefaultResourceTargetPath(self, targettype): |
|
1725 |
# the different default TARGETPATH values should come from the |
|
1726 |
# configuration rather than being hard-coded here. |
|
392
8f0708af8451
release note: SF Bug 2308 - [Raptor]: PLUGIN3 TARGETTYPEs don't set resource output offsets correctly
Jon Chatten
parents:
388
diff
changeset
|
1727 |
if targettype in ["plugin", "plugin3"]: |
3 | 1728 |
return "resource/plugins" |
1729 |
if targettype == "pdl": |
|
1730 |
return "resource/printers" |
|
1731 |
return "" |
|
1732 |
||
1733 |
def resolveOptionReplace(self, content): |
|
1734 |
""" |
|
1735 |
Constructs search/replace pairs based on .mmp OPTION_REPLACE entries for use on tool command lines |
|
1736 |
within FLMS. |
|
1737 |
||
1738 |
Depending on what's supplied to OPTION_REPLACE <TOOL>, the core part of the <TOOL> command line |
|
1739 |
in the relevant FLM will have search and replace actions performed on it post-expansion (but pre- |
|
1740 |
any OPTION <TOOL> additions). |
|
1741 |
||
1742 |
In terms of logic, we try to follow what ABLD does, as the current behaviour is undocumented. |
|
1743 |
What happens is a little inconsistent, and best described by some generic examples: |
|
1744 |
||
1745 |
OPTION_REPLACE TOOL existing_option replacement_value |
|
1746 |
||
1747 |
Replace all instances of "option existing_value" with "option replacement_value" |
|
1748 |
||
1749 |
OPTION_REPLACE TOOL existing_option replacement_option |
|
1750 |
||
1751 |
Replace all instances of "existing_option" with "replacement_option". |
|
1752 |
||
1753 |
If "existing_option" is present in isolation then a removal is performed. |
|
1754 |
||
1755 |
Any values encountered that don't follow an option are ignored. |
|
1756 |
Options are identified as being prefixed with either '-' or '--'. |
|
1757 |
||
1758 |
The front-end processes each OPTION_REPLACE entry and then appends one or more search/replace pairs |
|
1759 |
to an OPTION_REPLACE_<TOOL> variable in the following format: |
|
1760 |
||
1761 |
search<->replace |
|
1762 |
""" |
|
1763 |
# Note that, for compatibility reasons, the following is mostly a port to Python of the corresponding |
|
1764 |
# ABLD Perl, and hence maintains ABLD's idiosyncrasies in what it achieves |
|
1765 |
||
1766 |
searchReplacePairs = [] |
|
1767 |
matches = re.findall("-{1,2}\S+\s*(?!-)\S*",content) |
|
1768 |
||
1769 |
if matches: |
|
1770 |
# reverse so we can process as a stack whilst retaining original order |
|
1771 |
matches.reverse() |
|
1772 |
||
1773 |
while (len(matches)): |
|
1774 |
match = matches.pop() |
|
1775 |
||
1776 |
standaloneMatch = re.match('^(?P<option>\S+)\s+(?P<value>\S+)$', match) |
|
1777 |
||
1778 |
if (standaloneMatch): |
|
1779 |
# Option listed standalone with a replacement value |
|
1780 |
# Example: |
|
1781 |
# OPTION_REPLACE ARMCC --cpu 6 |
|
1782 |
# Intention: |
|
1783 |
# Replace instances of "--cpu <something>" with "--cpu 6" |
|
1784 |
||
1785 |
# Substitute any existing "option <existing_value>" instances with a single word |
|
1786 |
# "@@<existing_value>" for later replacement |
|
1787 |
searchReplacePairs.append('%s <->@@' % standaloneMatch.group('option')) |
|
1788 |
||
1789 |
# Replace "@@<existing_value>" entries from above with "option <new_value>" entries |
|
1790 |
# A pattern substitution is used to cover pre-existing values |
|
1791 |
searchReplacePairs.append('@@%%<->%s %s' % (standaloneMatch.group('option'), standaloneMatch.group('value'))) |
|
1792 |
else: |
|
1793 |
# Options specified in search/replace pairs with optional values |
|
1794 |
# Example: |
|
1795 |
# OPTION_REPLACE ARMCC --O2 --O3 |
|
1796 |
# Intention: |
|
1797 |
# Replace instances of "--O2" with "--O3" |
|
1798 |
||
1799 |
# At this point we will be looking at just the search option - there may or may not |
|
1800 |
# be a replacement to consider |
|
1801 |
search = match |
|
1802 |
replace = "" |
|
1803 |
if len(matches): |
|
1804 |
replace = matches.pop() |
|
5 | 1805 |
|
3 | 1806 |
searchReplacePairs.append('%s<->%s' % (search, replace)) |
1807 |
||
1808 |
# Replace spaces to maintain word-based grouping in downstream makefile lists |
|
1809 |
for i in range(0,len(searchReplacePairs)): |
|
1810 |
searchReplacePairs[i] = searchReplacePairs[i].replace(' ','%20') |
|
1811 |
||
1812 |
return searchReplacePairs |
|
1813 |
||
1814 |
def doStartResource(self,s,loc,toks): |
|
1815 |
self.__currentLineNumber += 1 |
|
1816 |
self.__debug("Start RESOURCE "+toks[1]) |
|
1817 |
||
1818 |
self.__current_resource = generic_path.Path(self.__sourcepath, toks[1]) |
|
1819 |
self.__current_resource = str(self.__current_resource) |
|
1820 |
||
1821 |
self.__debug("sourcepath: " + self.__sourcepath) |
|
1822 |
self.__debug("self.__current_resource source: " + toks[1]) |
|
1823 |
self.__debug("adjusted self.__current_resource source=" + self.__current_resource) |
|
1824 |
||
1825 |
self.__currentResourceVariant = raptor_data.Variant() |
|
1826 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("SOURCE", self.__current_resource)) |
|
1827 |
self.__resourceFiles.append(self.__current_resource) |
|
1828 |
||
1829 |
# The target name is the basename of the resource without the extension |
|
1830 |
# e.g. "/fred/129ab34f.rss" would have a target name of "129ab34f" |
|
1831 |
target = self.__current_resource.rsplit("/",1)[-1] |
|
1832 |
target = target.rsplit(".",1)[0] |
|
1833 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("TARGET", target)) |
|
1834 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("TARGET_lower", target.lower())) |
|
1835 |
self.__headerspecified = False |
|
1836 |
self.__headeronlyspecified = False |
|
1837 |
self.__current_resource_header = target.lower() + ".rsg" |
|
1838 |
||
1839 |
return "OK" |
|
1840 |
||
1841 |
def doResourceAssignment(self,s,loc,toks): |
|
1842 |
""" Assign variables for resource files """ |
|
1843 |
self.__currentLineNumber += 1 |
|
1844 |
varname = toks[0].upper() # the mmp keyword |
|
1845 |
varvalue = "".join(toks[1]) |
|
1846 |
||
1847 |
# Get rid of any .rsc extension because the build system |
|
1848 |
# needs to have it stripped off to calculate other names |
|
1849 |
# for other purposes and # we aren't going to make it |
|
1850 |
# optional anyhow. |
|
1851 |
if varname == "TARGET": |
|
1852 |
target_withext = varvalue.rsplit("/\\",1)[-1] |
|
1853 |
target = target_withext.rsplit(".",1)[0] |
|
1854 |
self.__current_resource_header = target.lower() + ".rsg" |
|
1855 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("TARGET_lower", target.lower())) |
|
1856 |
self.__debug("Set resource "+varname+" to " + target) |
|
1857 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(varname,target)) |
|
1858 |
if varname == "TARGETPATH": |
|
1859 |
varvalue=varvalue.replace('\\','/') |
|
1860 |
self.__debug("Set resource "+varname+" to " + varvalue) |
|
1861 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(varname,varvalue)) |
|
1862 |
else: |
|
1863 |
self.__debug("Set resource "+varname+" to " + varvalue) |
|
1864 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(varname,varvalue)) |
|
1865 |
return "OK" |
|
1866 |
||
1867 |
def doResourceAppend(self,s,loc,toks): |
|
1868 |
self.__currentLineNumber += 1 |
|
1869 |
self.__debug("Append resource to "+toks[0]+" the values: " +str(toks[1])) |
|
1870 |
varname = toks[0].upper() |
|
1871 |
||
1872 |
# we cannot use LANG as it interferes with the environment |
|
1873 |
if varname == "LANG": |
|
1874 |
varname = "LANGUAGES" |
|
1875 |
||
1876 |
for item in toks[1]: |
|
1877 |
if varname == "LANGUAGES": |
|
1878 |
item = item.lower() |
|
1879 |
self.__currentResourceVariant.AddOperation(raptor_data.Append(varname,item)) |
|
1880 |
return "OK" |
|
1881 |
||
1882 |
def doResourceSetSwitch(self,s,loc,toks): |
|
1883 |
self.__currentLineNumber += 1 |
|
1884 |
name = toks[0].upper() |
|
1885 |
||
1886 |
if name == "HEADER": |
|
1887 |
self.__headerspecified = True |
|
1888 |
||
1889 |
elif name == "HEADERONLY": |
|
1890 |
self.__headeronlyspecified = True |
|
1891 |
||
1892 |
else: |
|
1893 |
value = "1" |
|
1894 |
self.__debug( "Set resource switch " + name + " " + value) |
|
1895 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(name, value)) |
|
1896 |
||
1897 |
return "OK" |
|
1898 |
||
1899 |
def doEndResource(self,s,loc,toks): |
|
1900 |
self.__currentLineNumber += 1 |
|
1901 |
||
1902 |
# Header name can change, depening if there was a TARGET defined or not, so it must be appended at the end |
|
1903 |
if self.__headerspecified: |
|
1904 |
self.__debug("Set resource switch HEADER " + self.__current_resource_header) |
|
1905 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("HEADER", self.__current_resource_header)) |
|
1906 |
||
1907 |
if self.__headeronlyspecified: |
|
1908 |
self.__debug("Set resource switch HEADERONLY " + self.__current_resource_header) |
|
1909 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("HEADER", self.__current_resource_header)) |
|
1910 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("HEADERONLY", "True")) |
|
1911 |
||
1912 |
self.__debug("End RESOURCE") |
|
1913 |
self.ResourceVariants.append(self.__currentResourceVariant) |
|
1914 |
self.__currentResourceVariant = None |
|
1915 |
self.__current_resource = "" |
|
1916 |
return "OK" |
|
1917 |
||
1918 |
# Bitmap |
|
1919 |
||
1920 |
def doStartBitmap(self,s,loc,toks): |
|
1921 |
self.__currentLineNumber += 1 |
|
1922 |
self.__debug("Start BITMAP "+toks[1]) |
|
1923 |
||
5 | 1924 |
self.__currentBitmapVariant = raptor_data.Variant(name = toks[1].replace('.','_')) |
3 | 1925 |
# Use BMTARGET and BMTARGET_lower because that prevents |
1926 |
# confusion with the TARGET and TARGET_lower of our parent MMP |
|
1927 |
# when setting the OUTPUTPATH. This in turn allows us to |
|
1928 |
# not get tripped up by multiple mbms being generated with |
|
1929 |
# the same name to the same directory. |
|
1930 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set("BMTARGET", toks[1])) |
|
1931 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set("BMTARGET_lower", toks[1].lower())) |
|
1932 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set("SOURCE", "")) |
|
1933 |
return "OK" |
|
1934 |
||
1935 |
def doBitmapAssignment(self,s,loc,toks): |
|
1936 |
self.__currentLineNumber += 1 |
|
1937 |
self.__debug("Set bitmap "+toks[0]+" to " + str(toks[1])) |
|
1938 |
name = toks[0].upper() |
|
1939 |
value = "".join(toks[1]) |
|
1940 |
if name == "TARGETPATH": |
|
1941 |
value = value.replace('\\','/') |
|
1942 |
||
1943 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set(name,value)) |
|
1944 |
return "OK" |
|
1945 |
||
1946 |
def doBitmapSourcePathAssignment(self,s,loc,toks): |
|
1947 |
self.__currentLineNumber += 1 |
|
1948 |
self.__debug("Previous bitmap sourcepath:" + self.__bitmapSourcepath) |
|
1949 |
self.__bitmapSourcepath = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, toks[1]) |
|
1950 |
self.__debug("New bitmap sourcepath: " + self.__bitmapSourcepath) |
|
1951 |
||
1952 |
def doBitmapSourceAssignment(self,s,loc,toks): |
|
1953 |
self.__currentLineNumber += 1 |
|
1954 |
self.__debug( "Setting "+toks[0]+" to " + str(toks[1])) |
|
1955 |
# The first "source" is the colour depth for all the others. |
|
1956 |
# The depth format is b[,m] where b is the bitmap depth and m is |
|
1957 |
# the mask depth. |
|
1958 |
# Valid values for b are: 1 2 4 8 c4 c8 c12 c16 c24 c32 c32a (?) |
|
1959 |
# Valid values for m are: 1 8 (any number?) |
|
1960 |
# |
|
1961 |
# If m is specified then the bitmaps are in pairs: b0 m0 b1 m1... |
|
1962 |
# If m is not specified then there are no masks, just bitmaps: b0 b1... |
|
1963 |
colordepth = toks[1][0].lower() |
|
1964 |
if "," in colordepth: |
|
1965 |
(bitmapdepth, maskdepth) = colordepth.split(",") |
|
1966 |
else: |
|
1967 |
bitmapdepth = colordepth |
|
1968 |
maskdepth = 0 |
|
1969 |
||
1970 |
sources="" |
|
1971 |
mask = False |
|
1972 |
for file in toks[1][1:]: |
|
1973 |
path = generic_path.Join(self.__bitmapSourcepath, file) |
|
1974 |
if sources: |
|
1975 |
sources += " " |
|
1976 |
if mask: |
|
1977 |
sources += "DEPTH=" + maskdepth + " FILE=" + str(path) |
|
1978 |
else: |
|
1979 |
sources += "DEPTH=" + bitmapdepth + " FILE=" + str(path) |
|
1980 |
if maskdepth: |
|
1981 |
mask = not mask |
|
1982 |
self.__debug("sources: " + sources) |
|
1983 |
self.__currentBitmapVariant.AddOperation(raptor_data.Append("SOURCE", sources)) |
|
1984 |
return "OK" |
|
1985 |
||
1986 |
def doBitmapSetSwitch(self,s,loc,toks): |
|
1987 |
self.__currentLineNumber += 1 |
|
1988 |
self.__debug( "Set bitmap switch "+toks[0]+" ON") |
|
1989 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set(toks[0].upper(), "1")) |
|
1990 |
return "OK" |
|
1991 |
||
1992 |
def doEndBitmap(self,s,loc,toks): |
|
1993 |
self.__currentLineNumber += 1 |
|
1994 |
self.__bitmapSourcepath = self.__sourcepath |
|
1995 |
self.BitmapVariants.append(self.__currentBitmapVariant) |
|
1996 |
self.__currentBitmapVariant = None |
|
1997 |
self.__debug("End BITMAP") |
|
1998 |
return "OK" |
|
1999 |
||
2000 |
# Stringtable |
|
2001 |
||
2002 |
def doStartStringTable(self,s,loc,toks): |
|
2003 |
self.__currentLineNumber += 1 |
|
2004 |
self.__debug( "Start STRINGTABLE "+toks[1]) |
|
2005 |
||
2006 |
specstringtable = generic_path.Join(self.__sourcepath, toks[1]) |
|
2007 |
uniqname = specstringtable.File().replace('.','_') # corrected, filename only |
|
2008 |
source = str(specstringtable.FindCaseless()) |
|
2009 |
||
2010 |
self.__debug("sourcepath: " + self.__sourcepath) |
|
2011 |
self.__debug("stringtable: " + toks[1]) |
|
2012 |
self.__debug("adjusted stringtable source=" + source) |
|
2013 |
||
5 | 2014 |
self.__currentStringTableVariant = raptor_data.Variant(name = uniqname) |
3 | 2015 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set("SOURCE", source)) |
2016 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set("EXPORTPATH", "")) |
|
2017 |
self.__stringtableExported = False |
|
2018 |
||
2019 |
# The target name by default is the name of the stringtable without the extension |
|
2020 |
# e.g. the stringtable "/fred/http.st" would have a default target name of "http" |
|
2021 |
stringtable_withext = specstringtable.File() |
|
2022 |
self.__stringtable = stringtable_withext.rsplit(".",1)[0].lower() |
|
2023 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set("TARGET", self.__stringtable)) |
|
2024 |
||
2025 |
self.__stringtableHeaderonlyspecified = False |
|
2026 |
||
2027 |
return "OK" |
|
2028 |
||
2029 |
def doStringTableAssignment(self,s,loc,toks): |
|
2030 |
""" Assign variables for stringtables """ |
|
2031 |
self.__currentLineNumber += 1 |
|
2032 |
varname = toks[0].upper() # the mmp keyword |
|
2033 |
varvalue = "".join(toks[1]) |
|
2034 |
||
2035 |
# Get rid of any .rsc extension because the build system |
|
2036 |
# needs to have it stripped off to calculate other names |
|
2037 |
# for other purposes and # we aren't going to make it |
|
2038 |
# optional anyhow. |
|
2039 |
if varname == "EXPORTPATH": |
|
2040 |
finalvalue = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, varvalue) |
|
2041 |
self.__stringtableExported = True |
|
2042 |
else: |
|
2043 |
finalvalue = varvalue |
|
2044 |
||
2045 |
self.__debug("Set stringtable "+varname+" to " + finalvalue) |
|
2046 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set(varname,finalvalue)) |
|
2047 |
return "OK" |
|
2048 |
||
2049 |
def doStringTableSetSwitch(self,s,loc,toks): |
|
2050 |
self.__currentLineNumber += 1 |
|
2051 |
if toks[0].upper()== "HEADERONLY": |
|
2052 |
self.__stringtableHeaderonlyspecified = True |
|
2053 |
self.__debug( "Set stringtable switch "+toks[0]+" ON") |
|
2054 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set(toks[0].upper(), "1")) |
|
2055 |
return "OK" |
|
2056 |
||
2057 |
def doEndStringTable(self,s,loc,toks): |
|
2058 |
self.__currentLineNumber += 1 |
|
2059 |
||
2060 |
if not self.__stringtableExported: |
|
2061 |
# There was no EXPORTPATH specified for this stringtable |
|
2062 |
# so for our other code to be able to reference it we |
|
2063 |
# must add the path of the generated location to the userinclude path |
|
2064 |
||
2065 |
ipath = "$(OUTPUTPATH)" |
|
2066 |
self.BuildVariant.AddOperation(raptor_data.Append("USERINCLUDE",ipath)) |
|
2067 |
self.__userinclude += ' ' + ipath |
|
2068 |
self.__debug(" USERINCLUDE = %s", self.__userinclude) |
|
2069 |
self.__userinclude.strip() |
|
2070 |
||
2071 |
self.StringTableVariants.append(self.__currentStringTableVariant) |
|
2072 |
self.__currentStringTableVariant = None |
|
2073 |
self.__debug("End STRINGTABLE") |
|
2074 |
if not self.__stringtableHeaderonlyspecified: |
|
2075 |
# Have to assume that this is where the cpp file will be. This has to be maintained |
|
2076 |
# in sync with the FLM's idea of where this file should be. We need a better way. |
|
2077 |
# Interfaces also need outputs that allow other interfaces to refer to their outputs |
|
2078 |
# without having to "know" where they will be. |
|
2079 |
self.sources.append('$(OUTPUTPATH)/' + self.__stringtable + '.cpp') |
|
2080 |
return "OK" |
|
2081 |
||
2082 |
||
2083 |
def doUnknownStatement(self,s,loc,toks): |
|
2084 |
self.__warn("%s (%d) : Unrecognised Keyword %s", self.__currentMmpFile, self.__currentLineNumber, str(toks)) |
|
2085 |
self.__currentLineNumber += 1 |
|
2086 |
return "OK" |
|
2087 |
||
2088 |
||
2089 |
def doUnknownBlock(self,s,loc,toks): |
|
2090 |
self.__warn("%s (%d) : Unrecognised Block %s", self.__currentMmpFile, self.__currentLineNumber, str(toks)) |
|
2091 |
self.__currentLineNumber += 1 |
|
2092 |
return "OK" |
|
2093 |
||
2094 |
def doDeprecated(self,s,loc,toks): |
|
2095 |
self.__debug( "Deprecated command " + str(toks)) |
|
2096 |
self.__warn("%s (%d) : %s is deprecated .mmp file syntax", self.__currentMmpFile, self.__currentLineNumber, str(toks)) |
|
2097 |
self.__currentLineNumber += 1 |
|
2098 |
return "OK" |
|
2099 |
||
2100 |
def doNothing(self): |
|
2101 |
self.__currentLineNumber += 1 |
|
2102 |
return "OK" |
|
2103 |
||
2104 |
def finalise(self, aBuildPlatform): |
|
2105 |
"""Post-processing of data that is only applicable in the context of a fully |
|
2106 |
processed .mmp file.""" |
|
2107 |
resolvedDefFile = "" |
|
2108 |
||
2109 |
if self.__TARGET: |
|
2110 |
defaultRootName = self.__TARGET |
|
2111 |
if self.__TARGETEXT!="": |
|
2112 |
defaultRootName += "." + self.__TARGETEXT |
|
2113 |
||
2114 |
# NOTE: Changing default .def file name based on the LINKAS argument is actually |
|
2115 |
# a defect, but this follows the behaviour of the current build system. |
|
2116 |
if (self.__LINKAS): |
|
2117 |
defaultRootName = self.__LINKAS |
|
2118 |
||
2119 |
resolvedDefFile = self.resolveDefFile(defaultRootName, aBuildPlatform) |
|
2120 |
self.__debug("Resolved def file: %s" % resolvedDefFile ) |
|
2121 |
# We need to store this resolved deffile location for the FREEZE target |
|
2122 |
self.BuildVariant.AddOperation(raptor_data.Set("RESOLVED_DEFFILE", resolvedDefFile)) |
|
2123 |
||
2124 |
# If a deffile is specified, an FLM will put in a dependency. |
|
2125 |
# If a deffile is specified then raptor_meta will guess a name but: |
|
2126 |
# 1) If the guess is wrong then the FLM will complain "no rule to make ..." |
|
2127 |
# 2) In some cases, e.g. plugin, 1) is not desirable as the presence of a def file |
|
2128 |
# is not a necessity. In these cases the FLM needs to know if DEFFILE |
|
2129 |
# is a guess or not so it can decide if a dependency should be added. |
|
2130 |
||
2131 |
# We check that the def file exists and that it is non-zero (incredible |
|
2132 |
# that this should be needed). |
|
2133 |
||
2134 |
deffile_keyword="1" |
|
2135 |
if self.deffile == "": |
|
2136 |
# If the user didn't specify a deffile name then |
|
2137 |
# we must be guessing |
|
2138 |
# Let's check if our guess actually corresponds to a |
|
2139 |
# real file. If it does then that confims the guess. |
|
2140 |
# If there's no file then we still need to pass make the name |
|
2141 |
# so it can complain about there not being a DEF file |
|
2142 |
# for this particular target type and fail to build this target. |
|
2143 |
||
2144 |
deffile_keyword="" |
|
2145 |
try: |
|
2146 |
findpath = generic_path.Path(resolvedDefFile) |
|
2147 |
foundfile = findpath.FindCaseless() |
|
2148 |
||
2149 |
if foundfile == None: |
|
2150 |
raise IOError("file not found") |
|
2151 |
||
2152 |
self.__debug("Found DEFFILE " + foundfile.GetLocalString()) |
|
2153 |
rfstat = os.stat(foundfile.GetLocalString()) |
|
2154 |
||
2155 |
mode = rfstat[stat.ST_MODE] |
|
2156 |
if mode != None and stat.S_ISREG(mode) and rfstat[stat.ST_SIZE] > 0: |
|
2157 |
resolvedDefFile = str(foundfile) |
|
2158 |
else: |
|
2159 |
resolvedDefFile="" |
|
2160 |
except Exception,e: |
|
2161 |
self.__debug("While Searching for an IMPLIED DEFFILE: %s: %s" % (str(e),str(findpath)) ) |
|
2162 |
resolvedDefFile="" |
|
2163 |
else: |
|
2164 |
if not resolvedDefFile == "": |
|
2165 |
try: |
|
2166 |
findpath = generic_path.Path(resolvedDefFile) |
|
2167 |
resolvedDefFile = str(findpath.FindCaseless()) |
|
2168 |
if resolvedDefFile=="None": |
|
2169 |
raise IOError("file not found") |
|
2170 |
except Exception,e: |
|
2171 |
self.__warn("While Searching for a SPECIFIED DEFFILE: %s: %s" % (str(e),str(findpath)) ) |
|
2172 |
resolvedDefFile="" |
|
2173 |
else: |
|
2174 |
self.__warn("DEFFILE KEYWORD used (%s) but def file not resolved" % (self.deffile) ) |
|
2175 |
||
2176 |
||
2177 |
self.BuildVariant.AddOperation(raptor_data.Set("DEFFILE", resolvedDefFile)) |
|
2178 |
self.__debug("Set DEFFILE to " + resolvedDefFile) |
|
2179 |
self.BuildVariant.AddOperation(raptor_data.Set("DEFFILEKEYWORD", deffile_keyword)) |
|
2180 |
self.__debug("Set DEFFILEKEYWORD to '%s'",deffile_keyword) |
|
2181 |
||
245
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2182 |
# If target type is "implib" it must have a def file |
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2183 |
self.checkImplibDefFile(resolvedDefFile) |
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2184 |
|
3 | 2185 |
# if this target type has a default TARGETPATH other than "" for |
2186 |
# resources then we need to add that default to all resources which |
|
2187 |
# do not explicitly set the TARGETPATH themselves. |
|
2188 |
tp = self.getDefaultResourceTargetPath(self.getTargetType()) |
|
2189 |
if tp: |
|
2190 |
for i,var in enumerate(self.ResourceVariants): |
|
2191 |
# does this resource specify its own TARGETPATH? |
|
2192 |
needTP = True |
|
2193 |
for op in var.ops: |
|
2194 |
if isinstance(op, raptor_data.Set) \ |
|
2195 |
and op.name == "TARGETPATH": |
|
2196 |
needTP = False |
|
2197 |
break |
|
2198 |
if needTP: |
|
2199 |
self.ResourceVariants[i].AddOperation(raptor_data.Set("TARGETPATH", tp)) |
|
2200 |
||
2201 |
# some core build configurations need to know about the resource builds, and |
|
2202 |
# some resource building configurations need knowledge of the core build |
|
2203 |
for resourceFile in self.__resourceFiles: |
|
2204 |
self.BuildVariant.AddOperation(raptor_data.Append("RESOURCEFILES", resourceFile)) |
|
2205 |
||
2206 |
for i,var in enumerate(self.ResourceVariants): |
|
2207 |
self.ResourceVariants[i].AddOperation(raptor_data.Set("MAIN_TARGET_lower", self.__TARGET.lower())) |
|
2208 |
self.ResourceVariants[i].AddOperation(raptor_data.Set("MAIN_REQUESTEDTARGETEXT", self.__TARGETEXT.lower())) |
|
2209 |
||
5 | 2210 |
# Create Capability variable in one SET operation (more efficient than multiple appends) |
151
d4605037b3b2
set file format of raptor_meta.py to unix when on unix
timothy.murphy@nokia.com
parents:
144
diff
changeset
|
2211 |
|
d4605037b3b2
set file format of raptor_meta.py to unix when on unix
timothy.murphy@nokia.com
parents:
144
diff
changeset
|
2212 |
self.BuildVariant.AddOperation(raptor_data.Set("CAPABILITY","".join(self.capabilities))) |
5 | 2213 |
|
3 | 2214 |
# Resolve combined capabilities as hex flags, for configurations that require them |
2215 |
capabilityFlag1 = 0 |
|
2216 |
capabilityFlag2 = 0 # Always 0 |
|
2217 |
||
151
d4605037b3b2
set file format of raptor_meta.py to unix when on unix
timothy.murphy@nokia.com
parents:
144
diff
changeset
|
2218 |
for capability in self.capabilities: |
3 | 2219 |
invert = 0 |
2220 |
||
2221 |
if capability.startswith('-'): |
|
2222 |
invert = 0xffffffff |
|
160 | 2223 |
capability = capability[1:] |
3 | 2224 |
|
2225 |
if MMPRaptorBackend.supportedCapabilities.has_key(capability): |
|
2226 |
capabilityFlag1 = capabilityFlag1 ^ invert |
|
2227 |
capabilityFlag1 = capabilityFlag1 | MMPRaptorBackend.supportedCapabilities[capability] |
|
2228 |
capabilityFlag1 = capabilityFlag1 ^ invert |
|
2229 |
||
2230 |
capabilityFlag1 = "%08xu" % capabilityFlag1 |
|
2231 |
capabilityFlag2 = "%08xu" % capabilityFlag2 |
|
2232 |
||
2233 |
self.BuildVariant.AddOperation(raptor_data.Set("CAPABILITYFLAG1", capabilityFlag1)) |
|
2234 |
self.__debug ("Set CAPABILITYFLAG1 to " + capabilityFlag1) |
|
2235 |
self.BuildVariant.AddOperation(raptor_data.Set("CAPABILITYFLAG2", capabilityFlag2)) |
|
2236 |
self.__debug ("Set CAPABILITYFLAG2 to " + capabilityFlag2) |
|
2237 |
||
2238 |
# For non-Feature Variant builds, the location of the product include hrh file is |
|
2239 |
# appended to the SYSTEMINCLUDE list |
|
2240 |
if not aBuildPlatform['ISFEATUREVARIANT']: |
|
2241 |
productIncludePath = str(aBuildPlatform['VARIANT_HRH'].Dir()) |
|
2242 |
self.BuildVariant.AddOperation(raptor_data.Append("SYSTEMINCLUDE",productIncludePath)) |
|
2243 |
self.__debug("Appending product include location %s to SYSTEMINCLUDE",productIncludePath) |
|
2244 |
||
2245 |
# Specifying both a PAGED* and its opposite UNPAGED* keyword in a .mmp file |
|
2246 |
# will generate a warning and the last keyword specified will take effect. |
|
2247 |
self.__pageConflict.reverse() |
|
2248 |
if "PAGEDCODE" in self.__pageConflict and "UNPAGEDCODE" in self.__pageConflict: |
|
2249 |
for x in self.__pageConflict: |
|
2250 |
if x == "PAGEDCODE" or x == "UNPAGEDCODE": |
|
2251 |
self.__Raptor.Warn("Both PAGEDCODE and UNPAGEDCODE are specified. The last one %s will take effect" % x) |
|
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2252 |
if x == "PAGEDCODE": |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2253 |
self.resolveCompressionKeyword("BYTEPAIRCOMPRESSTARGET") |
3 | 2254 |
break |
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2255 |
elif "PAGEDCODE" in self.__pageConflict: |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2256 |
self.resolveCompressionKeyword("BYTEPAIRCOMPRESSTARGET") |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2257 |
|
3 | 2258 |
if "PAGEDDATA" in self.__pageConflict and "UNPAGEDDATA" in self.__pageConflict: |
2259 |
for x in self.__pageConflict: |
|
2260 |
if x == "PAGEDDATA" or x == "UNPAGEDDATA": |
|
2261 |
self.__Raptor.Warn("Both PAGEDDATA and UNPAGEDDATA are specified. The last one %s will take effect" % x) |
|
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2262 |
if x == "PAGEDDATA": |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2263 |
self.resolveCompressionKeyword("BYTEPAIRCOMPRESSTARGET") |
3 | 2264 |
break |
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2265 |
elif "PAGEDDATA" in self.__pageConflict: |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2266 |
self.resolveCompressionKeyword("BYTEPAIRCOMPRESSTARGET") |
3 | 2267 |
|
2268 |
# Set Debuggable |
|
2269 |
self.BuildVariant.AddOperation(raptor_data.Set("DEBUGGABLE", self.__debuggable)) |
|
2270 |
||
2271 |
if self.__explicitversion: |
|
2272 |
self.BuildVariant.AddOperation(raptor_data.Append("UNIQUETARGETPATH","$(TARGET_lower)_$(VERSIONHEX)_$(REQUESTEDTARGETEXT)",'/')) |
|
2273 |
else: |
|
2274 |
self.BuildVariant.AddOperation(raptor_data.Append("UNIQUETARGETPATH","$(TARGET_lower)_$(REQUESTEDTARGETEXT)",'/')) |
|
2275 |
||
2276 |
# Put the list of sourcefiles in with one Set operation - saves memory |
|
2277 |
# and performance over using multiple Append operations. |
|
2278 |
self.BuildVariant.AddOperation(raptor_data.Set("SOURCE", |
|
2279 |
" ".join(self.sources))) |
|
2280 |
||
2281 |
def getTargetType(self): |
|
2282 |
"""Target type in lower case - the standard format""" |
|
2283 |
return self.__targettype.lower() |
|
2284 |
||
388
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2285 |
def resolveCompressionKeyword(self, aCompressionKeyword): |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2286 |
"""If a compression keyword is set more than once either explicitly |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2287 |
or implicitly a warning is given and the last one takes effect |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2288 |
""" |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2289 |
if self.__compressionKeyword and self.__compressionKeyword != aCompressionKeyword: |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2290 |
self.__Raptor.Warn("%s keyword in %s overrides earlier use of %s" % \ |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2291 |
(aCompressionKeyword, self.__currentMmpFile, self.__compressionKeyword)) |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2292 |
self.BuildVariant.AddOperation(raptor_data.Set(self.__compressionKeyword, "")) |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2293 |
self.__debug( "Set switch " + self.__compressionKeyword + " OFF") |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2294 |
self.BuildVariant.AddOperation(raptor_data.Set(aCompressionKeyword,"1")) |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2295 |
self.__debug( "Set switch " + aCompressionKeyword + " ON") |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2296 |
self.__compressionKeyword = aCompressionKeyword |
3f46b91ff7d1
SF Bug 1939 - PAGED keyword in MMP files should imply byte pair compressed
yiluzhu
parents:
288
diff
changeset
|
2297 |
|
245
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2298 |
def checkImplibDefFile(self, defFile): |
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2299 |
"""Project with target type implib must have DEFFILE defined |
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2300 |
explicitly or implicitly, otherwise it is an error |
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2301 |
""" |
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2302 |
if self.getTargetType() == 'implib' and defFile == '': |
246
b9b473d0d6df
Release note: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
245
diff
changeset
|
2303 |
self.__Raptor.Error("No DEF File for IMPLIB target type in " + \ |
b9b473d0d6df
Release note: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
245
diff
changeset
|
2304 |
self.__currentMmpFile, bldinf=self.__bldInfFilename) |
245
cbc11ebd788f
Bug 1571: Raptor cannot report error or warning message in wrong implib project
yiluzhu
parents:
212
diff
changeset
|
2305 |
|
3 | 2306 |
def resolveDefFile(self, aTARGET, aBuildPlatform): |
2307 |
"""Returns a fully resolved DEFFILE entry depending on .mmp file location and TARGET, DEFFILE and NOSTRICTDEF |
|
2308 |
entries in the .mmp file itself (where appropriate). |
|
2309 |
Is able to deal with target names that have multiple '.' characters e.g. messageintercept.esockdebug.dll |
|
2310 |
""" |
|
2311 |
||
2312 |
resolvedDefFile = "" |
|
2313 |
platform = aBuildPlatform['PLATFORM'] |
|
2314 |
||
2315 |
# Not having a default .def file directory is a pretty strong indicator that |
|
2316 |
# .def files aren't supported for the particular platform |
|
2317 |
if PlatformDefaultDefFileDir.has_key(platform): |
|
2318 |
(targetname,targetext) = os.path.splitext(aTARGET) |
|
2319 |
(defname,defext) = os.path.splitext(self.deffile) |
|
2320 |
if defext=="": |
|
2321 |
defext = ".def" |
|
2322 |
||
2323 |
# NOTE: WORKAROUND |
|
2324 |
if len(targetext) > 4: |
|
2325 |
targetname += defext |
|
2326 |
||
2327 |
if not self.deffile: |
|
2328 |
resolvedDefFile = targetname |
|
2329 |
else: |
|
2330 |
if re.search('[\\|\/]$', self.deffile): |
|
2331 |
# If DEFFILE is *solely* a path, signified by ending in a slash, then TARGET is the |
|
2332 |
# basis for the default .def filename but with the specified path as prefix |
|
2333 |
resolvedDefFile = self.deffile + targetname |
|
2334 |
||
2335 |
else: |
|
2336 |
resolvedDefFile = defname |
|
2337 |
||
2338 |
resolvedDefFile = resolvedDefFile.replace('~', PlatformDefaultDefFileDir[platform]) |
|
2339 |
||
2340 |
if resolvedDefFile: |
|
2341 |
if not self.nostrictdef: |
|
2342 |
resolvedDefFile += 'u' |
|
2343 |
||
2344 |
if self.__explicitversion: |
|
2345 |
resolvedDefFile += '{' + self.__versionhex + '}' |
|
2346 |
||
2347 |
resolvedDefFile += defext |
|
2348 |
||
2349 |
||
2350 |
# If a DEFFILE statement doesn't specify a path in any shape or form, prepend the default .def file |
|
2351 |
# location based on the platform being built |
|
2352 |
if not re.search('[\\\/]+', self.deffile): |
|
2353 |
resolvedDefFile = '../'+PlatformDefaultDefFileDir[platform]+'/'+resolvedDefFile |
|
2354 |
||
2355 |
resolvedDefFile = raptor_utilities.resolveSymbianPath(self.__defFileRoot, resolvedDefFile, 'DEFFILE', "", str(aBuildPlatform['EPOCROOT'])) |
|
2356 |
||
2357 |
return resolvedDefFile |
|
2358 |
||
2359 |
||
5 | 2360 |
def CheckedGet(self, key, default = None): |
2361 |
"""extract a value from an self and raise an exception if None. |
|
2362 |
||
2363 |
An optional default can be set to replace a None value. |
|
2364 |
||
2365 |
This function belongs in the Evaluator class logically. But |
|
2366 |
Evaluator doesn't know how to raise a Metadata error. Since |
|
2367 |
being able to raise a metadata error is the whole point of |
|
2368 |
the method, it makes sense to adapt the Evaluator class from |
|
2369 |
raptor_meta for the use of everything inside raptor_meta. |
|
2370 |
||
2371 |
... so it will be added to the Evaluator class. |
|
2372 |
""" |
|
2373 |
||
2374 |
value = self.Get(key) |
|
2375 |
if value == None: |
|
2376 |
if default == None: |
|
2377 |
raise MetaDataError("configuration " + self.buildUnit.name + |
|
2378 |
" has no variable " + key) |
|
2379 |
else: |
|
2380 |
return default |
|
2381 |
return value |
|
2382 |
||
2383 |
raptor_data.Evaluator.CheckedGet = CheckedGet |
|
2384 |
||
2385 |
||
3 | 2386 |
class MetaReader(object): |
2387 |
"""Entry point class for Symbian metadata processing. |
|
2388 |
||
2389 |
Provides a means of integrating "traditional" Symbian metadata processing |
|
2390 |
with the new Raptor build system.""" |
|
2391 |
||
2392 |
filesplit_re = re.compile(r"^(?P<name>.*)\.(?P<ext>[^\.]*)$") |
|
2393 |
||
2394 |
def __init__(self, aRaptor, configsToBuild): |
|
2395 |
self.__Raptor = aRaptor |
|
2396 |
self.BuildPlatforms = [] |
|
2397 |
self.ExportPlatforms = [] |
|
2398 |
||
2399 |
# Get the version of CPP that we are using |
|
2400 |
metadata = self.__Raptor.cache.FindNamedVariant("meta") |
|
2401 |
evaluator = self.__Raptor.GetEvaluator(None, raptor_data.BuildUnit(metadata.name, [metadata]) ) |
|
5 | 2402 |
self.__gnucpp = evaluator.CheckedGet("GNUCPP") |
2403 |
self.__defaultplatforms = evaluator.CheckedGet("DEFAULT_PLATFORMS") |
|
2404 |
self.__basedefaultplatforms = evaluator.CheckedGet("BASE_DEFAULT_PLATFORMS") |
|
2405 |
self.__baseuserdefaultplatforms = evaluator.CheckedGet("BASE_USER_DEFAULT_PLATFORMS") |
|
3 | 2406 |
|
2407 |
# Only read each variant.cfg once |
|
2408 |
variantCfgs = {} |
|
2409 |
||
2410 |
# Group the list of configurations into "build platforms". |
|
2411 |
# A build platform is a set of configurations which share |
|
2412 |
# the same metadata. In other words, a set of configurations |
|
2413 |
# for which the bld.inf and MMP files pre-process to exactly |
|
2414 |
# the same text. |
|
2415 |
platforms = {} |
|
2416 |
||
2417 |
# Exports are not "platform dependent" but they are configuration |
|
2418 |
# dependent because different configs can have different EPOCROOT |
|
2419 |
# and VARIANT_HRH values. Each "build platform" has one associated |
|
2420 |
# "export platform" but several "build platforms" can be associated |
|
2421 |
# with the same "export platform". |
|
2422 |
exports = {} |
|
429
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2423 |
|
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2424 |
# We sort configurations by name here. This is solely to deal with situations |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2425 |
# where macros linked to builds end up being used in preprocessor conditionals |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2426 |
# within bld.inf files that then wrap exports under PRJ_EXPORTS statements. |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2427 |
# Having exports that are conditional on these macros isn't supported, but |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2428 |
# as there are areas of the source base that make this assumption, and |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2429 |
# fail if emulator macros are used instead of arm ones, we ensure that arm |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2430 |
# configurations come first when multiple configurations are active, and so are |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2431 |
# used first for determining exports. |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2432 |
sortedConfigsToBuild = sorted(configsToBuild,key=lambda config: config.name) |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2433 |
|
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2434 |
self.__Raptor.Debug("MetaReader: sortedConfigsToBuild: %s", [b.name for b in sortedConfigsToBuild]) |
d13352a0173e
Fix : sort build configurations by name for metadata preprocessing
Jon Chatten
parents:
422
diff
changeset
|
2435 |
for buildConfig in sortedConfigsToBuild: |
3 | 2436 |
# get everything we need to know about the configuration |
2437 |
evaluator = self.__Raptor.GetEvaluator(None, buildConfig) |
|
2438 |
||
2439 |
detail = {} |
|
5 | 2440 |
detail['PLATFORM'] = evaluator.CheckedGet("TRADITIONAL_PLATFORM") |
2441 |
epocroot = evaluator.CheckedGet("EPOCROOT") |
|
3 | 2442 |
detail['EPOCROOT'] = generic_path.Path(epocroot) |
2443 |
||
5 | 2444 |
sbs_build_dir = evaluator.CheckedGet("SBS_BUILD_DIR") |
3 | 2445 |
detail['SBS_BUILD_DIR'] = generic_path.Path(sbs_build_dir) |
5 | 2446 |
flm_export_dir = evaluator.CheckedGet("FLM_EXPORT_DIR") |
3 | 2447 |
detail['FLM_EXPORT_DIR'] = generic_path.Path(flm_export_dir) |
2448 |
detail['CACHEID'] = flm_export_dir |
|
2449 |
if raptor_utilities.getOSPlatform().startswith("win"): |
|
5 | 2450 |
detail['PLATMACROS'] = evaluator.CheckedGet("PLATMACROS.WINDOWS") |
3 | 2451 |
else: |
5 | 2452 |
detail['PLATMACROS'] = evaluator.CheckedGet("PLATMACROS.LINUX") |
3 | 2453 |
|
2454 |
# Apply OS variant provided we are not ignoring this |
|
2455 |
if not self.__Raptor.ignoreOsDetection: |
|
2456 |
self.__Raptor.Debug("Automatic OS detection enabled.") |
|
2457 |
self.ApplyOSVariant(buildConfig, epocroot) |
|
2458 |
else: # We are ignore OS versions so no detection required, so no variant will be applied |
|
2459 |
self.__Raptor.Debug("Automatic OS detection disabled.") |
|
2460 |
||
2461 |
# is this a feature variant config or an ordinary variant |
|
2462 |
fv = evaluator.Get("FEATUREVARIANTNAME") |
|
2463 |
if fv: |
|
5 | 2464 |
variantHdr = evaluator.CheckedGet("VARIANT_HRH") |
3 | 2465 |
variantHRH = generic_path.Path(variantHdr) |
2466 |
detail['ISFEATUREVARIANT'] = True |
|
2467 |
else: |
|
5 | 2468 |
variantCfg = evaluator.CheckedGet("VARIANT_CFG") |
3 | 2469 |
variantCfg = generic_path.Path(variantCfg) |
2470 |
if not variantCfg in variantCfgs: |
|
2471 |
# get VARIANT_HRH from the variant.cfg file |
|
2472 |
varCfg = getVariantCfgDetail(detail['EPOCROOT'], variantCfg) |
|
2473 |
variantCfgs[variantCfg] = varCfg['VARIANT_HRH'] |
|
2474 |
# we expect to always build ABIv2 |
|
2475 |
if not 'ENABLE_ABIV2_MODE' in varCfg: |
|
2476 |
self.__Raptor.Warn("missing flag ENABLE_ABIV2_MODE in %s file. ABIV1 builds are not supported.", |
|
2477 |
str(variantCfg)) |
|
2478 |
variantHRH = variantCfgs[variantCfg] |
|
2479 |
detail['ISFEATUREVARIANT'] = False |
|
2480 |
||
2481 |
detail['VARIANT_HRH'] = variantHRH |
|
2482 |
self.__Raptor.Info("'%s' uses variant hrh file '%s'", buildConfig.name, variantHRH) |
|
5 | 2483 |
detail['SYSTEMINCLUDE'] = evaluator.CheckedGet("SYSTEMINCLUDE") |
2484 |
||
3 | 2485 |
|
2486 |
# find all the interface names we need |
|
5 | 2487 |
ifaceTypes = evaluator.CheckedGet("INTERFACE_TYPES") |
3 | 2488 |
interfaces = ifaceTypes.split() |
2489 |
||
2490 |
for iface in interfaces: |
|
5 | 2491 |
detail[iface] = evaluator.CheckedGet("INTERFACE." + iface) |
3 | 2492 |
|
2493 |
# not test code unless positively specified |
|
5 | 2494 |
detail['TESTCODE'] = evaluator.CheckedGet("TESTCODE", "") |
3 | 2495 |
|
2496 |
# make a key that identifies this platform uniquely |
|
2497 |
# - used to tell us whether we have done the pre-processing |
|
2498 |
# we need already using another platform with compatible values. |
|
2499 |
||
2500 |
key = str(detail['VARIANT_HRH']) \ |
|
2501 |
+ str(detail['EPOCROOT']) \ |
|
2502 |
+ detail['SYSTEMINCLUDE'] \ |
|
138
681b6bf8a272
fix for ARM9E + ARMV5 preprocessing confusion
Richard Taylor <richard.i.taylor@nokia.com>
parents:
48
diff
changeset
|
2503 |
+ detail['PLATFORM'] \ |
681b6bf8a272
fix for ARM9E + ARMV5 preprocessing confusion
Richard Taylor <richard.i.taylor@nokia.com>
parents:
48
diff
changeset
|
2504 |
+ detail['PLATMACROS'] |
3 | 2505 |
|
2506 |
# Keep a short version of the key for use in filenames. |
|
2507 |
uniq = hashlib.md5() |
|
2508 |
uniq.update(key) |
|
2509 |
||
2510 |
detail['key'] = key |
|
2511 |
detail['key_md5'] = "p_" + uniq.hexdigest() |
|
2512 |
del uniq |
|
2513 |
||
2514 |
# compare this configuration to the ones we have already seen |
|
2515 |
||
2516 |
# Is this an unseen export platform? |
|
2517 |
# concatenate all the values we care about in a fixed order |
|
2518 |
# and use that as a signature for the exports. |
|
2519 |
items = ['EPOCROOT', 'VARIANT_HRH', 'SYSTEMINCLUDE', 'TESTCODE', 'export'] |
|
2520 |
export = "" |
|
2521 |
for i in items: |
|
2522 |
if i in detail: |
|
2523 |
export += i + str(detail[i]) |
|
2524 |
||
2525 |
if export in exports: |
|
2526 |
# add this configuration to an existing export platform |
|
2527 |
index = exports[export] |
|
2528 |
self.ExportPlatforms[index]['configs'].append(buildConfig) |
|
2529 |
else: |
|
2530 |
# create a new export platform with this configuration |
|
2531 |
exports[export] = len(self.ExportPlatforms) |
|
2532 |
exp = copy.copy(detail) |
|
2533 |
exp['PLATFORM'] = 'EXPORT' |
|
2534 |
exp['configs'] = [buildConfig] |
|
2535 |
self.ExportPlatforms.append(exp) |
|
2536 |
||
2537 |
# Is this an unseen build platform? |
|
2538 |
# concatenate all the values we care about in a fixed order |
|
2539 |
# and use that as a signature for the platform. |
|
138
681b6bf8a272
fix for ARM9E + ARMV5 preprocessing confusion
Richard Taylor <richard.i.taylor@nokia.com>
parents:
48
diff
changeset
|
2540 |
items = ['PLATFORM', 'PLATMACROS', 'EPOCROOT', 'VARIANT_HRH', 'SYSTEMINCLUDE', 'TESTCODE'] |
3 | 2541 |
|
2542 |
items.extend(interfaces) |
|
2543 |
platform = "" |
|
2544 |
for i in items: |
|
2545 |
if i in detail: |
|
2546 |
platform += i + str(detail[i]) |
|
2547 |
||
2548 |
if platform in platforms: |
|
2549 |
# add this configuration to an existing build platform |
|
2550 |
index = platforms[platform] |
|
2551 |
self.BuildPlatforms[index]['configs'].append(buildConfig) |
|
2552 |
else: |
|
2553 |
# create a new build platform with this configuration |
|
2554 |
platforms[platform] = len(self.BuildPlatforms) |
|
2555 |
detail['configs'] = [buildConfig] |
|
2556 |
self.BuildPlatforms.append(detail) |
|
2557 |
||
2558 |
# one platform is picked as the "default" for extracting things |
|
2559 |
# that are supposedly platform independent (e.g. PRJ_PLATFORMS) |
|
2560 |
self.defaultPlatform = self.ExportPlatforms[0] |
|
2561 |
||
5 | 2562 |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2563 |
def ReadBldInfFiles(self, aComponentList, doexport, dobuild = True): |
3 | 2564 |
"""Take a list of bld.inf files and return a list of build specs. |
2565 |
||
2566 |
The returned specification nodes will be suitable for all the build |
|
2567 |
configurations under consideration (using Filter nodes where required). |
|
2568 |
""" |
|
2569 |
||
2570 |
# we need a Filter node per export platform |
|
2571 |
exportNodes = [] |
|
2572 |
for i,ep in enumerate(self.ExportPlatforms): |
|
5 | 2573 |
filter = raptor_data.Filter(name = "export_" + str(i)) |
3 | 2574 |
|
2575 |
# what configurations is this node active for? |
|
2576 |
for config in ep['configs']: |
|
2577 |
filter.AddConfigCondition(config.name) |
|
2578 |
||
2579 |
exportNodes.append(filter) |
|
2580 |
||
2581 |
# we need a Filter node per build platform |
|
2582 |
platformNodes = [] |
|
2583 |
for i,bp in enumerate(self.BuildPlatforms): |
|
5 | 2584 |
filter = raptor_data.Filter(name = "build_" + str(i)) |
3 | 2585 |
|
2586 |
# what configurations is this node active for? |
|
2587 |
for config in bp['configs']: |
|
2588 |
filter.AddConfigCondition(config.name) |
|
2589 |
||
2590 |
# platform-wide data |
|
2591 |
platformVar = raptor_data.Variant() |
|
2592 |
platformVar.AddOperation(raptor_data.Set("PRODUCT_INCLUDE", |
|
2593 |
str(bp['VARIANT_HRH']))) |
|
2594 |
||
2595 |
filter.AddVariant(platformVar) |
|
2596 |
platformNodes.append(filter) |
|
2597 |
||
2598 |
# check that each bld.inf exists and add a Specification node for it |
|
2599 |
# to the nodes of the export and build platforms that it supports. |
|
5 | 2600 |
for c in aComponentList: |
2601 |
if c.bldinf_filename.isFile(): |
|
2602 |
self.__Raptor.Info("Processing %s", str(c.bldinf_filename)) |
|
3 | 2603 |
try: |
5 | 2604 |
self.AddComponentNodes(c, exportNodes, platformNodes) |
3 | 2605 |
|
2606 |
except MetaDataError, e: |
|
5 | 2607 |
self.__Raptor.Error(e.Text, bldinf=str(c.bldinf_filename)) |
3 | 2608 |
if not self.__Raptor.keepGoing: |
2609 |
return [] |
|
2610 |
else: |
|
5 | 2611 |
self.__Raptor.Error("build info file does not exist", bldinf=str(c.bldinf_filename)) |
3 | 2612 |
if not self.__Raptor.keepGoing: |
2613 |
return [] |
|
2614 |
||
2615 |
# now we have the top-level structure in place... |
|
2616 |
# |
|
2617 |
# <filter exports 1> |
|
2618 |
# <spec bld.inf 1 /> |
|
2619 |
# <spec bld.inf 2 /> |
|
2620 |
# <spec bld.inf N /> </filter> |
|
2621 |
# <filter build 1> |
|
2622 |
# <spec bld.inf 1 /> |
|
2623 |
# <spec bld.inf 2 /> |
|
2624 |
# <spec bld.inf N /> </filter> |
|
2625 |
# <filter build 2> |
|
2626 |
# <spec bld.inf 1 /> |
|
2627 |
# <spec bld.inf 2 /> |
|
2628 |
# <spec bld.inf N /> </filter> |
|
2629 |
# <filter build 3> |
|
2630 |
# <spec bld.inf 1 /> |
|
2631 |
# <spec bld.inf 2 /> |
|
2632 |
# <spec bld.inf N /> </filter> |
|
2633 |
# |
|
2634 |
# assuming that every bld.inf builds for every platform and all |
|
2635 |
# exports go to the same place. clearly, it is more likely that |
|
2636 |
# some filters have less than N child nodes. in bigger builds there |
|
2637 |
# will also be more than one export platform. |
|
2638 |
||
2639 |
# we now need to process the EXPORTS for all the bld.inf nodes |
|
2640 |
# before we can do anything else (because raptor itself must do |
|
2641 |
# some exports before the MMP files that include them can be |
|
2642 |
# processed). |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2643 |
if doexport: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2644 |
for i,p in enumerate(exportNodes): |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2645 |
exportPlatform = self.ExportPlatforms[i] |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2646 |
for s in p.GetChildSpecs(): |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2647 |
try: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2648 |
self.ProcessExports(s, exportPlatform) |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2649 |
|
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2650 |
except MetaDataError, e: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2651 |
self.__Raptor.Error("%s",e.Text) |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2652 |
if not self.__Raptor.keepGoing: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2653 |
return [] |
14 | 2654 |
else: |
2655 |
self.__Raptor.Info("Not Processing Exports (--noexport enabled)") |
|
3 | 2656 |
|
2657 |
# this is a switch to return the function at this point if export |
|
2658 |
# only option is specified in the run |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2659 |
if dobuild is not True: |
3 | 2660 |
self.__Raptor.Info("Processing Exports only") |
2661 |
return[] |
|
2662 |
||
2663 |
# after exports are done we can look to see if there are any |
|
2664 |
# new Interfaces which can be used for EXTENSIONS. Make sure |
|
2665 |
# that we only load each cache once as some export platforms |
|
2666 |
# may share a directory. |
|
2667 |
doneID = {} |
|
2668 |
for ep in self.ExportPlatforms: |
|
2669 |
flmDir = ep["FLM_EXPORT_DIR"] |
|
2670 |
cid = ep["CACHEID"] |
|
2671 |
if flmDir.isDir() and not cid in doneID: |
|
2672 |
self.__Raptor.cache.Load(flmDir, cid) |
|
2673 |
doneID[cid] = True |
|
2674 |
||
2675 |
# finally we can process all the other parts of the bld.inf nodes. |
|
2676 |
# Keep a list of the projects we were asked to build so that we can |
|
2677 |
# tell at the end if there were any we didn't know about. |
|
2678 |
self.projectList = list(self.__Raptor.projects) |
|
2679 |
for i,p in enumerate(platformNodes): |
|
2680 |
buildPlatform = self.BuildPlatforms[i] |
|
2681 |
for s in p.GetChildSpecs(): |
|
2682 |
try: |
|
2683 |
self.ProcessTEMs(s, buildPlatform) |
|
2684 |
self.ProcessMMPs(s, buildPlatform) |
|
2685 |
||
2686 |
except MetaDataError, e: |
|
2687 |
self.__Raptor.Error(e.Text) |
|
2688 |
if not self.__Raptor.keepGoing: |
|
2689 |
return [] |
|
2690 |
||
2691 |
for badProj in self.projectList: |
|
2692 |
self.__Raptor.Warn("Can't find project '%s' in any build info file", badProj) |
|
2693 |
||
2694 |
# everything is specified |
|
2695 |
return exportNodes + platformNodes |
|
2696 |
||
2697 |
def ModuleName(self,aBldInfPath): |
|
2698 |
"""Calculate the name of the ROM/emulator batch files that run the tests""" |
|
2699 |
||
2700 |
def LeftPortionOf(pth,sep): |
|
2701 |
""" Internal function to return portion of str that is to the left of sep. |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2702 |
The split is case-insensitive.""" |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2703 |
length = len((pth.lower().split(sep.lower()))[0]) |
3 | 2704 |
return pth[0:length] |
2705 |
||
2706 |
modulePath = LeftPortionOf(LeftPortionOf(os.path.dirname(aBldInfPath), "group"), "ongoing") |
|
2707 |
moduleName = os.path.basename(modulePath.strip("/")) |
|
2708 |
||
2709 |
# Ensure that ModuleName does not return blank, if the above calculation determines |
|
2710 |
# that moduleName is blank |
|
2711 |
if moduleName == "" or moduleName.endswith(":"): |
|
2712 |
moduleName = "module" |
|
2713 |
return moduleName |
|
2714 |
||
2715 |
||
5 | 2716 |
def AddComponentNodes(self, component, exportNodes, platformNodes): |
3 | 2717 |
"""Add Specification nodes for a bld.inf to the appropriate platforms.""" |
5 | 2718 |
bldInfFile = BldInfFile(component.bldinf_filename, self.__gnucpp, component.depfiles, self.__Raptor) |
2719 |
component.bldinf = bldInfFile |
|
2720 |
||
2721 |
specName = getSpecName(component.bldinf_filename, fullPath=True) |
|
2722 |
||
3 | 2723 |
# exports are independent of build platform |
2724 |
for i,ep in enumerate(self.ExportPlatforms): |
|
5 | 2725 |
specNode = raptor_data.Specification(name = specName) |
3 | 2726 |
|
2727 |
# keep the BldInfFile object for later |
|
5 | 2728 |
specNode.component = component |
3 | 2729 |
|
2730 |
# add some basic data in a component-wide variant |
|
5 | 2731 |
var = raptor_data.Variant(name='component-wide') |
2732 |
var.AddOperation(raptor_data.Set("COMPONENT_META", str(component.bldinf_filename))) |
|
268
692d9a4eefc4
Resurrect COMPONENT_NAME and LAYER_NAME output in logs when bld.inf files are gathered from system definition files.
Jon Chatten
parents:
246
diff
changeset
|
2733 |
var.AddOperation(raptor_data.Set("COMPONENT_NAME", component.componentname)) |
692d9a4eefc4
Resurrect COMPONENT_NAME and LAYER_NAME output in logs when bld.inf files are gathered from system definition files.
Jon Chatten
parents:
246
diff
changeset
|
2734 |
var.AddOperation(raptor_data.Set("COMPONENT_LAYER", component.layername)) |
3 | 2735 |
specNode.AddVariant(var) |
2736 |
||
2737 |
# add this bld.inf Specification to the export platform |
|
2738 |
exportNodes[i].AddChild(specNode) |
|
5 | 2739 |
component.exportspecs.append(specNode) |
3 | 2740 |
|
2741 |
# get the relevant build platforms |
|
2742 |
listedPlatforms = bldInfFile.getBuildPlatforms(self.defaultPlatform) |
|
2743 |
platforms = getBuildableBldInfBuildPlatforms(listedPlatforms, |
|
5 | 2744 |
self.__defaultplatforms, |
2745 |
self.__basedefaultplatforms, |
|
2746 |
self.__baseuserdefaultplatforms) |
|
2747 |
||
2748 |
||
2749 |
outputDir = BldInfFile.outputPathFragment(component.bldinf_filename) |
|
3 | 2750 |
|
2751 |
# Calculate "module name" |
|
5 | 2752 |
modulename = self.ModuleName(str(component.bldinf_filename)) |
3 | 2753 |
|
2754 |
for i,bp in enumerate(self.BuildPlatforms): |
|
5 | 2755 |
plat = bp['PLATFORM'] |
3 | 2756 |
if bp['PLATFORM'] in platforms: |
5 | 2757 |
specNode = raptor_data.Specification(name = specName) |
2758 |
||
2759 |
# remember what component this spec node comes from for later |
|
2760 |
specNode.component = component |
|
3 | 2761 |
|
2762 |
# add some basic data in a component-wide variant |
|
5 | 2763 |
var = raptor_data.Variant(name='component-wide-settings-' + plat) |
2764 |
var.AddOperation(raptor_data.Set("COMPONENT_META",str(component.bldinf_filename))) |
|
268
692d9a4eefc4
Resurrect COMPONENT_NAME and LAYER_NAME output in logs when bld.inf files are gathered from system definition files.
Jon Chatten
parents:
246
diff
changeset
|
2765 |
var.AddOperation(raptor_data.Set("COMPONENT_NAME", component.componentname)) |
692d9a4eefc4
Resurrect COMPONENT_NAME and LAYER_NAME output in logs when bld.inf files are gathered from system definition files.
Jon Chatten
parents:
246
diff
changeset
|
2766 |
var.AddOperation(raptor_data.Set("COMPONENT_LAYER", component.layername)) |
3 | 2767 |
var.AddOperation(raptor_data.Set("MODULE", modulename)) |
2768 |
var.AddOperation(raptor_data.Append("OUTPUTPATHOFFSET", outputDir, '/')) |
|
2769 |
var.AddOperation(raptor_data.Append("OUTPUTPATH", outputDir, '/')) |
|
2770 |
var.AddOperation(raptor_data.Append("BLDINF_OUTPUTPATH",outputDir, '/')) |
|
2771 |
||
5 | 2772 |
var.AddOperation(raptor_data.Set("TEST_OPTION", component.bldinf.getRomTestType(bp))) |
3 | 2773 |
specNode.AddVariant(var) |
2774 |
||
2775 |
# add this bld.inf Specification to the build platform |
|
2776 |
platformNodes[i].AddChild(specNode) |
|
5 | 2777 |
# also attach it into the component |
2778 |
component.specs.append(specNode) |
|
3 | 2779 |
|
2780 |
def ProcessExports(self, componentNode, exportPlatform): |
|
2781 |
"""Do the exports for a given platform and skeleton bld.inf node. |
|
2782 |
||
2783 |
This will actually perform exports as certain types of files (.mmh) |
|
2784 |
are required to be in place before the rest of the bld.inf node |
|
2785 |
(and parts of other bld.inf nodes) can be processed. |
|
2786 |
||
2787 |
[some MMP files #include exported .mmh files] |
|
2788 |
""" |
|
2789 |
if exportPlatform["TESTCODE"]: |
|
5 | 2790 |
exports = componentNode.component.bldinf.getTestExports(exportPlatform) |
3 | 2791 |
else: |
5 | 2792 |
exports = componentNode.component.bldinf.getExports(exportPlatform) |
3 | 2793 |
|
2794 |
self.__Raptor.Debug("%i exports for %s", |
|
5 | 2795 |
len(exports), str(componentNode.component.bldinf.filename)) |
3 | 2796 |
if exports: |
2797 |
||
2798 |
# each export is either a 'copy' or 'unzip' |
|
2799 |
# maybe we should trap multiple exports to the same location here? |
|
2800 |
epocroot = str(exportPlatform["EPOCROOT"]) |
|
5 | 2801 |
bldinf_filename = str(componentNode.component.bldinf.filename) |
3 | 2802 |
exportwhatlog="<whatlog bldinf='%s' mmp='' config=''>\n" % bldinf_filename |
2803 |
for export in exports: |
|
2804 |
expSrc = export.getSource() |
|
2805 |
expDstList = export.getDestination() # Might not be a list in all circumstances |
|
2806 |
||
2807 |
# make it a list if it isn't |
|
2808 |
if not isinstance(expDstList, list): |
|
2809 |
expDstList = [expDstList] |
|
2810 |
||
2811 |
fromFile = generic_path.Path(expSrc.replace("$(EPOCROOT)", epocroot)) |
|
2812 |
||
2813 |
# For each destination in the destination list, add an export target, perform it if required. |
|
2814 |
# This ensures that make knows the dependency situation but that the export is made |
|
2815 |
# before any other part of the metadata requires it. It also helps with the build |
|
2816 |
# from clean situation where we can't use order only prerequisites. |
|
2817 |
for expDst in expDstList: |
|
2818 |
toFile = generic_path.Path(expDst.replace("$(EPOCROOT)", epocroot)) |
|
2819 |
try: |
|
2820 |
if export.getAction() == "copy": |
|
2821 |
# export the file |
|
2822 |
exportwhatlog += self.CopyExport(fromFile, toFile, bldinf_filename) |
|
2823 |
else: |
|
2824 |
members = self.UnzipExport(fromFile, toFile, |
|
2825 |
str(exportPlatform['SBS_BUILD_DIR']), |
|
2826 |
bldinf_filename) |
|
48
f872a2538607
sf bug 170: invalid XML output when zip file is missing
Richard Taylor <richard.i.taylor@nokia.com>
parents:
32
diff
changeset
|
2827 |
|
f872a2538607
sf bug 170: invalid XML output when zip file is missing
Richard Taylor <richard.i.taylor@nokia.com>
parents:
32
diff
changeset
|
2828 |
exportwhatlog += ("<archive zipfile='" + str(fromFile) + "'>\n") |
3 | 2829 |
if members != None: |
2830 |
exportwhatlog += members |
|
2831 |
exportwhatlog += "</archive>\n" |
|
2832 |
except MetaDataError, e: |
|
2833 |
if self.__Raptor.keepGoing: |
|
2834 |
self.__Raptor.Error("%s",e.Text, bldinf=bldinf_filename) |
|
2835 |
else: |
|
2836 |
raise e |
|
2837 |
exportwhatlog+="</whatlog>\n" |
|
2838 |
self.__Raptor.PrintXML("%s",exportwhatlog) |
|
2839 |
||
2840 |
def CopyExport(self, _source, _destination, bldInfFile): |
|
2841 |
"""Copy the source file to the destination file (create a directory |
|
2842 |
to copy into if it does not exist). Don't copy if the destination |
|
2843 |
file exists and has an equal or newer modification time.""" |
|
2844 |
source = generic_path.Path(str(_source).replace('%20',' ')) |
|
2845 |
destination = generic_path.Path(str(_destination).replace('%20',' ')) |
|
2846 |
dest_str = str(destination) |
|
2847 |
source_str = str(source) |
|
2848 |
||
2849 |
exportwhatlog="<export destination='" + dest_str + "' source='" + \ |
|
2850 |
source_str + "'/>\n" |
|
2851 |
||
2852 |
try: |
|
2853 |
||
2854 |
||
2855 |
destDir = destination.Dir() |
|
2856 |
if not destDir.isDir(): |
|
2857 |
os.makedirs(str(destDir)) |
|
2858 |
shutil.copyfile(source_str, dest_str) |
|
2859 |
return exportwhatlog |
|
2860 |
||
2861 |
sourceMTime = 0 |
|
2862 |
destMTime = 0 |
|
278
c38bfd29ee57
SF Bug 2081 - [Raptor] - Exported file executable permissions not maintained (linux)
timothy.murphy@nokia.com
parents:
246
diff
changeset
|
2863 |
sourceStat = 0 |
3 | 2864 |
try: |
278
c38bfd29ee57
SF Bug 2081 - [Raptor] - Exported file executable permissions not maintained (linux)
timothy.murphy@nokia.com
parents:
246
diff
changeset
|
2865 |
sourceStat = os.stat(source_str) |
c38bfd29ee57
SF Bug 2081 - [Raptor] - Exported file executable permissions not maintained (linux)
timothy.murphy@nokia.com
parents:
246
diff
changeset
|
2866 |
sourceMTime = sourceStat[stat.ST_MTIME] |
3 | 2867 |
destMTime = os.stat(dest_str)[stat.ST_MTIME] |
2868 |
except OSError, e: |
|
2869 |
if sourceMTime == 0: |
|
2870 |
message = "Source of export does not exist: " + str(source) |
|
2871 |
if not self.__Raptor.keepGoing: |
|
2872 |
raise MetaDataError(message) |
|
2873 |
else: |
|
2874 |
self.__Raptor.Error(message, bldinf=bldInfFile) |
|
2875 |
||
2876 |
if destMTime == 0 or destMTime < sourceMTime: |
|
2877 |
if os.path.exists(dest_str): |
|
2878 |
os.chmod(dest_str,stat.S_IREAD | stat.S_IWRITE) |
|
2879 |
shutil.copyfile(source_str, dest_str) |
|
278
c38bfd29ee57
SF Bug 2081 - [Raptor] - Exported file executable permissions not maintained (linux)
timothy.murphy@nokia.com
parents:
246
diff
changeset
|
2880 |
|
c38bfd29ee57
SF Bug 2081 - [Raptor] - Exported file executable permissions not maintained (linux)
timothy.murphy@nokia.com
parents:
246
diff
changeset
|
2881 |
# Ensure that the destination file remains executable if the source was also: |
c38bfd29ee57
SF Bug 2081 - [Raptor] - Exported file executable permissions not maintained (linux)
timothy.murphy@nokia.com
parents:
246
diff
changeset
|
2882 |
os.chmod(dest_str,sourceStat[stat.ST_MODE] | stat.S_IREAD | stat.S_IWRITE | stat.S_IWGRP ) |
3 | 2883 |
self.__Raptor.Info("Copied %s to %s", source_str, dest_str) |
2884 |
else: |
|
2885 |
self.__Raptor.Info("Up-to-date: %s", dest_str) |
|
2886 |
||
2887 |
||
2888 |
except Exception,e: |
|
2889 |
message = "Could not export " + source_str + " to " + dest_str + " : " + str(e) |
|
2890 |
if not self.__Raptor.keepGoing: |
|
2891 |
raise MetaDataError(message) |
|
2892 |
else: |
|
2893 |
self.__Raptor.Error(message, bldinf=bldInfFile) |
|
2894 |
||
2895 |
return exportwhatlog |
|
2896 |
||
2897 |
||
2898 |
def UnzipExport(self, _source, _destination, _sbs_build_dir, bldinf_filename): |
|
2899 |
"""Unzip the source zipfile into the destination directory |
|
2900 |
but only if the markerfile does not already exist there |
|
2901 |
or it does exist but is older than the zipfile. |
|
2902 |
the markerfile is comprised of the name of the zipfile |
|
2903 |
with the ".zip" removed and ".unzipped" added. |
|
2904 |
""" |
|
2905 |
||
2906 |
# Insert spaces into file if they are there |
|
2907 |
source = str(_source).replace('%20',' ') |
|
2908 |
destination = str(_destination).replace('%20',' ') |
|
2909 |
sanitisedSource = raptor_utilities.sanitise(source) |
|
2910 |
sanitisedDestination = raptor_utilities.sanitise(destination) |
|
2911 |
||
2912 |
destination = str(_destination).replace('%20',' ') |
|
2913 |
exportwhatlog = "" |
|
2914 |
||
2915 |
||
2916 |
try: |
|
2917 |
if not _destination.isDir(): |
|
2918 |
os.makedirs(destination) |
|
2919 |
||
2920 |
# Form the directory to contain the unzipped marker files, and make the directory if require. |
|
2921 |
markerfiledir = generic_path.Path(_sbs_build_dir) |
|
2922 |
if not markerfiledir.isDir(): |
|
2923 |
os.makedirs(str(markerfiledir)) |
|
2924 |
||
2925 |
# Form the marker file name and convert to Python string |
|
2926 |
markerfilename = str(generic_path.Join(markerfiledir, sanitisedSource + sanitisedDestination + ".unzipped")) |
|
2927 |
||
2928 |
# Don't unzip if the marker file is already there or more uptodate |
|
2929 |
sourceMTime = 0 |
|
2930 |
destMTime = 0 |
|
2931 |
try: |
|
2932 |
sourceMTime = os.stat(source)[stat.ST_MTIME] |
|
2933 |
destMTime = os.stat(markerfilename)[stat.ST_MTIME] |
|
2934 |
except OSError, e: |
|
2935 |
if sourceMTime == 0: |
|
2936 |
raise MetaDataError("Source zip for export does not exist: " + source) |
|
2937 |
if destMTime != 0 and destMTime >= sourceMTime: |
|
2938 |
# This file has already been unzipped. Print members then return |
|
2939 |
exportzip = zipfile.ZipFile(source, 'r') |
|
2940 |
files = exportzip.namelist() |
|
2941 |
files.sort() |
|
2942 |
||
2943 |
for file in files: |
|
2944 |
if not file.endswith('/'): |
|
2945 |
expfilename = str(generic_path.Join(destination, file)) |
|
212
18372202b584
escape filenames in <member> tags
Richard Taylor <richard.i.taylor@nokia.com>
parents:
160
diff
changeset
|
2946 |
exportwhatlog += "<member>" + escape(expfilename) + "</member>\n" |
3 | 2947 |
|
2948 |
self.__Raptor.PrintXML("<clean bldinf='" + bldinf_filename + "' mmp='' config=''>\n") |
|
2949 |
self.__Raptor.PrintXML("<zipmarker>" + markerfilename + "</zipmarker>\n") |
|
2950 |
self.__Raptor.PrintXML("</clean>\n") |
|
2951 |
||
2952 |
return exportwhatlog |
|
2953 |
||
2954 |
exportzip = zipfile.ZipFile(source, 'r') |
|
2955 |
files = exportzip.namelist() |
|
2956 |
files.sort() |
|
2957 |
filecount = 0 |
|
2958 |
for file in files: |
|
2959 |
expfilename = str(generic_path.Join(destination, file)) |
|
2960 |
if file.endswith('/'): |
|
2961 |
try: |
|
2962 |
os.makedirs(expfilename) |
|
2963 |
except OSError, e: |
|
2964 |
pass # errors to do with "already exists" are not interesting. |
|
2965 |
else: |
|
2966 |
try: |
|
2967 |
os.makedirs(os.path.split(expfilename)[0]) |
|
2968 |
except OSError, e: |
|
2969 |
pass # errors to do with "already exists" are not interesting. |
|
2970 |
||
2971 |
try: |
|
2972 |
if os.path.exists(expfilename): |
|
2973 |
os.chmod(expfilename,stat.S_IREAD | stat.S_IWRITE) |
|
2974 |
expfile = open(expfilename, 'wb') |
|
2975 |
expfile.write(exportzip.read(file)) |
|
2976 |
expfile.close() |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2977 |
|
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2978 |
# Resurrect any file execution permissions present in the archived version |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2979 |
if (exportzip.getinfo(file).external_attr >> 16L) & 0100: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2980 |
os.chmod(expfilename, stat.S_IMODE(os.stat(expfilename).st_mode) | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2981 |
|
3 | 2982 |
# Each file keeps its modified time the same as what it was before unzipping |
2983 |
accesstime = time.time() |
|
2984 |
datetime = exportzip.getinfo(file).date_time |
|
2985 |
timeTuple=(int(datetime[0]), int(datetime[1]), int(datetime[2]), int(datetime[3]), \ |
|
2986 |
int(datetime[4]), int(datetime[5]), int(0), int(0), int(0)) |
|
2987 |
modifiedtime = time.mktime(timeTuple) |
|
2988 |
os.utime(expfilename,(accesstime, modifiedtime)) |
|
2989 |
||
2990 |
filecount += 1 |
|
212
18372202b584
escape filenames in <member> tags
Richard Taylor <richard.i.taylor@nokia.com>
parents:
160
diff
changeset
|
2991 |
exportwhatlog+="<member>" + escape(expfilename) + "</member>\n" |
3 | 2992 |
except IOError, e: |
2993 |
message = "Could not unzip %s to %s: file %s: %s" %(source, destination, expfilename, str(e)) |
|
2994 |
if not self.__Raptor.keepGoing: |
|
2995 |
raise MetaDataError(message) |
|
2996 |
else: |
|
2997 |
self.__Raptor.Error(message, bldinf=bldinf_filename) |
|
2998 |
||
2999 |
markerfile = open(markerfilename, 'wb+') |
|
3000 |
markerfile.close() |
|
3001 |
self.__Raptor.PrintXML("<clean bldinf='" + bldinf_filename + "' mmp='' config=''>\n") |
|
3002 |
self.__Raptor.PrintXML("<zipmarker>" + markerfilename + "</zipmarker>\n") |
|
3003 |
self.__Raptor.PrintXML("</clean>\n") |
|
3004 |
||
368
113d720d5a6c
Added test case for EPOCNESTEDEXCEPTIONS.
Stefan Karlsson <stefan.karlsson@nokia.com>
parents:
288
diff
changeset
|
3005 |
except IOError, e: |
3 | 3006 |
self.__Raptor.Warn("Problem while unzipping export %s to %s: %s",source,destination,str(e)) |
3007 |
||
3008 |
self.__Raptor.Info("Unzipped %d files from %s to %s", filecount, source, destination) |
|
3009 |
return exportwhatlog |
|
3010 |
||
3011 |
def ProcessTEMs(self, componentNode, buildPlatform): |
|
3012 |
"""Add Template Extension Makefile nodes for a given platform |
|
3013 |
to a skeleton bld.inf node. |
|
3014 |
||
3015 |
This happens after exports have been handled. |
|
3016 |
""" |
|
3017 |
if buildPlatform["ISFEATUREVARIANT"]: |
|
3018 |
return # feature variation does not run extensions at all |
|
3019 |
||
3020 |
if buildPlatform["TESTCODE"]: |
|
5 | 3021 |
extensions = componentNode.component.bldinf.getTestExtensions(buildPlatform) |
3 | 3022 |
else: |
5 | 3023 |
extensions = componentNode.component.bldinf.getExtensions(buildPlatform) |
3 | 3024 |
|
3025 |
self.__Raptor.Debug("%i template extension makefiles for %s", |
|
5 | 3026 |
len(extensions), str(componentNode.component.bldinf.filename)) |
3 | 3027 |
|
3028 |
for i,extension in enumerate(extensions): |
|
3029 |
if self.__Raptor.projects: |
|
3030 |
if not extension.nametag in self.__Raptor.projects: |
|
3031 |
self.__Raptor.Debug("Skipping %s", extension.getMakefile()) |
|
3032 |
continue |
|
3033 |
elif extension.nametag in self.projectList: |
|
3034 |
self.projectList.remove(extension.nametag) |
|
3035 |
||
3036 |
extensionSpec = raptor_data.Specification("extension" + str(i)) |
|
3037 |
||
3038 |
interface = buildPlatform["extension"] |
|
3039 |
customInterface = False |
|
3040 |
||
3041 |
# is there an FLM replacement for this extension? |
|
3042 |
if extension.interface: |
|
3043 |
try: |
|
3044 |
interface = self.__Raptor.cache.FindNamedInterface(extension.interface, buildPlatform["CACHEID"]) |
|
3045 |
customInterface = True |
|
3046 |
except KeyError: |
|
3047 |
# no, there isn't an FLM |
|
3048 |
pass |
|
3049 |
||
3050 |
extensionSpec.SetInterface(interface) |
|
3051 |
||
3052 |
var = raptor_data.Variant() |
|
3053 |
var.AddOperation(raptor_data.Set("EPOCBLD", "$(OUTPUTPATH)")) |
|
3054 |
var.AddOperation(raptor_data.Set("PLATFORM", buildPlatform["PLATFORM"])) |
|
3055 |
var.AddOperation(raptor_data.Set("PLATFORM_PATH", buildPlatform["PLATFORM"].lower())) |
|
3056 |
var.AddOperation(raptor_data.Set("CFG", "$(VARIANTTYPE)")) |
|
3057 |
var.AddOperation(raptor_data.Set("CFG_PATH", "$(VARIANTTYPE)")) |
|
3058 |
var.AddOperation(raptor_data.Set("GENERATEDCPP", "$(OUTPUTPATH)")) |
|
3059 |
var.AddOperation(raptor_data.Set("TEMPLATE_EXTENSION_MAKEFILE", extension.getMakefile())) |
|
3060 |
var.AddOperation(raptor_data.Set("TEMCOUNT", str(i))) |
|
3061 |
||
3062 |
# Extension inputs are added to the build spec. |
|
3063 |
# '$'s are escaped so that they are not expanded by Raptor or |
|
3064 |
# by Make in the call to the FLM |
|
3065 |
# The Extension makefiles are supposed to expand them themselves |
|
3066 |
# Path separators need not be parameterised anymore |
|
3067 |
# as bash is the standard shell |
|
3068 |
standardVariables = extension.getStandardVariables() |
|
3069 |
for standardVariable in standardVariables.keys(): |
|
3070 |
self.__Raptor.Debug("Set %s=%s", standardVariable, standardVariables[standardVariable]) |
|
3071 |
value = standardVariables[standardVariable].replace('$(', '$$$$(') |
|
3072 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3073 |
var.AddOperation(raptor_data.Set(standardVariable, value)) |
|
3074 |
||
3075 |
# . . . as with the standard variables but the names and number |
|
3076 |
# of options are not known in advance so we add them to |
|
3077 |
# a "structure" that is self-describing |
|
3078 |
var.AddOperation(raptor_data.Set("O._MEMBERS", "")) |
|
3079 |
options = extension.getOptions() |
|
3080 |
for option in options: |
|
3081 |
self.__Raptor.Debug("Set %s=%s", option, options[option]) |
|
3082 |
value = options[option].replace('$(EPOCROOT)', '$(EPOCROOT)/') |
|
3083 |
value = value.replace('$(', '$$$$(') |
|
3084 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3085 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3086 |
||
3087 |
if customInterface: |
|
3088 |
var.AddOperation(raptor_data.Set(option, value)) |
|
3089 |
else: |
|
3090 |
var.AddOperation(raptor_data.Append("O._MEMBERS", option)) |
|
3091 |
var.AddOperation(raptor_data.Set("O." + option, value)) |
|
3092 |
||
3093 |
extensionSpec.AddVariant(var) |
|
3094 |
componentNode.AddChild(extensionSpec) |
|
3095 |
||
3096 |
||
3097 |
def ProcessMMPs(self, componentNode, buildPlatform): |
|
3098 |
"""Add project nodes for a given platform to a skeleton bld.inf node. |
|
3099 |
||
3100 |
This happens after exports have been handled. |
|
3101 |
""" |
|
3102 |
gnuList = [] |
|
3103 |
makefileList = [] |
|
3104 |
||
5 | 3105 |
|
3106 |
component = componentNode.component |
|
3107 |
||
3108 |
||
3 | 3109 |
if buildPlatform["TESTCODE"]: |
5 | 3110 |
MMPList = component.bldinf.getTestMMPList(buildPlatform) |
3 | 3111 |
else: |
5 | 3112 |
MMPList = component.bldinf.getMMPList(buildPlatform) |
3113 |
||
3114 |
bldInfFile = component.bldinf.filename |
|
3 | 3115 |
|
3116 |
for mmpFileEntry in MMPList['mmpFileList']: |
|
5 | 3117 |
component.AddMMP(mmpFileEntry.filename) # Tell the component another mmp is specified (for this platform) |
3118 |
||
3 | 3119 |
projectname = mmpFileEntry.filename.File().lower() |
3120 |
||
3121 |
if self.__Raptor.projects: |
|
3122 |
if not projectname in self.__Raptor.projects: |
|
3123 |
self.__Raptor.Debug("Skipping %s", str(mmpFileEntry.filename)) |
|
3124 |
continue |
|
3125 |
elif projectname in self.projectList: |
|
3126 |
self.projectList.remove(projectname) |
|
3127 |
||
3128 |
foundmmpfile = (mmpFileEntry.filename).FindCaseless() |
|
3129 |
||
3130 |
if foundmmpfile == None: |
|
3131 |
self.__Raptor.Error("Can't find mmp file '%s'", str(mmpFileEntry.filename), bldinf=str(bldInfFile)) |
|
3132 |
continue |
|
3133 |
||
3134 |
mmpFile = MMPFile(foundmmpfile, |
|
3135 |
self.__gnucpp, |
|
5 | 3136 |
component.bldinf, |
3137 |
component.depfiles, |
|
3 | 3138 |
log = self.__Raptor) |
3139 |
||
3140 |
mmpFilename = mmpFile.filename |
|
3141 |
||
3142 |
self.__Raptor.Info("Processing %s for platform %s", |
|
3143 |
str(mmpFilename), |
|
3144 |
" + ".join([x.name for x in buildPlatform["configs"]])) |
|
3145 |
||
3146 |
# Run the Parser |
|
3147 |
# The backend supplies the actions |
|
3148 |
content = mmpFile.getContent(buildPlatform) |
|
3149 |
backend = MMPRaptorBackend(self.__Raptor, str(mmpFilename), str(bldInfFile)) |
|
3150 |
parser = MMPParser(backend) |
|
3151 |
parseresult = None |
|
3152 |
try: |
|
3153 |
parseresult = parser.mmp.parseString(content) |
|
3154 |
except ParseException,e: |
|
3155 |
self.__Raptor.Debug(e) # basically ignore parse exceptions |
|
3156 |
||
3157 |
if (not parseresult) or (parseresult[0] != 'MMP'): |
|
3158 |
self.__Raptor.Error("The MMP Parser didn't recognise the mmp file '%s'", |
|
3159 |
str(mmpFileEntry.filename), |
|
3160 |
bldinf=str(bldInfFile)) |
|
3161 |
self.__Raptor.Debug(content) |
|
3162 |
self.__Raptor.Debug("The parse result was %s", parseresult) |
|
3163 |
else: |
|
3164 |
backend.finalise(buildPlatform) |
|
3165 |
||
3166 |
# feature variation only processes FEATUREVARIANT binaries |
|
3167 |
if buildPlatform["ISFEATUREVARIANT"] and not backend.featureVariant: |
|
3168 |
continue |
|
3169 |
||
3170 |
# now build the specification tree |
|
5 | 3171 |
mmpSpec = raptor_data.Specification(generic_path.Path(getSpecName(mmpFilename))) |
3 | 3172 |
var = backend.BuildVariant |
3173 |
||
3174 |
var.AddOperation(raptor_data.Set("PROJECT_META", str(mmpFilename))) |
|
3175 |
||
3176 |
# If it is a TESTMMPFILE section, the FLM needs to know about it |
|
3177 |
if buildPlatform["TESTCODE"] and (mmpFileEntry.testoption in |
|
3178 |
["manual", "auto"]): |
|
3179 |
||
3180 |
var.AddOperation(raptor_data.Set("TESTPATH", |
|
3181 |
mmpFileEntry.testoption.lower() + ".bat")) |
|
3182 |
||
3183 |
# The output path for objects, stringtables and bitmaps specified by |
|
3184 |
# this MMP. Adding in the requested target extension prevents build |
|
3185 |
# "fouling" in cases where there are several mmp targets which only differ |
|
3186 |
# by the requested extension. e.g. elocl.01 and elocl.18 |
|
3187 |
var.AddOperation(raptor_data.Append("OUTPUTPATH","$(UNIQUETARGETPATH)",'/')) |
|
3188 |
||
3189 |
# If the bld.inf entry for this MMP had the BUILD_AS_ARM option then |
|
3190 |
# tell the FLM. |
|
3191 |
if mmpFileEntry.armoption: |
|
3192 |
var.AddOperation(raptor_data.Set("ALWAYS_BUILD_AS_ARM","1")) |
|
3193 |
||
3194 |
# what interface builds this node? |
|
3195 |
try: |
|
3196 |
interfaceName = buildPlatform[backend.getTargetType()] |
|
3197 |
mmpSpec.SetInterface(interfaceName) |
|
3198 |
except KeyError: |
|
3199 |
self.__Raptor.Error("Unsupported target type '%s' in %s", |
|
3200 |
backend.getTargetType(), |
|
3201 |
str(mmpFileEntry.filename), |
|
3202 |
bldinf=str(bldInfFile)) |
|
3203 |
continue |
|
3204 |
||
3205 |
# Although not part of the MMP, some MMP-based build specs additionally require knowledge of their |
|
3206 |
# container bld.inf exported headers |
|
5 | 3207 |
for export in componentNode.component.bldinf.getExports(buildPlatform): |
3 | 3208 |
destination = export.getDestination() |
3209 |
if isinstance(destination, list): |
|
3210 |
exportfile = str(destination[0]) |
|
3211 |
else: |
|
3212 |
exportfile = str(destination) |
|
3213 |
||
3214 |
if re.search('\.h',exportfile,re.IGNORECASE): |
|
3215 |
var.AddOperation(raptor_data.Append("EXPORTHEADERS", str(exportfile))) |
|
3216 |
||
3217 |
# now we have something worth adding to the component |
|
3218 |
mmpSpec.AddVariant(var) |
|
3219 |
componentNode.AddChild(mmpSpec) |
|
9 | 3220 |
|
3221 |
# if there are APPLY variants then add them to the mmpSpec too |
|
3222 |
for applyVar in backend.ApplyVariants: |
|
3223 |
try: |
|
3224 |
mmpSpec.AddVariant(self.__Raptor.cache.FindNamedVariant(applyVar)) |
|
3225 |
except KeyError: |
|
3226 |
self.__Raptor.Error("APPLY unknown variant '%s' in %s", |
|
3227 |
applyVar, |
|
3228 |
str(mmpFileEntry.filename), |
|
3229 |
bldinf=str(bldInfFile)) |
|
3 | 3230 |
|
3231 |
# resources, stringtables and bitmaps are sub-nodes of this project |
|
3232 |
# (do not add these for feature variant builds) |
|
3233 |
||
3234 |
if not buildPlatform["ISFEATUREVARIANT"]: |
|
3235 |
# Buildspec for Resource files |
|
3236 |
for i,rvar in enumerate(backend.ResourceVariants): |
|
3237 |
resourceSpec = raptor_data.Specification('resource' + str(i)) |
|
3238 |
resourceSpec.SetInterface(buildPlatform['resource']) |
|
3239 |
resourceSpec.AddVariant(rvar) |
|
3240 |
mmpSpec.AddChild(resourceSpec) |
|
3241 |
||
3242 |
# Buildspec for String Tables |
|
3243 |
for i,stvar in enumerate(backend.StringTableVariants): |
|
3244 |
stringTableSpec = raptor_data.Specification('stringtable' + str(i)) |
|
3245 |
stringTableSpec.SetInterface(buildPlatform['stringtable']) |
|
3246 |
stringTableSpec.AddVariant(stvar) |
|
3247 |
mmpSpec.AddChild(stringTableSpec) |
|
3248 |
||
3249 |
# Buildspec for Bitmaps |
|
3250 |
for i,bvar in enumerate(backend.BitmapVariants): |
|
3251 |
bitmapSpec = raptor_data.Specification('bitmap' + str(i)) |
|
3252 |
bitmapSpec.SetInterface(buildPlatform['bitmap']) |
|
3253 |
bitmapSpec.AddVariant(bvar) |
|
3254 |
mmpSpec.AddChild(bitmapSpec) |
|
3255 |
||
3256 |
# feature variation does not run extensions at all |
|
3257 |
# so return without considering .*MAKEFILE sections |
|
3258 |
if buildPlatform["ISFEATUREVARIANT"]: |
|
3259 |
return |
|
3260 |
||
3261 |
# Build spec for gnumakefile |
|
3262 |
for g in MMPList['gnuList']: |
|
3263 |
projectname = g.getMakefileName().lower() |
|
3264 |
||
3265 |
if self.__Raptor.projects: |
|
3266 |
if not projectname in self.__Raptor.projects: |
|
3267 |
self.__Raptor.Debug("Skipping %s", str(g.getMakefileName())) |
|
3268 |
continue |
|
3269 |
elif projectname in self.projectList: |
|
3270 |
self.projectList.remove(projectname) |
|
3271 |
||
3272 |
self.__Raptor.Debug("%i gnumakefile extension makefiles for %s", |
|
5 | 3273 |
len(gnuList), str(componentNode.component.bldinf.filename)) |
3 | 3274 |
var = raptor_data.Variant() |
3275 |
gnuSpec = raptor_data.Specification("gnumakefile " + str(g.getMakefileName())) |
|
3276 |
interface = buildPlatform["ext_makefile"] |
|
3277 |
gnuSpec.SetInterface(interface) |
|
3278 |
gnumakefilePath = raptor_utilities.resolveSymbianPath(str(bldInfFile), g.getMakefileName()) |
|
3279 |
var.AddOperation(raptor_data.Set("EPOCBLD", "$(OUTPUTPATH)")) |
|
3280 |
var.AddOperation(raptor_data.Set("PLATFORM", buildPlatform["PLATFORM"])) |
|
3281 |
var.AddOperation(raptor_data.Set("EXTMAKEFILENAME", g.getMakefileName())) |
|
3282 |
var.AddOperation(raptor_data.Set("DIRECTORY",g.getMakeDirectory())) |
|
3283 |
var.AddOperation(raptor_data.Set("CFG","$(VARIANTTYPE)")) |
|
3284 |
standardVariables = g.getStandardVariables() |
|
3285 |
for standardVariable in standardVariables.keys(): |
|
3286 |
self.__Raptor.Debug("Set %s=%s", standardVariable, standardVariables[standardVariable]) |
|
3287 |
value = standardVariables[standardVariable].replace('$(', '$$$$(') |
|
3288 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3289 |
var.AddOperation(raptor_data.Set(standardVariable, value)) |
|
3290 |
gnuSpec.AddVariant(var) |
|
3291 |
componentNode.AddChild(gnuSpec) |
|
3292 |
||
3293 |
# Build spec for makefile |
|
3294 |
for m in MMPList['makefileList']: |
|
3295 |
projectname = m.getMakefileName().lower() |
|
3296 |
||
3297 |
if self.__Raptor.projects: |
|
3298 |
if not projectname in self.__Raptor.projects: |
|
3299 |
self.__Raptor.Debug("Skipping %s", str(m.getMakefileName())) |
|
3300 |
continue |
|
3301 |
elif projectname in self.projectList: |
|
458
79718b9711e8
fix for bug 2297 : traceback on unmatched END in a bld.inf
Richard Taylor <richard.i.taylor@nokia.com>
parents:
422
diff
changeset
|
3302 |
self.projectList.remove(projectname) |
3 | 3303 |
|
3304 |
self.__Raptor.Debug("%i makefile extension makefiles for %s", |
|
5 | 3305 |
len(makefileList), str(componentNode.component.bldinf.filename)) |
3 | 3306 |
var = raptor_data.Variant() |
3307 |
gnuSpec = raptor_data.Specification("makefile " + str(m.getMakefileName())) |
|
3308 |
interface = buildPlatform["ext_makefile"] |
|
3309 |
gnuSpec.SetInterface(interface) |
|
3310 |
gnumakefilePath = raptor_utilities.resolveSymbianPath(str(bldInfFile), m.getMakefileName()) |
|
3311 |
var.AddOperation(raptor_data.Set("EPOCBLD", "$(OUTPUTPATH)")) |
|
3312 |
var.AddOperation(raptor_data.Set("PLATFORM", buildPlatform["PLATFORM"])) |
|
3313 |
var.AddOperation(raptor_data.Set("EXTMAKEFILENAME", m.getMakefileName())) |
|
3314 |
var.AddOperation(raptor_data.Set("DIRECTORY",m.getMakeDirectory())) |
|
3315 |
var.AddOperation(raptor_data.Set("CFG","$(VARIANTTYPE)")) |
|
3316 |
var.AddOperation(raptor_data.Set("USENMAKE","1")) |
|
3317 |
standardVariables = m.getStandardVariables() |
|
3318 |
for standardVariable in standardVariables.keys(): |
|
3319 |
self.__Raptor.Debug("Set %s=%s", standardVariable, standardVariables[standardVariable]) |
|
3320 |
value = standardVariables[standardVariable].replace('$(', '$$$$(') |
|
3321 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3322 |
var.AddOperation(raptor_data.Set(standardVariable, value)) |
|
3323 |
gnuSpec.AddVariant(var) |
|
3324 |
componentNode.AddChild(gnuSpec) |
|
3325 |
||
3326 |
||
3327 |
def ApplyOSVariant(self, aBuildUnit, aEpocroot): |
|
3328 |
# Form path to kif.xml and path to buildinfo.txt |
|
3329 |
kifXmlPath = generic_path.Join(aEpocroot, "epoc32", "data","kif.xml") |
|
3330 |
buildInfoTxtPath = generic_path.Join(aEpocroot, "epoc32", "data","buildinfo.txt") |
|
3331 |
||
3332 |
# Start with osVersion being None. This variable is a string and does two things: |
|
3333 |
# 1) is a representation of the OS version |
|
3334 |
# 2) is potentially the name of a variant |
|
3335 |
osVersion = None |
|
3336 |
if kifXmlPath.isFile(): # kif.xml exists so try to read it |
|
3337 |
osVersion = getOsVerFromKifXml(str(kifXmlPath)) |
|
3338 |
if osVersion != None: |
|
3339 |
self.__Raptor.Info("OS version \"%s\" determined from file \"%s\"" % (osVersion, kifXmlPath)) |
|
3340 |
||
3341 |
# OS version was not determined from the kif.xml, e.g. because it doesn't exist |
|
3342 |
# or there was a problem parsing it. So, we fall over to using the buildinfo.txt |
|
3343 |
if osVersion == None and buildInfoTxtPath.isFile(): |
|
3344 |
osVersion = getOsVerFromBuildInfoTxt(str(buildInfoTxtPath)) |
|
3345 |
if osVersion != None: |
|
3346 |
self.__Raptor.Info("OS version \"%s\" determined from file \"%s\"" % (osVersion, buildInfoTxtPath)) |
|
3347 |
||
3348 |
# If we determined a non-empty string for the OS Version, attempt to apply it |
|
3349 |
if osVersion and osVersion in self.__Raptor.cache.variants: |
|
3350 |
self.__Raptor.Info("applying the OS variant to the configuration \"%s\"." % aBuildUnit.name) |
|
3351 |
aBuildUnit.variants.append(self.__Raptor.cache.variants[osVersion]) |
|
3352 |
else: |
|
3353 |
self.__Raptor.Info("no OS variant for the configuration \"%s\"." % aBuildUnit.name) |
|
3354 |