]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
BaseTools/UPT: Fix an issue of adding Event twice
[mirror_edk2.git] / BaseTools / Source / Python / UPT / GenMetaFile / GenInfFile.py
1 ## @file GenInfFile.py
2 #
3 # This file contained the logical of transfer package object to INF files.
4 #
5 # Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
6 #
7 # This program and the accompanying materials are licensed and made available
8 # under the terms and conditions of the BSD License which accompanies this
9 # distribution. The full text of the license may be found at
10 # http://opensource.org/licenses/bsd-license.php
11 #
12 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #
15 '''
16 GenInf
17 '''
18 import os
19 import stat
20 import codecs
21 import md5
22 from Core.FileHook import __FileHookOpen__
23 from Library.String import GetSplitValueList
24 from Library.Parsing import GenSection
25 from Library.Parsing import GetWorkspacePackage
26 from Library.Parsing import ConvertArchForInstall
27 from Library.Misc import SaveFileOnChange
28 from Library.Misc import IsAllModuleList
29 from Library.Misc import Sdict
30 from Library.Misc import ConvertPath
31 from Library.Misc import ConvertSpec
32 from Library.Misc import GetRelativePath
33 from Library.Misc import GetLocalValue
34 from Library.CommentGenerating import GenHeaderCommentSection
35 from Library.CommentGenerating import GenGenericCommentF
36 from Library.CommentGenerating import _GetHelpStr
37 from Library import GlobalData
38 from Logger import StringTable as ST
39 from Logger import ToolError
40 import Logger.Log as Logger
41 from Library import DataType as DT
42 from GenMetaFile import GenMetaFileMisc
43 from Library.UniClassObject import FormatUniEntry
44 from Library.String import GetUniFileName
45
46
47 ## Transfer Module Object to Inf files
48 #
49 # Transfer all contents of a standard Module Object to an Inf file
50 # @param ModuleObject: A Module Object
51 #
52 def ModuleToInf(ModuleObject, PackageObject=None, DistHeader=None):
53 if not GlobalData.gWSPKG_LIST:
54 GlobalData.gWSPKG_LIST = GetWorkspacePackage()
55 #
56 # Init global information for the file
57 #
58 ContainerFile = ModuleObject.GetFullPath()
59
60 Content = ''
61 #
62 # Generate file header, If any Abstract, Description, Copyright or License XML elements are missing,
63 # should 1) use the Abstract, Description, Copyright or License from the PackageSurfaceArea.Header elements
64 # that the module belongs to, or 2) if this is a stand-alone module that is not included in a PackageSurfaceArea,
65 # use the abstract, description, copyright or license from the DistributionPackage.Header elements.
66 #
67 ModuleAbstract = GetLocalValue(ModuleObject.GetAbstract())
68 if not ModuleAbstract and PackageObject:
69 ModuleAbstract = GetLocalValue(PackageObject.GetAbstract())
70 if not ModuleAbstract and DistHeader:
71 ModuleAbstract = GetLocalValue(DistHeader.GetAbstract())
72 ModuleDescription = GetLocalValue(ModuleObject.GetDescription())
73 if not ModuleDescription and PackageObject:
74 ModuleDescription = GetLocalValue(PackageObject.GetDescription())
75 if not ModuleDescription and DistHeader:
76 ModuleDescription = GetLocalValue(DistHeader.GetDescription())
77 ModuleCopyright = ''
78 for (Lang, Copyright) in ModuleObject.GetCopyright():
79 if Lang:
80 pass
81 ModuleCopyright = Copyright
82 if not ModuleCopyright and PackageObject:
83 for (Lang, Copyright) in PackageObject.GetCopyright():
84 if Lang:
85 pass
86 ModuleCopyright = Copyright
87 if not ModuleCopyright and DistHeader:
88 for (Lang, Copyright) in DistHeader.GetCopyright():
89 if Lang:
90 pass
91 ModuleCopyright = Copyright
92 ModuleLicense = ''
93 for (Lang, License) in ModuleObject.GetLicense():
94 if Lang:
95 pass
96 ModuleLicense = License
97 if not ModuleLicense and PackageObject:
98 for (Lang, License) in PackageObject.GetLicense():
99 if Lang:
100 pass
101 ModuleLicense = License
102 if not ModuleLicense and DistHeader:
103 for (Lang, License) in DistHeader.GetLicense():
104 if Lang:
105 pass
106 ModuleLicense = License
107
108 #
109 # Generate header comment section of INF file
110 #
111 Content += GenHeaderCommentSection(ModuleAbstract,
112 ModuleDescription,
113 ModuleCopyright,
114 ModuleLicense).replace('\r\n', '\n')
115
116 #
117 # Generate Binary Header
118 #
119 for UserExtension in ModuleObject.GetUserExtensionList():
120 if UserExtension.GetUserID() == DT.TAB_BINARY_HEADER_USERID \
121 and UserExtension.GetIdentifier() == DT.TAB_BINARY_HEADER_IDENTIFIER:
122 ModuleBinaryAbstract = GetLocalValue(UserExtension.GetBinaryAbstract())
123 ModuleBinaryDescription = GetLocalValue(UserExtension.GetBinaryDescription())
124 ModuleBinaryCopyright = ''
125 ModuleBinaryLicense = ''
126 for (Lang, Copyright) in UserExtension.GetBinaryCopyright():
127 ModuleBinaryCopyright = Copyright
128 for (Lang, License) in UserExtension.GetBinaryLicense():
129 ModuleBinaryLicense = License
130 if ModuleBinaryAbstract and ModuleBinaryDescription and \
131 ModuleBinaryCopyright and ModuleBinaryLicense:
132 Content += GenHeaderCommentSection(ModuleBinaryAbstract,
133 ModuleBinaryDescription,
134 ModuleBinaryCopyright,
135 ModuleBinaryLicense,
136 True)
137
138 #
139 # Generate MODULE_UNI_FILE for module
140 #
141 FileHeader = GenHeaderCommentSection(ModuleAbstract, ModuleDescription, ModuleCopyright, ModuleLicense, False, \
142 DT.TAB_COMMENT_EDK1_SPLIT)
143 GenModuleUNIEncodeFile(ModuleObject, FileHeader)
144
145 #
146 # Judge whether the INF file is an AsBuild INF.
147 #
148 if ModuleObject.BinaryModule:
149 GlobalData.gIS_BINARY_INF = True
150 else:
151 GlobalData.gIS_BINARY_INF = False
152 #
153 # for each section, maintain a dict, sorted arch will be its key,
154 # statement list will be its data
155 # { 'Arch1 Arch2 Arch3': [statement1, statement2],
156 # 'Arch1' : [statement1, statement3]
157 # }
158 #
159 # Gen section contents
160 #
161 Content += GenDefines(ModuleObject)
162 Content += GenBuildOptions(ModuleObject)
163 Content += GenLibraryClasses(ModuleObject)
164 Content += GenPackages(ModuleObject)
165 Content += GenPcdSections(ModuleObject)
166 Content += GenSources(ModuleObject)
167 Content += GenProtocolPPiSections(ModuleObject.GetProtocolList(), True)
168 Content += GenProtocolPPiSections(ModuleObject.GetPpiList(), False)
169 Content += GenGuidSections(ModuleObject.GetGuidList())
170 Content += GenBinaries(ModuleObject)
171 Content += GenDepex(ModuleObject)
172 __UserExtensionsContent = GenUserExtensions(ModuleObject)
173 Content += __UserExtensionsContent
174 if ModuleObject.GetEventList() or ModuleObject.GetBootModeList() or ModuleObject.GetHobList():
175 Content += '\n'
176 #
177 # generate [Event], [BootMode], [Hob] section
178 #
179 Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event', __UserExtensionsContent)
180 Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode', __UserExtensionsContent)
181 Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob', __UserExtensionsContent)
182 SaveFileOnChange(ContainerFile, Content, False)
183 if DistHeader.ReadOnly:
184 os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
185 else:
186 os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)
187 return ContainerFile
188
189 ## GenModuleUNIEncodeFile
190 # GenModuleUNIEncodeFile, default is a UCS-2LE encode file
191 #
192 def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCODING_UTF16LE):
193 GenUNIFlag = False
194 OnlyLANGUAGE_EN_X = True
195 BinaryAbstract = []
196 BinaryDescription = []
197 #
198 # If more than one language code is used for any element that would be present in the MODULE_UNI_FILE,
199 # then the MODULE_UNI_FILE must be created.
200 #
201 for (Key, Value) in ModuleObject.GetAbstract() + ModuleObject.GetDescription():
202 if Key == DT.TAB_LANGUAGE_EN_X:
203 GenUNIFlag = True
204 else:
205 OnlyLANGUAGE_EN_X = False
206
207 for UserExtension in ModuleObject.GetUserExtensionList():
208 if UserExtension.GetUserID() == DT.TAB_BINARY_HEADER_USERID \
209 and UserExtension.GetIdentifier() == DT.TAB_BINARY_HEADER_IDENTIFIER:
210 for (Key, Value) in UserExtension.GetBinaryAbstract():
211 if Key == DT.TAB_LANGUAGE_EN_X:
212 GenUNIFlag = True
213 else:
214 OnlyLANGUAGE_EN_X = False
215 BinaryAbstract.append((Key, Value))
216 for (Key, Value) in UserExtension.GetBinaryDescription():
217 if Key == DT.TAB_LANGUAGE_EN_X:
218 GenUNIFlag = True
219 else:
220 OnlyLANGUAGE_EN_X = False
221 BinaryDescription.append((Key, Value))
222
223
224 if not GenUNIFlag:
225 return
226 elif OnlyLANGUAGE_EN_X:
227 return
228 else:
229 ModuleObject.UNIFlag = True
230 ContainerFile = GetUniFileName(os.path.dirname(ModuleObject.GetFullPath()), ModuleObject.GetBaseName())
231
232 if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())):
233 os.makedirs(os.path.dirname(ModuleObject.GetFullPath()))
234
235 Content = UniFileHeader + '\r\n'
236 Content += '\r\n'
237
238 Content += FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, ModuleObject.GetAbstract(), ContainerFile) + '\r\n'
239
240 Content += FormatUniEntry('#string ' + DT.TAB_INF_DESCRIPTION, ModuleObject.GetDescription(), ContainerFile) \
241 + '\r\n'
242
243 BinaryAbstractString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_ABSTRACT, BinaryAbstract, ContainerFile)
244 if BinaryAbstractString:
245 Content += BinaryAbstractString + '\r\n'
246
247 BinaryDescriptionString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_DESCRIPTION, BinaryDescription, \
248 ContainerFile)
249 if BinaryDescriptionString:
250 Content += BinaryDescriptionString + '\r\n'
251
252 if not os.path.exists(ContainerFile):
253 File = codecs.open(ContainerFile, 'wb', Encoding)
254 File.write(u'\uFEFF' + Content)
255 File.stream.close()
256 Md5Sigature = md5.new(__FileHookOpen__(str(ContainerFile), 'rb').read())
257 Md5Sum = Md5Sigature.hexdigest()
258 if (ContainerFile, Md5Sum) not in ModuleObject.FileList:
259 ModuleObject.FileList.append((ContainerFile, Md5Sum))
260
261 return ContainerFile
262 def GenDefines(ModuleObject):
263 #
264 # generate [Defines] section
265 #
266 LeftOffset = 31
267 Content = ''
268 NewSectionDict = {}
269
270 for UserExtension in ModuleObject.GetUserExtensionList():
271 DefinesDict = UserExtension.GetDefinesDict()
272 if not DefinesDict:
273 continue
274 for Statement in DefinesDict:
275 if Statement.split(DT.TAB_EQUAL_SPLIT) > 1:
276 Statement = (u'%s ' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[0]).ljust(LeftOffset) \
277 + u'= %s' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[1].lstrip()
278 SortedArch = DT.TAB_ARCH_COMMON
279 if Statement.strip().startswith(DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE):
280 pos = Statement.find(DT.TAB_VALUE_SPLIT)
281 if pos == -1:
282 pos = Statement.find(DT.TAB_EQUAL_SPLIT)
283 Makefile = ConvertPath(Statement[pos + 1:].strip())
284 Statement = Statement[:pos + 1] + ' ' + Makefile
285 if SortedArch in NewSectionDict:
286 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
287 else:
288 NewSectionDict[SortedArch] = [Statement]
289 SpecialStatementList = []
290
291 # TAB_INF_DEFINES_INF_VERSION
292 Statement = (u'%s ' % DT.TAB_INF_DEFINES_INF_VERSION).ljust(LeftOffset) + u'= %s' % '0x00010017'
293 SpecialStatementList.append(Statement)
294
295 # BaseName
296 BaseName = ModuleObject.GetBaseName()
297 if BaseName.startswith('.') or BaseName.startswith('-'):
298 BaseName = '_' + BaseName
299 Statement = (u'%s ' % DT.TAB_INF_DEFINES_BASE_NAME).ljust(LeftOffset) + u'= %s' % BaseName
300 SpecialStatementList.append(Statement)
301
302 # TAB_INF_DEFINES_FILE_GUID
303 Statement = (u'%s ' % DT.TAB_INF_DEFINES_FILE_GUID).ljust(LeftOffset) + u'= %s' % ModuleObject.GetGuid()
304 SpecialStatementList.append(Statement)
305
306 # TAB_INF_DEFINES_VERSION_STRING
307 Statement = (u'%s ' % DT.TAB_INF_DEFINES_VERSION_STRING).ljust(LeftOffset) + u'= %s' % ModuleObject.GetVersion()
308 SpecialStatementList.append(Statement)
309
310 # TAB_INF_DEFINES_VERSION_STRING
311 if ModuleObject.UNIFlag:
312 Statement = (u'%s ' % DT.TAB_INF_DEFINES_MODULE_UNI_FILE).ljust(LeftOffset) + \
313 u'= %s' % ModuleObject.GetBaseName() + '.uni'
314 SpecialStatementList.append(Statement)
315
316 # TAB_INF_DEFINES_MODULE_TYPE
317 if ModuleObject.GetModuleType():
318 Statement = (u'%s ' % DT.TAB_INF_DEFINES_MODULE_TYPE).ljust(LeftOffset) + u'= %s' % ModuleObject.GetModuleType()
319 SpecialStatementList.append(Statement)
320
321 # TAB_INF_DEFINES_PCD_IS_DRIVER
322 if ModuleObject.GetPcdIsDriver():
323 Statement = (u'%s ' % DT.TAB_INF_DEFINES_PCD_IS_DRIVER).ljust(LeftOffset) + \
324 u'= %s' % ModuleObject.GetPcdIsDriver()
325 SpecialStatementList.append(Statement)
326
327 # TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION
328 if ModuleObject.GetUefiSpecificationVersion():
329 Statement = (u'%s ' % DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION).ljust(LeftOffset) + \
330 u'= %s' % ModuleObject.GetUefiSpecificationVersion()
331 SpecialStatementList.append(Statement)
332
333 # TAB_INF_DEFINES_PI_SPECIFICATION_VERSION
334 if ModuleObject.GetPiSpecificationVersion():
335 Statement = (u'%s ' % DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION).ljust(LeftOffset) + \
336 u'= %s' % ModuleObject.GetPiSpecificationVersion()
337 SpecialStatementList.append(Statement)
338
339 # LibraryClass
340 for LibraryClass in ModuleObject.GetLibraryClassList():
341 if LibraryClass.GetUsage() == DT.USAGE_ITEM_PRODUCES or \
342 LibraryClass.GetUsage() == DT.USAGE_ITEM_SOMETIMES_PRODUCES:
343 Statement = (u'%s ' % DT.TAB_INF_DEFINES_LIBRARY_CLASS).ljust(LeftOffset) + \
344 u'= %s' % LibraryClass.GetLibraryClass()
345 if LibraryClass.GetSupModuleList():
346 Statement += '|' + DT.TAB_SPACE_SPLIT.join(l for l in LibraryClass.GetSupModuleList())
347 SpecialStatementList.append(Statement)
348
349 # Spec Item
350 for SpecItem in ModuleObject.GetSpecList():
351 Spec, Version = SpecItem
352 Spec = ConvertSpec(Spec)
353 Statement = '%s %s = %s' % (DT.TAB_INF_DEFINES_SPEC, Spec, Version)
354 SpecialStatementList.append(Statement)
355
356 # Extern
357 ExternList = []
358 for Extern in ModuleObject.GetExternList():
359 ArchList = Extern.GetSupArchList()
360 EntryPoint = Extern.GetEntryPoint()
361 UnloadImage = Extern.GetUnloadImage()
362 Constructor = Extern.GetConstructor()
363 Destructor = Extern.GetDestructor()
364 HelpStringList = Extern.GetHelpTextList()
365 FFE = Extern.GetFeatureFlag()
366 ExternList.append([ArchList, EntryPoint, UnloadImage, Constructor, Destructor, FFE, HelpStringList])
367 #
368 # Add VALID_ARCHITECTURES information
369 #
370 ValidArchStatement = None
371 if ModuleObject.SupArchList:
372 ValidArchStatement = '\n' + '# ' + '\n'
373 ValidArchStatement += '# The following information is for reference only and not required by the build tools.\n'
374 ValidArchStatement += '# ' + '\n'
375 ValidArchStatement += '# VALID_ARCHITECTURES = %s' % (' '.join(ModuleObject.SupArchList)) + '\n'
376 ValidArchStatement += '# '
377 if DT.TAB_ARCH_COMMON not in NewSectionDict:
378 NewSectionDict[DT.TAB_ARCH_COMMON] = []
379 NewSectionDict[DT.TAB_ARCH_COMMON] = NewSectionDict[DT.TAB_ARCH_COMMON] + SpecialStatementList
380 GenMetaFileMisc.AddExternToDefineSec(NewSectionDict, DT.TAB_ARCH_COMMON, ExternList)
381 if ValidArchStatement is not None:
382 NewSectionDict[DT.TAB_ARCH_COMMON] = NewSectionDict[DT.TAB_ARCH_COMMON] + [ValidArchStatement]
383 Content += GenSection('Defines', NewSectionDict)
384 return Content
385
386 def GenLibraryClasses(ModuleObject):
387 #
388 # generate [LibraryClasses] section
389 #
390 Content = ''
391 NewSectionDict = {}
392 if not GlobalData.gIS_BINARY_INF:
393 for LibraryClass in ModuleObject.GetLibraryClassList():
394 if LibraryClass.GetUsage() == DT.USAGE_ITEM_PRODUCES:
395 continue
396 #
397 # Generate generic comment
398 #
399 HelpTextList = LibraryClass.GetHelpTextList()
400 HelpStr = _GetHelpStr(HelpTextList)
401 CommentStr = GenGenericCommentF(HelpStr)
402 Statement = CommentStr
403 Name = LibraryClass.GetLibraryClass()
404 FFE = LibraryClass.GetFeatureFlag()
405 Statement += Name
406 if FFE:
407 Statement += '|' + FFE
408 ModuleList = LibraryClass.GetSupModuleList()
409 ArchList = LibraryClass.GetSupArchList()
410 for Index in xrange(0, len(ArchList)):
411 ArchList[Index] = ConvertArchForInstall(ArchList[Index])
412 ArchList.sort()
413 SortedArch = ' '.join(ArchList)
414 KeyList = []
415 if not ModuleList or IsAllModuleList(ModuleList):
416 KeyList = [SortedArch]
417 else:
418 ModuleString = DT.TAB_VALUE_SPLIT.join(l for l in ModuleList)
419 if not ArchList:
420 SortedArch = DT.TAB_ARCH_COMMON
421 KeyList = [SortedArch + '.' + ModuleString]
422 else:
423 KeyList = [Arch + '.' + ModuleString for Arch in ArchList]
424 for Key in KeyList:
425 if Key in NewSectionDict:
426 NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
427 else:
428 NewSectionDict[Key] = [Statement]
429 Content += GenSection('LibraryClasses', NewSectionDict)
430 else:
431 LibraryClassDict = {}
432 for BinaryFile in ModuleObject.GetBinaryFileList():
433 if not BinaryFile.AsBuiltList:
434 continue
435 for LibraryItem in BinaryFile.AsBuiltList[0].LibraryInstancesList:
436 Statement = '# Guid: ' + LibraryItem.Guid + ' Version: ' + LibraryItem.Version
437
438 if len(BinaryFile.SupArchList) == 0:
439 if LibraryClassDict.has_key('COMMON') and Statement not in LibraryClassDict['COMMON']:
440 LibraryClassDict['COMMON'].append(Statement)
441 else:
442 LibraryClassDict['COMMON'] = ['## @LIB_INSTANCES']
443 LibraryClassDict['COMMON'].append(Statement)
444 else:
445 for Arch in BinaryFile.SupArchList:
446 if LibraryClassDict.has_key(Arch):
447 if Statement not in LibraryClassDict[Arch]:
448 LibraryClassDict[Arch].append(Statement)
449 else:
450 continue
451 else:
452 LibraryClassDict[Arch] = ['## @LIB_INSTANCES']
453 LibraryClassDict[Arch].append(Statement)
454 Content += GenSection('LibraryClasses', LibraryClassDict)
455
456 return Content
457
458 def GenPackages(ModuleObject):
459 Content = ''
460 #
461 # generate [Packages] section
462 #
463 NewSectionDict = Sdict()
464 WorkspaceDir = GlobalData.gWORKSPACE
465 for PackageDependency in ModuleObject.GetPackageDependencyList():
466 #
467 # Generate generic comment
468 #
469 CommentStr = ''
470 HelpText = PackageDependency.GetHelpText()
471 if HelpText:
472 HelpStr = HelpText.GetString()
473 CommentStr = GenGenericCommentF(HelpStr)
474 Statement = CommentStr
475 Guid = PackageDependency.GetGuid()
476 Version = PackageDependency.GetVersion()
477 FFE = PackageDependency.GetFeatureFlag()
478 Path = ''
479 #
480 # find package path/name
481 #
482 for PkgInfo in GlobalData.gWSPKG_LIST:
483 if Guid == PkgInfo[1]:
484 if (not Version) or (Version == PkgInfo[2]):
485 Path = PkgInfo[3]
486 break
487 #
488 # get relative path
489 #
490 RelaPath = GetRelativePath(Path, WorkspaceDir)
491 Statement += RelaPath.replace('\\', '/')
492 if FFE:
493 Statement += '|' + FFE
494 ArchList = PackageDependency.GetSupArchList()
495 ArchList.sort()
496 SortedArch = ' '.join(ArchList)
497 if SortedArch in NewSectionDict:
498 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
499 else:
500 NewSectionDict[SortedArch] = [Statement]
501 Content += GenSection('Packages', NewSectionDict)
502 return Content
503
504 def GenSources(ModuleObject):
505 #
506 # generate [Sources] section
507 #
508 Content = ''
509 NewSectionDict = {}
510 for Source in ModuleObject.GetSourceFileList():
511 SourceFile = Source.GetSourceFile()
512 Family = Source.GetFamily()
513 FeatureFlag = Source.GetFeatureFlag()
514 SupArchList = Source.GetSupArchList()
515 SupArchList.sort()
516 SortedArch = ' '.join(SupArchList)
517 Statement = GenSourceStatement(ConvertPath(SourceFile), Family, FeatureFlag)
518 if SortedArch in NewSectionDict:
519 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
520 else:
521 NewSectionDict[SortedArch] = [Statement]
522 Content += GenSection('Sources', NewSectionDict)
523
524 return Content
525
526 def GenDepex(ModuleObject):
527 #
528 # generate [Depex] section
529 #
530 NewSectionDict = Sdict()
531 Content = ''
532 for Depex in ModuleObject.GetPeiDepex() + ModuleObject.GetDxeDepex() + ModuleObject.GetSmmDepex():
533 HelpTextList = Depex.GetHelpTextList()
534 HelpStr = _GetHelpStr(HelpTextList)
535 CommentStr = GenGenericCommentF(HelpStr)
536 SupArchList = Depex.GetSupArchList()
537 SupModList = Depex.GetModuleType()
538 Expression = Depex.GetDepex()
539 Statement = CommentStr + Expression
540 SupArchList.sort()
541 KeyList = []
542 if not SupArchList:
543 SupArchList.append(DT.TAB_ARCH_COMMON.lower())
544 if not SupModList:
545 KeyList = SupArchList
546 else:
547 for ModuleType in SupModList:
548 for Arch in SupArchList:
549 KeyList.append(ConvertArchForInstall(Arch) + '.' + ModuleType)
550 for Key in KeyList:
551 if Key in NewSectionDict:
552 NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
553 else:
554 NewSectionDict[Key] = [Statement]
555 Content += GenSection('Depex', NewSectionDict, False)
556
557 return Content
558 ## GenUserExtensions
559 #
560 # GenUserExtensions
561 #
562 def GenUserExtensions(ModuleObject):
563 NewSectionDict = {}
564 for UserExtension in ModuleObject.GetUserExtensionList():
565 if UserExtension.GetUserID() == DT.TAB_BINARY_HEADER_USERID and \
566 UserExtension.GetIdentifier() == DT.TAB_BINARY_HEADER_IDENTIFIER:
567 continue
568 if UserExtension.GetIdentifier() == 'Depex':
569 continue
570 Statement = UserExtension.GetStatement()
571 if not Statement:
572 continue
573 ArchList = UserExtension.GetSupArchList()
574 for Index in xrange(0, len(ArchList)):
575 ArchList[Index] = ConvertArchForInstall(ArchList[Index])
576 ArchList.sort()
577 KeyList = []
578 CommonPreFix = ''
579 if UserExtension.GetUserID():
580 CommonPreFix = UserExtension.GetUserID()
581 if CommonPreFix.find('.') > -1:
582 CommonPreFix = '"' + CommonPreFix + '"'
583 if UserExtension.GetIdentifier():
584 CommonPreFix += '.' + '"' + UserExtension.GetIdentifier() + '"'
585 if ArchList:
586 KeyList = [CommonPreFix + '.' + Arch for Arch in ArchList]
587 else:
588 KeyList = [CommonPreFix]
589 for Key in KeyList:
590 if Key in NewSectionDict:
591 NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
592 else:
593 NewSectionDict[Key] = [Statement]
594 Content = GenSection('UserExtensions', NewSectionDict, False)
595
596 return Content
597
598 # GenSourceStatement
599 #
600 # @param SourceFile: string of source file path/name
601 # @param Family: string of source file family field
602 # @param FeatureFlag: string of source file FeatureFlag field
603 # @param TagName: string of source file TagName field
604 # @param ToolCode: string of source file ToolCode field
605 # @param HelpStr: string of source file HelpStr field
606 #
607 # @retval Statement: The generated statement for source
608 #
609 def GenSourceStatement(SourceFile, Family, FeatureFlag, TagName=None,
610 ToolCode=None, HelpStr=None):
611 Statement = ''
612 if HelpStr:
613 Statement += GenGenericCommentF(HelpStr)
614 #
615 # format of SourceFile|Family|TagName|ToolCode|FeatureFlag
616 #
617 Statement += SourceFile
618 if TagName == None:
619 TagName = ''
620 if ToolCode == None:
621 ToolCode = ''
622 if HelpStr == None:
623 HelpStr = ''
624 if FeatureFlag:
625 Statement += '|' + Family + '|' + TagName + '|' + ToolCode + '|' + FeatureFlag
626 elif ToolCode:
627 Statement += '|' + Family + '|' + TagName + '|' + ToolCode
628 elif TagName:
629 Statement += '|' + Family + '|' + TagName
630 elif Family:
631 Statement += '|' + Family
632 return Statement
633
634 # GenBinaryStatement
635 #
636 # @param Key: (FileName, FileType, FFE, SortedArch)
637 # @param Value: (Target, Family, TagName, Comment)
638 #
639 #
640 def GenBinaryStatement(Key, Value, SubTypeGuidValue=None):
641 (FileName, FileType, FFE, SortedArch) = Key
642 if SortedArch:
643 pass
644 if Value:
645 (Target, Family, TagName, Comment) = Value
646 else:
647 Target = ''
648 Family = ''
649 TagName = ''
650 Comment = ''
651 if Comment:
652 Statement = GenGenericCommentF(Comment)
653 else:
654 Statement = ''
655 if FileType == 'SUBTYPE_GUID' and SubTypeGuidValue:
656 Statement += FileType + '|' + SubTypeGuidValue + '|' + FileName
657 else:
658 Statement += FileType + '|' + FileName
659 if FileType in DT.BINARY_FILE_TYPE_UI_LIST + DT.BINARY_FILE_TYPE_VER_LIST:
660 if FFE:
661 Statement += '|' + Target + '|' + FFE
662 elif Target:
663 Statement += '|' + Target
664 else:
665 if FFE:
666 Statement += '|' + Target + '|' + Family + '|' + TagName + '|' + FFE
667 elif TagName:
668 Statement += '|' + Target + '|' + Family + '|' + TagName
669 elif Family:
670 Statement += '|' + Target + '|' + Family
671 elif Target:
672 Statement += '|' + Target
673 return Statement
674 ## GenGuidSections
675 #
676 # @param GuidObjList: List of GuidObject
677 # @retVal Content: The generated section contents
678 #
679 def GenGuidSections(GuidObjList):
680 #
681 # generate [Guids] section
682 #
683 Content = ''
684 GuidDict = Sdict()
685 for Guid in GuidObjList:
686 HelpTextList = Guid.GetHelpTextList()
687 HelpStr = _GetHelpStr(HelpTextList)
688 CName = Guid.GetCName()
689 FFE = Guid.GetFeatureFlag()
690 Statement = CName
691 if FFE:
692 Statement += '|' + FFE
693 Usage = Guid.GetUsage()
694 GuidType = Guid.GetGuidTypeList()[0]
695 VariableName = Guid.GetVariableName()
696 #
697 # Differentiate the generic comment and usage comment as multiple generic comment need to be put at first
698 #
699 if Usage == DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
700 # generate list of generic comment
701 Comment = GenGenericCommentF(HelpStr)
702 else:
703 # generate list of other comment
704 Comment = HelpStr.replace('\n', ' ')
705 Comment = Comment.strip()
706 if Comment:
707 Comment = ' # ' + Comment
708 else:
709 Comment = ''
710 if Usage != DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
711 Comment = '## ' + Usage + Comment
712 elif GuidType == 'Variable':
713 Comment = '## ' + Usage + ' ## ' + GuidType + ':' + VariableName + Comment
714 else:
715 Comment = '## ' + Usage + ' ## ' + GuidType + Comment
716
717 if Comment:
718 Comment += '\n'
719 #
720 # merge duplicate items
721 #
722 ArchList = Guid.GetSupArchList()
723 ArchList.sort()
724 SortedArch = ' '.join(ArchList)
725 if (Statement, SortedArch) in GuidDict:
726 PreviousComment = GuidDict[Statement, SortedArch]
727 Comment = PreviousComment + Comment
728 GuidDict[Statement, SortedArch] = Comment
729 NewSectionDict = GenMetaFileMisc.TransferDict(GuidDict, 'INF_GUID')
730 #
731 # generate the section contents
732 #
733 if NewSectionDict:
734 Content = GenSection('Guids', NewSectionDict)
735
736 return Content
737
738 ## GenProtocolPPiSections
739 #
740 # @param ObjList: List of ProtocolObject or Ppi Object
741 # @retVal Content: The generated section contents
742 #
743 def GenProtocolPPiSections(ObjList, IsProtocol):
744 Content = ''
745 Dict = Sdict()
746 for Object in ObjList:
747 HelpTextList = Object.GetHelpTextList()
748 HelpStr = _GetHelpStr(HelpTextList)
749 CName = Object.GetCName()
750 FFE = Object.GetFeatureFlag()
751 Statement = CName
752 if FFE:
753 Statement += '|' + FFE
754 Usage = Object.GetUsage()
755 Notify = Object.GetNotify()
756 #
757 # Differentiate the generic comment and usage comment as consecutive generic comment need to be put together
758 #
759 if Usage == DT.ITEM_UNDEFINED and Notify == '':
760 # generate list of generic comment
761 Comment = GenGenericCommentF(HelpStr)
762 else:
763 # generate list of other comment
764 Comment = HelpStr.replace('\n', ' ')
765 Comment = Comment.strip()
766 if Comment:
767 Comment = ' # ' + Comment
768 else:
769 Comment = ''
770 if Usage == DT.ITEM_UNDEFINED and not Comment and Notify == '':
771 Comment = ''
772 else:
773 if Notify:
774 Comment = '## ' + Usage + ' ## ' + 'NOTIFY' + Comment
775 else:
776 Comment = '## ' + Usage + Comment
777 if Comment:
778 Comment += '\n'
779 #
780 # merge duplicate items
781 #
782 ArchList = Object.GetSupArchList()
783 ArchList.sort()
784 SortedArch = ' '.join(ArchList)
785 if (Statement, SortedArch) in Dict:
786 PreviousComment = Dict[Statement, SortedArch]
787 Comment = PreviousComment + Comment
788 Dict[Statement, SortedArch] = Comment
789 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PPI_PROTOCOL')
790 #
791 # generate the section contents
792 #
793 if NewSectionDict:
794 if IsProtocol:
795 Content = GenSection('Protocols', NewSectionDict)
796 else:
797 Content = GenSection('Ppis', NewSectionDict)
798
799 return Content
800
801 ## GenPcdSections
802 #
803 #
804 def GenPcdSections(ModuleObject):
805 Content = ''
806 if not GlobalData.gIS_BINARY_INF:
807 #
808 # for each Pcd Itemtype, maintain a dict so the same type will be grouped
809 # together
810 #
811 ItemTypeDict = {}
812 for Pcd in ModuleObject.GetPcdList():
813 HelpTextList = Pcd.GetHelpTextList()
814 HelpStr = _GetHelpStr(HelpTextList)
815 Statement = ''
816 CName = Pcd.GetCName()
817 TokenSpaceGuidCName = Pcd.GetTokenSpaceGuidCName()
818 DefaultValue = Pcd.GetDefaultValue()
819 ItemType = Pcd.GetItemType()
820 if ItemType in ItemTypeDict:
821 Dict = ItemTypeDict[ItemType]
822 else:
823 Dict = Sdict()
824 ItemTypeDict[ItemType] = Dict
825 FFE = Pcd.GetFeatureFlag()
826 Statement += TokenSpaceGuidCName + '.' + CName
827 if DefaultValue:
828 Statement += '|' + DefaultValue
829 if FFE:
830 Statement += '|' + FFE
831 elif FFE:
832 Statement += '||' + FFE
833 #
834 # Generate comment
835 #
836 Usage = Pcd.GetValidUsage()
837 # if FeatureFlag Pcd, then assume all Usage is CONSUMES
838 if ItemType == DT.TAB_INF_FEATURE_PCD:
839 Usage = DT.USAGE_ITEM_CONSUMES
840 if Usage == DT.ITEM_UNDEFINED:
841 # generate list of generic comment
842 Comment = GenGenericCommentF(HelpStr)
843 else:
844 # generate list of other comment
845 Comment = HelpStr.replace('\n', ' ')
846 Comment = Comment.strip()
847 if Comment:
848 Comment = ' # ' + Comment
849 else:
850 Comment = ''
851 Comment = '## ' + Usage + Comment
852 if Comment:
853 Comment += '\n'
854 #
855 # Merge duplicate entries
856 #
857 ArchList = Pcd.GetSupArchList()
858 ArchList.sort()
859 SortedArch = ' '.join(ArchList)
860 if (Statement, SortedArch) in Dict:
861 PreviousComment = Dict[Statement, SortedArch]
862 Comment = PreviousComment + Comment
863 Dict[Statement, SortedArch] = Comment
864 for ItemType in ItemTypeDict:
865 # First we need to transfer the Dict to use SortedArch as key
866 Dict = ItemTypeDict[ItemType]
867 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PCD')
868 if NewSectionDict:
869 Content += GenSection(ItemType, NewSectionDict)
870 #
871 # For AsBuild INF files
872 #
873 else:
874 Content += GenAsBuiltPacthPcdSections(ModuleObject)
875 Content += GenAsBuiltPcdExSections(ModuleObject)
876
877 return Content
878
879 ## GenPcdSections
880 #
881 #
882 def GenAsBuiltPacthPcdSections(ModuleObject):
883 PatchPcdDict = {}
884 for BinaryFile in ModuleObject.GetBinaryFileList():
885 if not BinaryFile.AsBuiltList:
886 continue
887 for PatchPcd in BinaryFile.AsBuiltList[0].PatchPcdList:
888 TokenSpaceName = ''
889 PcdCName = PatchPcd.CName
890 PcdValue = PatchPcd.DefaultValue
891 PcdOffset = PatchPcd.Offset
892 TokenSpaceGuidValue = PatchPcd.TokenSpaceGuidValue
893 Token = PatchPcd.Token
894 HelpTextList = PatchPcd.HelpTextList
895 HelpString = ''
896 for HelpStringItem in HelpTextList:
897 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
898 HelpString += '## ' + HelpLine + '\n'
899 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
900 TokenSpaceGuidValue,
901 Token)
902 if TokenSpaceName == '' or PcdCName == '':
903 Logger.Error("Upt",
904 ToolError.RESOURCE_NOT_AVAILABLE,
905 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
906 File=ModuleObject.GetFullPath())
907 Statement = HelpString + TokenSpaceName + '.' + PcdCName + ' | ' + PcdValue + ' | ' + \
908 PcdOffset + DT.TAB_SPACE_SPLIT
909 #
910 # Use binary file's Arch to be Pcd's Arch
911 #
912 ArchList = []
913 FileNameObjList = BinaryFile.GetFileNameList()
914 if FileNameObjList:
915 ArchList = FileNameObjList[0].GetSupArchList()
916 if len(ArchList) == 0:
917 if PatchPcdDict.has_key(DT.TAB_ARCH_COMMON):
918 if Statement not in PatchPcdDict[DT.TAB_ARCH_COMMON]:
919 PatchPcdDict[DT.TAB_ARCH_COMMON].append(Statement)
920 else:
921 PatchPcdDict[DT.TAB_ARCH_COMMON] = [Statement]
922 else:
923 for Arch in ArchList:
924 if PatchPcdDict.has_key(Arch):
925 if Statement not in PatchPcdDict[Arch]:
926 PatchPcdDict[Arch].append(Statement)
927 else:
928 PatchPcdDict[Arch] = [Statement]
929 return GenSection(DT.TAB_INF_PATCH_PCD, PatchPcdDict)
930 ## GenPcdSections
931 #
932 #
933 def GenAsBuiltPcdExSections(ModuleObject):
934 PcdExDict = {}
935 for BinaryFile in ModuleObject.GetBinaryFileList():
936 if not BinaryFile.AsBuiltList:
937 continue
938 for PcdExItem in BinaryFile.AsBuiltList[0].PcdExValueList:
939 TokenSpaceName = ''
940 PcdCName = PcdExItem.CName
941 TokenSpaceGuidValue = PcdExItem.TokenSpaceGuidValue
942 Token = PcdExItem.Token
943 HelpTextList = PcdExItem.HelpTextList
944 HelpString = ''
945 for HelpStringItem in HelpTextList:
946 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
947 HelpString += '## ' + HelpLine + '\n'
948 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
949 TokenSpaceGuidValue, Token)
950 if TokenSpaceName == '' or PcdCName == '':
951 Logger.Error("Upt",
952 ToolError.RESOURCE_NOT_AVAILABLE,
953 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
954 File=ModuleObject.GetFullPath())
955
956 Statement = HelpString + TokenSpaceName + DT.TAB_SPLIT + PcdCName + DT.TAB_SPACE_SPLIT
957
958 #
959 # Use binary file's Arch to be Pcd's Arch
960 #
961 ArchList = []
962 FileNameObjList = BinaryFile.GetFileNameList()
963 if FileNameObjList:
964 ArchList = FileNameObjList[0].GetSupArchList()
965
966 if len(ArchList) == 0:
967 if PcdExDict.has_key('COMMON'):
968 PcdExDict['COMMON'].append(Statement)
969 else:
970 PcdExDict['COMMON'] = [Statement]
971 else:
972 for Arch in ArchList:
973 if PcdExDict.has_key(Arch):
974 if Statement not in PcdExDict[Arch]:
975 PcdExDict[Arch].append(Statement)
976 else:
977 PcdExDict[Arch] = [Statement]
978 return GenSection('PcdEx', PcdExDict)
979
980 ## GenSpecialSections
981 # generate special sections for Event/BootMode/Hob
982 #
983 def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
984 #
985 # generate section
986 #
987 Content = ''
988 NewSectionDict = {}
989 for Obj in ObjectList:
990 #
991 # Generate comment
992 #
993 CommentStr = ''
994 HelpTextList = Obj.GetHelpTextList()
995 HelpStr = _GetHelpStr(HelpTextList)
996 CommentStr = GenGenericCommentF(HelpStr)
997 if SectionName == 'Hob':
998 Type = Obj.GetHobType()
999 elif SectionName == 'Event':
1000 Type = Obj.GetEventType()
1001 elif SectionName == 'BootMode':
1002 Type = Obj.GetSupportedBootModes()
1003 else:
1004 assert(SectionName)
1005 Usage = Obj.GetUsage()
1006
1007 # If the content already in UserExtensionsContent then ignore
1008 if '[%s]' % SectionName in UserExtensionsContent and Type in UserExtensionsContent:
1009 return ''
1010
1011 Statement = ' ' + Type + ' ## ' + Usage
1012 if CommentStr in ['#\n', '#\n#\n']:
1013 CommentStr = '#\n#\n#\n'
1014 #
1015 # the first head comment line should start with '##\n', if it starts with '#\n', then add one '#'
1016 # else add '##\n' to meet the format defined in INF spec
1017 #
1018 if CommentStr.startswith('#\n'):
1019 CommentStr = '#' + CommentStr
1020 elif CommentStr:
1021 CommentStr = '##\n' + CommentStr
1022 if CommentStr and not CommentStr.endswith('\n#\n'):
1023 CommentStr = CommentStr + '#\n'
1024 NewStateMent = CommentStr + Statement
1025 SupArch = Obj.GetSupArchList()
1026 SupArch.sort()
1027 SortedArch = ' '.join(SupArch)
1028 if SortedArch in NewSectionDict:
1029 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [NewStateMent]
1030 else:
1031 NewSectionDict[SortedArch] = [NewStateMent]
1032 SectionContent = GenSection(SectionName, NewSectionDict)
1033 SectionContent = SectionContent.strip()
1034 if SectionContent:
1035 Content = '# ' + ('\n' + '# ').join(GetSplitValueList(SectionContent, '\n'))
1036 Content = Content.lstrip()
1037 #
1038 # add a return to differentiate it between other possible sections
1039 #
1040 if Content:
1041 Content += '\n'
1042 return Content
1043 ## GenBuildOptions
1044 #
1045 #
1046 def GenBuildOptions(ModuleObject):
1047 Content = ''
1048 if not ModuleObject.BinaryModule:
1049 #
1050 # generate [BuildOptions] section
1051 #
1052 NewSectionDict = {}
1053 for UserExtension in ModuleObject.GetUserExtensionList():
1054 BuildOptionDict = UserExtension.GetBuildOptionDict()
1055 if not BuildOptionDict:
1056 continue
1057 for Arch in BuildOptionDict:
1058 if Arch in NewSectionDict:
1059 NewSectionDict[Arch] = NewSectionDict[Arch] + [BuildOptionDict[Arch]]
1060 else:
1061 NewSectionDict[Arch] = [BuildOptionDict[Arch]]
1062 Content = GenSection('BuildOptions', NewSectionDict)
1063 else:
1064 BuildOptionDict = {}
1065 for BinaryFile in ModuleObject.GetBinaryFileList():
1066 if not BinaryFile.AsBuiltList:
1067 continue
1068 for BuilOptionItem in BinaryFile.AsBuiltList[0].BinaryBuildFlagList:
1069 Statement = '#' + BuilOptionItem.AsBuiltOptionFlags
1070 if len(BinaryFile.SupArchList) == 0:
1071 if BuildOptionDict.has_key('COMMON'):
1072 if Statement not in BuildOptionDict['COMMON']:
1073 BuildOptionDict['COMMON'].append(Statement)
1074 else:
1075 BuildOptionDict['COMMON'] = ['## @AsBuilt']
1076 BuildOptionDict['COMMON'].append(Statement)
1077 else:
1078 for Arch in BinaryFile.SupArchList:
1079 if BuildOptionDict.has_key(Arch):
1080 if Statement not in BuildOptionDict[Arch]:
1081 BuildOptionDict[Arch].append(Statement)
1082 else:
1083 BuildOptionDict[Arch] = ['## @AsBuilt']
1084 BuildOptionDict[Arch].append(Statement)
1085 Content = GenSection('BuildOptions', BuildOptionDict)
1086
1087 return Content
1088 ## GenBinaries
1089 #
1090 #
1091 def GenBinaries(ModuleObject):
1092 NewSectionDict = {}
1093 BinariesDict = []
1094 for UserExtension in ModuleObject.GetUserExtensionList():
1095 BinariesDict = UserExtension.GetBinariesDict()
1096 if BinariesDict:
1097 break
1098 for BinaryFile in ModuleObject.GetBinaryFileList():
1099 FileNameObjList = BinaryFile.GetFileNameList()
1100 for FileNameObj in FileNameObjList:
1101 FileName = ConvertPath(FileNameObj.GetFilename())
1102 FileType = FileNameObj.GetFileType()
1103 FFE = FileNameObj.GetFeatureFlag()
1104 ArchList = FileNameObj.GetSupArchList()
1105 ArchList.sort()
1106 SortedArch = ' '.join(ArchList)
1107 Key = (FileName, FileType, FFE, SortedArch)
1108 if Key in BinariesDict:
1109 ValueList = BinariesDict[Key]
1110 for ValueItem in ValueList:
1111 Statement = GenBinaryStatement(Key, ValueItem)
1112 if SortedArch in NewSectionDict:
1113 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1114 else:
1115 NewSectionDict[SortedArch] = [Statement]
1116 #
1117 # as we already generated statement for this DictKey here set the Valuelist to be empty
1118 # to avoid generate duplicate entries as the DictKey may have multiple entries
1119 #
1120 BinariesDict[Key] = []
1121 else:
1122 if FileType == 'SUBTYPE_GUID' and FileNameObj.GetGuidValue():
1123 Statement = GenBinaryStatement(Key, None, FileNameObj.GetGuidValue())
1124 else:
1125 Statement = GenBinaryStatement(Key, None)
1126 if SortedArch in NewSectionDict:
1127 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1128 else:
1129 NewSectionDict[SortedArch] = [Statement]
1130 Content = GenSection('Binaries', NewSectionDict)
1131
1132 return Content