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