]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
a376f56fcfa80fc0d162e73402bc553f8b0dc187
[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 # 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 == None:
620 TagName = ''
621 if ToolCode == None:
622 ToolCode = ''
623 if HelpStr == 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 = Guid.GetSupArchList()
724 ArchList.sort()
725 SortedArch = ' '.join(ArchList)
726 if (Statement, SortedArch) in GuidDict:
727 PreviousComment = GuidDict[Statement, SortedArch]
728 Comment = PreviousComment + Comment
729 GuidDict[Statement, SortedArch] = Comment
730 NewSectionDict = GenMetaFileMisc.TransferDict(GuidDict, 'INF_GUID')
731 #
732 # generate the section contents
733 #
734 if NewSectionDict:
735 Content = GenSection('Guids', NewSectionDict)
736
737 return Content
738
739 ## GenProtocolPPiSections
740 #
741 # @param ObjList: List of ProtocolObject or Ppi Object
742 # @retVal Content: The generated section contents
743 #
744 def GenProtocolPPiSections(ObjList, IsProtocol):
745 Content = ''
746 Dict = Sdict()
747 for Object in ObjList:
748 HelpTextList = Object.GetHelpTextList()
749 HelpStr = _GetHelpStr(HelpTextList)
750 CName = Object.GetCName()
751 FFE = Object.GetFeatureFlag()
752 Statement = CName
753 if FFE:
754 Statement += '|' + FFE
755 Usage = Object.GetUsage()
756 Notify = Object.GetNotify()
757 #
758 # Differentiate the generic comment and usage comment as consecutive generic comment need to be put together
759 #
760 if Usage == DT.ITEM_UNDEFINED and Notify == '':
761 # generate list of generic comment
762 Comment = GenGenericCommentF(HelpStr)
763 else:
764 # generate list of other comment
765 Comment = HelpStr.replace('\n', ' ')
766 Comment = Comment.strip()
767 if Comment:
768 Comment = ' # ' + Comment
769 else:
770 Comment = ''
771 if Usage == DT.ITEM_UNDEFINED and not Comment and Notify == '':
772 Comment = ''
773 else:
774 if Notify:
775 Comment = '## ' + Usage + ' ## ' + 'NOTIFY' + Comment
776 else:
777 Comment = '## ' + Usage + Comment
778 if Comment:
779 Comment += '\n'
780 #
781 # merge duplicate items
782 #
783 ArchList = Object.GetSupArchList()
784 ArchList.sort()
785 SortedArch = ' '.join(ArchList)
786 if (Statement, SortedArch) in Dict:
787 PreviousComment = Dict[Statement, SortedArch]
788 Comment = PreviousComment + Comment
789 Dict[Statement, SortedArch] = Comment
790 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PPI_PROTOCOL')
791 #
792 # generate the section contents
793 #
794 if NewSectionDict:
795 if IsProtocol:
796 Content = GenSection('Protocols', NewSectionDict)
797 else:
798 Content = GenSection('Ppis', NewSectionDict)
799
800 return Content
801
802 ## GenPcdSections
803 #
804 #
805 def GenPcdSections(ModuleObject):
806 Content = ''
807 if not GlobalData.gIS_BINARY_INF:
808 #
809 # for each Pcd Itemtype, maintain a dict so the same type will be grouped
810 # together
811 #
812 ItemTypeDict = {}
813 for Pcd in ModuleObject.GetPcdList():
814 HelpTextList = Pcd.GetHelpTextList()
815 HelpStr = _GetHelpStr(HelpTextList)
816 Statement = ''
817 CName = Pcd.GetCName()
818 TokenSpaceGuidCName = Pcd.GetTokenSpaceGuidCName()
819 DefaultValue = Pcd.GetDefaultValue()
820 ItemType = Pcd.GetItemType()
821 if ItemType in ItemTypeDict:
822 Dict = ItemTypeDict[ItemType]
823 else:
824 Dict = Sdict()
825 ItemTypeDict[ItemType] = Dict
826 FFE = Pcd.GetFeatureFlag()
827 Statement += TokenSpaceGuidCName + '.' + CName
828 if DefaultValue:
829 Statement += '|' + DefaultValue
830 if FFE:
831 Statement += '|' + FFE
832 elif FFE:
833 Statement += '||' + FFE
834 #
835 # Generate comment
836 #
837 Usage = Pcd.GetValidUsage()
838 # if FeatureFlag Pcd, then assume all Usage is CONSUMES
839 if ItemType == DT.TAB_INF_FEATURE_PCD:
840 Usage = DT.USAGE_ITEM_CONSUMES
841 if Usage == DT.ITEM_UNDEFINED:
842 # generate list of generic comment
843 Comment = GenGenericCommentF(HelpStr)
844 else:
845 # generate list of other comment
846 Comment = HelpStr.replace('\n', ' ')
847 Comment = Comment.strip()
848 if Comment:
849 Comment = ' # ' + Comment
850 else:
851 Comment = ''
852 Comment = '## ' + Usage + Comment
853 if Comment:
854 Comment += '\n'
855 #
856 # Merge duplicate entries
857 #
858 ArchList = Pcd.GetSupArchList()
859 ArchList.sort()
860 SortedArch = ' '.join(ArchList)
861 if (Statement, SortedArch) in Dict:
862 PreviousComment = Dict[Statement, SortedArch]
863 Comment = PreviousComment + Comment
864 Dict[Statement, SortedArch] = Comment
865 for ItemType in ItemTypeDict:
866 # First we need to transfer the Dict to use SortedArch as key
867 Dict = ItemTypeDict[ItemType]
868 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PCD')
869 if NewSectionDict:
870 Content += GenSection(ItemType, NewSectionDict)
871 #
872 # For AsBuild INF files
873 #
874 else:
875 Content += GenAsBuiltPacthPcdSections(ModuleObject)
876 Content += GenAsBuiltPcdExSections(ModuleObject)
877
878 return Content
879
880 ## GenPcdSections
881 #
882 #
883 def GenAsBuiltPacthPcdSections(ModuleObject):
884 PatchPcdDict = {}
885 for BinaryFile in ModuleObject.GetBinaryFileList():
886 if not BinaryFile.AsBuiltList:
887 continue
888 for PatchPcd in BinaryFile.AsBuiltList[0].PatchPcdList:
889 TokenSpaceName = ''
890 PcdCName = PatchPcd.CName
891 PcdValue = PatchPcd.DefaultValue
892 PcdOffset = PatchPcd.Offset
893 TokenSpaceGuidValue = PatchPcd.TokenSpaceGuidValue
894 Token = PatchPcd.Token
895 HelpTextList = PatchPcd.HelpTextList
896 HelpString = ''
897 for HelpStringItem in HelpTextList:
898 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
899 HelpString += '## ' + HelpLine + '\n'
900 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
901 TokenSpaceGuidValue,
902 Token)
903 if TokenSpaceName == '' or PcdCName == '':
904 Logger.Error("Upt",
905 ToolError.RESOURCE_NOT_AVAILABLE,
906 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
907 File=ModuleObject.GetFullPath())
908 Statement = HelpString + TokenSpaceName + '.' + PcdCName + ' | ' + PcdValue + ' | ' + \
909 PcdOffset + DT.TAB_SPACE_SPLIT
910 #
911 # Use binary file's Arch to be Pcd's Arch
912 #
913 ArchList = []
914 FileNameObjList = BinaryFile.GetFileNameList()
915 if FileNameObjList:
916 ArchList = FileNameObjList[0].GetSupArchList()
917 if len(ArchList) == 0:
918 if PatchPcdDict.has_key(DT.TAB_ARCH_COMMON):
919 if Statement not in PatchPcdDict[DT.TAB_ARCH_COMMON]:
920 PatchPcdDict[DT.TAB_ARCH_COMMON].append(Statement)
921 else:
922 PatchPcdDict[DT.TAB_ARCH_COMMON] = [Statement]
923 else:
924 for Arch in ArchList:
925 if PatchPcdDict.has_key(Arch):
926 if Statement not in PatchPcdDict[Arch]:
927 PatchPcdDict[Arch].append(Statement)
928 else:
929 PatchPcdDict[Arch] = [Statement]
930 return GenSection(DT.TAB_INF_PATCH_PCD, PatchPcdDict)
931 ## GenPcdSections
932 #
933 #
934 def GenAsBuiltPcdExSections(ModuleObject):
935 PcdExDict = {}
936 for BinaryFile in ModuleObject.GetBinaryFileList():
937 if not BinaryFile.AsBuiltList:
938 continue
939 for PcdExItem in BinaryFile.AsBuiltList[0].PcdExValueList:
940 TokenSpaceName = ''
941 PcdCName = PcdExItem.CName
942 TokenSpaceGuidValue = PcdExItem.TokenSpaceGuidValue
943 Token = PcdExItem.Token
944 HelpTextList = PcdExItem.HelpTextList
945 HelpString = ''
946 for HelpStringItem in HelpTextList:
947 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
948 HelpString += '## ' + HelpLine + '\n'
949 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
950 TokenSpaceGuidValue, Token)
951 if TokenSpaceName == '' or PcdCName == '':
952 Logger.Error("Upt",
953 ToolError.RESOURCE_NOT_AVAILABLE,
954 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
955 File=ModuleObject.GetFullPath())
956
957 Statement = HelpString + TokenSpaceName + DT.TAB_SPLIT + PcdCName + DT.TAB_SPACE_SPLIT
958
959 #
960 # Use binary file's Arch to be Pcd's Arch
961 #
962 ArchList = []
963 FileNameObjList = BinaryFile.GetFileNameList()
964 if FileNameObjList:
965 ArchList = FileNameObjList[0].GetSupArchList()
966
967 if len(ArchList) == 0:
968 if PcdExDict.has_key('COMMON'):
969 PcdExDict['COMMON'].append(Statement)
970 else:
971 PcdExDict['COMMON'] = [Statement]
972 else:
973 for Arch in ArchList:
974 if PcdExDict.has_key(Arch):
975 if Statement not in PcdExDict[Arch]:
976 PcdExDict[Arch].append(Statement)
977 else:
978 PcdExDict[Arch] = [Statement]
979 return GenSection('PcdEx', PcdExDict)
980
981 ## GenSpecialSections
982 # generate special sections for Event/BootMode/Hob
983 #
984 def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
985 #
986 # generate section
987 #
988 Content = ''
989 NewSectionDict = {}
990 for Obj in ObjectList:
991 #
992 # Generate comment
993 #
994 CommentStr = ''
995 HelpTextList = Obj.GetHelpTextList()
996 HelpStr = _GetHelpStr(HelpTextList)
997 CommentStr = GenGenericCommentF(HelpStr)
998 if SectionName == 'Hob':
999 Type = Obj.GetHobType()
1000 elif SectionName == 'Event':
1001 Type = Obj.GetEventType()
1002 elif SectionName == 'BootMode':
1003 Type = Obj.GetSupportedBootModes()
1004 else:
1005 assert(SectionName)
1006 Usage = Obj.GetUsage()
1007
1008 # If the content already in UserExtensionsContent then ignore
1009 if '[%s]' % SectionName in UserExtensionsContent and Type in UserExtensionsContent:
1010 return ''
1011
1012 Statement = ' ' + Type + ' ## ' + Usage
1013 if CommentStr in ['#\n', '#\n#\n']:
1014 CommentStr = '#\n#\n#\n'
1015 #
1016 # the first head comment line should start with '##\n', if it starts with '#\n', then add one '#'
1017 # else add '##\n' to meet the format defined in INF spec
1018 #
1019 if CommentStr.startswith('#\n'):
1020 CommentStr = '#' + CommentStr
1021 elif CommentStr:
1022 CommentStr = '##\n' + CommentStr
1023 if CommentStr and not CommentStr.endswith('\n#\n'):
1024 CommentStr = CommentStr + '#\n'
1025 NewStateMent = CommentStr + Statement
1026 SupArch = Obj.GetSupArchList()
1027 SupArch.sort()
1028 SortedArch = ' '.join(SupArch)
1029 if SortedArch in NewSectionDict:
1030 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [NewStateMent]
1031 else:
1032 NewSectionDict[SortedArch] = [NewStateMent]
1033 SectionContent = GenSection(SectionName, NewSectionDict)
1034 SectionContent = SectionContent.strip()
1035 if SectionContent:
1036 Content = '# ' + ('\n' + '# ').join(GetSplitValueList(SectionContent, '\n'))
1037 Content = Content.lstrip()
1038 #
1039 # add a return to differentiate it between other possible sections
1040 #
1041 if Content:
1042 Content += '\n'
1043 return Content
1044 ## GenBuildOptions
1045 #
1046 #
1047 def GenBuildOptions(ModuleObject):
1048 Content = ''
1049 if not ModuleObject.BinaryModule:
1050 #
1051 # generate [BuildOptions] section
1052 #
1053 NewSectionDict = {}
1054 for UserExtension in ModuleObject.GetUserExtensionList():
1055 BuildOptionDict = UserExtension.GetBuildOptionDict()
1056 if not BuildOptionDict:
1057 continue
1058 for Arch in BuildOptionDict:
1059 if Arch in NewSectionDict:
1060 NewSectionDict[Arch] = NewSectionDict[Arch] + [BuildOptionDict[Arch]]
1061 else:
1062 NewSectionDict[Arch] = [BuildOptionDict[Arch]]
1063 Content = GenSection('BuildOptions', NewSectionDict)
1064 else:
1065 BuildOptionDict = {}
1066 for BinaryFile in ModuleObject.GetBinaryFileList():
1067 if not BinaryFile.AsBuiltList:
1068 continue
1069 for BuilOptionItem in BinaryFile.AsBuiltList[0].BinaryBuildFlagList:
1070 Statement = '#' + BuilOptionItem.AsBuiltOptionFlags
1071 if len(BinaryFile.SupArchList) == 0:
1072 if BuildOptionDict.has_key('COMMON'):
1073 if Statement not in BuildOptionDict['COMMON']:
1074 BuildOptionDict['COMMON'].append(Statement)
1075 else:
1076 BuildOptionDict['COMMON'] = ['## @AsBuilt']
1077 BuildOptionDict['COMMON'].append(Statement)
1078 else:
1079 for Arch in BinaryFile.SupArchList:
1080 if BuildOptionDict.has_key(Arch):
1081 if Statement not in BuildOptionDict[Arch]:
1082 BuildOptionDict[Arch].append(Statement)
1083 else:
1084 BuildOptionDict[Arch] = ['## @AsBuilt']
1085 BuildOptionDict[Arch].append(Statement)
1086 Content = GenSection('BuildOptions', BuildOptionDict)
1087
1088 return Content
1089 ## GenBinaries
1090 #
1091 #
1092 def GenBinaries(ModuleObject):
1093 NewSectionDict = {}
1094 BinariesDict = []
1095 for UserExtension in ModuleObject.GetUserExtensionList():
1096 BinariesDict = UserExtension.GetBinariesDict()
1097 if BinariesDict:
1098 break
1099 for BinaryFile in ModuleObject.GetBinaryFileList():
1100 FileNameObjList = BinaryFile.GetFileNameList()
1101 for FileNameObj in FileNameObjList:
1102 FileName = ConvertPath(FileNameObj.GetFilename())
1103 FileType = FileNameObj.GetFileType()
1104 FFE = FileNameObj.GetFeatureFlag()
1105 ArchList = FileNameObj.GetSupArchList()
1106 ArchList.sort()
1107 SortedArch = ' '.join(ArchList)
1108 Key = (FileName, FileType, FFE, SortedArch)
1109 if Key in BinariesDict:
1110 ValueList = BinariesDict[Key]
1111 for ValueItem in ValueList:
1112 Statement = GenBinaryStatement(Key, ValueItem)
1113 if SortedArch in NewSectionDict:
1114 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1115 else:
1116 NewSectionDict[SortedArch] = [Statement]
1117 #
1118 # as we already generated statement for this DictKey here set the Valuelist to be empty
1119 # to avoid generate duplicate entries as the DictKey may have multiple entries
1120 #
1121 BinariesDict[Key] = []
1122 else:
1123 if FileType == 'SUBTYPE_GUID' and FileNameObj.GetGuidValue():
1124 Statement = GenBinaryStatement(Key, None, FileNameObj.GetGuidValue())
1125 else:
1126 Statement = GenBinaryStatement(Key, None)
1127 if SortedArch in NewSectionDict:
1128 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1129 else:
1130 NewSectionDict[SortedArch] = [Statement]
1131 Content = GenSection('Binaries', NewSectionDict)
1132
1133 return Content