]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
b97b319e0956e7209484af0d77ca07805168e0be
[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 = PackageDependency.GetSupArchList()
497 ArchList.sort()
498 SortedArch = ' '.join(ArchList)
499 if SortedArch in NewSectionDict:
500 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
501 else:
502 NewSectionDict[SortedArch] = [Statement]
503 Content += GenSection('Packages', NewSectionDict)
504 return Content
505
506 def GenSources(ModuleObject):
507 #
508 # generate [Sources] section
509 #
510 Content = ''
511 NewSectionDict = {}
512 for Source in ModuleObject.GetSourceFileList():
513 SourceFile = Source.GetSourceFile()
514 Family = Source.GetFamily()
515 FeatureFlag = Source.GetFeatureFlag()
516 SupArchList = Source.GetSupArchList()
517 SupArchList.sort()
518 SortedArch = ' '.join(SupArchList)
519 Statement = GenSourceStatement(ConvertPath(SourceFile), Family, FeatureFlag)
520 if SortedArch in NewSectionDict:
521 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
522 else:
523 NewSectionDict[SortedArch] = [Statement]
524 Content += GenSection('Sources', NewSectionDict)
525
526 return Content
527
528 def GenDepex(ModuleObject):
529 #
530 # generate [Depex] section
531 #
532 NewSectionDict = Sdict()
533 Content = ''
534 for Depex in ModuleObject.GetPeiDepex() + ModuleObject.GetDxeDepex() + ModuleObject.GetSmmDepex():
535 HelpTextList = Depex.GetHelpTextList()
536 HelpStr = _GetHelpStr(HelpTextList)
537 CommentStr = GenGenericCommentF(HelpStr)
538 SupArchList = Depex.GetSupArchList()
539 SupModList = Depex.GetModuleType()
540 Expression = Depex.GetDepex()
541 Statement = CommentStr + Expression
542 SupArchList.sort()
543 KeyList = []
544 if not SupArchList:
545 SupArchList.append(DT.TAB_ARCH_COMMON.lower())
546 if not SupModList:
547 KeyList = SupArchList
548 else:
549 for ModuleType in SupModList:
550 for Arch in SupArchList:
551 KeyList.append(ConvertArchForInstall(Arch) + '.' + ModuleType)
552 for Key in KeyList:
553 if Key in NewSectionDict:
554 NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
555 else:
556 NewSectionDict[Key] = [Statement]
557 Content += GenSection('Depex', NewSectionDict, False)
558
559 return Content
560 ## GenUserExtensions
561 #
562 # GenUserExtensions
563 #
564 def GenUserExtensions(ModuleObject):
565 NewSectionDict = {}
566 for UserExtension in ModuleObject.GetUserExtensionList():
567 if UserExtension.GetUserID() == DT.TAB_BINARY_HEADER_USERID and \
568 UserExtension.GetIdentifier() == DT.TAB_BINARY_HEADER_IDENTIFIER:
569 continue
570 if UserExtension.GetIdentifier() == 'Depex':
571 continue
572 Statement = UserExtension.GetStatement()
573 # Comment the code to support user extension without any statement just the section header in []
574 # if not Statement:
575 # continue
576 ArchList = UserExtension.GetSupArchList()
577 for Index in xrange(0, len(ArchList)):
578 ArchList[Index] = ConvertArchForInstall(ArchList[Index])
579 ArchList.sort()
580 KeyList = []
581 CommonPreFix = ''
582 if UserExtension.GetUserID():
583 CommonPreFix = UserExtension.GetUserID()
584 if CommonPreFix.find('.') > -1:
585 CommonPreFix = '"' + CommonPreFix + '"'
586 if UserExtension.GetIdentifier():
587 CommonPreFix += '.' + '"' + UserExtension.GetIdentifier() + '"'
588 if ArchList:
589 KeyList = [CommonPreFix + '.' + Arch for Arch in ArchList]
590 else:
591 KeyList = [CommonPreFix]
592 for Key in KeyList:
593 if Key in NewSectionDict:
594 NewSectionDict[Key] = NewSectionDict[Key] + [Statement]
595 else:
596 NewSectionDict[Key] = [Statement]
597 Content = GenSection('UserExtensions', NewSectionDict, False)
598
599 return Content
600
601 # GenSourceStatement
602 #
603 # @param SourceFile: string of source file path/name
604 # @param Family: string of source file family field
605 # @param FeatureFlag: string of source file FeatureFlag field
606 # @param TagName: string of source file TagName field
607 # @param ToolCode: string of source file ToolCode field
608 # @param HelpStr: string of source file HelpStr field
609 #
610 # @retval Statement: The generated statement for source
611 #
612 def GenSourceStatement(SourceFile, Family, FeatureFlag, TagName=None,
613 ToolCode=None, HelpStr=None):
614 Statement = ''
615 if HelpStr:
616 Statement += GenGenericCommentF(HelpStr)
617 #
618 # format of SourceFile|Family|TagName|ToolCode|FeatureFlag
619 #
620 Statement += SourceFile
621 if TagName is None:
622 TagName = ''
623 if ToolCode is None:
624 ToolCode = ''
625 if HelpStr is None:
626 HelpStr = ''
627 if FeatureFlag:
628 Statement += '|' + Family + '|' + TagName + '|' + ToolCode + '|' + FeatureFlag
629 elif ToolCode:
630 Statement += '|' + Family + '|' + TagName + '|' + ToolCode
631 elif TagName:
632 Statement += '|' + Family + '|' + TagName
633 elif Family:
634 Statement += '|' + Family
635 return Statement
636
637 # GenBinaryStatement
638 #
639 # @param Key: (FileName, FileType, FFE, SortedArch)
640 # @param Value: (Target, Family, TagName, Comment)
641 #
642 #
643 def GenBinaryStatement(Key, Value, SubTypeGuidValue=None):
644 (FileName, FileType, FFE, SortedArch) = Key
645 if SortedArch:
646 pass
647 if Value:
648 (Target, Family, TagName, Comment) = Value
649 else:
650 Target = ''
651 Family = ''
652 TagName = ''
653 Comment = ''
654 if Comment:
655 Statement = GenGenericCommentF(Comment)
656 else:
657 Statement = ''
658 if FileType == 'SUBTYPE_GUID' and SubTypeGuidValue:
659 Statement += FileType + '|' + SubTypeGuidValue + '|' + FileName
660 else:
661 Statement += FileType + '|' + FileName
662 if FileType in DT.BINARY_FILE_TYPE_UI_LIST + DT.BINARY_FILE_TYPE_VER_LIST:
663 if FFE:
664 Statement += '|' + Target + '|' + FFE
665 elif Target:
666 Statement += '|' + Target
667 else:
668 if FFE:
669 Statement += '|' + Target + '|' + Family + '|' + TagName + '|' + FFE
670 elif TagName:
671 Statement += '|' + Target + '|' + Family + '|' + TagName
672 elif Family:
673 Statement += '|' + Target + '|' + Family
674 elif Target:
675 Statement += '|' + Target
676 return Statement
677 ## GenGuidSections
678 #
679 # @param GuidObjList: List of GuidObject
680 # @retVal Content: The generated section contents
681 #
682 def GenGuidSections(GuidObjList):
683 #
684 # generate [Guids] section
685 #
686 Content = ''
687 GuidDict = Sdict()
688 for Guid in GuidObjList:
689 HelpTextList = Guid.GetHelpTextList()
690 HelpStr = _GetHelpStr(HelpTextList)
691 CName = Guid.GetCName()
692 FFE = Guid.GetFeatureFlag()
693 Statement = CName
694 if FFE:
695 Statement += '|' + FFE
696 Usage = Guid.GetUsage()
697 GuidType = Guid.GetGuidTypeList()[0]
698 VariableName = Guid.GetVariableName()
699 #
700 # Differentiate the generic comment and usage comment as multiple generic comment need to be put at first
701 #
702 if Usage == DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
703 # generate list of generic comment
704 Comment = GenGenericCommentF(HelpStr)
705 else:
706 # generate list of other comment
707 Comment = HelpStr.replace('\n', ' ')
708 Comment = Comment.strip()
709 if Comment:
710 Comment = ' # ' + Comment
711 else:
712 Comment = ''
713 if Usage != DT.ITEM_UNDEFINED and GuidType == DT.ITEM_UNDEFINED:
714 Comment = '## ' + Usage + Comment
715 elif GuidType == 'Variable':
716 Comment = '## ' + Usage + ' ## ' + GuidType + ':' + VariableName + Comment
717 else:
718 Comment = '## ' + Usage + ' ## ' + GuidType + Comment
719
720 if Comment:
721 Comment += '\n'
722 #
723 # merge duplicate items
724 #
725 ArchList = Guid.GetSupArchList()
726 ArchList.sort()
727 SortedArch = ' '.join(ArchList)
728 if (Statement, SortedArch) in GuidDict:
729 PreviousComment = GuidDict[Statement, SortedArch]
730 Comment = PreviousComment + Comment
731 GuidDict[Statement, SortedArch] = Comment
732 NewSectionDict = GenMetaFileMisc.TransferDict(GuidDict, 'INF_GUID')
733 #
734 # generate the section contents
735 #
736 if NewSectionDict:
737 Content = GenSection('Guids', NewSectionDict)
738
739 return Content
740
741 ## GenProtocolPPiSections
742 #
743 # @param ObjList: List of ProtocolObject or Ppi Object
744 # @retVal Content: The generated section contents
745 #
746 def GenProtocolPPiSections(ObjList, IsProtocol):
747 Content = ''
748 Dict = Sdict()
749 for Object in ObjList:
750 HelpTextList = Object.GetHelpTextList()
751 HelpStr = _GetHelpStr(HelpTextList)
752 CName = Object.GetCName()
753 FFE = Object.GetFeatureFlag()
754 Statement = CName
755 if FFE:
756 Statement += '|' + FFE
757 Usage = Object.GetUsage()
758 Notify = Object.GetNotify()
759 #
760 # Differentiate the generic comment and usage comment as consecutive generic comment need to be put together
761 #
762 if Usage == DT.ITEM_UNDEFINED and Notify == '':
763 # generate list of generic comment
764 Comment = GenGenericCommentF(HelpStr)
765 else:
766 # generate list of other comment
767 Comment = HelpStr.replace('\n', ' ')
768 Comment = Comment.strip()
769 if Comment:
770 Comment = ' # ' + Comment
771 else:
772 Comment = ''
773 if Usage == DT.ITEM_UNDEFINED and not Comment and Notify == '':
774 Comment = ''
775 else:
776 if Notify:
777 Comment = '## ' + Usage + ' ## ' + 'NOTIFY' + Comment
778 else:
779 Comment = '## ' + Usage + Comment
780 if Comment:
781 Comment += '\n'
782 #
783 # merge duplicate items
784 #
785 ArchList = Object.GetSupArchList()
786 ArchList.sort()
787 SortedArch = ' '.join(ArchList)
788 if (Statement, SortedArch) in Dict:
789 PreviousComment = Dict[Statement, SortedArch]
790 Comment = PreviousComment + Comment
791 Dict[Statement, SortedArch] = Comment
792 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PPI_PROTOCOL')
793 #
794 # generate the section contents
795 #
796 if NewSectionDict:
797 if IsProtocol:
798 Content = GenSection('Protocols', NewSectionDict)
799 else:
800 Content = GenSection('Ppis', NewSectionDict)
801
802 return Content
803
804 ## GenPcdSections
805 #
806 #
807 def GenPcdSections(ModuleObject):
808 Content = ''
809 if not GlobalData.gIS_BINARY_INF:
810 #
811 # for each Pcd Itemtype, maintain a dict so the same type will be grouped
812 # together
813 #
814 ItemTypeDict = {}
815 for Pcd in ModuleObject.GetPcdList():
816 HelpTextList = Pcd.GetHelpTextList()
817 HelpStr = _GetHelpStr(HelpTextList)
818 Statement = ''
819 CName = Pcd.GetCName()
820 TokenSpaceGuidCName = Pcd.GetTokenSpaceGuidCName()
821 DefaultValue = Pcd.GetDefaultValue()
822 ItemType = Pcd.GetItemType()
823 if ItemType in ItemTypeDict:
824 Dict = ItemTypeDict[ItemType]
825 else:
826 Dict = Sdict()
827 ItemTypeDict[ItemType] = Dict
828 FFE = Pcd.GetFeatureFlag()
829 Statement += TokenSpaceGuidCName + '.' + CName
830 if DefaultValue:
831 Statement += '|' + DefaultValue
832 if FFE:
833 Statement += '|' + FFE
834 elif FFE:
835 Statement += '||' + FFE
836 #
837 # Generate comment
838 #
839 Usage = Pcd.GetValidUsage()
840 # if FeatureFlag Pcd, then assume all Usage is CONSUMES
841 if ItemType == DT.TAB_INF_FEATURE_PCD:
842 Usage = DT.USAGE_ITEM_CONSUMES
843 if Usage == DT.ITEM_UNDEFINED:
844 # generate list of generic comment
845 Comment = GenGenericCommentF(HelpStr)
846 else:
847 # generate list of other comment
848 Comment = HelpStr.replace('\n', ' ')
849 Comment = Comment.strip()
850 if Comment:
851 Comment = ' # ' + Comment
852 else:
853 Comment = ''
854 Comment = '## ' + Usage + Comment
855 if Comment:
856 Comment += '\n'
857 #
858 # Merge duplicate entries
859 #
860 ArchList = Pcd.GetSupArchList()
861 ArchList.sort()
862 SortedArch = ' '.join(ArchList)
863 if (Statement, SortedArch) in Dict:
864 PreviousComment = Dict[Statement, SortedArch]
865 Comment = PreviousComment + Comment
866 Dict[Statement, SortedArch] = Comment
867 for ItemType in ItemTypeDict:
868 # First we need to transfer the Dict to use SortedArch as key
869 Dict = ItemTypeDict[ItemType]
870 NewSectionDict = GenMetaFileMisc.TransferDict(Dict, 'INF_PCD')
871 if NewSectionDict:
872 Content += GenSection(ItemType, NewSectionDict)
873 #
874 # For AsBuild INF files
875 #
876 else:
877 Content += GenAsBuiltPacthPcdSections(ModuleObject)
878 Content += GenAsBuiltPcdExSections(ModuleObject)
879
880 return Content
881
882 ## GenPcdSections
883 #
884 #
885 def GenAsBuiltPacthPcdSections(ModuleObject):
886 PatchPcdDict = {}
887 for BinaryFile in ModuleObject.GetBinaryFileList():
888 if not BinaryFile.AsBuiltList:
889 continue
890 for PatchPcd in BinaryFile.AsBuiltList[0].PatchPcdList:
891 TokenSpaceName = ''
892 PcdCName = PatchPcd.CName
893 PcdValue = PatchPcd.DefaultValue
894 PcdOffset = PatchPcd.Offset
895 TokenSpaceGuidValue = PatchPcd.TokenSpaceGuidValue
896 Token = PatchPcd.Token
897 HelpTextList = PatchPcd.HelpTextList
898 HelpString = ''
899 for HelpStringItem in HelpTextList:
900 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
901 HelpString += '## ' + HelpLine + '\n'
902 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
903 TokenSpaceGuidValue,
904 Token)
905 if TokenSpaceName == '' or PcdCName == '':
906 Logger.Error("Upt",
907 ToolError.RESOURCE_NOT_AVAILABLE,
908 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
909 File=ModuleObject.GetFullPath())
910 Statement = HelpString + TokenSpaceName + '.' + PcdCName + ' | ' + PcdValue + ' | ' + \
911 PcdOffset + DT.TAB_SPACE_SPLIT
912 #
913 # Use binary file's Arch to be Pcd's Arch
914 #
915 ArchList = []
916 FileNameObjList = BinaryFile.GetFileNameList()
917 if FileNameObjList:
918 ArchList = FileNameObjList[0].GetSupArchList()
919 if len(ArchList) == 0:
920 if DT.TAB_ARCH_COMMON in PatchPcdDict:
921 if Statement not in PatchPcdDict[DT.TAB_ARCH_COMMON]:
922 PatchPcdDict[DT.TAB_ARCH_COMMON].append(Statement)
923 else:
924 PatchPcdDict[DT.TAB_ARCH_COMMON] = [Statement]
925 else:
926 for Arch in ArchList:
927 if Arch in PatchPcdDict:
928 if Statement not in PatchPcdDict[Arch]:
929 PatchPcdDict[Arch].append(Statement)
930 else:
931 PatchPcdDict[Arch] = [Statement]
932 return GenSection(DT.TAB_INF_PATCH_PCD, PatchPcdDict)
933 ## GenPcdSections
934 #
935 #
936 def GenAsBuiltPcdExSections(ModuleObject):
937 PcdExDict = {}
938 for BinaryFile in ModuleObject.GetBinaryFileList():
939 if not BinaryFile.AsBuiltList:
940 continue
941 for PcdExItem in BinaryFile.AsBuiltList[0].PcdExValueList:
942 TokenSpaceName = ''
943 PcdCName = PcdExItem.CName
944 TokenSpaceGuidValue = PcdExItem.TokenSpaceGuidValue
945 Token = PcdExItem.Token
946 HelpTextList = PcdExItem.HelpTextList
947 HelpString = ''
948 for HelpStringItem in HelpTextList:
949 for HelpLine in GetSplitValueList(HelpStringItem.String, '\n'):
950 HelpString += '## ' + HelpLine + '\n'
951 TokenSpaceName, PcdCName = GenMetaFileMisc.ObtainPcdName(ModuleObject.PackageDependencyList,
952 TokenSpaceGuidValue, Token)
953 if TokenSpaceName == '' or PcdCName == '':
954 Logger.Error("Upt",
955 ToolError.RESOURCE_NOT_AVAILABLE,
956 ST.ERR_INSTALL_FILE_DEC_FILE_ERROR % (TokenSpaceGuidValue, Token),
957 File=ModuleObject.GetFullPath())
958
959 Statement = HelpString + TokenSpaceName + DT.TAB_SPLIT + PcdCName + DT.TAB_SPACE_SPLIT
960
961 #
962 # Use binary file's Arch to be Pcd's Arch
963 #
964 ArchList = []
965 FileNameObjList = BinaryFile.GetFileNameList()
966 if FileNameObjList:
967 ArchList = FileNameObjList[0].GetSupArchList()
968
969 if len(ArchList) == 0:
970 if 'COMMON' in PcdExDict:
971 PcdExDict['COMMON'].append(Statement)
972 else:
973 PcdExDict['COMMON'] = [Statement]
974 else:
975 for Arch in ArchList:
976 if Arch in PcdExDict:
977 if Statement not in PcdExDict[Arch]:
978 PcdExDict[Arch].append(Statement)
979 else:
980 PcdExDict[Arch] = [Statement]
981 return GenSection('PcdEx', PcdExDict)
982
983 ## GenSpecialSections
984 # generate special sections for Event/BootMode/Hob
985 #
986 def GenSpecialSections(ObjectList, SectionName, UserExtensionsContent=''):
987 #
988 # generate section
989 #
990 Content = ''
991 NewSectionDict = {}
992 for Obj in ObjectList:
993 #
994 # Generate comment
995 #
996 CommentStr = ''
997 HelpTextList = Obj.GetHelpTextList()
998 HelpStr = _GetHelpStr(HelpTextList)
999 CommentStr = GenGenericCommentF(HelpStr)
1000 if SectionName == 'Hob':
1001 Type = Obj.GetHobType()
1002 elif SectionName == 'Event':
1003 Type = Obj.GetEventType()
1004 elif SectionName == 'BootMode':
1005 Type = Obj.GetSupportedBootModes()
1006 else:
1007 assert(SectionName)
1008 Usage = Obj.GetUsage()
1009
1010 # If the content already in UserExtensionsContent then ignore
1011 if '[%s]' % SectionName in UserExtensionsContent and Type in UserExtensionsContent:
1012 return ''
1013
1014 Statement = ' ' + Type + ' ## ' + Usage
1015 if CommentStr in ['#\n', '#\n#\n']:
1016 CommentStr = '#\n#\n#\n'
1017 #
1018 # the first head comment line should start with '##\n', if it starts with '#\n', then add one '#'
1019 # else add '##\n' to meet the format defined in INF spec
1020 #
1021 if CommentStr.startswith('#\n'):
1022 CommentStr = '#' + CommentStr
1023 elif CommentStr:
1024 CommentStr = '##\n' + CommentStr
1025 if CommentStr and not CommentStr.endswith('\n#\n'):
1026 CommentStr = CommentStr + '#\n'
1027 NewStateMent = CommentStr + Statement
1028 SupArch = Obj.GetSupArchList()
1029 SupArch.sort()
1030 SortedArch = ' '.join(SupArch)
1031 if SortedArch in NewSectionDict:
1032 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [NewStateMent]
1033 else:
1034 NewSectionDict[SortedArch] = [NewStateMent]
1035 SectionContent = GenSection(SectionName, NewSectionDict)
1036 SectionContent = SectionContent.strip()
1037 if SectionContent:
1038 Content = '# ' + ('\n' + '# ').join(GetSplitValueList(SectionContent, '\n'))
1039 Content = Content.lstrip()
1040 #
1041 # add a return to differentiate it between other possible sections
1042 #
1043 if Content:
1044 Content += '\n'
1045 return Content
1046 ## GenBuildOptions
1047 #
1048 #
1049 def GenBuildOptions(ModuleObject):
1050 Content = ''
1051 if not ModuleObject.BinaryModule:
1052 #
1053 # generate [BuildOptions] section
1054 #
1055 NewSectionDict = {}
1056 for UserExtension in ModuleObject.GetUserExtensionList():
1057 BuildOptionDict = UserExtension.GetBuildOptionDict()
1058 if not BuildOptionDict:
1059 continue
1060 for Arch in BuildOptionDict:
1061 if Arch in NewSectionDict:
1062 NewSectionDict[Arch] = NewSectionDict[Arch] + [BuildOptionDict[Arch]]
1063 else:
1064 NewSectionDict[Arch] = [BuildOptionDict[Arch]]
1065 Content = GenSection('BuildOptions', NewSectionDict)
1066 else:
1067 BuildOptionDict = {}
1068 for BinaryFile in ModuleObject.GetBinaryFileList():
1069 if not BinaryFile.AsBuiltList:
1070 continue
1071 for BuilOptionItem in BinaryFile.AsBuiltList[0].BinaryBuildFlagList:
1072 Statement = '#' + BuilOptionItem.AsBuiltOptionFlags
1073 if len(BinaryFile.SupArchList) == 0:
1074 if 'COMMON' in BuildOptionDict:
1075 if Statement not in BuildOptionDict['COMMON']:
1076 BuildOptionDict['COMMON'].append(Statement)
1077 else:
1078 BuildOptionDict['COMMON'] = ['## @AsBuilt']
1079 BuildOptionDict['COMMON'].append(Statement)
1080 else:
1081 for Arch in BinaryFile.SupArchList:
1082 if Arch in BuildOptionDict:
1083 if Statement not in BuildOptionDict[Arch]:
1084 BuildOptionDict[Arch].append(Statement)
1085 else:
1086 BuildOptionDict[Arch] = ['## @AsBuilt']
1087 BuildOptionDict[Arch].append(Statement)
1088 Content = GenSection('BuildOptions', BuildOptionDict)
1089
1090 return Content
1091 ## GenBinaries
1092 #
1093 #
1094 def GenBinaries(ModuleObject):
1095 NewSectionDict = {}
1096 BinariesDict = []
1097 for UserExtension in ModuleObject.GetUserExtensionList():
1098 BinariesDict = UserExtension.GetBinariesDict()
1099 if BinariesDict:
1100 break
1101 for BinaryFile in ModuleObject.GetBinaryFileList():
1102 FileNameObjList = BinaryFile.GetFileNameList()
1103 for FileNameObj in FileNameObjList:
1104 FileName = ConvertPath(FileNameObj.GetFilename())
1105 FileType = FileNameObj.GetFileType()
1106 FFE = FileNameObj.GetFeatureFlag()
1107 ArchList = FileNameObj.GetSupArchList()
1108 ArchList.sort()
1109 SortedArch = ' '.join(ArchList)
1110 Key = (FileName, FileType, FFE, SortedArch)
1111 if Key in BinariesDict:
1112 ValueList = BinariesDict[Key]
1113 for ValueItem in ValueList:
1114 Statement = GenBinaryStatement(Key, ValueItem)
1115 if SortedArch in NewSectionDict:
1116 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1117 else:
1118 NewSectionDict[SortedArch] = [Statement]
1119 #
1120 # as we already generated statement for this DictKey here set the Valuelist to be empty
1121 # to avoid generate duplicate entries as the DictKey may have multiple entries
1122 #
1123 BinariesDict[Key] = []
1124 else:
1125 if FileType == 'SUBTYPE_GUID' and FileNameObj.GetGuidValue():
1126 Statement = GenBinaryStatement(Key, None, FileNameObj.GetGuidValue())
1127 else:
1128 Statement = GenBinaryStatement(Key, None)
1129 if SortedArch in NewSectionDict:
1130 NewSectionDict[SortedArch] = NewSectionDict[SortedArch] + [Statement]
1131 else:
1132 NewSectionDict[SortedArch] = [Statement]
1133 Content = GenSection('Binaries', NewSectionDict)
1134
1135 return Content