author | timothy.murphy@nokia.com |
Sun, 06 Dec 2009 18:26:19 +0000 | |
branch | wip |
changeset 88 | b5820d0f3a1c |
parent 32 | fdfc59a2ae7e |
child 44 | cf0c187b284a |
child 48 | f872a2538607 |
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]: |
|
1454 |
self.__debug("Setting "+toks[0]+": " + cap) |
|
5 | 1455 |
self.capabilities.append(cap) |
3 | 1456 |
elif varname=='DEFFILE': |
1457 |
self.__defFileRoot = self.__currentMmpFile |
|
1458 |
self.deffile = toks[1] |
|
1459 |
elif varname=='LINKAS': |
|
1460 |
self.__debug("Set "+toks[0]+" OPTION to " + str(toks[1])) |
|
1461 |
self.__LINKAS = toks[1] |
|
1462 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, toks[1])) |
|
1463 |
elif varname=='SECUREID' or varname=='VENDORID': |
|
1464 |
hexoutput = MMPRaptorBackend.canonicalUID(toks[1]) |
|
1465 |
self.__debug("Set "+toks[0]+" OPTION to " + hexoutput) |
|
1466 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, hexoutput)) |
|
1467 |
elif varname=='VERSION': |
|
1468 |
if toks[-1] == "EXPLICIT": |
|
1469 |
self.__explicitversion = True |
|
1470 |
self.BuildVariant.AddOperation(raptor_data.Set("EXPLICITVERSION", "1")) |
|
1471 |
||
1472 |
vm = re.match(r'^(\d+)(\.(\d+))?$', toks[1]) |
|
1473 |
if vm is not None: |
|
1474 |
version = vm.groups() |
|
1475 |
# the major version number |
|
1476 |
major = int(version[0],10) |
|
1477 |
||
1478 |
# add in the minor number |
|
1479 |
minor = 0 |
|
1480 |
if version[1] is not None: |
|
1481 |
minor = int(version[2],10) |
|
1482 |
else: |
|
1483 |
self.__Raptor.Warn("VERSION (%s) missing '.minor' in %s, using '.0'" % (toks[1],self.__currentMmpFile)) |
|
1484 |
||
1485 |
self.__versionhex = "%04x%04x" % (major, minor) |
|
1486 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, "%d.%d" %(major, minor))) |
|
1487 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"HEX", self.__versionhex)) |
|
1488 |
self.__debug("Set "+toks[0]+" OPTION to " + toks[1]) |
|
1489 |
self.__debug("Set "+toks[0]+"HEX OPTION to " + "%04x%04x" % (major,minor)) |
|
1490 |
||
1491 |
else: |
|
1492 |
self.__Raptor.Warn("Invalid version supplied to VERSION (%s), using default value" % toks[1]) |
|
1493 |
||
1494 |
elif varname=='EPOCHEAPSIZE': |
|
1495 |
# Standardise on sending hex numbers to the FLMS. |
|
1496 |
||
1497 |
if toks[1].lower().startswith('0x'): |
|
1498 |
min = long(toks[1],16) |
|
1499 |
else: |
|
1500 |
min = long(toks[1],10) |
|
1501 |
||
1502 |
if toks[2].lower().startswith('0x'): |
|
1503 |
max = long(toks[2],16) |
|
1504 |
else: |
|
1505 |
max = long(toks[2],10) |
|
1506 |
||
1507 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MIN", "%x" % min)) |
|
1508 |
self.__debug("Set "+varname+"MIN OPTION to '%x' (hex)" % min ) |
|
1509 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MAX", "%x" % max)) |
|
1510 |
self.__debug("Set "+varname+"MAX OPTION to '%x' (hex)" % max ) |
|
1511 |
||
1512 |
# Some toolchains require decimal versions of the min/max values, converted to KB and |
|
1513 |
# rounded up to the next 1KB boundary |
|
1514 |
min_dec_kb = (int(min) + 1023) / 1024 |
|
1515 |
max_dec_kb = (int(max) + 1023) / 1024 |
|
1516 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MIN_DEC_KB", "%d" % min_dec_kb)) |
|
1517 |
self.__debug("Set "+varname+"MIN OPTION KB to '%d' (dec)" % min_dec_kb ) |
|
1518 |
self.BuildVariant.AddOperation(raptor_data.Set(varname+"MAX_DEC_KB", "%d" % max_dec_kb)) |
|
1519 |
self.__debug("Set "+varname+"MAX OPTION KB to '%d' (dec)" % max_dec_kb ) |
|
1520 |
||
1521 |
elif varname=='EPOCSTACKSIZE': |
|
1522 |
if toks[1].lower().startswith('0x'): |
|
1523 |
stack = long(toks[1],16) |
|
1524 |
else: |
|
1525 |
stack = long(toks[1],10) |
|
1526 |
self.BuildVariant.AddOperation(raptor_data.Set(varname, "%x" % stack)) |
|
1527 |
self.__debug("Set "+varname+" OPTION to '%x' (hex)" % stack ) |
|
1528 |
elif varname=='EPOCPROCESSPRIORITY': |
|
1529 |
# low, background, foreground, high, windowserver, fileserver, realtimeserver or supervisor |
|
1530 |
# These are case insensitive in metadata entries, but must be mapped to a static case pattern for use |
|
1531 |
prio = toks[1].lower() |
|
1532 |
||
1533 |
# NOTE: Original validation here didn't actually work. This has been corrected to provide an error, but probably needs re-examination. |
|
1534 |
if not MMPRaptorBackend.epoc32priorities.has_key(prio): |
|
1535 |
self.__Raptor.Error("Priority setting '%s' is not a valid priority - should be one of %s.", prio, MMPRaptorBackend.epoc32priorities.values()) |
|
1536 |
else: |
|
1537 |
self.__debug("Set "+toks[0]+" to " + MMPRaptorBackend.epoc32priorities[prio]) |
|
1538 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,MMPRaptorBackend.epoc32priorities[prio])) |
|
1539 |
elif varname=='ROMTARGET' or varname=='RAMTARGET': |
|
1540 |
if len(toks) == 1: |
|
1541 |
self.__debug("Set "+toks[0]+" to <none>" ) |
|
1542 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,"<none>")) |
|
1543 |
else: |
|
1544 |
toks1 = str(toks[1]).replace("\\","/") |
|
1545 |
if toks1.find(","): |
|
1546 |
toks1 = re.sub("[,'\[\]]", "", toks1).replace("//","/") |
|
1547 |
self.__debug("Set "+toks[0]+" to " + toks1) |
|
1548 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,toks1)) |
|
9 | 1549 |
elif varname=='APPLY': |
1550 |
self.ApplyVariants.append(toks[1]) |
|
3 | 1551 |
else: |
1552 |
self.__debug("Set "+toks[0]+" to " + str(toks[1])) |
|
1553 |
self.BuildVariant.AddOperation(raptor_data.Set(varname,"".join(toks[1]))) |
|
1554 |
||
1555 |
if varname=='LINKAS': |
|
1556 |
self.__LINKAS = toks[1] |
|
1557 |
||
1558 |
return "OK" |
|
1559 |
||
1560 |
def doAppend(self,s,loc,toks): |
|
1561 |
self.__currentLineNumber += 1 |
|
1562 |
"""MMP command |
|
1563 |
""" |
|
1564 |
name=toks[0].upper() |
|
1565 |
if len(toks) == 1: |
|
1566 |
# list can be empty e.g. MACRO _FRED_ when fred it defined in the HRH |
|
1567 |
# causes us to see just "MACRO" in the input - it is valid to ignore this |
|
1568 |
self.__debug("Empty append list for " + name) |
|
1569 |
return "OK" |
|
1570 |
self.__debug("Append to "+name+" the values: " +str(toks[1])) |
|
1571 |
||
1572 |
if name=='MACRO': |
|
1573 |
name='MMPDEFS' |
|
1574 |
elif name=='LANG': |
|
1575 |
# don't break the environment variable |
|
1576 |
name='LANGUAGES' |
|
1577 |
||
1578 |
for item in toks[1]: |
|
1579 |
if name=='MMPDEFS': |
|
1580 |
# Unquote any macros since the FLM does it anyhow |
|
1581 |
if item.startswith('"') and item.endswith('"') \ |
|
1582 |
or item.startswith("'") and item.endswith("'"): |
|
1583 |
item = item.strip("'\"") |
|
1584 |
if name=='LIBRARY' or name=='DEBUGLIBRARY': |
|
1585 |
im = MMPRaptorBackend.library_re.match(item) |
|
1586 |
if not im: |
|
1587 |
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) |
|
1588 |
d = im.groupdict() |
|
1589 |
||
1590 |
item = d['name'] |
|
1591 |
if d['version'] is not None: |
|
1592 |
item += "{%04x%04x}" % (int(d['major']), int(d['minor'])) |
|
1593 |
item += ".dso" |
|
1594 |
elif name=='STATICLIBRARY': |
|
1595 |
# the FLM will decide on the ending appropriate to the platform |
|
1596 |
item = re.sub(r"^(.*)\.[Ll][Ii][Bb]$",r"\1", item) |
|
1597 |
elif name=="LANGUAGES": |
|
1598 |
item = item.lower() |
|
1599 |
elif (name=="WIN32_LIBRARY" and (item.startswith(".") or re.search(r'[\\|/]',item))) \ |
|
1600 |
or (name=="WIN32_RESOURCE"): |
|
1601 |
# Relatively pathed win32 libraries, and all win32 resources, are resolved in relation |
|
1602 |
# to the wrapper bld.inf file in which their .mmp file is specified. This equates to |
|
1603 |
# the current working directory in ABLD operation. |
|
1604 |
item = raptor_utilities.resolveSymbianPath(self.__bldInfFilename, item) |
|
1605 |
||
1606 |
self.BuildVariant.AddOperation(raptor_data.Append(name,item," ")) |
|
1607 |
||
1608 |
# maintain a debug library list, the same as LIBRARY but with DEBUGLIBRARY values |
|
1609 |
# appended as they are encountered |
|
1610 |
if name=='LIBRARY' or name=='DEBUGLIBRARY': |
|
1611 |
self.BuildVariant.AddOperation(raptor_data.Append("LIBRARY_DEBUG",item," ")) |
|
1612 |
||
1613 |
return "OK" |
|
1614 |
||
1615 |
def canonicalUID(number): |
|
1616 |
""" convert a UID string into an 8 digit hexadecimal string without leading 0x """ |
|
1617 |
if number.lower().startswith("0x"): |
|
1618 |
n = int(number,16) |
|
1619 |
else: |
|
1620 |
n = int(number,10) |
|
1621 |
||
1622 |
return "%08x" % n |
|
1623 |
||
1624 |
canonicalUID = staticmethod(canonicalUID) |
|
1625 |
||
1626 |
def doUIDAssignment(self,s,loc,toks): |
|
1627 |
"""A single UID command results in a number of spec variables""" |
|
1628 |
self.__currentLineNumber += 1 |
|
1629 |
||
1630 |
hexoutput = MMPRaptorBackend.canonicalUID(toks[1][0]) |
|
1631 |
self.__debug( "Set UID2 to %s" % hexoutput ) |
|
1632 |
self.BuildVariant.AddOperation(raptor_data.Set("UID2", hexoutput)) |
|
1633 |
||
1634 |
if len(toks[1]) > 1: |
|
1635 |
hexoutput = MMPRaptorBackend.canonicalUID(toks[1][1]) |
|
1636 |
self.__debug( "Set UID3 to %s" % hexoutput) |
|
1637 |
self.BuildVariant.AddOperation(raptor_data.Set("UID3", hexoutput)) |
|
1638 |
||
1639 |
self.__debug( "done set UID") |
|
1640 |
return "OK" |
|
1641 |
||
1642 |
def doSourcePathAssignment(self,s,loc,toks): |
|
1643 |
self.__currentLineNumber += 1 |
|
1644 |
self.__sourcepath = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, toks[1]) |
|
1645 |
self.__debug( "Remembering self.sourcepath state: "+str(toks[0])+" is now " + self.__sourcepath) |
|
1646 |
self.__debug("selfcurrentMmpFile: " + self.__currentMmpFile) |
|
1647 |
return "OK" |
|
1648 |
||
1649 |
||
1650 |
def doSourceAssignment(self,s,loc,toks): |
|
1651 |
self.__currentLineNumber += 1 |
|
1652 |
self.__debug( "Setting "+toks[0]+" to " + str(toks[1])) |
|
1653 |
for file in toks[1]: |
|
1654 |
# file is always relative to sourcepath but some MMP files |
|
1655 |
# have items that begin with a slash... |
|
1656 |
file = file.lstrip("/") |
|
1657 |
source = generic_path.Join(self.__sourcepath, file) |
|
1658 |
||
1659 |
# If the SOURCEPATH itself begins with a '/', then dont look up the caseless version, since |
|
1660 |
# we don't know at this time what $(EPOCROOT) will evaluate to. |
|
1661 |
if source.GetLocalString().startswith('$(EPOCROOT)'): |
|
1662 |
self.sources.append(str(source)) |
|
1663 |
self.__debug("Append SOURCE " + str(source)) |
|
1664 |
||
1665 |
else: |
|
1666 |
foundsource = source.FindCaseless() |
|
1667 |
if foundsource == None: |
|
1668 |
# Hope that the file will be generated later |
|
1669 |
self.__debug("Sourcefile not found: %s" % source) |
|
1670 |
foundsource = source |
|
1671 |
||
1672 |
self.sources.append(str(foundsource)) |
|
1673 |
self.__debug("Append SOURCE " + str(foundsource)) |
|
1674 |
||
1675 |
||
1676 |
self.__debug(" sourcepath: " + self.__sourcepath) |
|
1677 |
return "OK" |
|
1678 |
||
1679 |
# Resource |
|
1680 |
||
1681 |
def doOldResourceAssignment(self,s,loc,toks): |
|
1682 |
# Technically deprecated, but still used, so... |
|
1683 |
self.__currentLineNumber += 1 |
|
1684 |
self.__debug("Processing old-style "+toks[0]+" "+str(toks[1])) |
|
1685 |
||
1686 |
sysRes = (toks[0].lower() == "systemresource") |
|
1687 |
||
1688 |
for rss in toks[1]: |
|
1689 |
variant = raptor_data.Variant() |
|
1690 |
||
1691 |
source = generic_path.Join(self.__sourcepath, rss) |
|
1692 |
variant.AddOperation(raptor_data.Set("SOURCE", str(source))) |
|
1693 |
self.__resourceFiles.append(str(source)) |
|
1694 |
||
1695 |
target = source.File().rsplit(".", 1)[0] # remove the extension |
|
1696 |
variant.AddOperation(raptor_data.Set("TARGET", target)) |
|
1697 |
variant.AddOperation(raptor_data.Set("TARGET_lower", target.lower())) |
|
1698 |
||
1699 |
header = target.lower() + ".rsg" # filename policy |
|
1700 |
variant.AddOperation(raptor_data.Set("HEADER", header)) |
|
1701 |
||
1702 |
if sysRes: |
|
1703 |
dsrtp = self.getDefaultSystemResourceTargetPath() |
|
1704 |
variant.AddOperation(raptor_data.Set("TARGETPATH", dsrtp)) |
|
1705 |
||
1706 |
self.ResourceVariants.append(variant) |
|
1707 |
||
1708 |
return "OK" |
|
1709 |
||
1710 |
def getDefaultSystemResourceTargetPath(self): |
|
1711 |
# the default systemresource TARGETPATH value should come from the |
|
1712 |
# configuration rather than being hard-coded here. Then again, this |
|
1713 |
# should really be deprecated away into oblivion... |
|
1714 |
return "system/data" |
|
1715 |
||
1716 |
||
1717 |
def getDefaultResourceTargetPath(self, targettype): |
|
1718 |
# the different default TARGETPATH values should come from the |
|
1719 |
# configuration rather than being hard-coded here. |
|
1720 |
if targettype == "plugin": |
|
1721 |
return "resource/plugins" |
|
1722 |
if targettype == "pdl": |
|
1723 |
return "resource/printers" |
|
1724 |
return "" |
|
1725 |
||
1726 |
def resolveOptionReplace(self, content): |
|
1727 |
""" |
|
1728 |
Constructs search/replace pairs based on .mmp OPTION_REPLACE entries for use on tool command lines |
|
1729 |
within FLMS. |
|
1730 |
||
1731 |
Depending on what's supplied to OPTION_REPLACE <TOOL>, the core part of the <TOOL> command line |
|
1732 |
in the relevant FLM will have search and replace actions performed on it post-expansion (but pre- |
|
1733 |
any OPTION <TOOL> additions). |
|
1734 |
||
1735 |
In terms of logic, we try to follow what ABLD does, as the current behaviour is undocumented. |
|
1736 |
What happens is a little inconsistent, and best described by some generic examples: |
|
1737 |
||
1738 |
OPTION_REPLACE TOOL existing_option replacement_value |
|
1739 |
||
1740 |
Replace all instances of "option existing_value" with "option replacement_value" |
|
1741 |
||
1742 |
OPTION_REPLACE TOOL existing_option replacement_option |
|
1743 |
||
1744 |
Replace all instances of "existing_option" with "replacement_option". |
|
1745 |
||
1746 |
If "existing_option" is present in isolation then a removal is performed. |
|
1747 |
||
1748 |
Any values encountered that don't follow an option are ignored. |
|
1749 |
Options are identified as being prefixed with either '-' or '--'. |
|
1750 |
||
1751 |
The front-end processes each OPTION_REPLACE entry and then appends one or more search/replace pairs |
|
1752 |
to an OPTION_REPLACE_<TOOL> variable in the following format: |
|
1753 |
||
1754 |
search<->replace |
|
1755 |
""" |
|
1756 |
# Note that, for compatibility reasons, the following is mostly a port to Python of the corresponding |
|
1757 |
# ABLD Perl, and hence maintains ABLD's idiosyncrasies in what it achieves |
|
1758 |
||
1759 |
searchReplacePairs = [] |
|
1760 |
matches = re.findall("-{1,2}\S+\s*(?!-)\S*",content) |
|
1761 |
||
1762 |
if matches: |
|
1763 |
# reverse so we can process as a stack whilst retaining original order |
|
1764 |
matches.reverse() |
|
1765 |
||
1766 |
while (len(matches)): |
|
1767 |
match = matches.pop() |
|
1768 |
||
1769 |
standaloneMatch = re.match('^(?P<option>\S+)\s+(?P<value>\S+)$', match) |
|
1770 |
||
1771 |
if (standaloneMatch): |
|
1772 |
# Option listed standalone with a replacement value |
|
1773 |
# Example: |
|
1774 |
# OPTION_REPLACE ARMCC --cpu 6 |
|
1775 |
# Intention: |
|
1776 |
# Replace instances of "--cpu <something>" with "--cpu 6" |
|
1777 |
||
1778 |
# Substitute any existing "option <existing_value>" instances with a single word |
|
1779 |
# "@@<existing_value>" for later replacement |
|
1780 |
searchReplacePairs.append('%s <->@@' % standaloneMatch.group('option')) |
|
1781 |
||
1782 |
# Replace "@@<existing_value>" entries from above with "option <new_value>" entries |
|
1783 |
# A pattern substitution is used to cover pre-existing values |
|
1784 |
searchReplacePairs.append('@@%%<->%s %s' % (standaloneMatch.group('option'), standaloneMatch.group('value'))) |
|
1785 |
else: |
|
1786 |
# Options specified in search/replace pairs with optional values |
|
1787 |
# Example: |
|
1788 |
# OPTION_REPLACE ARMCC --O2 --O3 |
|
1789 |
# Intention: |
|
1790 |
# Replace instances of "--O2" with "--O3" |
|
1791 |
||
1792 |
# At this point we will be looking at just the search option - there may or may not |
|
1793 |
# be a replacement to consider |
|
1794 |
search = match |
|
1795 |
replace = "" |
|
1796 |
if len(matches): |
|
1797 |
replace = matches.pop() |
|
5 | 1798 |
|
3 | 1799 |
searchReplacePairs.append('%s<->%s' % (search, replace)) |
1800 |
||
1801 |
# Replace spaces to maintain word-based grouping in downstream makefile lists |
|
1802 |
for i in range(0,len(searchReplacePairs)): |
|
1803 |
searchReplacePairs[i] = searchReplacePairs[i].replace(' ','%20') |
|
1804 |
||
1805 |
return searchReplacePairs |
|
1806 |
||
1807 |
def doStartResource(self,s,loc,toks): |
|
1808 |
self.__currentLineNumber += 1 |
|
1809 |
self.__debug("Start RESOURCE "+toks[1]) |
|
1810 |
||
1811 |
self.__current_resource = generic_path.Path(self.__sourcepath, toks[1]) |
|
1812 |
self.__current_resource = str(self.__current_resource) |
|
1813 |
||
1814 |
self.__debug("sourcepath: " + self.__sourcepath) |
|
1815 |
self.__debug("self.__current_resource source: " + toks[1]) |
|
1816 |
self.__debug("adjusted self.__current_resource source=" + self.__current_resource) |
|
1817 |
||
1818 |
self.__currentResourceVariant = raptor_data.Variant() |
|
1819 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("SOURCE", self.__current_resource)) |
|
1820 |
self.__resourceFiles.append(self.__current_resource) |
|
1821 |
||
1822 |
# The target name is the basename of the resource without the extension |
|
1823 |
# e.g. "/fred/129ab34f.rss" would have a target name of "129ab34f" |
|
1824 |
target = self.__current_resource.rsplit("/",1)[-1] |
|
1825 |
target = target.rsplit(".",1)[0] |
|
1826 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("TARGET", target)) |
|
1827 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("TARGET_lower", target.lower())) |
|
1828 |
self.__headerspecified = False |
|
1829 |
self.__headeronlyspecified = False |
|
1830 |
self.__current_resource_header = target.lower() + ".rsg" |
|
1831 |
||
1832 |
return "OK" |
|
1833 |
||
1834 |
def doResourceAssignment(self,s,loc,toks): |
|
1835 |
""" Assign variables for resource files """ |
|
1836 |
self.__currentLineNumber += 1 |
|
1837 |
varname = toks[0].upper() # the mmp keyword |
|
1838 |
varvalue = "".join(toks[1]) |
|
1839 |
||
1840 |
# Get rid of any .rsc extension because the build system |
|
1841 |
# needs to have it stripped off to calculate other names |
|
1842 |
# for other purposes and # we aren't going to make it |
|
1843 |
# optional anyhow. |
|
1844 |
if varname == "TARGET": |
|
1845 |
target_withext = varvalue.rsplit("/\\",1)[-1] |
|
1846 |
target = target_withext.rsplit(".",1)[0] |
|
1847 |
self.__current_resource_header = target.lower() + ".rsg" |
|
1848 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("TARGET_lower", target.lower())) |
|
1849 |
self.__debug("Set resource "+varname+" to " + target) |
|
1850 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(varname,target)) |
|
1851 |
if varname == "TARGETPATH": |
|
1852 |
varvalue=varvalue.replace('\\','/') |
|
1853 |
self.__debug("Set resource "+varname+" to " + varvalue) |
|
1854 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(varname,varvalue)) |
|
1855 |
else: |
|
1856 |
self.__debug("Set resource "+varname+" to " + varvalue) |
|
1857 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(varname,varvalue)) |
|
1858 |
return "OK" |
|
1859 |
||
1860 |
def doResourceAppend(self,s,loc,toks): |
|
1861 |
self.__currentLineNumber += 1 |
|
1862 |
self.__debug("Append resource to "+toks[0]+" the values: " +str(toks[1])) |
|
1863 |
varname = toks[0].upper() |
|
1864 |
||
1865 |
# we cannot use LANG as it interferes with the environment |
|
1866 |
if varname == "LANG": |
|
1867 |
varname = "LANGUAGES" |
|
1868 |
||
1869 |
for item in toks[1]: |
|
1870 |
if varname == "LANGUAGES": |
|
1871 |
item = item.lower() |
|
1872 |
self.__currentResourceVariant.AddOperation(raptor_data.Append(varname,item)) |
|
1873 |
return "OK" |
|
1874 |
||
1875 |
def doResourceSetSwitch(self,s,loc,toks): |
|
1876 |
self.__currentLineNumber += 1 |
|
1877 |
name = toks[0].upper() |
|
1878 |
||
1879 |
if name == "HEADER": |
|
1880 |
self.__headerspecified = True |
|
1881 |
||
1882 |
elif name == "HEADERONLY": |
|
1883 |
self.__headeronlyspecified = True |
|
1884 |
||
1885 |
else: |
|
1886 |
value = "1" |
|
1887 |
self.__debug( "Set resource switch " + name + " " + value) |
|
1888 |
self.__currentResourceVariant.AddOperation(raptor_data.Set(name, value)) |
|
1889 |
||
1890 |
return "OK" |
|
1891 |
||
1892 |
def doEndResource(self,s,loc,toks): |
|
1893 |
self.__currentLineNumber += 1 |
|
1894 |
||
1895 |
# Header name can change, depening if there was a TARGET defined or not, so it must be appended at the end |
|
1896 |
if self.__headerspecified: |
|
1897 |
self.__debug("Set resource switch HEADER " + self.__current_resource_header) |
|
1898 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("HEADER", self.__current_resource_header)) |
|
1899 |
||
1900 |
if self.__headeronlyspecified: |
|
1901 |
self.__debug("Set resource switch HEADERONLY " + self.__current_resource_header) |
|
1902 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("HEADER", self.__current_resource_header)) |
|
1903 |
self.__currentResourceVariant.AddOperation(raptor_data.Set("HEADERONLY", "True")) |
|
1904 |
||
1905 |
self.__debug("End RESOURCE") |
|
1906 |
self.ResourceVariants.append(self.__currentResourceVariant) |
|
1907 |
self.__currentResourceVariant = None |
|
1908 |
self.__current_resource = "" |
|
1909 |
return "OK" |
|
1910 |
||
1911 |
# Bitmap |
|
1912 |
||
1913 |
def doStartBitmap(self,s,loc,toks): |
|
1914 |
self.__currentLineNumber += 1 |
|
1915 |
self.__debug("Start BITMAP "+toks[1]) |
|
1916 |
||
5 | 1917 |
self.__currentBitmapVariant = raptor_data.Variant(name = toks[1].replace('.','_')) |
3 | 1918 |
# Use BMTARGET and BMTARGET_lower because that prevents |
1919 |
# confusion with the TARGET and TARGET_lower of our parent MMP |
|
1920 |
# when setting the OUTPUTPATH. This in turn allows us to |
|
1921 |
# not get tripped up by multiple mbms being generated with |
|
1922 |
# the same name to the same directory. |
|
1923 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set("BMTARGET", toks[1])) |
|
1924 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set("BMTARGET_lower", toks[1].lower())) |
|
1925 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set("SOURCE", "")) |
|
1926 |
return "OK" |
|
1927 |
||
1928 |
def doBitmapAssignment(self,s,loc,toks): |
|
1929 |
self.__currentLineNumber += 1 |
|
1930 |
self.__debug("Set bitmap "+toks[0]+" to " + str(toks[1])) |
|
1931 |
name = toks[0].upper() |
|
1932 |
value = "".join(toks[1]) |
|
1933 |
if name == "TARGETPATH": |
|
1934 |
value = value.replace('\\','/') |
|
1935 |
||
1936 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set(name,value)) |
|
1937 |
return "OK" |
|
1938 |
||
1939 |
def doBitmapSourcePathAssignment(self,s,loc,toks): |
|
1940 |
self.__currentLineNumber += 1 |
|
1941 |
self.__debug("Previous bitmap sourcepath:" + self.__bitmapSourcepath) |
|
1942 |
self.__bitmapSourcepath = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, toks[1]) |
|
1943 |
self.__debug("New bitmap sourcepath: " + self.__bitmapSourcepath) |
|
1944 |
||
1945 |
def doBitmapSourceAssignment(self,s,loc,toks): |
|
1946 |
self.__currentLineNumber += 1 |
|
1947 |
self.__debug( "Setting "+toks[0]+" to " + str(toks[1])) |
|
1948 |
# The first "source" is the colour depth for all the others. |
|
1949 |
# The depth format is b[,m] where b is the bitmap depth and m is |
|
1950 |
# the mask depth. |
|
1951 |
# Valid values for b are: 1 2 4 8 c4 c8 c12 c16 c24 c32 c32a (?) |
|
1952 |
# Valid values for m are: 1 8 (any number?) |
|
1953 |
# |
|
1954 |
# If m is specified then the bitmaps are in pairs: b0 m0 b1 m1... |
|
1955 |
# If m is not specified then there are no masks, just bitmaps: b0 b1... |
|
1956 |
colordepth = toks[1][0].lower() |
|
1957 |
if "," in colordepth: |
|
1958 |
(bitmapdepth, maskdepth) = colordepth.split(",") |
|
1959 |
else: |
|
1960 |
bitmapdepth = colordepth |
|
1961 |
maskdepth = 0 |
|
1962 |
||
1963 |
sources="" |
|
1964 |
mask = False |
|
1965 |
for file in toks[1][1:]: |
|
1966 |
path = generic_path.Join(self.__bitmapSourcepath, file) |
|
1967 |
if sources: |
|
1968 |
sources += " " |
|
1969 |
if mask: |
|
1970 |
sources += "DEPTH=" + maskdepth + " FILE=" + str(path) |
|
1971 |
else: |
|
1972 |
sources += "DEPTH=" + bitmapdepth + " FILE=" + str(path) |
|
1973 |
if maskdepth: |
|
1974 |
mask = not mask |
|
1975 |
self.__debug("sources: " + sources) |
|
1976 |
self.__currentBitmapVariant.AddOperation(raptor_data.Append("SOURCE", sources)) |
|
1977 |
return "OK" |
|
1978 |
||
1979 |
def doBitmapSetSwitch(self,s,loc,toks): |
|
1980 |
self.__currentLineNumber += 1 |
|
1981 |
self.__debug( "Set bitmap switch "+toks[0]+" ON") |
|
1982 |
self.__currentBitmapVariant.AddOperation(raptor_data.Set(toks[0].upper(), "1")) |
|
1983 |
return "OK" |
|
1984 |
||
1985 |
def doEndBitmap(self,s,loc,toks): |
|
1986 |
self.__currentLineNumber += 1 |
|
1987 |
self.__bitmapSourcepath = self.__sourcepath |
|
1988 |
self.BitmapVariants.append(self.__currentBitmapVariant) |
|
1989 |
self.__currentBitmapVariant = None |
|
1990 |
self.__debug("End BITMAP") |
|
1991 |
return "OK" |
|
1992 |
||
1993 |
# Stringtable |
|
1994 |
||
1995 |
def doStartStringTable(self,s,loc,toks): |
|
1996 |
self.__currentLineNumber += 1 |
|
1997 |
self.__debug( "Start STRINGTABLE "+toks[1]) |
|
1998 |
||
1999 |
specstringtable = generic_path.Join(self.__sourcepath, toks[1]) |
|
2000 |
uniqname = specstringtable.File().replace('.','_') # corrected, filename only |
|
2001 |
source = str(specstringtable.FindCaseless()) |
|
2002 |
||
2003 |
self.__debug("sourcepath: " + self.__sourcepath) |
|
2004 |
self.__debug("stringtable: " + toks[1]) |
|
2005 |
self.__debug("adjusted stringtable source=" + source) |
|
2006 |
||
5 | 2007 |
self.__currentStringTableVariant = raptor_data.Variant(name = uniqname) |
3 | 2008 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set("SOURCE", source)) |
2009 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set("EXPORTPATH", "")) |
|
2010 |
self.__stringtableExported = False |
|
2011 |
||
2012 |
# The target name by default is the name of the stringtable without the extension |
|
2013 |
# e.g. the stringtable "/fred/http.st" would have a default target name of "http" |
|
2014 |
stringtable_withext = specstringtable.File() |
|
2015 |
self.__stringtable = stringtable_withext.rsplit(".",1)[0].lower() |
|
2016 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set("TARGET", self.__stringtable)) |
|
2017 |
||
2018 |
self.__stringtableHeaderonlyspecified = False |
|
2019 |
||
2020 |
return "OK" |
|
2021 |
||
2022 |
def doStringTableAssignment(self,s,loc,toks): |
|
2023 |
""" Assign variables for stringtables """ |
|
2024 |
self.__currentLineNumber += 1 |
|
2025 |
varname = toks[0].upper() # the mmp keyword |
|
2026 |
varvalue = "".join(toks[1]) |
|
2027 |
||
2028 |
# Get rid of any .rsc extension because the build system |
|
2029 |
# needs to have it stripped off to calculate other names |
|
2030 |
# for other purposes and # we aren't going to make it |
|
2031 |
# optional anyhow. |
|
2032 |
if varname == "EXPORTPATH": |
|
2033 |
finalvalue = raptor_utilities.resolveSymbianPath(self.__currentMmpFile, varvalue) |
|
2034 |
self.__stringtableExported = True |
|
2035 |
else: |
|
2036 |
finalvalue = varvalue |
|
2037 |
||
2038 |
self.__debug("Set stringtable "+varname+" to " + finalvalue) |
|
2039 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set(varname,finalvalue)) |
|
2040 |
return "OK" |
|
2041 |
||
2042 |
def doStringTableSetSwitch(self,s,loc,toks): |
|
2043 |
self.__currentLineNumber += 1 |
|
2044 |
if toks[0].upper()== "HEADERONLY": |
|
2045 |
self.__stringtableHeaderonlyspecified = True |
|
2046 |
self.__debug( "Set stringtable switch "+toks[0]+" ON") |
|
2047 |
self.__currentStringTableVariant.AddOperation(raptor_data.Set(toks[0].upper(), "1")) |
|
2048 |
return "OK" |
|
2049 |
||
2050 |
def doEndStringTable(self,s,loc,toks): |
|
2051 |
self.__currentLineNumber += 1 |
|
2052 |
||
2053 |
if not self.__stringtableExported: |
|
2054 |
# There was no EXPORTPATH specified for this stringtable |
|
2055 |
# so for our other code to be able to reference it we |
|
2056 |
# must add the path of the generated location to the userinclude path |
|
2057 |
||
2058 |
ipath = "$(OUTPUTPATH)" |
|
2059 |
self.BuildVariant.AddOperation(raptor_data.Append("USERINCLUDE",ipath)) |
|
2060 |
self.__userinclude += ' ' + ipath |
|
2061 |
self.__debug(" USERINCLUDE = %s", self.__userinclude) |
|
2062 |
self.__userinclude.strip() |
|
2063 |
||
2064 |
self.StringTableVariants.append(self.__currentStringTableVariant) |
|
2065 |
self.__currentStringTableVariant = None |
|
2066 |
self.__debug("End STRINGTABLE") |
|
2067 |
if not self.__stringtableHeaderonlyspecified: |
|
2068 |
# Have to assume that this is where the cpp file will be. This has to be maintained |
|
2069 |
# in sync with the FLM's idea of where this file should be. We need a better way. |
|
2070 |
# Interfaces also need outputs that allow other interfaces to refer to their outputs |
|
2071 |
# without having to "know" where they will be. |
|
2072 |
self.sources.append('$(OUTPUTPATH)/' + self.__stringtable + '.cpp') |
|
2073 |
return "OK" |
|
2074 |
||
2075 |
||
2076 |
def doUnknownStatement(self,s,loc,toks): |
|
2077 |
self.__warn("%s (%d) : Unrecognised Keyword %s", self.__currentMmpFile, self.__currentLineNumber, str(toks)) |
|
2078 |
self.__currentLineNumber += 1 |
|
2079 |
return "OK" |
|
2080 |
||
2081 |
||
2082 |
def doUnknownBlock(self,s,loc,toks): |
|
2083 |
self.__warn("%s (%d) : Unrecognised Block %s", self.__currentMmpFile, self.__currentLineNumber, str(toks)) |
|
2084 |
self.__currentLineNumber += 1 |
|
2085 |
return "OK" |
|
2086 |
||
2087 |
def doDeprecated(self,s,loc,toks): |
|
2088 |
self.__debug( "Deprecated command " + str(toks)) |
|
2089 |
self.__warn("%s (%d) : %s is deprecated .mmp file syntax", self.__currentMmpFile, self.__currentLineNumber, str(toks)) |
|
2090 |
self.__currentLineNumber += 1 |
|
2091 |
return "OK" |
|
2092 |
||
2093 |
def doNothing(self): |
|
2094 |
self.__currentLineNumber += 1 |
|
2095 |
return "OK" |
|
2096 |
||
2097 |
def finalise(self, aBuildPlatform): |
|
2098 |
"""Post-processing of data that is only applicable in the context of a fully |
|
2099 |
processed .mmp file.""" |
|
2100 |
resolvedDefFile = "" |
|
2101 |
||
2102 |
if self.__TARGET: |
|
2103 |
defaultRootName = self.__TARGET |
|
2104 |
if self.__TARGETEXT!="": |
|
2105 |
defaultRootName += "." + self.__TARGETEXT |
|
2106 |
||
2107 |
# NOTE: Changing default .def file name based on the LINKAS argument is actually |
|
2108 |
# a defect, but this follows the behaviour of the current build system. |
|
2109 |
if (self.__LINKAS): |
|
2110 |
defaultRootName = self.__LINKAS |
|
2111 |
||
2112 |
resolvedDefFile = self.resolveDefFile(defaultRootName, aBuildPlatform) |
|
2113 |
self.__debug("Resolved def file: %s" % resolvedDefFile ) |
|
2114 |
# We need to store this resolved deffile location for the FREEZE target |
|
2115 |
self.BuildVariant.AddOperation(raptor_data.Set("RESOLVED_DEFFILE", resolvedDefFile)) |
|
2116 |
||
2117 |
# If a deffile is specified, an FLM will put in a dependency. |
|
2118 |
# If a deffile is specified then raptor_meta will guess a name but: |
|
2119 |
# 1) If the guess is wrong then the FLM will complain "no rule to make ..." |
|
2120 |
# 2) In some cases, e.g. plugin, 1) is not desirable as the presence of a def file |
|
2121 |
# is not a necessity. In these cases the FLM needs to know if DEFFILE |
|
2122 |
# is a guess or not so it can decide if a dependency should be added. |
|
2123 |
||
2124 |
# We check that the def file exists and that it is non-zero (incredible |
|
2125 |
# that this should be needed). |
|
2126 |
||
2127 |
deffile_keyword="1" |
|
2128 |
if self.deffile == "": |
|
2129 |
# If the user didn't specify a deffile name then |
|
2130 |
# we must be guessing |
|
2131 |
# Let's check if our guess actually corresponds to a |
|
2132 |
# real file. If it does then that confims the guess. |
|
2133 |
# If there's no file then we still need to pass make the name |
|
2134 |
# so it can complain about there not being a DEF file |
|
2135 |
# for this particular target type and fail to build this target. |
|
2136 |
||
2137 |
deffile_keyword="" |
|
2138 |
try: |
|
2139 |
findpath = generic_path.Path(resolvedDefFile) |
|
2140 |
foundfile = findpath.FindCaseless() |
|
2141 |
||
2142 |
if foundfile == None: |
|
2143 |
raise IOError("file not found") |
|
2144 |
||
2145 |
self.__debug("Found DEFFILE " + foundfile.GetLocalString()) |
|
2146 |
rfstat = os.stat(foundfile.GetLocalString()) |
|
2147 |
||
2148 |
mode = rfstat[stat.ST_MODE] |
|
2149 |
if mode != None and stat.S_ISREG(mode) and rfstat[stat.ST_SIZE] > 0: |
|
2150 |
resolvedDefFile = str(foundfile) |
|
2151 |
else: |
|
2152 |
resolvedDefFile="" |
|
2153 |
except Exception,e: |
|
2154 |
self.__debug("While Searching for an IMPLIED DEFFILE: %s: %s" % (str(e),str(findpath)) ) |
|
2155 |
resolvedDefFile="" |
|
2156 |
else: |
|
2157 |
if not resolvedDefFile == "": |
|
2158 |
try: |
|
2159 |
findpath = generic_path.Path(resolvedDefFile) |
|
2160 |
resolvedDefFile = str(findpath.FindCaseless()) |
|
2161 |
if resolvedDefFile=="None": |
|
2162 |
raise IOError("file not found") |
|
2163 |
except Exception,e: |
|
2164 |
self.__warn("While Searching for a SPECIFIED DEFFILE: %s: %s" % (str(e),str(findpath)) ) |
|
2165 |
resolvedDefFile="" |
|
2166 |
else: |
|
2167 |
self.__warn("DEFFILE KEYWORD used (%s) but def file not resolved" % (self.deffile) ) |
|
2168 |
||
2169 |
||
2170 |
self.BuildVariant.AddOperation(raptor_data.Set("DEFFILE", resolvedDefFile)) |
|
2171 |
self.__debug("Set DEFFILE to " + resolvedDefFile) |
|
2172 |
self.BuildVariant.AddOperation(raptor_data.Set("DEFFILEKEYWORD", deffile_keyword)) |
|
2173 |
self.__debug("Set DEFFILEKEYWORD to '%s'",deffile_keyword) |
|
2174 |
||
2175 |
# if this target type has a default TARGETPATH other than "" for |
|
2176 |
# resources then we need to add that default to all resources which |
|
2177 |
# do not explicitly set the TARGETPATH themselves. |
|
2178 |
tp = self.getDefaultResourceTargetPath(self.getTargetType()) |
|
2179 |
if tp: |
|
2180 |
for i,var in enumerate(self.ResourceVariants): |
|
2181 |
# does this resource specify its own TARGETPATH? |
|
2182 |
needTP = True |
|
2183 |
for op in var.ops: |
|
2184 |
if isinstance(op, raptor_data.Set) \ |
|
2185 |
and op.name == "TARGETPATH": |
|
2186 |
needTP = False |
|
2187 |
break |
|
2188 |
if needTP: |
|
2189 |
self.ResourceVariants[i].AddOperation(raptor_data.Set("TARGETPATH", tp)) |
|
2190 |
||
2191 |
# some core build configurations need to know about the resource builds, and |
|
2192 |
# some resource building configurations need knowledge of the core build |
|
2193 |
for resourceFile in self.__resourceFiles: |
|
2194 |
self.BuildVariant.AddOperation(raptor_data.Append("RESOURCEFILES", resourceFile)) |
|
2195 |
||
2196 |
for i,var in enumerate(self.ResourceVariants): |
|
2197 |
self.ResourceVariants[i].AddOperation(raptor_data.Set("MAIN_TARGET_lower", self.__TARGET.lower())) |
|
2198 |
self.ResourceVariants[i].AddOperation(raptor_data.Set("MAIN_REQUESTEDTARGETEXT", self.__TARGETEXT.lower())) |
|
2199 |
||
5 | 2200 |
# Create Capability variable in one SET operation (more efficient than multiple appends) |
2201 |
self.BuildVariant.AddOperation(raptor_data.Set("CAPABILITY"," ".join(self.capabilities))) |
|
2202 |
||
3 | 2203 |
# Resolve combined capabilities as hex flags, for configurations that require them |
2204 |
capabilityFlag1 = 0 |
|
2205 |
capabilityFlag2 = 0 # Always 0 |
|
2206 |
||
5 | 2207 |
for capability in [c.lower() for c in self.capabilities]: |
3 | 2208 |
invert = 0 |
2209 |
||
2210 |
if capability.startswith('-'): |
|
2211 |
invert = 0xffffffff |
|
2212 |
capability = capability.lstrip('-') |
|
2213 |
||
2214 |
if MMPRaptorBackend.supportedCapabilities.has_key(capability): |
|
2215 |
capabilityFlag1 = capabilityFlag1 ^ invert |
|
2216 |
capabilityFlag1 = capabilityFlag1 | MMPRaptorBackend.supportedCapabilities[capability] |
|
2217 |
capabilityFlag1 = capabilityFlag1 ^ invert |
|
2218 |
||
2219 |
capabilityFlag1 = "%08xu" % capabilityFlag1 |
|
2220 |
capabilityFlag2 = "%08xu" % capabilityFlag2 |
|
2221 |
||
2222 |
self.BuildVariant.AddOperation(raptor_data.Set("CAPABILITYFLAG1", capabilityFlag1)) |
|
2223 |
self.__debug ("Set CAPABILITYFLAG1 to " + capabilityFlag1) |
|
2224 |
self.BuildVariant.AddOperation(raptor_data.Set("CAPABILITYFLAG2", capabilityFlag2)) |
|
2225 |
self.__debug ("Set CAPABILITYFLAG2 to " + capabilityFlag2) |
|
2226 |
||
2227 |
# For non-Feature Variant builds, the location of the product include hrh file is |
|
2228 |
# appended to the SYSTEMINCLUDE list |
|
2229 |
if not aBuildPlatform['ISFEATUREVARIANT']: |
|
2230 |
productIncludePath = str(aBuildPlatform['VARIANT_HRH'].Dir()) |
|
2231 |
self.BuildVariant.AddOperation(raptor_data.Append("SYSTEMINCLUDE",productIncludePath)) |
|
2232 |
self.__debug("Appending product include location %s to SYSTEMINCLUDE",productIncludePath) |
|
2233 |
||
2234 |
# Specifying both a PAGED* and its opposite UNPAGED* keyword in a .mmp file |
|
2235 |
# will generate a warning and the last keyword specified will take effect. |
|
2236 |
self.__pageConflict.reverse() |
|
2237 |
if "PAGEDCODE" in self.__pageConflict and "UNPAGEDCODE" in self.__pageConflict: |
|
2238 |
for x in self.__pageConflict: |
|
2239 |
if x == "PAGEDCODE" or x == "UNPAGEDCODE": |
|
2240 |
self.__Raptor.Warn("Both PAGEDCODE and UNPAGEDCODE are specified. The last one %s will take effect" % x) |
|
2241 |
break |
|
2242 |
if "PAGEDDATA" in self.__pageConflict and "UNPAGEDDATA" in self.__pageConflict: |
|
2243 |
for x in self.__pageConflict: |
|
2244 |
if x == "PAGEDDATA" or x == "UNPAGEDDATA": |
|
2245 |
self.__Raptor.Warn("Both PAGEDDATA and UNPAGEDDATA are specified. The last one %s will take effect" % x) |
|
2246 |
break |
|
2247 |
||
2248 |
# Set Debuggable |
|
2249 |
self.BuildVariant.AddOperation(raptor_data.Set("DEBUGGABLE", self.__debuggable)) |
|
2250 |
||
2251 |
if self.__explicitversion: |
|
2252 |
self.BuildVariant.AddOperation(raptor_data.Append("UNIQUETARGETPATH","$(TARGET_lower)_$(VERSIONHEX)_$(REQUESTEDTARGETEXT)",'/')) |
|
2253 |
else: |
|
2254 |
self.BuildVariant.AddOperation(raptor_data.Append("UNIQUETARGETPATH","$(TARGET_lower)_$(REQUESTEDTARGETEXT)",'/')) |
|
2255 |
||
2256 |
# Put the list of sourcefiles in with one Set operation - saves memory |
|
2257 |
# and performance over using multiple Append operations. |
|
2258 |
self.BuildVariant.AddOperation(raptor_data.Set("SOURCE", |
|
2259 |
" ".join(self.sources))) |
|
2260 |
||
2261 |
def getTargetType(self): |
|
2262 |
"""Target type in lower case - the standard format""" |
|
2263 |
return self.__targettype.lower() |
|
2264 |
||
2265 |
def resolveDefFile(self, aTARGET, aBuildPlatform): |
|
2266 |
"""Returns a fully resolved DEFFILE entry depending on .mmp file location and TARGET, DEFFILE and NOSTRICTDEF |
|
2267 |
entries in the .mmp file itself (where appropriate). |
|
2268 |
Is able to deal with target names that have multiple '.' characters e.g. messageintercept.esockdebug.dll |
|
2269 |
""" |
|
2270 |
||
2271 |
resolvedDefFile = "" |
|
2272 |
platform = aBuildPlatform['PLATFORM'] |
|
2273 |
||
2274 |
# Not having a default .def file directory is a pretty strong indicator that |
|
2275 |
# .def files aren't supported for the particular platform |
|
2276 |
if PlatformDefaultDefFileDir.has_key(platform): |
|
2277 |
(targetname,targetext) = os.path.splitext(aTARGET) |
|
2278 |
(defname,defext) = os.path.splitext(self.deffile) |
|
2279 |
if defext=="": |
|
2280 |
defext = ".def" |
|
2281 |
||
2282 |
# NOTE: WORKAROUND |
|
2283 |
if len(targetext) > 4: |
|
2284 |
targetname += defext |
|
2285 |
||
2286 |
if not self.deffile: |
|
2287 |
resolvedDefFile = targetname |
|
2288 |
else: |
|
2289 |
if re.search('[\\|\/]$', self.deffile): |
|
2290 |
# If DEFFILE is *solely* a path, signified by ending in a slash, then TARGET is the |
|
2291 |
# basis for the default .def filename but with the specified path as prefix |
|
2292 |
resolvedDefFile = self.deffile + targetname |
|
2293 |
||
2294 |
else: |
|
2295 |
resolvedDefFile = defname |
|
2296 |
||
2297 |
resolvedDefFile = resolvedDefFile.replace('~', PlatformDefaultDefFileDir[platform]) |
|
2298 |
||
2299 |
if resolvedDefFile: |
|
2300 |
if not self.nostrictdef: |
|
2301 |
resolvedDefFile += 'u' |
|
2302 |
||
2303 |
if self.__explicitversion: |
|
2304 |
resolvedDefFile += '{' + self.__versionhex + '}' |
|
2305 |
||
2306 |
resolvedDefFile += defext |
|
2307 |
||
2308 |
||
2309 |
# If a DEFFILE statement doesn't specify a path in any shape or form, prepend the default .def file |
|
2310 |
# location based on the platform being built |
|
2311 |
if not re.search('[\\\/]+', self.deffile): |
|
2312 |
resolvedDefFile = '../'+PlatformDefaultDefFileDir[platform]+'/'+resolvedDefFile |
|
2313 |
||
2314 |
resolvedDefFile = raptor_utilities.resolveSymbianPath(self.__defFileRoot, resolvedDefFile, 'DEFFILE', "", str(aBuildPlatform['EPOCROOT'])) |
|
2315 |
||
2316 |
return resolvedDefFile |
|
2317 |
||
2318 |
||
5 | 2319 |
def CheckedGet(self, key, default = None): |
2320 |
"""extract a value from an self and raise an exception if None. |
|
2321 |
||
2322 |
An optional default can be set to replace a None value. |
|
2323 |
||
2324 |
This function belongs in the Evaluator class logically. But |
|
2325 |
Evaluator doesn't know how to raise a Metadata error. Since |
|
2326 |
being able to raise a metadata error is the whole point of |
|
2327 |
the method, it makes sense to adapt the Evaluator class from |
|
2328 |
raptor_meta for the use of everything inside raptor_meta. |
|
2329 |
||
2330 |
... so it will be added to the Evaluator class. |
|
2331 |
""" |
|
2332 |
||
2333 |
value = self.Get(key) |
|
2334 |
if value == None: |
|
2335 |
if default == None: |
|
2336 |
raise MetaDataError("configuration " + self.buildUnit.name + |
|
2337 |
" has no variable " + key) |
|
2338 |
else: |
|
2339 |
return default |
|
2340 |
return value |
|
2341 |
||
2342 |
raptor_data.Evaluator.CheckedGet = CheckedGet |
|
2343 |
||
2344 |
||
3 | 2345 |
class MetaReader(object): |
2346 |
"""Entry point class for Symbian metadata processing. |
|
2347 |
||
2348 |
Provides a means of integrating "traditional" Symbian metadata processing |
|
2349 |
with the new Raptor build system.""" |
|
2350 |
||
2351 |
filesplit_re = re.compile(r"^(?P<name>.*)\.(?P<ext>[^\.]*)$") |
|
2352 |
||
2353 |
def __init__(self, aRaptor, configsToBuild): |
|
2354 |
self.__Raptor = aRaptor |
|
2355 |
self.BuildPlatforms = [] |
|
2356 |
self.ExportPlatforms = [] |
|
2357 |
||
2358 |
# Get the version of CPP that we are using |
|
2359 |
metadata = self.__Raptor.cache.FindNamedVariant("meta") |
|
2360 |
evaluator = self.__Raptor.GetEvaluator(None, raptor_data.BuildUnit(metadata.name, [metadata]) ) |
|
5 | 2361 |
self.__gnucpp = evaluator.CheckedGet("GNUCPP") |
2362 |
self.__defaultplatforms = evaluator.CheckedGet("DEFAULT_PLATFORMS") |
|
2363 |
self.__basedefaultplatforms = evaluator.CheckedGet("BASE_DEFAULT_PLATFORMS") |
|
2364 |
self.__baseuserdefaultplatforms = evaluator.CheckedGet("BASE_USER_DEFAULT_PLATFORMS") |
|
3 | 2365 |
|
2366 |
# Only read each variant.cfg once |
|
2367 |
variantCfgs = {} |
|
2368 |
||
2369 |
# Group the list of configurations into "build platforms". |
|
2370 |
# A build platform is a set of configurations which share |
|
2371 |
# the same metadata. In other words, a set of configurations |
|
2372 |
# for which the bld.inf and MMP files pre-process to exactly |
|
2373 |
# the same text. |
|
2374 |
platforms = {} |
|
2375 |
||
2376 |
# Exports are not "platform dependent" but they are configuration |
|
2377 |
# dependent because different configs can have different EPOCROOT |
|
2378 |
# and VARIANT_HRH values. Each "build platform" has one associated |
|
2379 |
# "export platform" but several "build platforms" can be associated |
|
2380 |
# with the same "export platform". |
|
2381 |
exports = {} |
|
2382 |
||
5 | 2383 |
self.__Raptor.Debug("MetaReader: configsToBuild: %s", [b.name for b in configsToBuild]) |
3 | 2384 |
for buildConfig in configsToBuild: |
2385 |
# get everything we need to know about the configuration |
|
2386 |
evaluator = self.__Raptor.GetEvaluator(None, buildConfig) |
|
2387 |
||
2388 |
detail = {} |
|
5 | 2389 |
detail['PLATFORM'] = evaluator.CheckedGet("TRADITIONAL_PLATFORM") |
2390 |
epocroot = evaluator.CheckedGet("EPOCROOT") |
|
3 | 2391 |
detail['EPOCROOT'] = generic_path.Path(epocroot) |
2392 |
||
5 | 2393 |
sbs_build_dir = evaluator.CheckedGet("SBS_BUILD_DIR") |
3 | 2394 |
detail['SBS_BUILD_DIR'] = generic_path.Path(sbs_build_dir) |
5 | 2395 |
flm_export_dir = evaluator.CheckedGet("FLM_EXPORT_DIR") |
3 | 2396 |
detail['FLM_EXPORT_DIR'] = generic_path.Path(flm_export_dir) |
2397 |
detail['CACHEID'] = flm_export_dir |
|
2398 |
if raptor_utilities.getOSPlatform().startswith("win"): |
|
5 | 2399 |
detail['PLATMACROS'] = evaluator.CheckedGet("PLATMACROS.WINDOWS") |
3 | 2400 |
else: |
5 | 2401 |
detail['PLATMACROS'] = evaluator.CheckedGet("PLATMACROS.LINUX") |
3 | 2402 |
|
2403 |
# Apply OS variant provided we are not ignoring this |
|
2404 |
if not self.__Raptor.ignoreOsDetection: |
|
2405 |
self.__Raptor.Debug("Automatic OS detection enabled.") |
|
2406 |
self.ApplyOSVariant(buildConfig, epocroot) |
|
2407 |
else: # We are ignore OS versions so no detection required, so no variant will be applied |
|
2408 |
self.__Raptor.Debug("Automatic OS detection disabled.") |
|
2409 |
||
2410 |
# is this a feature variant config or an ordinary variant |
|
2411 |
fv = evaluator.Get("FEATUREVARIANTNAME") |
|
2412 |
if fv: |
|
5 | 2413 |
variantHdr = evaluator.CheckedGet("VARIANT_HRH") |
3 | 2414 |
variantHRH = generic_path.Path(variantHdr) |
2415 |
detail['ISFEATUREVARIANT'] = True |
|
2416 |
else: |
|
5 | 2417 |
variantCfg = evaluator.CheckedGet("VARIANT_CFG") |
3 | 2418 |
variantCfg = generic_path.Path(variantCfg) |
2419 |
if not variantCfg in variantCfgs: |
|
2420 |
# get VARIANT_HRH from the variant.cfg file |
|
2421 |
varCfg = getVariantCfgDetail(detail['EPOCROOT'], variantCfg) |
|
2422 |
variantCfgs[variantCfg] = varCfg['VARIANT_HRH'] |
|
2423 |
# we expect to always build ABIv2 |
|
2424 |
if not 'ENABLE_ABIV2_MODE' in varCfg: |
|
2425 |
self.__Raptor.Warn("missing flag ENABLE_ABIV2_MODE in %s file. ABIV1 builds are not supported.", |
|
2426 |
str(variantCfg)) |
|
2427 |
variantHRH = variantCfgs[variantCfg] |
|
2428 |
detail['ISFEATUREVARIANT'] = False |
|
2429 |
||
2430 |
detail['VARIANT_HRH'] = variantHRH |
|
2431 |
self.__Raptor.Info("'%s' uses variant hrh file '%s'", buildConfig.name, variantHRH) |
|
5 | 2432 |
detail['SYSTEMINCLUDE'] = evaluator.CheckedGet("SYSTEMINCLUDE") |
2433 |
||
3 | 2434 |
|
2435 |
# find all the interface names we need |
|
5 | 2436 |
ifaceTypes = evaluator.CheckedGet("INTERFACE_TYPES") |
3 | 2437 |
interfaces = ifaceTypes.split() |
2438 |
||
2439 |
for iface in interfaces: |
|
5 | 2440 |
detail[iface] = evaluator.CheckedGet("INTERFACE." + iface) |
3 | 2441 |
|
2442 |
# not test code unless positively specified |
|
5 | 2443 |
detail['TESTCODE'] = evaluator.CheckedGet("TESTCODE", "") |
3 | 2444 |
|
2445 |
# make a key that identifies this platform uniquely |
|
2446 |
# - used to tell us whether we have done the pre-processing |
|
2447 |
# we need already using another platform with compatible values. |
|
2448 |
||
2449 |
key = str(detail['VARIANT_HRH']) \ |
|
2450 |
+ str(detail['EPOCROOT']) \ |
|
2451 |
+ detail['SYSTEMINCLUDE'] \ |
|
2452 |
+ detail['PLATFORM'] |
|
2453 |
||
2454 |
# Keep a short version of the key for use in filenames. |
|
2455 |
uniq = hashlib.md5() |
|
2456 |
uniq.update(key) |
|
2457 |
||
2458 |
detail['key'] = key |
|
2459 |
detail['key_md5'] = "p_" + uniq.hexdigest() |
|
2460 |
del uniq |
|
2461 |
||
2462 |
# compare this configuration to the ones we have already seen |
|
2463 |
||
2464 |
# Is this an unseen export platform? |
|
2465 |
# concatenate all the values we care about in a fixed order |
|
2466 |
# and use that as a signature for the exports. |
|
2467 |
items = ['EPOCROOT', 'VARIANT_HRH', 'SYSTEMINCLUDE', 'TESTCODE', 'export'] |
|
2468 |
export = "" |
|
2469 |
for i in items: |
|
2470 |
if i in detail: |
|
2471 |
export += i + str(detail[i]) |
|
2472 |
||
2473 |
if export in exports: |
|
2474 |
# add this configuration to an existing export platform |
|
2475 |
index = exports[export] |
|
2476 |
self.ExportPlatforms[index]['configs'].append(buildConfig) |
|
2477 |
else: |
|
2478 |
# create a new export platform with this configuration |
|
2479 |
exports[export] = len(self.ExportPlatforms) |
|
2480 |
exp = copy.copy(detail) |
|
2481 |
exp['PLATFORM'] = 'EXPORT' |
|
2482 |
exp['configs'] = [buildConfig] |
|
2483 |
self.ExportPlatforms.append(exp) |
|
2484 |
||
2485 |
# Is this an unseen build platform? |
|
2486 |
# concatenate all the values we care about in a fixed order |
|
2487 |
# and use that as a signature for the platform. |
|
2488 |
items = ['PLATFORM', 'EPOCROOT', 'VARIANT_HRH', 'SYSTEMINCLUDE', 'TESTCODE'] |
|
2489 |
if raptor_utilities.getOSPlatform().startswith("win"): |
|
2490 |
items.append('PLATMACROS.WINDOWS') |
|
2491 |
else: |
|
2492 |
items.append('PLATMACROS.LINUX') |
|
2493 |
||
2494 |
items.extend(interfaces) |
|
2495 |
platform = "" |
|
2496 |
for i in items: |
|
2497 |
if i in detail: |
|
2498 |
platform += i + str(detail[i]) |
|
2499 |
||
2500 |
if platform in platforms: |
|
2501 |
# add this configuration to an existing build platform |
|
2502 |
index = platforms[platform] |
|
2503 |
self.BuildPlatforms[index]['configs'].append(buildConfig) |
|
2504 |
else: |
|
2505 |
# create a new build platform with this configuration |
|
2506 |
platforms[platform] = len(self.BuildPlatforms) |
|
2507 |
detail['configs'] = [buildConfig] |
|
2508 |
self.BuildPlatforms.append(detail) |
|
2509 |
||
2510 |
# one platform is picked as the "default" for extracting things |
|
2511 |
# that are supposedly platform independent (e.g. PRJ_PLATFORMS) |
|
2512 |
self.defaultPlatform = self.ExportPlatforms[0] |
|
2513 |
||
5 | 2514 |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2515 |
def ReadBldInfFiles(self, aComponentList, doexport, dobuild = True): |
3 | 2516 |
"""Take a list of bld.inf files and return a list of build specs. |
2517 |
||
2518 |
The returned specification nodes will be suitable for all the build |
|
2519 |
configurations under consideration (using Filter nodes where required). |
|
2520 |
""" |
|
2521 |
||
2522 |
# we need a Filter node per export platform |
|
2523 |
exportNodes = [] |
|
2524 |
for i,ep in enumerate(self.ExportPlatforms): |
|
5 | 2525 |
filter = raptor_data.Filter(name = "export_" + str(i)) |
3 | 2526 |
|
2527 |
# what configurations is this node active for? |
|
2528 |
for config in ep['configs']: |
|
2529 |
filter.AddConfigCondition(config.name) |
|
2530 |
||
2531 |
exportNodes.append(filter) |
|
2532 |
||
2533 |
# we need a Filter node per build platform |
|
2534 |
platformNodes = [] |
|
2535 |
for i,bp in enumerate(self.BuildPlatforms): |
|
5 | 2536 |
filter = raptor_data.Filter(name = "build_" + str(i)) |
3 | 2537 |
|
2538 |
# what configurations is this node active for? |
|
2539 |
for config in bp['configs']: |
|
2540 |
filter.AddConfigCondition(config.name) |
|
2541 |
||
2542 |
# platform-wide data |
|
2543 |
platformVar = raptor_data.Variant() |
|
2544 |
platformVar.AddOperation(raptor_data.Set("PRODUCT_INCLUDE", |
|
2545 |
str(bp['VARIANT_HRH']))) |
|
2546 |
||
2547 |
filter.AddVariant(platformVar) |
|
2548 |
platformNodes.append(filter) |
|
2549 |
||
2550 |
# check that each bld.inf exists and add a Specification node for it |
|
2551 |
# to the nodes of the export and build platforms that it supports. |
|
5 | 2552 |
for c in aComponentList: |
2553 |
if c.bldinf_filename.isFile(): |
|
2554 |
self.__Raptor.Info("Processing %s", str(c.bldinf_filename)) |
|
3 | 2555 |
try: |
5 | 2556 |
self.AddComponentNodes(c, exportNodes, platformNodes) |
3 | 2557 |
|
2558 |
except MetaDataError, e: |
|
5 | 2559 |
self.__Raptor.Error(e.Text, bldinf=str(c.bldinf_filename)) |
3 | 2560 |
if not self.__Raptor.keepGoing: |
2561 |
return [] |
|
2562 |
else: |
|
5 | 2563 |
self.__Raptor.Error("build info file does not exist", bldinf=str(c.bldinf_filename)) |
3 | 2564 |
if not self.__Raptor.keepGoing: |
2565 |
return [] |
|
2566 |
||
2567 |
# now we have the top-level structure in place... |
|
2568 |
# |
|
2569 |
# <filter exports 1> |
|
2570 |
# <spec bld.inf 1 /> |
|
2571 |
# <spec bld.inf 2 /> |
|
2572 |
# <spec bld.inf N /> </filter> |
|
2573 |
# <filter build 1> |
|
2574 |
# <spec bld.inf 1 /> |
|
2575 |
# <spec bld.inf 2 /> |
|
2576 |
# <spec bld.inf N /> </filter> |
|
2577 |
# <filter build 2> |
|
2578 |
# <spec bld.inf 1 /> |
|
2579 |
# <spec bld.inf 2 /> |
|
2580 |
# <spec bld.inf N /> </filter> |
|
2581 |
# <filter build 3> |
|
2582 |
# <spec bld.inf 1 /> |
|
2583 |
# <spec bld.inf 2 /> |
|
2584 |
# <spec bld.inf N /> </filter> |
|
2585 |
# |
|
2586 |
# assuming that every bld.inf builds for every platform and all |
|
2587 |
# exports go to the same place. clearly, it is more likely that |
|
2588 |
# some filters have less than N child nodes. in bigger builds there |
|
2589 |
# will also be more than one export platform. |
|
2590 |
||
2591 |
# we now need to process the EXPORTS for all the bld.inf nodes |
|
2592 |
# before we can do anything else (because raptor itself must do |
|
2593 |
# some exports before the MMP files that include them can be |
|
2594 |
# processed). |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2595 |
if doexport: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2596 |
for i,p in enumerate(exportNodes): |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2597 |
exportPlatform = self.ExportPlatforms[i] |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2598 |
for s in p.GetChildSpecs(): |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2599 |
try: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2600 |
self.ProcessExports(s, exportPlatform) |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2601 |
|
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2602 |
except MetaDataError, e: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2603 |
self.__Raptor.Error("%s",e.Text) |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2604 |
if not self.__Raptor.keepGoing: |
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2605 |
return [] |
14 | 2606 |
else: |
2607 |
self.__Raptor.Info("Not Processing Exports (--noexport enabled)") |
|
3 | 2608 |
|
2609 |
# this is a switch to return the function at this point if export |
|
2610 |
# only option is specified in the run |
|
11
ea23b18a2ff6
Initial implementation of noexport
tnmurphy@4GBL06592.nokia.com
parents:
5
diff
changeset
|
2611 |
if dobuild is not True: |
3 | 2612 |
self.__Raptor.Info("Processing Exports only") |
2613 |
return[] |
|
2614 |
||
2615 |
# after exports are done we can look to see if there are any |
|
2616 |
# new Interfaces which can be used for EXTENSIONS. Make sure |
|
2617 |
# that we only load each cache once as some export platforms |
|
2618 |
# may share a directory. |
|
2619 |
doneID = {} |
|
2620 |
for ep in self.ExportPlatforms: |
|
2621 |
flmDir = ep["FLM_EXPORT_DIR"] |
|
2622 |
cid = ep["CACHEID"] |
|
2623 |
if flmDir.isDir() and not cid in doneID: |
|
2624 |
self.__Raptor.cache.Load(flmDir, cid) |
|
2625 |
doneID[cid] = True |
|
2626 |
||
2627 |
# finally we can process all the other parts of the bld.inf nodes. |
|
2628 |
# Keep a list of the projects we were asked to build so that we can |
|
2629 |
# tell at the end if there were any we didn't know about. |
|
2630 |
self.projectList = list(self.__Raptor.projects) |
|
2631 |
for i,p in enumerate(platformNodes): |
|
2632 |
buildPlatform = self.BuildPlatforms[i] |
|
2633 |
for s in p.GetChildSpecs(): |
|
2634 |
try: |
|
2635 |
self.ProcessTEMs(s, buildPlatform) |
|
2636 |
self.ProcessMMPs(s, buildPlatform) |
|
2637 |
||
2638 |
except MetaDataError, e: |
|
2639 |
self.__Raptor.Error(e.Text) |
|
2640 |
if not self.__Raptor.keepGoing: |
|
2641 |
return [] |
|
2642 |
||
2643 |
for badProj in self.projectList: |
|
2644 |
self.__Raptor.Warn("Can't find project '%s' in any build info file", badProj) |
|
2645 |
||
2646 |
# everything is specified |
|
2647 |
return exportNodes + platformNodes |
|
2648 |
||
2649 |
def ModuleName(self,aBldInfPath): |
|
2650 |
"""Calculate the name of the ROM/emulator batch files that run the tests""" |
|
2651 |
||
2652 |
def LeftPortionOf(pth,sep): |
|
2653 |
""" 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
|
2654 |
The split is case-insensitive.""" |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2655 |
length = len((pth.lower().split(sep.lower()))[0]) |
3 | 2656 |
return pth[0:length] |
2657 |
||
2658 |
modulePath = LeftPortionOf(LeftPortionOf(os.path.dirname(aBldInfPath), "group"), "ongoing") |
|
2659 |
moduleName = os.path.basename(modulePath.strip("/")) |
|
2660 |
||
2661 |
# Ensure that ModuleName does not return blank, if the above calculation determines |
|
2662 |
# that moduleName is blank |
|
2663 |
if moduleName == "" or moduleName.endswith(":"): |
|
2664 |
moduleName = "module" |
|
2665 |
return moduleName |
|
2666 |
||
2667 |
||
5 | 2668 |
def AddComponentNodes(self, component, exportNodes, platformNodes): |
3 | 2669 |
"""Add Specification nodes for a bld.inf to the appropriate platforms.""" |
5 | 2670 |
bldInfFile = BldInfFile(component.bldinf_filename, self.__gnucpp, component.depfiles, self.__Raptor) |
2671 |
component.bldinf = bldInfFile |
|
2672 |
||
2673 |
specName = getSpecName(component.bldinf_filename, fullPath=True) |
|
2674 |
||
2675 |
if isinstance(component.bldinf, raptor_xml.SystemModelComponent): |
|
3 | 2676 |
# this component came from a system_definition.xml |
5 | 2677 |
layer = component.bldinf.GetContainerName("layer") |
2678 |
componentName = component.bldinf.GetContainerName("component") |
|
3 | 2679 |
else: |
2680 |
# this is a plain old bld.inf file from the command-line |
|
2681 |
layer = "" |
|
5 | 2682 |
componentName = "" |
3 | 2683 |
|
2684 |
# exports are independent of build platform |
|
2685 |
for i,ep in enumerate(self.ExportPlatforms): |
|
5 | 2686 |
specNode = raptor_data.Specification(name = specName) |
3 | 2687 |
|
2688 |
# keep the BldInfFile object for later |
|
5 | 2689 |
specNode.component = component |
3 | 2690 |
|
2691 |
# add some basic data in a component-wide variant |
|
5 | 2692 |
var = raptor_data.Variant(name='component-wide') |
2693 |
var.AddOperation(raptor_data.Set("COMPONENT_META", str(component.bldinf_filename))) |
|
2694 |
var.AddOperation(raptor_data.Set("COMPONENT_NAME", componentName)) |
|
3 | 2695 |
var.AddOperation(raptor_data.Set("COMPONENT_LAYER", layer)) |
2696 |
specNode.AddVariant(var) |
|
2697 |
||
2698 |
# add this bld.inf Specification to the export platform |
|
2699 |
exportNodes[i].AddChild(specNode) |
|
5 | 2700 |
component.exportspecs.append(specNode) |
3 | 2701 |
|
2702 |
# get the relevant build platforms |
|
2703 |
listedPlatforms = bldInfFile.getBuildPlatforms(self.defaultPlatform) |
|
2704 |
platforms = getBuildableBldInfBuildPlatforms(listedPlatforms, |
|
5 | 2705 |
self.__defaultplatforms, |
2706 |
self.__basedefaultplatforms, |
|
2707 |
self.__baseuserdefaultplatforms) |
|
2708 |
||
2709 |
||
2710 |
outputDir = BldInfFile.outputPathFragment(component.bldinf_filename) |
|
3 | 2711 |
|
2712 |
# Calculate "module name" |
|
5 | 2713 |
modulename = self.ModuleName(str(component.bldinf_filename)) |
3 | 2714 |
|
2715 |
for i,bp in enumerate(self.BuildPlatforms): |
|
5 | 2716 |
plat = bp['PLATFORM'] |
3 | 2717 |
if bp['PLATFORM'] in platforms: |
5 | 2718 |
specNode = raptor_data.Specification(name = specName) |
2719 |
||
2720 |
# remember what component this spec node comes from for later |
|
2721 |
specNode.component = component |
|
3 | 2722 |
|
2723 |
# add some basic data in a component-wide variant |
|
5 | 2724 |
var = raptor_data.Variant(name='component-wide-settings-' + plat) |
2725 |
var.AddOperation(raptor_data.Set("COMPONENT_META",str(component.bldinf_filename))) |
|
2726 |
var.AddOperation(raptor_data.Set("COMPONENT_NAME", componentName)) |
|
3 | 2727 |
var.AddOperation(raptor_data.Set("COMPONENT_LAYER", layer)) |
2728 |
var.AddOperation(raptor_data.Set("MODULE", modulename)) |
|
2729 |
var.AddOperation(raptor_data.Append("OUTPUTPATHOFFSET", outputDir, '/')) |
|
2730 |
var.AddOperation(raptor_data.Append("OUTPUTPATH", outputDir, '/')) |
|
2731 |
var.AddOperation(raptor_data.Append("BLDINF_OUTPUTPATH",outputDir, '/')) |
|
2732 |
||
5 | 2733 |
var.AddOperation(raptor_data.Set("TEST_OPTION", component.bldinf.getRomTestType(bp))) |
3 | 2734 |
specNode.AddVariant(var) |
2735 |
||
2736 |
# add this bld.inf Specification to the build platform |
|
2737 |
platformNodes[i].AddChild(specNode) |
|
5 | 2738 |
# also attach it into the component |
2739 |
component.specs.append(specNode) |
|
3 | 2740 |
|
2741 |
def ProcessExports(self, componentNode, exportPlatform): |
|
2742 |
"""Do the exports for a given platform and skeleton bld.inf node. |
|
2743 |
||
2744 |
This will actually perform exports as certain types of files (.mmh) |
|
2745 |
are required to be in place before the rest of the bld.inf node |
|
2746 |
(and parts of other bld.inf nodes) can be processed. |
|
2747 |
||
2748 |
[some MMP files #include exported .mmh files] |
|
2749 |
""" |
|
2750 |
if exportPlatform["TESTCODE"]: |
|
5 | 2751 |
exports = componentNode.component.bldinf.getTestExports(exportPlatform) |
3 | 2752 |
else: |
5 | 2753 |
exports = componentNode.component.bldinf.getExports(exportPlatform) |
3 | 2754 |
|
2755 |
self.__Raptor.Debug("%i exports for %s", |
|
5 | 2756 |
len(exports), str(componentNode.component.bldinf.filename)) |
3 | 2757 |
if exports: |
2758 |
||
2759 |
# each export is either a 'copy' or 'unzip' |
|
2760 |
# maybe we should trap multiple exports to the same location here? |
|
2761 |
epocroot = str(exportPlatform["EPOCROOT"]) |
|
5 | 2762 |
bldinf_filename = str(componentNode.component.bldinf.filename) |
3 | 2763 |
exportwhatlog="<whatlog bldinf='%s' mmp='' config=''>\n" % bldinf_filename |
2764 |
for export in exports: |
|
2765 |
expSrc = export.getSource() |
|
2766 |
expDstList = export.getDestination() # Might not be a list in all circumstances |
|
2767 |
||
2768 |
# make it a list if it isn't |
|
2769 |
if not isinstance(expDstList, list): |
|
2770 |
expDstList = [expDstList] |
|
2771 |
||
2772 |
fromFile = generic_path.Path(expSrc.replace("$(EPOCROOT)", epocroot)) |
|
2773 |
||
2774 |
# For each destination in the destination list, add an export target, perform it if required. |
|
2775 |
# This ensures that make knows the dependency situation but that the export is made |
|
2776 |
# before any other part of the metadata requires it. It also helps with the build |
|
2777 |
# from clean situation where we can't use order only prerequisites. |
|
2778 |
for expDst in expDstList: |
|
2779 |
toFile = generic_path.Path(expDst.replace("$(EPOCROOT)", epocroot)) |
|
2780 |
try: |
|
2781 |
if export.getAction() == "copy": |
|
2782 |
# export the file |
|
2783 |
exportwhatlog += self.CopyExport(fromFile, toFile, bldinf_filename) |
|
2784 |
else: |
|
2785 |
exportwhatlog += ("<archive zipfile='" + str(fromFile) + "'>\n") |
|
2786 |
members = self.UnzipExport(fromFile, toFile, |
|
2787 |
str(exportPlatform['SBS_BUILD_DIR']), |
|
2788 |
bldinf_filename) |
|
2789 |
if members != None: |
|
2790 |
exportwhatlog += members |
|
2791 |
exportwhatlog += "</archive>\n" |
|
2792 |
except MetaDataError, e: |
|
2793 |
if self.__Raptor.keepGoing: |
|
2794 |
self.__Raptor.Error("%s",e.Text, bldinf=bldinf_filename) |
|
2795 |
else: |
|
2796 |
raise e |
|
2797 |
exportwhatlog+="</whatlog>\n" |
|
2798 |
self.__Raptor.PrintXML("%s",exportwhatlog) |
|
2799 |
||
2800 |
def CopyExport(self, _source, _destination, bldInfFile): |
|
2801 |
"""Copy the source file to the destination file (create a directory |
|
2802 |
to copy into if it does not exist). Don't copy if the destination |
|
2803 |
file exists and has an equal or newer modification time.""" |
|
2804 |
source = generic_path.Path(str(_source).replace('%20',' ')) |
|
2805 |
destination = generic_path.Path(str(_destination).replace('%20',' ')) |
|
2806 |
dest_str = str(destination) |
|
2807 |
source_str = str(source) |
|
2808 |
||
2809 |
exportwhatlog="<export destination='" + dest_str + "' source='" + \ |
|
2810 |
source_str + "'/>\n" |
|
2811 |
||
2812 |
try: |
|
2813 |
||
2814 |
||
2815 |
destDir = destination.Dir() |
|
2816 |
if not destDir.isDir(): |
|
2817 |
os.makedirs(str(destDir)) |
|
2818 |
shutil.copyfile(source_str, dest_str) |
|
2819 |
return exportwhatlog |
|
2820 |
||
2821 |
sourceMTime = 0 |
|
2822 |
destMTime = 0 |
|
2823 |
try: |
|
2824 |
sourceMTime = os.stat(source_str)[stat.ST_MTIME] |
|
2825 |
destMTime = os.stat(dest_str)[stat.ST_MTIME] |
|
2826 |
except OSError, e: |
|
2827 |
if sourceMTime == 0: |
|
2828 |
message = "Source of export does not exist: " + str(source) |
|
2829 |
if not self.__Raptor.keepGoing: |
|
2830 |
raise MetaDataError(message) |
|
2831 |
else: |
|
2832 |
self.__Raptor.Error(message, bldinf=bldInfFile) |
|
2833 |
||
2834 |
if destMTime == 0 or destMTime < sourceMTime: |
|
2835 |
if os.path.exists(dest_str): |
|
2836 |
os.chmod(dest_str,stat.S_IREAD | stat.S_IWRITE) |
|
2837 |
shutil.copyfile(source_str, dest_str) |
|
2838 |
self.__Raptor.Info("Copied %s to %s", source_str, dest_str) |
|
2839 |
else: |
|
2840 |
self.__Raptor.Info("Up-to-date: %s", dest_str) |
|
2841 |
||
2842 |
||
2843 |
except Exception,e: |
|
2844 |
message = "Could not export " + source_str + " to " + dest_str + " : " + str(e) |
|
2845 |
if not self.__Raptor.keepGoing: |
|
2846 |
raise MetaDataError(message) |
|
2847 |
else: |
|
2848 |
self.__Raptor.Error(message, bldinf=bldInfFile) |
|
2849 |
||
2850 |
return exportwhatlog |
|
2851 |
||
2852 |
||
2853 |
def UnzipExport(self, _source, _destination, _sbs_build_dir, bldinf_filename): |
|
2854 |
"""Unzip the source zipfile into the destination directory |
|
2855 |
but only if the markerfile does not already exist there |
|
2856 |
or it does exist but is older than the zipfile. |
|
2857 |
the markerfile is comprised of the name of the zipfile |
|
2858 |
with the ".zip" removed and ".unzipped" added. |
|
2859 |
""" |
|
2860 |
||
2861 |
# Insert spaces into file if they are there |
|
2862 |
source = str(_source).replace('%20',' ') |
|
2863 |
destination = str(_destination).replace('%20',' ') |
|
2864 |
sanitisedSource = raptor_utilities.sanitise(source) |
|
2865 |
sanitisedDestination = raptor_utilities.sanitise(destination) |
|
2866 |
||
2867 |
destination = str(_destination).replace('%20',' ') |
|
2868 |
exportwhatlog = "" |
|
2869 |
||
2870 |
||
2871 |
try: |
|
2872 |
if not _destination.isDir(): |
|
2873 |
os.makedirs(destination) |
|
2874 |
||
2875 |
# Form the directory to contain the unzipped marker files, and make the directory if require. |
|
2876 |
markerfiledir = generic_path.Path(_sbs_build_dir) |
|
2877 |
if not markerfiledir.isDir(): |
|
2878 |
os.makedirs(str(markerfiledir)) |
|
2879 |
||
2880 |
# Form the marker file name and convert to Python string |
|
2881 |
markerfilename = str(generic_path.Join(markerfiledir, sanitisedSource + sanitisedDestination + ".unzipped")) |
|
2882 |
||
2883 |
# Don't unzip if the marker file is already there or more uptodate |
|
2884 |
sourceMTime = 0 |
|
2885 |
destMTime = 0 |
|
2886 |
try: |
|
2887 |
sourceMTime = os.stat(source)[stat.ST_MTIME] |
|
2888 |
destMTime = os.stat(markerfilename)[stat.ST_MTIME] |
|
2889 |
except OSError, e: |
|
2890 |
if sourceMTime == 0: |
|
2891 |
raise MetaDataError("Source zip for export does not exist: " + source) |
|
2892 |
if destMTime != 0 and destMTime >= sourceMTime: |
|
2893 |
# This file has already been unzipped. Print members then return |
|
2894 |
exportzip = zipfile.ZipFile(source, 'r') |
|
2895 |
files = exportzip.namelist() |
|
2896 |
files.sort() |
|
2897 |
||
2898 |
for file in files: |
|
2899 |
if not file.endswith('/'): |
|
2900 |
expfilename = str(generic_path.Join(destination, file)) |
|
2901 |
exportwhatlog += "<member>" + expfilename + "</member>\n" |
|
2902 |
||
2903 |
self.__Raptor.PrintXML("<clean bldinf='" + bldinf_filename + "' mmp='' config=''>\n") |
|
2904 |
self.__Raptor.PrintXML("<zipmarker>" + markerfilename + "</zipmarker>\n") |
|
2905 |
self.__Raptor.PrintXML("</clean>\n") |
|
2906 |
||
2907 |
return exportwhatlog |
|
2908 |
||
2909 |
exportzip = zipfile.ZipFile(source, 'r') |
|
2910 |
files = exportzip.namelist() |
|
2911 |
files.sort() |
|
2912 |
filecount = 0 |
|
2913 |
for file in files: |
|
2914 |
expfilename = str(generic_path.Join(destination, file)) |
|
2915 |
if file.endswith('/'): |
|
2916 |
try: |
|
2917 |
os.makedirs(expfilename) |
|
2918 |
except OSError, e: |
|
2919 |
pass # errors to do with "already exists" are not interesting. |
|
2920 |
else: |
|
2921 |
try: |
|
2922 |
os.makedirs(os.path.split(expfilename)[0]) |
|
2923 |
except OSError, e: |
|
2924 |
pass # errors to do with "already exists" are not interesting. |
|
2925 |
||
2926 |
try: |
|
2927 |
if os.path.exists(expfilename): |
|
2928 |
os.chmod(expfilename,stat.S_IREAD | stat.S_IWRITE) |
|
2929 |
expfile = open(expfilename, 'wb') |
|
2930 |
expfile.write(exportzip.read(file)) |
|
2931 |
expfile.close() |
|
29
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2932 |
|
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2933 |
# 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
|
2934 |
if (exportzip.getinfo(file).external_attr >> 16L) & 0100: |
ee00c00df073
Catchup to Perforce WIP with timing, python24
timothy.murphy@nokia.com
parents:
14
diff
changeset
|
2935 |
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
|
2936 |
|
3 | 2937 |
# Each file keeps its modified time the same as what it was before unzipping |
2938 |
accesstime = time.time() |
|
2939 |
datetime = exportzip.getinfo(file).date_time |
|
2940 |
timeTuple=(int(datetime[0]), int(datetime[1]), int(datetime[2]), int(datetime[3]), \ |
|
2941 |
int(datetime[4]), int(datetime[5]), int(0), int(0), int(0)) |
|
2942 |
modifiedtime = time.mktime(timeTuple) |
|
2943 |
os.utime(expfilename,(accesstime, modifiedtime)) |
|
2944 |
||
2945 |
filecount += 1 |
|
2946 |
exportwhatlog+="<member>" + expfilename + "</member>\n" |
|
2947 |
except IOError, e: |
|
2948 |
message = "Could not unzip %s to %s: file %s: %s" %(source, destination, expfilename, str(e)) |
|
2949 |
if not self.__Raptor.keepGoing: |
|
2950 |
raise MetaDataError(message) |
|
2951 |
else: |
|
2952 |
self.__Raptor.Error(message, bldinf=bldinf_filename) |
|
2953 |
||
2954 |
markerfile = open(markerfilename, 'wb+') |
|
2955 |
markerfile.close() |
|
2956 |
self.__Raptor.PrintXML("<clean bldinf='" + bldinf_filename + "' mmp='' config=''>\n") |
|
2957 |
self.__Raptor.PrintXML("<zipmarker>" + markerfilename + "</zipmarker>\n") |
|
2958 |
self.__Raptor.PrintXML("</clean>\n") |
|
2959 |
||
2960 |
except IOError: |
|
2961 |
self.__Raptor.Warn("Problem while unzipping export %s to %s: %s",source,destination,str(e)) |
|
2962 |
||
2963 |
self.__Raptor.Info("Unzipped %d files from %s to %s", filecount, source, destination) |
|
2964 |
return exportwhatlog |
|
2965 |
||
2966 |
def ProcessTEMs(self, componentNode, buildPlatform): |
|
2967 |
"""Add Template Extension Makefile nodes for a given platform |
|
2968 |
to a skeleton bld.inf node. |
|
2969 |
||
2970 |
This happens after exports have been handled. |
|
2971 |
""" |
|
2972 |
if buildPlatform["ISFEATUREVARIANT"]: |
|
2973 |
return # feature variation does not run extensions at all |
|
2974 |
||
2975 |
if buildPlatform["TESTCODE"]: |
|
5 | 2976 |
extensions = componentNode.component.bldinf.getTestExtensions(buildPlatform) |
3 | 2977 |
else: |
5 | 2978 |
extensions = componentNode.component.bldinf.getExtensions(buildPlatform) |
3 | 2979 |
|
2980 |
self.__Raptor.Debug("%i template extension makefiles for %s", |
|
5 | 2981 |
len(extensions), str(componentNode.component.bldinf.filename)) |
3 | 2982 |
|
2983 |
for i,extension in enumerate(extensions): |
|
2984 |
if self.__Raptor.projects: |
|
2985 |
if not extension.nametag in self.__Raptor.projects: |
|
2986 |
self.__Raptor.Debug("Skipping %s", extension.getMakefile()) |
|
2987 |
continue |
|
2988 |
elif extension.nametag in self.projectList: |
|
2989 |
self.projectList.remove(extension.nametag) |
|
2990 |
||
2991 |
extensionSpec = raptor_data.Specification("extension" + str(i)) |
|
2992 |
||
2993 |
interface = buildPlatform["extension"] |
|
2994 |
customInterface = False |
|
2995 |
||
2996 |
# is there an FLM replacement for this extension? |
|
2997 |
if extension.interface: |
|
2998 |
try: |
|
2999 |
interface = self.__Raptor.cache.FindNamedInterface(extension.interface, buildPlatform["CACHEID"]) |
|
3000 |
customInterface = True |
|
3001 |
except KeyError: |
|
3002 |
# no, there isn't an FLM |
|
3003 |
pass |
|
3004 |
||
3005 |
extensionSpec.SetInterface(interface) |
|
3006 |
||
3007 |
var = raptor_data.Variant() |
|
3008 |
var.AddOperation(raptor_data.Set("EPOCBLD", "$(OUTPUTPATH)")) |
|
3009 |
var.AddOperation(raptor_data.Set("PLATFORM", buildPlatform["PLATFORM"])) |
|
3010 |
var.AddOperation(raptor_data.Set("PLATFORM_PATH", buildPlatform["PLATFORM"].lower())) |
|
3011 |
var.AddOperation(raptor_data.Set("CFG", "$(VARIANTTYPE)")) |
|
3012 |
var.AddOperation(raptor_data.Set("CFG_PATH", "$(VARIANTTYPE)")) |
|
3013 |
var.AddOperation(raptor_data.Set("GENERATEDCPP", "$(OUTPUTPATH)")) |
|
3014 |
var.AddOperation(raptor_data.Set("TEMPLATE_EXTENSION_MAKEFILE", extension.getMakefile())) |
|
3015 |
var.AddOperation(raptor_data.Set("TEMCOUNT", str(i))) |
|
3016 |
||
3017 |
# Extension inputs are added to the build spec. |
|
3018 |
# '$'s are escaped so that they are not expanded by Raptor or |
|
3019 |
# by Make in the call to the FLM |
|
3020 |
# The Extension makefiles are supposed to expand them themselves |
|
3021 |
# Path separators need not be parameterised anymore |
|
3022 |
# as bash is the standard shell |
|
3023 |
standardVariables = extension.getStandardVariables() |
|
3024 |
for standardVariable in standardVariables.keys(): |
|
3025 |
self.__Raptor.Debug("Set %s=%s", standardVariable, standardVariables[standardVariable]) |
|
3026 |
value = standardVariables[standardVariable].replace('$(', '$$$$(') |
|
3027 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3028 |
var.AddOperation(raptor_data.Set(standardVariable, value)) |
|
3029 |
||
3030 |
# . . . as with the standard variables but the names and number |
|
3031 |
# of options are not known in advance so we add them to |
|
3032 |
# a "structure" that is self-describing |
|
3033 |
var.AddOperation(raptor_data.Set("O._MEMBERS", "")) |
|
3034 |
options = extension.getOptions() |
|
3035 |
for option in options: |
|
3036 |
self.__Raptor.Debug("Set %s=%s", option, options[option]) |
|
3037 |
value = options[option].replace('$(EPOCROOT)', '$(EPOCROOT)/') |
|
3038 |
value = value.replace('$(', '$$$$(') |
|
3039 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3040 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3041 |
||
3042 |
if customInterface: |
|
3043 |
var.AddOperation(raptor_data.Set(option, value)) |
|
3044 |
else: |
|
3045 |
var.AddOperation(raptor_data.Append("O._MEMBERS", option)) |
|
3046 |
var.AddOperation(raptor_data.Set("O." + option, value)) |
|
3047 |
||
3048 |
extensionSpec.AddVariant(var) |
|
3049 |
componentNode.AddChild(extensionSpec) |
|
3050 |
||
3051 |
||
3052 |
def ProcessMMPs(self, componentNode, buildPlatform): |
|
3053 |
"""Add project nodes for a given platform to a skeleton bld.inf node. |
|
3054 |
||
3055 |
This happens after exports have been handled. |
|
3056 |
""" |
|
3057 |
gnuList = [] |
|
3058 |
makefileList = [] |
|
3059 |
||
5 | 3060 |
|
3061 |
component = componentNode.component |
|
3062 |
||
3063 |
||
3 | 3064 |
if buildPlatform["TESTCODE"]: |
5 | 3065 |
MMPList = component.bldinf.getTestMMPList(buildPlatform) |
3 | 3066 |
else: |
5 | 3067 |
MMPList = component.bldinf.getMMPList(buildPlatform) |
3068 |
||
3069 |
bldInfFile = component.bldinf.filename |
|
3 | 3070 |
|
3071 |
for mmpFileEntry in MMPList['mmpFileList']: |
|
5 | 3072 |
component.AddMMP(mmpFileEntry.filename) # Tell the component another mmp is specified (for this platform) |
3073 |
||
3 | 3074 |
projectname = mmpFileEntry.filename.File().lower() |
3075 |
||
3076 |
if self.__Raptor.projects: |
|
3077 |
if not projectname in self.__Raptor.projects: |
|
3078 |
self.__Raptor.Debug("Skipping %s", str(mmpFileEntry.filename)) |
|
3079 |
continue |
|
3080 |
elif projectname in self.projectList: |
|
3081 |
self.projectList.remove(projectname) |
|
3082 |
||
3083 |
foundmmpfile = (mmpFileEntry.filename).FindCaseless() |
|
3084 |
||
3085 |
if foundmmpfile == None: |
|
3086 |
self.__Raptor.Error("Can't find mmp file '%s'", str(mmpFileEntry.filename), bldinf=str(bldInfFile)) |
|
3087 |
continue |
|
3088 |
||
3089 |
mmpFile = MMPFile(foundmmpfile, |
|
3090 |
self.__gnucpp, |
|
5 | 3091 |
component.bldinf, |
3092 |
component.depfiles, |
|
3 | 3093 |
log = self.__Raptor) |
3094 |
||
3095 |
mmpFilename = mmpFile.filename |
|
3096 |
||
3097 |
self.__Raptor.Info("Processing %s for platform %s", |
|
3098 |
str(mmpFilename), |
|
3099 |
" + ".join([x.name for x in buildPlatform["configs"]])) |
|
3100 |
||
3101 |
# Run the Parser |
|
3102 |
# The backend supplies the actions |
|
3103 |
content = mmpFile.getContent(buildPlatform) |
|
3104 |
backend = MMPRaptorBackend(self.__Raptor, str(mmpFilename), str(bldInfFile)) |
|
3105 |
parser = MMPParser(backend) |
|
3106 |
parseresult = None |
|
3107 |
try: |
|
3108 |
parseresult = parser.mmp.parseString(content) |
|
3109 |
except ParseException,e: |
|
3110 |
self.__Raptor.Debug(e) # basically ignore parse exceptions |
|
3111 |
||
3112 |
if (not parseresult) or (parseresult[0] != 'MMP'): |
|
3113 |
self.__Raptor.Error("The MMP Parser didn't recognise the mmp file '%s'", |
|
3114 |
str(mmpFileEntry.filename), |
|
3115 |
bldinf=str(bldInfFile)) |
|
3116 |
self.__Raptor.Debug(content) |
|
3117 |
self.__Raptor.Debug("The parse result was %s", parseresult) |
|
3118 |
else: |
|
3119 |
backend.finalise(buildPlatform) |
|
3120 |
||
3121 |
# feature variation only processes FEATUREVARIANT binaries |
|
3122 |
if buildPlatform["ISFEATUREVARIANT"] and not backend.featureVariant: |
|
3123 |
continue |
|
3124 |
||
3125 |
# now build the specification tree |
|
5 | 3126 |
mmpSpec = raptor_data.Specification(generic_path.Path(getSpecName(mmpFilename))) |
3 | 3127 |
var = backend.BuildVariant |
3128 |
||
3129 |
var.AddOperation(raptor_data.Set("PROJECT_META", str(mmpFilename))) |
|
3130 |
||
3131 |
# If it is a TESTMMPFILE section, the FLM needs to know about it |
|
3132 |
if buildPlatform["TESTCODE"] and (mmpFileEntry.testoption in |
|
3133 |
["manual", "auto"]): |
|
3134 |
||
3135 |
var.AddOperation(raptor_data.Set("TESTPATH", |
|
3136 |
mmpFileEntry.testoption.lower() + ".bat")) |
|
3137 |
||
3138 |
# The output path for objects, stringtables and bitmaps specified by |
|
3139 |
# this MMP. Adding in the requested target extension prevents build |
|
3140 |
# "fouling" in cases where there are several mmp targets which only differ |
|
3141 |
# by the requested extension. e.g. elocl.01 and elocl.18 |
|
3142 |
var.AddOperation(raptor_data.Append("OUTPUTPATH","$(UNIQUETARGETPATH)",'/')) |
|
3143 |
||
3144 |
# If the bld.inf entry for this MMP had the BUILD_AS_ARM option then |
|
3145 |
# tell the FLM. |
|
3146 |
if mmpFileEntry.armoption: |
|
3147 |
var.AddOperation(raptor_data.Set("ALWAYS_BUILD_AS_ARM","1")) |
|
3148 |
||
3149 |
# what interface builds this node? |
|
3150 |
try: |
|
3151 |
interfaceName = buildPlatform[backend.getTargetType()] |
|
3152 |
mmpSpec.SetInterface(interfaceName) |
|
3153 |
except KeyError: |
|
3154 |
self.__Raptor.Error("Unsupported target type '%s' in %s", |
|
3155 |
backend.getTargetType(), |
|
3156 |
str(mmpFileEntry.filename), |
|
3157 |
bldinf=str(bldInfFile)) |
|
3158 |
continue |
|
3159 |
||
3160 |
# Although not part of the MMP, some MMP-based build specs additionally require knowledge of their |
|
3161 |
# container bld.inf exported headers |
|
5 | 3162 |
for export in componentNode.component.bldinf.getExports(buildPlatform): |
3 | 3163 |
destination = export.getDestination() |
3164 |
if isinstance(destination, list): |
|
3165 |
exportfile = str(destination[0]) |
|
3166 |
else: |
|
3167 |
exportfile = str(destination) |
|
3168 |
||
3169 |
if re.search('\.h',exportfile,re.IGNORECASE): |
|
3170 |
var.AddOperation(raptor_data.Append("EXPORTHEADERS", str(exportfile))) |
|
3171 |
||
3172 |
# now we have something worth adding to the component |
|
3173 |
mmpSpec.AddVariant(var) |
|
3174 |
componentNode.AddChild(mmpSpec) |
|
9 | 3175 |
|
3176 |
# if there are APPLY variants then add them to the mmpSpec too |
|
3177 |
for applyVar in backend.ApplyVariants: |
|
3178 |
try: |
|
3179 |
mmpSpec.AddVariant(self.__Raptor.cache.FindNamedVariant(applyVar)) |
|
3180 |
except KeyError: |
|
3181 |
self.__Raptor.Error("APPLY unknown variant '%s' in %s", |
|
3182 |
applyVar, |
|
3183 |
str(mmpFileEntry.filename), |
|
3184 |
bldinf=str(bldInfFile)) |
|
3 | 3185 |
|
3186 |
# resources, stringtables and bitmaps are sub-nodes of this project |
|
3187 |
# (do not add these for feature variant builds) |
|
3188 |
||
3189 |
if not buildPlatform["ISFEATUREVARIANT"]: |
|
3190 |
# Buildspec for Resource files |
|
3191 |
for i,rvar in enumerate(backend.ResourceVariants): |
|
3192 |
resourceSpec = raptor_data.Specification('resource' + str(i)) |
|
3193 |
resourceSpec.SetInterface(buildPlatform['resource']) |
|
3194 |
resourceSpec.AddVariant(rvar) |
|
3195 |
mmpSpec.AddChild(resourceSpec) |
|
3196 |
||
3197 |
# Buildspec for String Tables |
|
3198 |
for i,stvar in enumerate(backend.StringTableVariants): |
|
3199 |
stringTableSpec = raptor_data.Specification('stringtable' + str(i)) |
|
3200 |
stringTableSpec.SetInterface(buildPlatform['stringtable']) |
|
3201 |
stringTableSpec.AddVariant(stvar) |
|
3202 |
mmpSpec.AddChild(stringTableSpec) |
|
3203 |
||
3204 |
# Buildspec for Bitmaps |
|
3205 |
for i,bvar in enumerate(backend.BitmapVariants): |
|
3206 |
bitmapSpec = raptor_data.Specification('bitmap' + str(i)) |
|
3207 |
bitmapSpec.SetInterface(buildPlatform['bitmap']) |
|
3208 |
bitmapSpec.AddVariant(bvar) |
|
3209 |
mmpSpec.AddChild(bitmapSpec) |
|
3210 |
||
3211 |
# feature variation does not run extensions at all |
|
3212 |
# so return without considering .*MAKEFILE sections |
|
3213 |
if buildPlatform["ISFEATUREVARIANT"]: |
|
3214 |
return |
|
3215 |
||
3216 |
# Build spec for gnumakefile |
|
3217 |
for g in MMPList['gnuList']: |
|
3218 |
projectname = g.getMakefileName().lower() |
|
3219 |
||
3220 |
if self.__Raptor.projects: |
|
3221 |
if not projectname in self.__Raptor.projects: |
|
3222 |
self.__Raptor.Debug("Skipping %s", str(g.getMakefileName())) |
|
3223 |
continue |
|
3224 |
elif projectname in self.projectList: |
|
3225 |
self.projectList.remove(projectname) |
|
3226 |
||
3227 |
self.__Raptor.Debug("%i gnumakefile extension makefiles for %s", |
|
5 | 3228 |
len(gnuList), str(componentNode.component.bldinf.filename)) |
3 | 3229 |
var = raptor_data.Variant() |
3230 |
gnuSpec = raptor_data.Specification("gnumakefile " + str(g.getMakefileName())) |
|
3231 |
interface = buildPlatform["ext_makefile"] |
|
3232 |
gnuSpec.SetInterface(interface) |
|
3233 |
gnumakefilePath = raptor_utilities.resolveSymbianPath(str(bldInfFile), g.getMakefileName()) |
|
3234 |
var.AddOperation(raptor_data.Set("EPOCBLD", "$(OUTPUTPATH)")) |
|
3235 |
var.AddOperation(raptor_data.Set("PLATFORM", buildPlatform["PLATFORM"])) |
|
3236 |
var.AddOperation(raptor_data.Set("EXTMAKEFILENAME", g.getMakefileName())) |
|
3237 |
var.AddOperation(raptor_data.Set("DIRECTORY",g.getMakeDirectory())) |
|
3238 |
var.AddOperation(raptor_data.Set("CFG","$(VARIANTTYPE)")) |
|
3239 |
standardVariables = g.getStandardVariables() |
|
3240 |
for standardVariable in standardVariables.keys(): |
|
3241 |
self.__Raptor.Debug("Set %s=%s", standardVariable, standardVariables[standardVariable]) |
|
3242 |
value = standardVariables[standardVariable].replace('$(', '$$$$(') |
|
3243 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3244 |
var.AddOperation(raptor_data.Set(standardVariable, value)) |
|
3245 |
gnuSpec.AddVariant(var) |
|
3246 |
componentNode.AddChild(gnuSpec) |
|
3247 |
||
3248 |
# Build spec for makefile |
|
3249 |
for m in MMPList['makefileList']: |
|
3250 |
projectname = m.getMakefileName().lower() |
|
3251 |
||
3252 |
if self.__Raptor.projects: |
|
3253 |
if not projectname in self.__Raptor.projects: |
|
3254 |
self.__Raptor.Debug("Skipping %s", str(m.getMakefileName())) |
|
3255 |
continue |
|
3256 |
elif projectname in self.projectList: |
|
3257 |
projectList.remove(projectname) |
|
3258 |
||
3259 |
self.__Raptor.Debug("%i makefile extension makefiles for %s", |
|
5 | 3260 |
len(makefileList), str(componentNode.component.bldinf.filename)) |
3 | 3261 |
var = raptor_data.Variant() |
3262 |
gnuSpec = raptor_data.Specification("makefile " + str(m.getMakefileName())) |
|
3263 |
interface = buildPlatform["ext_makefile"] |
|
3264 |
gnuSpec.SetInterface(interface) |
|
3265 |
gnumakefilePath = raptor_utilities.resolveSymbianPath(str(bldInfFile), m.getMakefileName()) |
|
3266 |
var.AddOperation(raptor_data.Set("EPOCBLD", "$(OUTPUTPATH)")) |
|
3267 |
var.AddOperation(raptor_data.Set("PLATFORM", buildPlatform["PLATFORM"])) |
|
3268 |
var.AddOperation(raptor_data.Set("EXTMAKEFILENAME", m.getMakefileName())) |
|
3269 |
var.AddOperation(raptor_data.Set("DIRECTORY",m.getMakeDirectory())) |
|
3270 |
var.AddOperation(raptor_data.Set("CFG","$(VARIANTTYPE)")) |
|
3271 |
var.AddOperation(raptor_data.Set("USENMAKE","1")) |
|
3272 |
standardVariables = m.getStandardVariables() |
|
3273 |
for standardVariable in standardVariables.keys(): |
|
3274 |
self.__Raptor.Debug("Set %s=%s", standardVariable, standardVariables[standardVariable]) |
|
3275 |
value = standardVariables[standardVariable].replace('$(', '$$$$(') |
|
3276 |
value = value.replace('$/', '/').replace('$;', ':') |
|
3277 |
var.AddOperation(raptor_data.Set(standardVariable, value)) |
|
3278 |
gnuSpec.AddVariant(var) |
|
3279 |
componentNode.AddChild(gnuSpec) |
|
3280 |
||
3281 |
||
3282 |
def ApplyOSVariant(self, aBuildUnit, aEpocroot): |
|
3283 |
# Form path to kif.xml and path to buildinfo.txt |
|
3284 |
kifXmlPath = generic_path.Join(aEpocroot, "epoc32", "data","kif.xml") |
|
3285 |
buildInfoTxtPath = generic_path.Join(aEpocroot, "epoc32", "data","buildinfo.txt") |
|
3286 |
||
3287 |
# Start with osVersion being None. This variable is a string and does two things: |
|
3288 |
# 1) is a representation of the OS version |
|
3289 |
# 2) is potentially the name of a variant |
|
3290 |
osVersion = None |
|
3291 |
if kifXmlPath.isFile(): # kif.xml exists so try to read it |
|
3292 |
osVersion = getOsVerFromKifXml(str(kifXmlPath)) |
|
3293 |
if osVersion != None: |
|
3294 |
self.__Raptor.Info("OS version \"%s\" determined from file \"%s\"" % (osVersion, kifXmlPath)) |
|
3295 |
||
3296 |
# OS version was not determined from the kif.xml, e.g. because it doesn't exist |
|
3297 |
# or there was a problem parsing it. So, we fall over to using the buildinfo.txt |
|
3298 |
if osVersion == None and buildInfoTxtPath.isFile(): |
|
3299 |
osVersion = getOsVerFromBuildInfoTxt(str(buildInfoTxtPath)) |
|
3300 |
if osVersion != None: |
|
3301 |
self.__Raptor.Info("OS version \"%s\" determined from file \"%s\"" % (osVersion, buildInfoTxtPath)) |
|
3302 |
||
3303 |
# If we determined a non-empty string for the OS Version, attempt to apply it |
|
3304 |
if osVersion and osVersion in self.__Raptor.cache.variants: |
|
3305 |
self.__Raptor.Info("applying the OS variant to the configuration \"%s\"." % aBuildUnit.name) |
|
3306 |
aBuildUnit.variants.append(self.__Raptor.cache.variants[osVersion]) |
|
3307 |
else: |
|
3308 |
self.__Raptor.Info("no OS variant for the configuration \"%s\"." % aBuildUnit.name) |
|
3309 |