]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Common/DecClassObjectLight.py
cba88b64f22e431721e60a756fc71a43387e7784
[mirror_edk2.git] / BaseTools / Source / Python / Common / DecClassObjectLight.py
1 ## @file
2 # This file is used to define each component of DEC file in light mode
3 #
4 # Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
5 # This program and the accompanying materials
6 # are licensed and made available under the terms and conditions of the BSD License
7 # which accompanies this distribution. The full text of the license may be found at
8 # http://opensource.org/licenses/bsd-license.php
9 #
10 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 #
13
14 ##
15 # Import Modules
16 #
17 import os
18 from Misc import GetFiles
19 from String import *
20 from DataType import *
21 from CommonDataClass.PackageClass import *
22 from CommonDataClass import CommonClass
23 from BuildToolError import *
24 from Parsing import *
25
26 # Global variable
27 Section = {TAB_UNKNOWN.upper() : MODEL_UNKNOWN,
28 TAB_DEC_DEFINES.upper() : MODEL_META_DATA_HEADER,
29 TAB_INCLUDES.upper() : MODEL_EFI_INCLUDE,
30 TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS,
31 TAB_COMPONENTS.upper() : MODEL_META_DATA_COMPONENT,
32 TAB_GUIDS.upper() : MODEL_EFI_GUID,
33 TAB_PROTOCOLS.upper() : MODEL_EFI_PROTOCOL,
34 TAB_PPIS.upper() : MODEL_EFI_PPI,
35 TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT_BUILD,
36 TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABLE_IN_MODULE,
37 TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_FLAG,
38 TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_EX,
39 TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC,
40 TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION
41 }
42
43 ## DecObject
44 #
45 # This class defined basic Dec object which is used by inheriting
46 #
47 # @param object: Inherited from object class
48 #
49 class DecObject(object):
50 def __init__(self):
51 object.__init__()
52
53 ## Dec
54 #
55 # This class defined the structure used in Dec object
56 #
57 # @param DecObject: Inherited from DecObject class
58 # @param Filename: Input value for Filename of Dec file, default is None
59 # @param IsMergeAllArches: Input value for IsMergeAllArches
60 # True is to merge all arches
61 # Fales is not to merge all arches
62 # default is False
63 # @param IsToPackage: Input value for IsToPackage
64 # True is to transfer to PackageObject automatically
65 # False is not to transfer to PackageObject automatically
66 # default is False
67 # @param WorkspaceDir: Input value for current workspace directory, default is None
68 #
69 # @var Identification: To store value for Identification, it is a structure as Identification
70 # @var Defines: To store value for Defines, it is a structure as DecDefines
71 # @var UserExtensions: To store value for UserExtensions
72 # @var Package: To store value for Package, it is a structure as PackageClass
73 # @var WorkspaceDir: To store value for WorkspaceDir
74 # @var Contents: To store value for Contents, it is a structure as DecContents
75 # @var KeyList: To store value for KeyList, a list for all Keys used in Dec
76 #
77 class Dec(DecObject):
78 def __init__(self, Filename = None, IsToPackage = False, WorkspaceDir = None, AllGuidVersionDict = None, SupArchList = DataType.ARCH_LIST):
79 self.Identification = IdentificationClass()
80 self.Package = PackageClass()
81 self.UserExtensions = ''
82 self.WorkspaceDir = WorkspaceDir
83 self.SupArchList = SupArchList
84 self.AllGuidVersionDict = {}
85 if AllGuidVersionDict:
86 self.AllGuidVersionDict = AllGuidVersionDict
87
88 self.KeyList = [
89 TAB_INCLUDES, TAB_GUIDS, TAB_PROTOCOLS, TAB_PPIS, TAB_LIBRARY_CLASSES, \
90 TAB_PCDS_FIXED_AT_BUILD_NULL, TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL, \
91 TAB_PCDS_DYNAMIC_NULL, TAB_PCDS_DYNAMIC_EX_NULL, TAB_DEC_DEFINES
92 ]
93 # Upper all KEYs to ignore case sensitive when parsing
94 self.KeyList = map(lambda c: c.upper(), self.KeyList)
95
96 # Init RecordSet
97 self.RecordSet = {}
98 for Key in self.KeyList:
99 self.RecordSet[Section[Key]] = []
100
101 # Init Comment
102 self.SectionHeaderCommentDict = {}
103
104 # Load Dec file if filename is not None
105 if Filename != None:
106 self.LoadDecFile(Filename)
107
108 # Transfer to Package Object if IsToPackage is True
109 if IsToPackage:
110 self.DecToPackage()
111
112 ## Load Dec file
113 #
114 # Load the file if it exists
115 #
116 # @param Filename: Input value for filename of Dec file
117 #
118 def LoadDecFile(self, Filename):
119 # Insert a record for file
120 Filename = NormPath(Filename)
121 self.Identification.FullPath = Filename
122 (self.Identification.RelaPath, self.Identification.FileName) = os.path.split(Filename)
123 if self.Identification.FullPath.find(self.WorkspaceDir) > -1:
124 self.Identification.PackagePath = os.path.dirname(self.Identification.FullPath[len(self.WorkspaceDir) + 1:])
125
126 # Init common datas
127 IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \
128 [], [], TAB_UNKNOWN, [], [], []
129 LineNo = 0
130
131 # Parse file content
132 IsFindBlockComment = False
133 ReservedLine = ''
134 Comment = ''
135 for Line in open(Filename, 'r'):
136 LineNo = LineNo + 1
137 # Remove comment block
138 if Line.find(TAB_COMMENT_EDK_START) > -1:
139 ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
140 if ReservedLine.strip().startswith(TAB_COMMENT_SPLIT):
141 Comment = Comment + Line.strip() + '\n'
142 ReservedLine = ''
143 else:
144 Comment = Comment + Line[len(ReservedLine):] + '\n'
145 IsFindBlockComment = True
146 if not ReservedLine:
147 continue
148 if Line.find(TAB_COMMENT_EDK_END) > -1:
149 Comment = Comment + Line[:Line.find(TAB_COMMENT_EDK_END) + len(TAB_COMMENT_EDK_END)] + '\n'
150 Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
151 ReservedLine = ''
152 IsFindBlockComment = False
153 if IsFindBlockComment:
154 Comment = Comment + Line.strip() + '\n'
155 continue
156
157 # Remove comments at tail and remove spaces again
158 if Line.strip().startswith(TAB_COMMENT_SPLIT) or Line.strip().startswith('--/'):
159 Comment = Comment + Line.strip() + '\n'
160 Line = CleanString(Line)
161 if Line == '':
162 continue
163
164 ## Find a new section tab
165 # First insert previous section items
166 # And then parse the content of the new section
167 #
168 if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SECTION_END):
169 # Insert items data of previous section
170 Model = Section[CurrentSection.upper()]
171 InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet)
172 # Parse the new section
173 SectionItemList = []
174 ArchList = []
175 ThirdList = []
176
177 CurrentSection = ''
178 LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
179 for Item in LineList:
180 ItemList = GetSplitValueList(Item, TAB_SPLIT)
181 if CurrentSection == '':
182 CurrentSection = ItemList[0]
183 else:
184 if CurrentSection != ItemList[0]:
185 EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
186 if CurrentSection.upper() not in self.KeyList:
187 RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
188 ItemList.append('')
189 ItemList.append('')
190 if len(ItemList) > 5:
191 RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
192 else:
193 if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
194 EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
195 ArchList.append(ItemList[1].upper())
196 ThirdList.append(ItemList[2])
197
198 if Comment:
199 if Comment.endswith('\n'):
200 Comment = Comment[:len(Comment) - len('\n')]
201 self.SectionHeaderCommentDict[Section[CurrentSection.upper()]] = Comment
202 Comment = ''
203 continue
204
205 # Not in any defined section
206 if CurrentSection == TAB_UNKNOWN:
207 ErrorMsg = "%s is not in any defined section" % Line
208 EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
209
210 # Add a section item
211 SectionItemList.append([Line, LineNo, Comment])
212 Comment = ''
213 # End of parse
214 #End of For
215
216 #
217 # Insert items data of last section
218 #
219 Model = Section[CurrentSection.upper()]
220 InsertSectionItems(Model, CurrentSection, SectionItemList, ArchList, ThirdList, self.RecordSet)
221 if Comment != '':
222 self.SectionHeaderCommentDict[Model] = Comment
223 Comment = ''
224
225 ## Package Object to DEC file
226 def PackageToDec(self, Package):
227 Dec = ''
228 DecList = sdict()
229 SectionHeaderCommentDict = {}
230 if Package == None:
231 return Dec
232
233 PackageHeader = Package.PackageHeader
234 TmpList = []
235 if PackageHeader.Name:
236 TmpList.append(TAB_DEC_DEFINES_PACKAGE_NAME + ' = ' + PackageHeader.Name)
237 if PackageHeader.Guid:
238 TmpList.append(TAB_DEC_DEFINES_PACKAGE_GUID + ' = ' + PackageHeader.Guid)
239 if PackageHeader.Version:
240 TmpList.append(TAB_DEC_DEFINES_PACKAGE_VERSION + ' = ' + PackageHeader.Version)
241 if PackageHeader.DecSpecification:
242 TmpList.append(TAB_DEC_DEFINES_DEC_SPECIFICATION + ' = ' + PackageHeader.DecSpecification)
243 if Package.UserExtensions != None:
244 for Item in Package.UserExtensions.Defines:
245 TmpList.append(Item)
246 DecList['Defines'] =TmpList
247 if PackageHeader.Description != '':
248 SectionHeaderCommentDict['Defines'] = PackageHeader.Description
249
250 for Item in Package.Includes:
251 Key = 'Includes.' + Item.SupArchList
252 Value = Item.FilePath
253 GenMetaDatSectionItem(Key, Value, DecList)
254
255 for Item in Package.GuidDeclarations:
256 Key = 'Guids.' + Item.SupArchList
257 Value = Item.CName + '=' + Item.Guid
258 GenMetaDatSectionItem(Key, Value, DecList)
259
260 for Item in Package.ProtocolDeclarations:
261 Key = 'Protocols.' + Item.SupArchList
262 Value = Item.CName + '=' + Item.Guid
263 GenMetaDatSectionItem(Key, Value, DecList)
264
265 for Item in Package.PpiDeclarations:
266 Key = 'Ppis.' + Item.SupArchList
267 Value = Item.CName + '=' + Item.Guid
268 GenMetaDatSectionItem(Key, Value, DecList)
269
270 for Item in Package.LibraryClassDeclarations:
271 Key = 'LibraryClasses.' + Item.SupArchList
272 Value = Item.LibraryClass + '|' + Item.RecommendedInstance
273 GenMetaDatSectionItem(Key, Value, DecList)
274
275 for Item in Package.PcdDeclarations:
276 Key = 'Pcds' + Item.ItemType + '.' + Item.SupArchList
277 Value = Item.TokenSpaceGuidCName + '.' + Item.CName
278 if Item.DefaultValue != '':
279 Value = Value + '|' + Item.DefaultValue
280 if Item.DatumType != '':
281 Value = Value + '|' + Item.DatumType
282 if Item.Token != '':
283 Value = Value + '|' + Item.Token
284 GenMetaDatSectionItem(Key, Value, DecList)
285
286 # Transfer Package to Inf
287 for Key in DecList:
288 if Key in SectionHeaderCommentDict:
289 List = SectionHeaderCommentDict[Key].split('\r')
290 for Item in List:
291 Dec = Dec + Item + '\n'
292 Dec = Dec + '[' + Key + ']' + '\n'
293 for Value in DecList[Key]:
294 if type(Value) == type([]):
295 for SubValue in Value:
296 Dec = Dec + ' ' + SubValue + '\n'
297 else:
298 Dec = Dec + ' ' + Value + '\n'
299 Dec = Dec + '\n'
300
301 return Dec
302
303 ## Transfer to Package Object
304 #
305 # Transfer all contents of a Dec file to a standard Package Object
306 #
307 def DecToPackage(self):
308 # Init global information for the file
309 ContainerFile = self.Identification.FullPath
310
311 # Generate Package Header
312 self.GenPackageHeader(ContainerFile)
313
314 # Generate Includes
315 # Only for Edk
316 self.GenIncludes(ContainerFile)
317
318 # Generate Guids
319 self.GenGuidProtocolPpis(DataType.TAB_GUIDS, ContainerFile)
320
321 # Generate Protocols
322 self.GenGuidProtocolPpis(DataType.TAB_PROTOCOLS, ContainerFile)
323
324 # Generate Ppis
325 self.GenGuidProtocolPpis(DataType.TAB_PPIS, ContainerFile)
326
327 # Generate LibraryClasses
328 self.GenLibraryClasses(ContainerFile)
329
330 # Generate Pcds
331 self.GenPcds(ContainerFile)
332
333 # Init MiscFiles
334 self.GenMiscFiles(ContainerFile)
335
336 ## GenMiscFiles
337 #
338 def GenMiscFiles(self, ContainerFile):
339 MiscFiles = MiscFileClass()
340 MiscFiles.Name = 'ModuleFiles'
341 for Item in GetFiles(os.path.dirname(ContainerFile), ['CVS', '.svn'], False):
342 File = CommonClass.FileClass()
343 File.Filename = Item
344 MiscFiles.Files.append(File)
345 self.Package.MiscFiles = MiscFiles
346
347 ## Get Package Header
348 #
349 # Gen Package Header of Dec as <Key> = <Value>
350 #
351 # @param ContainerFile: The Dec file full path
352 #
353 def GenPackageHeader(self, ContainerFile):
354 EdkLogger.debug(2, "Generate PackageHeader ...")
355 #
356 # Update all defines item in database
357 #
358 RecordSet = self.RecordSet[MODEL_META_DATA_HEADER]
359 PackageHeader = PackageHeaderClass()
360 OtherDefines = []
361 for Record in RecordSet:
362 ValueList = GetSplitValueList(Record[0], TAB_EQUAL_SPLIT)
363 if len(ValueList) != 2:
364 OtherDefines.append(Record[0])
365 else:
366 Name = ValueList[0]
367 Value = ValueList[1]
368 if Name == TAB_DEC_DEFINES_PACKAGE_NAME:
369 PackageHeader.Name = Value
370 elif Name == TAB_DEC_DEFINES_PACKAGE_GUID:
371 PackageHeader.Guid = Value
372 elif Name == TAB_DEC_DEFINES_PACKAGE_VERSION:
373 PackageHeader.Version = Value
374 elif Name == TAB_DEC_DEFINES_DEC_SPECIFICATION:
375 PackageHeader.DecSpecification = Value
376 else:
377 OtherDefines.append(Record[0])
378
379 PackageHeader.FileName = self.Identification.FileName
380 PackageHeader.FullPath = self.Identification.FullPath
381 PackageHeader.RelaPath = self.Identification.RelaPath
382 PackageHeader.PackagePath = self.Identification.PackagePath
383 PackageHeader.ModulePath = self.Identification.ModulePath
384 PackageHeader.CombinePath = os.path.normpath(os.path.join(PackageHeader.PackagePath, PackageHeader.ModulePath, PackageHeader.FileName))
385
386 if MODEL_META_DATA_HEADER in self.SectionHeaderCommentDict:
387 PackageHeader.Description = self.SectionHeaderCommentDict[MODEL_META_DATA_HEADER]
388
389 self.Package.PackageHeader = PackageHeader
390 UE = UserExtensionsClass()
391 UE.Defines = OtherDefines
392 self.Package.UserExtensions = UE
393
394
395 ## GenIncludes
396 #
397 # Gen Includes of Dec
398 #
399 # @param ContainerFile: The Dec file full path
400 #
401 def GenIncludes(self, ContainerFile):
402 EdkLogger.debug(2, "Generate %s ..." % TAB_INCLUDES)
403 Includes = {}
404 # Get all Includes
405 RecordSet = self.RecordSet[MODEL_EFI_INCLUDE]
406
407 # Go through each arch
408 for Record in RecordSet:
409 Arch = Record[1]
410 Key = Record[0]
411 Include = IncludeClass()
412 Include.FilePath = NormPath(Key)
413 Include.SupArchList = Arch
414 self.Package.Includes.append(Include)
415
416 ## GenPpis
417 #
418 # Gen Ppis of Dec
419 # <CName>=<GuidValue>
420 #
421 # @param ContainerFile: The Dec file full path
422 #
423 def GenGuidProtocolPpis(self, Type, ContainerFile):
424 EdkLogger.debug(2, "Generate %s ..." % Type)
425 Lists = {}
426 # Get all Items
427 RecordSet = self.RecordSet[Section[Type.upper()]]
428
429 # Go through each arch
430 for Record in RecordSet:
431 Arch = Record[1]
432 (Name, Value) = GetGuidsProtocolsPpisOfDec(Record[0], Type, ContainerFile, Record[2])
433
434 ListMember = None
435 if Type == TAB_GUIDS:
436 ListMember = self.Package.GuidDeclarations
437 elif Type == TAB_PROTOCOLS:
438 ListMember = self.Package.ProtocolDeclarations
439 elif Type == TAB_PPIS:
440 ListMember = self.Package.PpiDeclarations
441
442 ListClass = GuidProtocolPpiCommonClass()
443 ListClass.CName = Name
444 ListClass.Guid = Value
445 ListClass.SupArchList = Arch
446 ListMember.append(ListClass)
447
448 ## GenLibraryClasses
449 #
450 # Gen LibraryClasses of Dec
451 # <CName>=<GuidValue>
452 #
453 # @param ContainerFile: The Dec file full path
454 #
455 def GenLibraryClasses(self, ContainerFile):
456 EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)
457 LibraryClasses = {}
458 # Get all Guids
459 RecordSet = self.RecordSet[MODEL_EFI_LIBRARY_CLASS]
460
461 # Go through each arch
462 for Record in RecordSet:
463 Arch = Record[1]
464 List = GetSplitValueList(Record[0], DataType.TAB_VALUE_SPLIT)
465 if len(List) != 2:
466 continue
467 LibraryClass = LibraryClassClass()
468 LibraryClass.LibraryClass = List[0]
469 LibraryClass.RecommendedInstance = NormPath(List[1])
470 LibraryClass.SupArchList = Arch
471 self.Package.LibraryClassDeclarations.append(LibraryClass)
472
473 def AddPcd(self, CName, Token, TokenSpaceGuidCName, DatumType, DefaultValue, ItemType, Arch):
474 Pcd = CommonClass.PcdClass()
475 Pcd.CName = CName
476 Pcd.Token = Token
477 Pcd.TokenSpaceGuidCName = TokenSpaceGuidCName
478 Pcd.DatumType = DatumType
479 Pcd.DefaultValue = DefaultValue
480 Pcd.ItemType = ItemType
481 Pcd.SupArchList = Arch
482 self.Package.PcdDeclarations.append(Pcd)
483
484 ## GenPcds
485 #
486 # Gen Pcds of Dec
487 # <TokenSpcCName>.<TokenCName>|<Value>|<DatumType>|<Token>
488 #
489 # @param ContainerFile: The Dec file full path
490 #
491 def GenPcds(self, ContainerFile):
492 EdkLogger.debug(2, "Generate %s ..." % TAB_PCDS)
493 Pcds = {}
494 PcdToken = {}
495 # Get all Pcds
496 RecordSet1 = self.RecordSet[MODEL_PCD_FIXED_AT_BUILD]
497 RecordSet2 = self.RecordSet[MODEL_PCD_PATCHABLE_IN_MODULE]
498 RecordSet3 = self.RecordSet[MODEL_PCD_FEATURE_FLAG]
499 RecordSet4 = self.RecordSet[MODEL_PCD_DYNAMIC_EX]
500 RecordSet5 = self.RecordSet[MODEL_PCD_DYNAMIC]
501
502 # Go through each pcd
503 for Record in RecordSet1:
504 Arch = Record[1]
505 (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_FIXED_AT_BUILD, ContainerFile, Record[2])
506 self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch)
507 for Record in RecordSet2:
508 Arch = Record[1]
509 (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile, Record[2])
510 self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch)
511 for Record in RecordSet3:
512 Arch = Record[1]
513 (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_FEATURE_FLAG, ContainerFile, Record[2])
514 self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch)
515 for Record in RecordSet4:
516 Arch = Record[1]
517 (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC_EX, ContainerFile, Record[2])
518 self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch)
519 for Record in RecordSet5:
520 Arch = Record[1]
521 (TokenGuidCName, TokenName, DefaultValue, DatumType, Token, ItemType) = GetPcdOfDec(Record[0], TAB_PCDS_DYNAMIC, ContainerFile, Record[2])
522 self.AddPcd(TokenName, Token, TokenGuidCName, DatumType, DefaultValue, ItemType, Arch)
523
524 ## Show detailed information of Package
525 #
526 # Print all members and their values of Package class
527 #
528 def ShowPackage(self):
529 M = self.Package
530 print 'Filename =', M.PackageHeader.FileName
531 print 'FullPath =', M.PackageHeader.FullPath
532 print 'RelaPath =', M.PackageHeader.RelaPath
533 print 'PackagePath =', M.PackageHeader.PackagePath
534 print 'ModulePath =', M.PackageHeader.ModulePath
535 print 'CombinePath =', M.PackageHeader.CombinePath
536
537 print 'BaseName =', M.PackageHeader.Name
538 print 'Guid =', M.PackageHeader.Guid
539 print 'Version =', M.PackageHeader.Version
540 print 'DecSpecification =', M.PackageHeader.DecSpecification
541
542 print '\nIncludes ='#, M.Includes
543 for Item in M.Includes:
544 print Item.FilePath, Item.SupArchList
545 print '\nGuids ='#, M.GuidDeclarations
546 for Item in M.GuidDeclarations:
547 print Item.CName, Item.Guid, Item.SupArchList
548 print '\nProtocols ='#, M.ProtocolDeclarations
549 for Item in M.ProtocolDeclarations:
550 print Item.CName, Item.Guid, Item.SupArchList
551 print '\nPpis ='#, M.PpiDeclarations
552 for Item in M.PpiDeclarations:
553 print Item.CName, Item.Guid, Item.SupArchList
554 print '\nLibraryClasses ='#, M.LibraryClassDeclarations
555 for Item in M.LibraryClassDeclarations:
556 print Item.LibraryClass, Item.RecommendedInstance, Item.SupModuleList, Item.SupArchList
557 print '\nPcds ='#, M.PcdDeclarations
558 for Item in M.PcdDeclarations:
559 print 'CName=', Item.CName, 'TokenSpaceGuidCName=', Item.TokenSpaceGuidCName, 'DefaultValue=', Item.DefaultValue, 'ItemType=', Item.ItemType, 'Token=', Item.Token, 'DatumType=', Item.DatumType, Item.SupArchList
560 print '\nUserExtensions =', M.UserExtensions.Defines
561 print '\n*** FileList ***'
562 for Item in M.MiscFiles.Files:
563 print Item.Filename
564 print '****************\n'
565
566 ##
567 #
568 # This acts like the main() function for the script, unless it is 'import'ed into another
569 # script.
570 #
571 if __name__ == '__main__':
572 EdkLogger.Initialize()
573 EdkLogger.SetLevel(EdkLogger.QUIET)
574
575 W = os.getenv('WORKSPACE')
576 F = os.path.join(W, 'MdeModulePkg/MdeModulePkg.dec')
577
578 P = Dec(os.path.normpath(F), True, W)
579 P.ShowPackage()
580 print P.PackageToDec(P.Package)