]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
BaseTools: Fix old python2 idioms
[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 - 2018, 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.StringUtils 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.StringUtils 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 ModuleUniFile = GenModuleUNIEncodeFile(ModuleObject, FileHeader)
144 if ModuleUniFile:
145 ModuleObject.SetModuleUniFile(os.path.basename(ModuleUniFile))
146
147 #
148 # Judge whether the INF file is an AsBuild INF.
149 #
150 if ModuleObject.BinaryModule:
151 GlobalData.gIS_BINARY_INF = True
152 else:
153 GlobalData.gIS_BINARY_INF = False
154 #
155 # for each section, maintain a dict, sorted arch will be its key,
156 # statement list will be its data
157 # { 'Arch1 Arch2 Arch3': [statement1, statement2],
158 # 'Arch1' : [statement1, statement3]
159 # }
160 #
161 # Gen section contents
162 #
163 Content += GenDefines(ModuleObject)
164 Content += GenBuildOptions(ModuleObject)
165 Content += GenLibraryClasses(ModuleObject)
166 Content += GenPackages(ModuleObject)
167 Content += GenPcdSections(ModuleObject)
168 Content += GenSources(ModuleObject)
169 Content += GenProtocolPPiSections(ModuleObject.GetProtocolList(), True)
170 Content += GenProtocolPPiSections(ModuleObject.GetPpiList(), False)
171 Content += GenGuidSections(ModuleObject.GetGuidList())
172 Content += GenBinaries(ModuleObject)
173 Content += GenDepex(ModuleObject)
174 __UserExtensionsContent = GenUserExtensions(ModuleObject)
175 Content += __UserExtensionsContent
176 if ModuleObject.GetEventList() or ModuleObject.GetBootModeList() or ModuleObject.GetHobList():
177 Content += '\n'
178 #
179 # generate [Event], [BootMode], [Hob] section
180 #
181 Content += GenSpecialSections(ModuleObject.GetEventList(), 'Event', __UserExtensionsContent)
182 Content += GenSpecialSections(ModuleObject.GetBootModeList(), 'BootMode', __UserExtensionsContent)
183 Content += GenSpecialSections(ModuleObject.GetHobList(), 'Hob', __UserExtensionsContent)
184 SaveFileOnChange(ContainerFile, Content, False)
185 if DistHeader.ReadOnly:
186 os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
187 else:
188 os.chmod(ContainerFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)
189 return ContainerFile
190
191 ## GenModuleUNIEncodeFile
192 # GenModuleUNIEncodeFile, default is a UCS-2LE encode file
193 #
194 def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCODING_UTF16LE):
195 GenUNIFlag = False
196 OnlyLANGUAGE_EN_X = True
197 BinaryAbstract = []
198 BinaryDescription = []
199 #
200 # If more than one language code is used for any element that would be present in the MODULE_UNI_FILE,
201 # then the MODULE_UNI_FILE must be created.
202 #
203 for (Key, Value) in ModuleObject.GetAbstract() + ModuleObject.GetDescription():
204 if Key == DT.TAB_LANGUAGE_EN_X:
205 GenUNIFlag = True
206 else:
207 OnlyLANGUAGE_EN_X = False
208
209 for UserExtension in ModuleObject.GetUserExtensionList():
210 if UserExtension.GetUserID() == DT.TAB_BINARY_HEADER_USERID \
211 and UserExtension.GetIdentifier() == DT.TAB_BINARY_HEADER_IDENTIFIER:
212 for (Key, Value) in UserExtension.GetBinaryAbstract():
213 if Key == DT.TAB_LANGUAGE_EN_X:
214 GenUNIFlag = True
215 else:
216 OnlyLANGUAGE_EN_X = False
217 BinaryAbstract.append((Key, Value))
218 for (Key, Value) in UserExtension.GetBinaryDescription():
219 if Key == DT.TAB_LANGUAGE_EN_X:
220 GenUNIFlag = True
221 else:
222 OnlyLANGUAGE_EN_X = False
223 BinaryDescription.append((Key, Value))
224
225
226 if not GenUNIFlag:
227 return
228 elif OnlyLANGUAGE_EN_X:
229 return
230 else:
231 ModuleObject.UNIFlag = True
232 ContainerFile = GetUniFileName(os.path.dirname(ModuleObject.GetFullPath()), ModuleObject.GetBaseName())
233
234 if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())):
235 os.makedirs(os.path.dirname(ModuleObject.GetFullPath()))
236
237 Content = UniFileHeader + '\r\n'
238 Content += '\r\n'
239
240 Content += FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, ModuleObject.GetAbstract(), ContainerFile) + '\r\n'
241
242 Content += FormatUniEntry('#string ' + DT.TAB_INF_DESCRIPTION, ModuleObject.GetDescription(), ContainerFile) \
243 + '\r\n'
244
245 BinaryAbstractString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_ABSTRACT, BinaryAbstract, ContainerFile)
246 if BinaryAbstractString:
247 Content += BinaryAbstractString + '\r\n'
248
249 BinaryDescriptionString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_DESCRIPTION, BinaryDescription, \
250 ContainerFile)
251 if BinaryDescriptionString:
252 Content += BinaryDescriptionString + '\r\n'
253
254 if not os.path.exists(ContainerFile):
255 File = codecs.open(ContainerFile, 'wb', Encoding)
256 File.write(u'\uFEFF' + Content)
257 File.stream.close()
258 Md5Sigature = md5.new(__FileHookOpen__(str(ContainerFile), 'rb').read())
259 Md5Sum = Md5Sigature.hexdigest()
260 if (ContainerFile, Md5Sum) not in ModuleObject.FileList:
261 ModuleObject.FileList.append((ContainerFile, Md5Sum))
262
263 return ContainerFile
264 def GenDefines(ModuleObject):
265 #
266 # generate [Defines] section
267 #
268 LeftOffset = 31
269 Content = ''
270 NewSectionDict = {}
271
272 for UserExtension in ModuleObject.GetUserExtensionList():
273 DefinesDict = UserExtension.GetDefinesDict()
274 if not DefinesDict:
275 continue
276 for Statement in DefinesDict:
277 if Statement.split(DT.TAB_EQUAL_SPLIT) > 1:
278 Statement = (u'%s ' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[0]).ljust(LeftOffset) \
279 + u'= %s' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[1].lstrip()
280 SortedArch = DT.TAB_ARCH_COMMON
281 if Statement.strip().startswith(DT.TAB_INF_DEFINES_CUSTOM_MAKEFILE):
282 pos = Statement.find(DT.TAB_VALUE_SPLIT)
283 if pos == -1:
284 pos = Statement.find(DT.TAB_EQUAL_SPLIT)
285 Makefile = ConvertPath(Statement[pos + 1:].strip())
286 Statement = Statement[:pos + 1] + ' ' + Makefile
287 if SortedArch in NewSectionDict:
288 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
289 else:
290 NewSectionDict[SortedArch] = [Statement]
291 SpecialStatementList = []
292
293 # TAB_INF_DEFINES_INF_VERSION
294 Statement = (u'%s ' % DT.TAB_INF_DEFINES_INF_VERSION).ljust(LeftOffset) + u'= %s' % '0x00010017'
295 SpecialStatementList.append(Statement)
296
297 # BaseName
298 BaseName = ModuleObject.GetBaseName()
299 if BaseName.startswith('.') or BaseName.startswith('-'):
300 BaseName = '_' + BaseName
301 Statement = (u'%s ' % DT.TAB_INF_DEFINES_BASE_NAME).ljust(LeftOffset) + u'= %s' % BaseName
302 SpecialStatementList.append(Statement)
303
304 # TAB_INF_DEFINES_FILE_GUID
305 Statement = (u'%s ' % DT.TAB_INF_DEFINES_FILE_GUID).ljust(LeftOffset) + u'= %s' % ModuleObject.GetGuid()
306 SpecialStatementList.append(Statement)
307
308 # TAB_INF_DEFINES_VERSION_STRING
309 Statement = (u'%s ' % DT.TAB_INF_DEFINES_VERSION_STRING).ljust(LeftOffset) + u'= %s' % ModuleObject.GetVersion()
310 SpecialStatementList.append(Statement)
311
312 # TAB_INF_DEFINES_VERSION_STRING
313 if ModuleObject.UNIFlag:
314 Statement = (u'%s ' % DT.TAB_INF_DEFINES_MODULE_UNI_FILE).ljust(LeftOffset) + \
315 u'= %s' % ModuleObject.GetModuleUniFile()
316 SpecialStatementList.append(Statement)
317
318 # TAB_INF_DEFINES_MODULE_TYPE
319 if ModuleObject.GetModuleType():
320 Statement = (u'%s ' % DT.TAB_INF_DEFINES_MODULE_TYPE).ljust(LeftOffset) + u'= %s' % ModuleObject.GetModuleType()
321 SpecialStatementList.append(Statement)
322
323 # TAB_INF_DEFINES_PCD_IS_DRIVER
324 if ModuleObject.GetPcdIsDriver():
325 Statement = (u'%s ' % DT.TAB_INF_DEFINES_PCD_IS_DRIVER).ljust(LeftOffset) + \
326 u'= %s' % ModuleObject.GetPcdIsDriver()
327 SpecialStatementList.append(Statement)
328
329 # TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION
330 if ModuleObject.GetUefiSpecificationVersion():
331 Statement = (u'%s ' % DT.TAB_INF_DEFINES_UEFI_SPECIFICATION_VERSION).ljust(LeftOffset) + \
332 u'= %s' % ModuleObject.GetUefiSpecificationVersion()
333 SpecialStatementList.append(Statement)
334
335 # TAB_INF_DEFINES_PI_SPECIFICATION_VERSION
336 if ModuleObject.GetPiSpecificationVersion():
337 Statement = (u'%s ' % DT.TAB_INF_DEFINES_PI_SPECIFICATION_VERSION).ljust(LeftOffset) + \
338 u'= %s' % ModuleObject.GetPiSpecificationVersion()
339 SpecialStatementList.append(Statement)
340
341 # LibraryClass
342 for LibraryClass in ModuleObject.GetLibraryClassList():
343 if LibraryClass.GetUsage() == DT.USAGE_ITEM_PRODUCES or \
344 LibraryClass.GetUsage() == DT.USAGE_ITEM_SOMETIMES_PRODUCES:
345 Statement = (u'%s ' % DT.TAB_INF_DEFINES_LIBRARY_CLASS).ljust(LeftOffset) + \
346 u'= %s' % LibraryClass.GetLibraryClass()
347 if LibraryClass.GetSupModuleList():
348 Statement += '|' + DT.TAB_SPACE_SPLIT.join(l for l in LibraryClass.GetSupModuleList())
349 SpecialStatementList.append(Statement)
350
351 # Spec Item
352 for SpecItem in ModuleObject.GetSpecList():
353 Spec, Version = SpecItem
354 Spec = ConvertSpec(Spec)
355 Statement = '%s %s = %s' % (DT.TAB_INF_DEFINES_SPEC, Spec, Version)
356 SpecialStatementList.append(Statement)
357
358 # Extern
359 ExternList = []
360 for Extern in ModuleObject.GetExternList():
361 ArchList = Extern.GetSupArchList()
362 EntryPoint = Extern.GetEntryPoint()
363 UnloadImage = Extern.GetUnloadImage()
364 Constructor = Extern.GetConstructor()
365 Destructor = Extern.GetDestructor()
366 HelpStringList = Extern.GetHelpTextList()
367 FFE = Extern.GetFeatureFlag()
368 ExternList.append([ArchList, EntryPoint, UnloadImage, Constructor, Destructor, FFE, HelpStringList])
369 #
370 # Add VALID_ARCHITECTURES information
371 #
372 ValidArchStatement = None
373 if ModuleObject.SupArchList:
374 ValidArchStatement = '\n' + '# ' + '\n'
375 ValidArchStatement += '# The following information is for reference only and not required by the build tools.\n'
376 ValidArchStatement += '# ' + '\n'
377 ValidArchStatement += '# VALID_ARCHITECTURES = %s' % (' '.join(ModuleObject.SupArchList)) + '\n'
378 ValidArchStatement += '# '
379 if DT.TAB_ARCH_COMMON not in NewSectionDict:
380 NewSectionDict[DT.TAB_ARCH_COMMON] = []
381 NewSectionDict[DT.TAB_ARCH_COMMON] = NewSectionDict[DT.TAB_ARCH_COMMON] + SpecialStatementList
382 GenMetaFileMisc.AddExternToDefineSec(NewSectionDict, DT.TAB_ARCH_COMMON, ExternList)
383 if ValidArchStatement is not None:
384 NewSectionDict[DT.TAB_ARCH_COMMON] = NewSectionDict[DT.TAB_ARCH_COMMON] + [ValidArchStatement]
385 Content += GenSection('Defines', NewSectionDict)
386 return Content
387
388 def GenLibraryClasses(ModuleObject):
389 #
390 # generate [LibraryClasses] section
391 #
392 Content = ''
393 NewSectionDict = {}
394 if not GlobalData.gIS_BINARY_INF:
395 for LibraryClass in ModuleObject.GetLibraryClassList():
396 if LibraryClass.GetUsage() == DT.USAGE_ITEM_PRODUCES:
397 continue
398 #
399 # Generate generic comment
400 #
401 HelpTextList = LibraryClass.GetHelpTextList()
402 HelpStr = _GetHelpStr(HelpTextList)
403 CommentStr = GenGenericCommentF(HelpStr)
404 Statement = CommentStr
405 Name = LibraryClass.GetLibraryClass()
406 FFE = LibraryClass.GetFeatureFlag()
407 Statement += Name
408 if FFE:
409 Statement += '|' + FFE
410 ModuleList = LibraryClass.GetSupModuleList()
411 ArchList = LibraryClass.GetSupArchList()
412 for Index in xrange(0, len(ArchList)):
413 ArchList[Index] = ConvertArchForInstall(ArchList[Index])
414 ArchList.sort()
415 SortedArch = ' '.join(ArchList)
416 KeyList = []
417 if not ModuleList or IsAllModuleList(ModuleList):
418 KeyList = [SortedArch]
419 else:
420 ModuleString = DT.TAB_VALUE_SPLIT.join(l for l in ModuleList)
421 if not ArchList:
422 SortedArch = DT.TAB_ARCH_COMMON
423 KeyList = [SortedArch + '.' + ModuleString]
424 else:
425 KeyList = [Arch + '.' + ModuleString for Arch in ArchList]
426 for Key in KeyList:
427 if Key in NewSectionDict:
428 NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
429 else:
430 NewSectionDict[Key] = [Statement]
431 Content += GenSection('LibraryClasses', NewSectionDict)
432 else:
433 LibraryClassDict = {}
434 for BinaryFile in ModuleObject.GetBinaryFileList():
435 if not BinaryFile.AsBuiltList:
436 continue
437 for LibraryItem in BinaryFile.AsBuiltList[0].LibraryInstancesList:
438 Statement = '# Guid: ' + LibraryItem.Guid + ' Version: ' + LibraryItem.Version
439
440 if len(BinaryFile.SupArchList) == 0:
441 if 'COMMON' in LibraryClassDict and Statement not in LibraryClassDict['COMMON']:
442 LibraryClassDict['COMMON'].append(Statement)
443 else:
444 LibraryClassDict['COMMON'] = ['## @LIB_INSTANCES']
445 LibraryClassDict['COMMON'].append(Statement)
446 else:
447 for Arch in BinaryFile.SupArchList:
448 if Arch in LibraryClassDict:
449 if Statement not in LibraryClassDict[Arch]:
450 LibraryClassDict[Arch].append(Statement)
451 else:
452 continue
453 else:
454 LibraryClassDict[Arch] = ['## @LIB_INSTANCES']
455 LibraryClassDict[Arch].append(Statement)
456 Content += GenSection('LibraryClasses', LibraryClassDict)
457
458 return Content
459
460 def GenPackages(ModuleObject):
461 Content = ''
462 #
463 # generate [Packages] section
464 #
465 NewSectionDict = Sdict()
466 WorkspaceDir = GlobalData.gWORKSPACE
467 for PackageDependency in ModuleObject.GetPackageDependencyList():
468 #
469 # Generate generic comment
470 #
471 CommentStr = ''
472 HelpText = PackageDependency.GetHelpText()
473 if HelpText:
474 HelpStr = HelpText.GetString()
475 CommentStr = GenGenericCommentF(HelpStr)
476 Statement = CommentStr
477 Guid = PackageDependency.GetGuid()
478 Version = PackageDependency.GetVersion()
479 FFE = PackageDependency.GetFeatureFlag()
480 Path = ''
481 #
482 # find package path/name
483 #
484 for PkgInfo in GlobalData.gWSPKG_LIST:
485 if Guid == PkgInfo[1]:
486 if (not Version) or (Version == PkgInfo[2]):
487 Path = PkgInfo[3]
488 break
489 #
490 # get relative path
491 #
492 RelaPath = GetRelativePath(Path, WorkspaceDir)
493 Statement += RelaPath.replace('\\', '/')
494 if FFE:
495 Statement += '|' + FFE
496 ArchList = sorted(PackageDependency.GetSupArchList())
497 SortedArch = ' '.join(ArchList)
498 if SortedArch in NewSectionDict:
499 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
500 else:
501 NewSectionDict[SortedArch] = [Statement]
502 Content += GenSection('Packages', NewSectionDict)
503 return Content
504
505 def GenSources(ModuleObject):
506 #
507 # generate [Sources] section
508 #
509 Content = ''
510 NewSectionDict = {}
511 for Source in ModuleObject.GetSourceFileList():
512 SourceFile = Source.GetSourceFile()
513 Family = Source.GetFamily()
514 FeatureFlag = Source.GetFeatureFlag()
515 SupArchList = sorted(Source.GetSupArchList())
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 # Comment the code to support user extension without any statement just the section header in []
572 # if not Statement:
573 # continue
574 ArchList = UserExtension.GetSupArchList()
575 for Index in xrange(0, len(ArchList)):
576 ArchList[Index] = ConvertArchForInstall(ArchList[Index])
577 ArchList.sort()
578 KeyList = []
579 CommonPreFix = ''
580 if UserExtension.GetUserID():
581 CommonPreFix = UserExtension.GetUserID()
582 if CommonPreFix.find('.') > -1:
583 CommonPreFix = '"' + CommonPreFix + '"'
584 if UserExtension.GetIdentifier():
585 CommonPreFix += '.' + '"' + UserExtension.GetIdentifier() + '"'
586 if ArchList:
587 KeyList = [CommonPreFix + '.' + Arch for Arch in ArchList]
588 else:
589 KeyList = [CommonPreFix]
590 for Key in KeyList:
591 if Key in NewSectionDict:
592 NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
593 else:
594 NewSectionDict[Key] = [Statement]
595 Content = GenSection('UserExtensions', NewSectionDict, False)
596
597 return Content
598
599 # GenSourceStatement
600 #
601 # @param SourceFile: string of source file path/name
602 # @param Family: string of source file family field
603 # @param FeatureFlag: string of source file FeatureFlag field
604 # @param TagName: string of source file TagName field
605 # @param ToolCode: string of source file ToolCode field
606 # @param HelpStr: string of source file HelpStr field
607 #
608 # @retval Statement: The generated statement for source
609 #
610 def GenSourceStatement(SourceFile, Family, FeatureFlag, TagName=None,
611 ToolCode=None, HelpStr=None):
612 Statement = ''
613 if HelpStr:
614 Statement += GenGenericCommentF(HelpStr)
615 #
616 # format of SourceFile|Family|TagName|ToolCode|FeatureFlag
617 #
618 Statement += SourceFile
619 if TagName is None:
620 TagName = ''
621 if ToolCode is None:
622 ToolCode = ''
623 if HelpStr is None:
624 HelpStr = ''
625 if FeatureFlag:
626 Statement += '|' + Family + '|' + TagName + '|' + ToolCode + '|' + FeatureFlag
627 elif ToolCode:
628 Statement += '|' + Family + '|' + TagName + '|' + ToolCode
629 elif TagName:
630 Statement += '|' + Family + '|' + TagName
631 elif Family:
632 Statement += '|' + Family
633 return Statement
634
635 # GenBinaryStatement
636 #
637 # @param Key: (FileName, FileType, FFE, SortedArch)
638 # @param Value: (Target, Family, TagName, Comment)
639 #
640 #
641 def GenBinaryStatement(Key, Value, SubTypeGuidValue=None):
642 (FileName, FileType, FFE, SortedArch) = Key
643 if SortedArch:
644 pass
645 if Value:
646 (Target, Family, TagName, Comment) = Value
647 else:
648 Target = ''
649 Family = ''
650 TagName = ''
651 Comment = ''
652 if Comment:
653 Statement = GenGenericCommentF(Comment)
654 else:
655 Statement = ''
656 if FileType == 'SUBTYPE_GUID' and SubTypeGuidValue:
657 Statement += FileType + '|' + SubTypeGuidValue + '|' + FileName
658 else:
659 Statement += FileType + '|' + FileName
660 if FileType in DT.BINARY_FILE_TYPE_UI_LIST + DT.BINARY_FILE_TYPE_VER_LIST:
661 if FFE:
662 Statement += '|' + Target + '|' + FFE
663 elif Target:
664 Statement += '|' + Target
665 else:
666 if FFE:
667 Statement += '|' + Target + '|' + Family + '|' + TagName + '|' + FFE
668 elif TagName:
669 Statement += '|' + Target + '|' + Family + '|' + TagName
670 elif Family:
671 Statement += '|' + Target + '|' + Family
672 elif Target:
673 Statement += '|' + Target
674 return Statement
675 ## GenGuidSections
676 #
677 # @param GuidObjList: List of GuidObject
678 # @retVal Content: The generated section contents
679 #
680 def GenGuidSections(GuidObjList):
681 #
682 # generate [Guids] section
683 #
684 Content = ''
685 GuidDict = Sdict()
686 for Guid in GuidObjList:
687 HelpTextList = Guid.GetHelpTextList()
688 HelpStr = _GetHelpStr(HelpTextList)
689 CName = Guid.GetCName()
690 FFE = Guid.GetFeatureFlag()
691 Statement = CName
692 if FFE:
693 Statement += '|' + FFE
694 Usage = Guid.GetUsage()
695 GuidType = Guid.GetGuidTypeList()[0]
696 VariableName = Guid.GetVariableName()
697 #
698 # Differentiate the generic comment and usage comment as multiple generic comment need to be put at first
699 #
700 if Usage == DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
701 # generate list of generic comment
702 Comment = GenGenericCommentF(HelpStr)
703 else:
704 # generate list of other comment
705 Comment = HelpStr.replace('\n', ' ')
706 Comment = Comment.strip()
707 if Comment:
708 Comment = ' # ' + Comment
709 else:
710 Comment = ''
711 if Usage != DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
712 Comment = '## ' + Usage + Comment
713 elif GuidType == 'Variable':
714 Comment = '## ' + Usage + ' ## ' + GuidType + ':' + VariableName + Comment
715 else:
716 Comment = '## ' + Usage + ' ## ' + GuidType + Comment
717
718 if Comment:
719 Comment += '\n'
720 #
721 # merge duplicate items
722 #
723 ArchList = sorted(Guid.GetSupArchList())
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 = sorted(Object.GetSupArchList())
783 SortedArch = ' '.join(ArchList)
784 if (Statement, SortedArch) in Dict:
785 PreviousComment = Dict[Statement, SortedArch]
786 Comment = PreviousComment + Comment
787 Dict[Statement, SortedArch] = Comment
788 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PPI_PROTOCOL')
789 #
790 # generate the section contents
791 #
792 if NewSectionDict:
793 if IsProtocol:
794 Content = GenSection('Protocols', NewSectionDict)
795 else:
796 Content = GenSection('Ppis', NewSectionDict)
797
798 return Content
799
800 ## GenPcdSections
801 #
802 #
803 def GenPcdSections(ModuleObject):
804 Content = ''
805 if not GlobalData.gIS_BINARY_INF:
806 #
807 # for each Pcd Itemtype, maintain a dict so the same type will be grouped
808 # together
809 #
810 ItemTypeDict = {}
811 for Pcd in ModuleObject.GetPcdList():
812 HelpTextList = Pcd.GetHelpTextList()
813 HelpStr = _GetHelpStr(HelpTextList)
814 Statement = ''
815 CName = Pcd.GetCName()
816 TokenSpaceGuidCName = Pcd.GetTokenSpaceGuidCName()
817 DefaultValue = Pcd.GetDefaultValue()
818 ItemType = Pcd.GetItemType()
819 if ItemType in ItemTypeDict:
820 Dict = ItemTypeDict[ItemType]
821 else:
822 Dict = Sdict()
823 ItemTypeDict[ItemType] = Dict
824 FFE = Pcd.GetFeatureFlag()
825 Statement += TokenSpaceGuidCName + '.' + CName
826 if DefaultValue:
827 Statement += '|' + DefaultValue
828 if FFE:
829 Statement += '|' + FFE
830 elif FFE:
831 Statement += '||' + FFE
832 #
833 # Generate comment
834 #
835 Usage = Pcd.GetValidUsage()
836 # if FeatureFlag Pcd, then assume all Usage is CONSUMES
837 if ItemType == DT.TAB_INF_FEATURE_PCD:
838 Usage = DT.USAGE_ITEM_CONSUMES
839 if Usage == DT.ITEM_UNDEFINED:
840 # generate list of generic comment
841 Comment = GenGenericCommentF(HelpStr)
842 else:
843 # generate list of other comment
844 Comment = HelpStr.replace('\n', ' ')
845 Comment = Comment.strip()
846 if Comment:
847 Comment = ' # ' + Comment
848 else:
849 Comment = ''
850 Comment = '## ' + Usage + Comment
851 if Comment:
852 Comment += '\n'
853 #
854 # Merge duplicate entries
855 #
856 ArchList = sorted(Pcd.GetSupArchList())
857 SortedArch = ' '.join(ArchList)
858 if (Statement, SortedArch) in Dict:
859 PreviousComment = Dict[Statement, SortedArch]
860 Comment = PreviousComment + Comment
861 Dict[Statement, SortedArch] = Comment
862 for ItemType in ItemTypeDict:
863 # First we need to transfer the Dict to use SortedArch as key
864 Dict = ItemTypeDict[ItemType]
865 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PCD')
866 if NewSectionDict:
867 Content += GenSection(ItemType, NewSectionDict)
868 #
869 # For AsBuild INF files
870 #
871 else:
872 Content += GenAsBuiltPacthPcdSections(ModuleObject)
873 Content += GenAsBuiltPcdExSections(ModuleObject)
874
875 return Content
876
877 ## GenPcdSections
878 #
879 #
880 def GenAsBuiltPacthPcdSections(ModuleObject):
881 PatchPcdDict = {}
882 for BinaryFile in ModuleObject.GetBinaryFileList():
883 if not BinaryFile.AsBuiltList:
884 continue
885 for PatchPcd in BinaryFile.AsBuiltList[0].PatchPcdList:
886 TokenSpaceName = ''
887 PcdCName = PatchPcd.CName
888 PcdValue = PatchPcd.DefaultValue
889 PcdOffset = PatchPcd.Offset
890 TokenSpaceGuidValue = PatchPcd.TokenSpaceGuidValue
891 Token = PatchPcd.Token
892 HelpTextList = PatchPcd.HelpTextList
893 HelpString = ''
894 for HelpStringItem in HelpTextList:
895 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
896 HelpString += '## ' + HelpLine + '\n'
897 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
898 TokenSpaceGuidValue,
899 Token)
900 if TokenSpaceName == '' or PcdCName == '':
901 Logger.Error("Upt",
902 ToolError.RESOURCE_NOT_AVAILABLE,
903 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
904 File=ModuleObject.GetFullPath())
905 Statement = HelpString + TokenSpaceName + '.' + PcdCName + ' | ' + PcdValue + ' | ' + \
906 PcdOffset + DT.TAB_SPACE_SPLIT
907 #
908 # Use binary file's Arch to be Pcd's Arch
909 #
910 ArchList = []
911 FileNameObjList = BinaryFile.GetFileNameList()
912 if FileNameObjList:
913 ArchList = FileNameObjList[0].GetSupArchList()
914 if len(ArchList) == 0:
915 if DT.TAB_ARCH_COMMON in PatchPcdDict:
916 if Statement not in PatchPcdDict[DT.TAB_ARCH_COMMON]:
917 PatchPcdDict[DT.TAB_ARCH_COMMON].append(Statement)
918 else:
919 PatchPcdDict[DT.TAB_ARCH_COMMON] = [Statement]
920 else:
921 for Arch in ArchList:
922 if Arch in PatchPcdDict:
923 if Statement not in PatchPcdDict[Arch]:
924 PatchPcdDict[Arch].append(Statement)
925 else:
926 PatchPcdDict[Arch] = [Statement]
927 return GenSection(DT.TAB_INF_PATCH_PCD, PatchPcdDict)
928 ## GenPcdSections
929 #
930 #
931 def GenAsBuiltPcdExSections(ModuleObject):
932 PcdExDict = {}
933 for BinaryFile in ModuleObject.GetBinaryFileList():
934 if not BinaryFile.AsBuiltList:
935 continue
936 for PcdExItem in BinaryFile.AsBuiltList[0].PcdExValueList:
937 TokenSpaceName = ''
938 PcdCName = PcdExItem.CName
939 TokenSpaceGuidValue = PcdExItem.TokenSpaceGuidValue
940 Token = PcdExItem.Token
941 HelpTextList = PcdExItem.HelpTextList
942 HelpString = ''
943 for HelpStringItem in HelpTextList:
944 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
945 HelpString += '## ' + HelpLine + '\n'
946 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
947 TokenSpaceGuidValue, Token)
948 if TokenSpaceName == '' or PcdCName == '':
949 Logger.Error("Upt",
950 ToolError.RESOURCE_NOT_AVAILABLE,
951 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
952 File=ModuleObject.GetFullPath())
953
954 Statement = HelpString + TokenSpaceName + DT.TAB_SPLIT + PcdCName + DT.TAB_SPACE_SPLIT
955
956 #
957 # Use binary file's Arch to be Pcd's Arch
958 #
959 ArchList = []
960 FileNameObjList = BinaryFile.GetFileNameList()
961 if FileNameObjList:
962 ArchList = FileNameObjList[0].GetSupArchList()
963
964 if len(ArchList) == 0:
965 if 'COMMON' in PcdExDict:
966 PcdExDict['COMMON'].append(Statement)
967 else:
968 PcdExDict['COMMON'] = [Statement]
969 else:
970 for Arch in ArchList:
971 if Arch in PcdExDict:
972 if Statement not in PcdExDict[Arch]:
973 PcdExDict[Arch].append(Statement)
974 else:
975 PcdExDict[Arch] = [Statement]
976 return GenSection('PcdEx', PcdExDict)
977
978 ## GenSpecialSections
979 # generate special sections for Event/BootMode/Hob
980 #
981 def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
982 #
983 # generate section
984 #
985 Content = ''
986 NewSectionDict = {}
987 for Obj in ObjectList:
988 #
989 # Generate comment
990 #
991 CommentStr = ''
992 HelpTextList = Obj.GetHelpTextList()
993 HelpStr = _GetHelpStr(HelpTextList)
994 CommentStr = GenGenericCommentF(HelpStr)
995 if SectionName == 'Hob':
996 Type = Obj.GetHobType()
997 elif SectionName == 'Event':
998 Type = Obj.GetEventType()
999 elif SectionName == 'BootMode':
1000 Type = Obj.GetSupportedBootModes()
1001 else:
1002 assert(SectionName)
1003 Usage = Obj.GetUsage()
1004
1005 # If the content already in UserExtensionsContent then ignore
1006 if '[%s]' % SectionName in UserExtensionsContent and Type in UserExtensionsContent:
1007 return ''
1008
1009 Statement = ' ' + Type + ' ## ' + Usage
1010 if CommentStr in ['#\n', '#\n#\n']:
1011 CommentStr = '#\n#\n#\n'
1012 #
1013 # the first head comment line should start with '##\n', if it starts with '#\n', then add one '#'
1014 # else add '##\n' to meet the format defined in INF spec
1015 #
1016 if CommentStr.startswith('#\n'):
1017 CommentStr = '#' + CommentStr
1018 elif CommentStr:
1019 CommentStr = '##\n' + CommentStr
1020 if CommentStr and not CommentStr.endswith('\n#\n'):
1021 CommentStr = CommentStr + '#\n'
1022 NewStateMent = CommentStr + Statement
1023 SupArch = sorted(Obj.GetSupArchList())
1024 SortedArch = ' '.join(SupArch)
1025 if SortedArch in NewSectionDict:
1026 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [NewStateMent]
1027 else:
1028 NewSectionDict[SortedArch] = [NewStateMent]
1029 SectionContent = GenSection(SectionName, NewSectionDict)
1030 SectionContent = SectionContent.strip()
1031 if SectionContent:
1032 Content = '# ' + ('\n' + '# ').join(GetSplitValueList(SectionContent, '\n'))
1033 Content = Content.lstrip()
1034 #
1035 # add a return to differentiate it between other possible sections
1036 #
1037 if Content:
1038 Content += '\n'
1039 return Content
1040 ## GenBuildOptions
1041 #
1042 #
1043 def GenBuildOptions(ModuleObject):
1044 Content = ''
1045 if not ModuleObject.BinaryModule:
1046 #
1047 # generate [BuildOptions] section
1048 #
1049 NewSectionDict = {}
1050 for UserExtension in ModuleObject.GetUserExtensionList():
1051 BuildOptionDict = UserExtension.GetBuildOptionDict()
1052 if not BuildOptionDict:
1053 continue
1054 for Arch in BuildOptionDict:
1055 if Arch in NewSectionDict:
1056 NewSectionDict[Arch] = NewSectionDict[Arch] + [BuildOptionDict[Arch]]
1057 else:
1058 NewSectionDict[Arch] = [BuildOptionDict[Arch]]
1059 Content = GenSection('BuildOptions', NewSectionDict)
1060 else:
1061 BuildOptionDict = {}
1062 for BinaryFile in ModuleObject.GetBinaryFileList():
1063 if not BinaryFile.AsBuiltList:
1064 continue
1065 for BuilOptionItem in BinaryFile.AsBuiltList[0].BinaryBuildFlagList:
1066 Statement = '#' + BuilOptionItem.AsBuiltOptionFlags
1067 if len(BinaryFile.SupArchList) == 0:
1068 if 'COMMON' in BuildOptionDict:
1069 if Statement not in BuildOptionDict['COMMON']:
1070 BuildOptionDict['COMMON'].append(Statement)
1071 else:
1072 BuildOptionDict['COMMON'] = ['## @AsBuilt']
1073 BuildOptionDict['COMMON'].append(Statement)
1074 else:
1075 for Arch in BinaryFile.SupArchList:
1076 if Arch in BuildOptionDict:
1077 if Statement not in BuildOptionDict[Arch]:
1078 BuildOptionDict[Arch].append(Statement)
1079 else:
1080 BuildOptionDict[Arch] = ['## @AsBuilt']
1081 BuildOptionDict[Arch].append(Statement)
1082 Content = GenSection('BuildOptions', BuildOptionDict)
1083
1084 return Content
1085 ## GenBinaries
1086 #
1087 #
1088 def GenBinaries(ModuleObject):
1089 NewSectionDict = {}
1090 BinariesDict = []
1091 for UserExtension in ModuleObject.GetUserExtensionList():
1092 BinariesDict = UserExtension.GetBinariesDict()
1093 if BinariesDict:
1094 break
1095 for BinaryFile in ModuleObject.GetBinaryFileList():
1096 FileNameObjList = BinaryFile.GetFileNameList()
1097 for FileNameObj in FileNameObjList:
1098 FileName = ConvertPath(FileNameObj.GetFilename())
1099 FileType = FileNameObj.GetFileType()
1100 FFE = FileNameObj.GetFeatureFlag()
1101 ArchList = sorted(FileNameObj.GetSupArchList())
1102 SortedArch = ' '.join(ArchList)
1103 Key = (FileName, FileType, FFE, SortedArch)
1104 if Key in BinariesDict:
1105 ValueList = BinariesDict[Key]
1106 for ValueItem in ValueList:
1107 Statement = GenBinaryStatement(Key, ValueItem)
1108 if SortedArch in NewSectionDict:
1109 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1110 else:
1111 NewSectionDict[SortedArch] = [Statement]
1112 #
1113 # as we already generated statement for this DictKey here set the Valuelist to be empty
1114 # to avoid generate duplicate entries as the DictKey may have multiple entries
1115 #
1116 BinariesDict[Key] = []
1117 else:
1118 if FileType == 'SUBTYPE_GUID' and FileNameObj.GetGuidValue():
1119 Statement = GenBinaryStatement(Key, None, FileNameObj.GetGuidValue())
1120 else:
1121 Statement = GenBinaryStatement(Key, None)
1122 if SortedArch in NewSectionDict:
1123 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1124 else:
1125 NewSectionDict[SortedArch] = [Statement]
1126 Content = GenSection('Binaries', NewSectionDict)
1127
1128 return Content