]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Common/DscClassObject.py
MdePkg/BaseLib: Replaced inline assembly for ARMGCC by GCC assembly source file
[mirror_edk2.git] / BaseTools / Source / Python / Common / DscClassObject.py
1 ## @file
2 # This file is used to define each component of DSC file
3 #
4 # Copyright (c) 2007 - 2010, 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 import EdkLogger as EdkLogger
19 import Database
20 from String import *
21 from Parsing import *
22 from DataType import *
23 from Identification import *
24 from Dictionary import *
25 from CommonDataClass.PlatformClass import *
26 from CommonDataClass.CommonClass import SkuInfoClass
27 from BuildToolError import *
28 from Misc import sdict
29 import GlobalData
30 from Table.TableDsc import TableDsc
31
32 #
33 # Global variable
34 #
35 Section = {TAB_UNKNOWN.upper() : MODEL_UNKNOWN,
36 TAB_DSC_DEFINES.upper() : MODEL_META_DATA_HEADER,
37 TAB_BUILD_OPTIONS.upper() : MODEL_META_DATA_BUILD_OPTION,
38 TAB_SKUIDS.upper() : MODEL_EFI_SKU_ID,
39 TAB_LIBRARIES.upper() : MODEL_EFI_LIBRARY_INSTANCE,
40 TAB_LIBRARY_CLASSES.upper() : MODEL_EFI_LIBRARY_CLASS,
41 TAB_PCDS_FIXED_AT_BUILD_NULL.upper() : MODEL_PCD_FIXED_AT_BUILD,
42 TAB_PCDS_PATCHABLE_IN_MODULE_NULL.upper() : MODEL_PCD_PATCHABLE_IN_MODULE,
43 TAB_PCDS_FEATURE_FLAG_NULL.upper() : MODEL_PCD_FEATURE_FLAG,
44 TAB_PCDS_DYNAMIC_EX_NULL.upper() : MODEL_PCD_DYNAMIC_EX,
45 TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_EX_DEFAULT,
46 TAB_PCDS_DYNAMIC_EX_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_EX_VPD,
47 TAB_PCDS_DYNAMIC_EX_HII_NULL.upper() : MODEL_PCD_DYNAMIC_EX_HII,
48 TAB_PCDS_DYNAMIC_NULL.upper() : MODEL_PCD_DYNAMIC,
49 TAB_PCDS_DYNAMIC_DEFAULT_NULL.upper() : MODEL_PCD_DYNAMIC_DEFAULT,
50 TAB_PCDS_DYNAMIC_VPD_NULL.upper() : MODEL_PCD_DYNAMIC_VPD,
51 TAB_PCDS_DYNAMIC_HII_NULL.upper() : MODEL_PCD_DYNAMIC_HII,
52 TAB_COMPONENTS.upper() : MODEL_META_DATA_COMPONENT,
53 TAB_USER_EXTENSIONS.upper() : MODEL_META_DATA_USER_EXTENSION
54 }
55
56 ## DscObject
57 #
58 # This class defined basic Dsc object which is used by inheriting
59 #
60 # @param object: Inherited from object class
61 #
62 class DscObject(object):
63 def __init__(self):
64 object.__init__()
65
66 ## Dsc
67 #
68 # This class defined the structure used in Dsc object
69 #
70 # @param DscObject: Inherited from InfObject class
71 # @param Ffilename: Input value for Ffilename of Inf file, default is None
72 # @param IsMergeAllArches: Input value for IsMergeAllArches
73 # True is to merge all arches
74 # Fales is not to merge all arches
75 # default is False
76 # @param IsToPlatform: Input value for IsToPlatform
77 # True is to transfer to ModuleObject automatically
78 # False is not to transfer to ModuleObject automatically
79 # default is False
80 # @param WorkspaceDir: Input value for current workspace directory, default is None
81 #
82 # @var _NullClassIndex: To store value for _NullClassIndex, default is 0
83 # @var Identification: To store value for Identification, it is a structure as Identification
84 # @var Defines: To store value for Defines, it is a structure as DscDefines
85 # @var Contents: To store value for Contents, it is a structure as DscContents
86 # @var UserExtensions: To store value for UserExtensions
87 # @var Platform: To store value for Platform, it is a structure as PlatformClass
88 # @var WorkspaceDir: To store value for WorkspaceDir
89 # @var KeyList: To store value for KeyList, a list for all Keys used in Dec
90 #
91 class Dsc(DscObject):
92 _NullClassIndex = 0
93
94 def __init__(self, Filename = None, IsToDatabase = False, IsToPlatform = False, WorkspaceDir = None, Database = None):
95 self.Identification = Identification()
96 self.Platform = PlatformClass()
97 self.UserExtensions = ''
98 self.WorkspaceDir = WorkspaceDir
99 self.IsToDatabase = IsToDatabase
100
101 self.Cur = Database.Cur
102 self.TblFile = Database.TblFile
103 self.TblDsc = Database.TblDsc
104
105
106 self.KeyList = [
107 TAB_SKUIDS, TAB_LIBRARIES, TAB_LIBRARY_CLASSES, TAB_BUILD_OPTIONS, TAB_PCDS_FIXED_AT_BUILD_NULL, \
108 TAB_PCDS_PATCHABLE_IN_MODULE_NULL, TAB_PCDS_FEATURE_FLAG_NULL, \
109 TAB_PCDS_DYNAMIC_DEFAULT_NULL, TAB_PCDS_DYNAMIC_HII_NULL, TAB_PCDS_DYNAMIC_VPD_NULL, \
110 TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL, TAB_PCDS_DYNAMIC_EX_VPD_NULL, \
111 TAB_COMPONENTS, TAB_DSC_DEFINES
112 ]
113
114 self.PcdToken = {}
115
116 #
117 # Upper all KEYs to ignore case sensitive when parsing
118 #
119 self.KeyList = map(lambda c: c.upper(), self.KeyList)
120
121 #
122 # Init RecordSet
123 #
124 # self.RecordSet = {}
125 # for Key in self.KeyList:
126 # self.RecordSet[Section[Key]] = []
127
128 #
129 # Load Dsc file if filename is not None
130 #
131 if Filename != None:
132 self.LoadDscFile(Filename)
133
134 #
135 # Transfer to Platform Object if IsToPlatform is True
136 #
137 if IsToPlatform:
138 self.DscToPlatform()
139
140 ## Transfer to Platform Object
141 #
142 # Transfer all contents of an Inf file to a standard Module Object
143 #
144 def DscToPlatform(self):
145 #
146 # Init global information for the file
147 #
148 ContainerFile = self.Identification.FileFullPath
149
150 #
151 # Generate Platform Header
152 #
153 self.GenPlatformHeader(ContainerFile)
154
155 #
156 # Generate BuildOptions
157 #
158 self.GenBuildOptions(ContainerFile)
159
160 #
161 # Generate SkuInfos
162 #
163 self.GenSkuInfos(ContainerFile)
164
165 #
166 # Generate Libraries
167 #
168 self.GenLibraries(ContainerFile)
169
170 #
171 # Generate LibraryClasses
172 #
173 self.GenLibraryClasses(ContainerFile)
174
175 #
176 # Generate Pcds
177 #
178 self.GenPcds(DataType.TAB_PCDS_FIXED_AT_BUILD, ContainerFile)
179 self.GenPcds(DataType.TAB_PCDS_PATCHABLE_IN_MODULE, ContainerFile)
180 self.GenFeatureFlagPcds(DataType.TAB_PCDS_FEATURE_FLAG, ContainerFile)
181 self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_DEFAULT, ContainerFile)
182 self.GenDynamicDefaultPcds(DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT, ContainerFile)
183 self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_HII, ContainerFile)
184 self.GenDynamicHiiPcds(DataType.TAB_PCDS_DYNAMIC_EX_HII, ContainerFile)
185 self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_VPD, ContainerFile)
186 self.GenDynamicVpdPcds(DataType.TAB_PCDS_DYNAMIC_EX_VPD, ContainerFile)
187
188 #
189 # Generate Components
190 #
191 self.GenComponents(ContainerFile)
192
193 #
194 # Update to database
195 #
196 if self.IsToDatabase:
197 for Key in self.PcdToken.keys():
198 SqlCommand = """update %s set Value2 = '%s' where ID = %s""" % (self.TblDsc.Table, ".".join((self.PcdToken[Key][0], self.PcdToken[Key][1])), Key)
199 self.TblDsc.Exec(SqlCommand)
200 #End of DscToPlatform
201
202 ## Get Platform Header
203 #
204 # Gen Platform Header of Dsc as <Key> = <Value>
205 #
206 # @param ContainerFile: The Dsc file full path
207 #
208 def GenPlatformHeader(self, ContainerFile):
209 EdkLogger.debug(2, "Generate PlatformHeader ...")
210 #
211 # Update all defines item in database
212 #
213 SqlCommand = """select ID, Value1, Arch, StartLine from %s
214 where Model = %s
215 and BelongsToFile = %s
216 and Enabled > -1""" % (self.TblDsc.Table, MODEL_META_DATA_HEADER, self.FileID)
217 RecordSet = self.TblDsc.Exec(SqlCommand)
218 for Record in RecordSet:
219 ValueList = GetSplitValueList(Record[1], TAB_EQUAL_SPLIT)
220 if len(ValueList) != 2:
221 RaiseParserError(Record[1], 'Defines', ContainerFile, '<Key> = <Value>', Record[3])
222 ID, Value1, Value2, Arch = Record[0], ValueList[0], ValueList[1], Record[2]
223 SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
224 where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Value1), ConvertToSqlString2(Value2), ID)
225 self.TblDsc.Exec(SqlCommand)
226
227 #
228 # Get detailed information
229 #
230 for Arch in DataType.ARCH_LIST:
231 PlatformHeader = PlatformHeaderClass()
232
233 PlatformHeader.Name = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_NAME, Arch, self.FileID)[0]
234 PlatformHeader.Guid = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_GUID, Arch, self.FileID)[0]
235 PlatformHeader.Version = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_VERSION, Arch, self.FileID)[0]
236 PlatformHeader.FileName = self.Identification.FileName
237 PlatformHeader.FullPath = self.Identification.FileFullPath
238 PlatformHeader.DscSpecification = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_DSC_SPECIFICATION, Arch, self.FileID)[0]
239
240 PlatformHeader.SkuIdName = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_SKUID_IDENTIFIER, Arch, self.FileID)
241 PlatformHeader.SupArchList = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES, Arch, self.FileID)
242 PlatformHeader.BuildTargets = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BUILD_TARGETS, Arch, self.FileID)
243 PlatformHeader.OutputDirectory = NormPath(QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_OUTPUT_DIRECTORY, Arch, self.FileID)[0])
244 PlatformHeader.BuildNumber = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BUILD_NUMBER, Arch, self.FileID)[0]
245 PlatformHeader.MakefileName = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_MAKEFILE_NAME, Arch, self.FileID)[0]
246
247 PlatformHeader.BsBaseAddress = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BS_BASE_ADDRESS, Arch, self.FileID)[0]
248 PlatformHeader.RtBaseAddress = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_RT_BASE_ADDRESS, Arch, self.FileID)[0]
249
250 self.Platform.Header[Arch] = PlatformHeader
251 Fdf = PlatformFlashDefinitionFileClass()
252 Fdf.FilePath = NormPath(QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_FLASH_DEFINITION, Arch, self.FileID)[0])
253 self.Platform.FlashDefinitionFile = Fdf
254
255 ## GenBuildOptions
256 #
257 # Gen BuildOptions of Dsc
258 # [<Family>:]<ToolFlag>=Flag
259 #
260 # @param ContainerFile: The Dsc file full path
261 #
262 def GenBuildOptions(self, ContainerFile):
263 EdkLogger.debug(2, "Generate %s ..." % TAB_BUILD_OPTIONS)
264 BuildOptions = {}
265 #
266 # Get all include files
267 #
268 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_BUILD_OPTION, self.FileID)
269
270 #
271 # Get all BuildOptions
272 #
273 RecordSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTION, -1, self.FileID)
274
275 #
276 # Go through each arch
277 #
278 for Arch in DataType.ARCH_LIST:
279 for IncludeFile in IncludeFiles:
280 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
281 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_BUILD_OPTIONS, '', IncludeFile[2])
282 for NewItem in open(Filename, 'r').readlines():
283 if CleanString(NewItem) == '':
284 continue
285 (Family, ToolChain, Flag) = GetBuildOption(NewItem, Filename, -1)
286 MergeArches(BuildOptions, (Family, ToolChain, Flag), Arch)
287
288 for Record in RecordSet:
289 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
290 (Family, ToolChain, Flag) = GetBuildOption(Record[0], ContainerFile, Record[2])
291 MergeArches(BuildOptions, (Family, ToolChain, Flag), Arch)
292 #
293 # Update to Database
294 #
295 if self.IsToDatabase:
296 SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
297 where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), ConvertToSqlString2(Flag), Record[3])
298 self.TblDsc.Exec(SqlCommand)
299
300 for Key in BuildOptions.keys():
301 BuildOption = BuildOptionClass(Key[0], Key[1], Key[2])
302 BuildOption.SupArchList = BuildOptions[Key]
303 self.Platform.BuildOptions.BuildOptionList.append(BuildOption)
304
305 ## GenSkuInfos
306 #
307 # Gen SkuInfos of Dsc
308 # <Integer>|<UiName>
309 #
310 # @param ContainerFile: The Dsc file full path
311 #
312 def GenSkuInfos(self, ContainerFile):
313 EdkLogger.debug(2, "Generate %s ..." % TAB_SKUIDS)
314 #
315 # SkuIds
316 # <Integer>|<UiName>
317 #
318 self.Platform.SkuInfos.SkuInfoList['DEFAULT'] = '0'
319
320 #
321 # Get all include files
322 #
323 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_SKU_ID, self.FileID)
324
325 #
326 # Get all SkuInfos
327 #
328 RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_SKU_ID, -1, self.FileID)
329
330 #
331 # Go through each arch
332 #
333 for Arch in DataType.ARCH_LIST:
334 for IncludeFile in IncludeFiles:
335 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
336 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_SKUIDS, '', IncludeFile[2])
337 for NewItem in open(Filename, 'r').readlines():
338 if CleanString(NewItem) == '':
339 continue
340 List = GetSplitValueList(NewItem)
341 if len(List) != 2:
342 RaiseParserError(NewItem, TAB_SKUIDS, Filename, '<Integer>|<UiName>')
343 else:
344 self.Platform.SkuInfos.SkuInfoList[List[1]] = List[0]
345
346 for Record in RecordSet:
347 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
348 List = GetSplitValueList(Record[0])
349 if len(List) != 2:
350 RaiseParserError(Record[0], TAB_SKUIDS, ContainerFile, '<Integer>|<UiName>')
351 else:
352 self.Platform.SkuInfos.SkuInfoList[List[1]] = List[0]
353 #
354 # Update to Database
355 #
356 if self.IsToDatabase:
357 SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
358 where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), Record[3])
359 self.TblDsc.Exec(SqlCommand)
360
361 ## GenLibraries
362 #
363 # Gen Libraries of Dsc
364 # <PathAndFilename>
365 #
366 # @param ContainerFile: The Dsc file full path
367 #
368 def GenLibraries(self, ContainerFile):
369 EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARIES)
370 Libraries = {}
371 #
372 # Get all include files
373 #
374 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_INSTANCE, self.FileID)
375
376 #
377 # Get all Libraries
378 #
379 RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_INSTANCE, -1, self.FileID)
380
381 #
382 # Go through each arch
383 #
384 for Arch in DataType.ARCH_LIST:
385 for IncludeFile in IncludeFiles:
386 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
387 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARIES, '', IncludeFile[2])
388 if os.path.exists(Filename):
389 for NewItem in open(Filename, 'r').readlines():
390 if CleanString(NewItem) == '':
391 continue
392 MergeArches(Libraries, NewItem, Arch)
393
394 for Record in RecordSet:
395 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
396 MergeArches(Libraries, Record[0], Arch)
397
398 for Key in Libraries.keys():
399 Library = PlatformLibraryClass()
400 Library.FilePath = NormPath(Key)
401 Library.SupArchList = Libraries[Key]
402 self.Platform.Libraries.LibraryList.append(Library)
403
404 ## GenLibraryClasses
405 #
406 # Get LibraryClasses of Dsc
407 # <LibraryClassKeyWord>|<LibraryInstance>
408 #
409 # @param ContainerFile: The Dsc file full path
410 #
411 def GenLibraryClasses(self, ContainerFile):
412 EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)
413 LibraryClasses = {}
414 #
415 # Get all include files
416 #
417 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_CLASS, self.FileID)
418
419 #
420 # Get all LibraryClasses
421 #
422 RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, -1, self.FileID)
423
424 #
425 # Go through each arch
426 #
427 for Arch in DataType.ARCH_LIST:
428 for IncludeFile in IncludeFiles:
429 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
430 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARY_CLASSES, '', IncludeFile[2])
431 for NewItem in open(Filename, 'r').readlines():
432 if CleanString(NewItem) == '':
433 continue
434 MergeArches(LibraryClasses, GetLibraryClass([NewItem, IncludeFile[4]], Filename, self.WorkspaceDir, -1), Arch)
435
436 for Record in RecordSet:
437 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
438 (LibClassName, LibClassIns, SupModelList) = GetLibraryClass([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
439 MergeArches(LibraryClasses, (LibClassName, LibClassIns, SupModelList), Arch)
440 #
441 # Update to Database
442 #
443 if self.IsToDatabase:
444 SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
445 where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])
446 self.TblDsc.Exec(SqlCommand)
447
448 for Key in LibraryClasses.keys():
449 Library = PlatformLibraryClass()
450 Library.Name = Key[0]
451 Library.FilePath = NormPath(Key[1])
452 Library.SupModuleList = GetSplitValueList(Key[2])
453 Library.SupArchList = LibraryClasses[Key]
454 self.Platform.LibraryClasses.LibraryList.append(Library)
455
456 ## Gen Pcds
457 #
458 # Gen Pcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]
459 #
460 # @param Type: The type of Pcd
461 # @param ContainerFile: The file which describes the pcd, used for error report
462 #
463 def GenPcds(self, Type = '', ContainerFile = ''):
464 Pcds = {}
465 if Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:
466 Model = MODEL_PCD_PATCHABLE_IN_MODULE
467 elif Type == DataType.TAB_PCDS_FIXED_AT_BUILD:
468 Model = MODEL_PCD_FIXED_AT_BUILD
469 else:
470 pass
471 EdkLogger.debug(2, "Generate %s ..." % Type)
472
473 #
474 # Get all include files
475 #
476 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
477
478 #
479 # Get all Pcds
480 #
481 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
482
483 #
484 # Go through each arch
485 #
486 for Arch in DataType.ARCH_LIST:
487 for IncludeFile in IncludeFiles:
488 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
489 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
490 for NewItem in open(Filename, 'r').readlines():
491 if CleanString(NewItem) == '':
492 continue
493 (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(NewItem, Type, Filename, -1)
494 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)
495 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
496
497 for Record in RecordSet:
498 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
499 (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(Record[0], Type, ContainerFile, Record[2])
500 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)
501 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
502
503 for Key in Pcds:
504 Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], {}, [])
505 Pcd.SupArchList = Pcds[Key]
506 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
507
508 ## Gen FeatureFlagPcds
509 #
510 # Gen FeatureFlagPcds of Dsc file as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
511 #
512 # @param Type: The type of Pcd
513 # @param ContainerFile: The file which describes the pcd, used for error report
514 #
515 def GenFeatureFlagPcds(self, Type = '', ContainerFile = ''):
516 Pcds = {}
517 if Type == DataType.TAB_PCDS_FEATURE_FLAG:
518 Model = MODEL_PCD_FEATURE_FLAG
519 else:
520 pass
521 EdkLogger.debug(2, "Generate %s ..." % Type)
522
523 #
524 # Get all include files
525 #
526 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
527
528 #
529 # Get all FeatureFlagPcds
530 #
531 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
532
533 #
534 # Go through each arch
535 #
536 for Arch in DataType.ARCH_LIST:
537 for IncludeFile in IncludeFiles:
538 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
539 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
540 for NewItem in open(Filename, 'r').readlines():
541 if CleanString(NewItem) == '':
542 continue
543 (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(NewItem, Type, Filename, -1)
544 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)
545 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
546
547 for Record in RecordSet:
548 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
549 (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(Record[0], Type, ContainerFile, Record[2])
550 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)
551 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
552
553 for Key in Pcds:
554 Pcd = PcdClass(Key[0], '', Key[1], '', '', Key[2], Key[3], [], {}, [])
555 Pcd.SupArchList = Pcds[Key]
556 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
557
558 ## Gen DynamicDefaultPcds
559 #
560 # Gen DynamicDefaultPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<DatumTyp>[|<MaxDatumSize>]]
561 #
562 # @param Type: The type of Pcd
563 # @param ContainerFile: The file which describes the pcd, used for error report
564 #
565 def GenDynamicDefaultPcds(self, Type = '', ContainerFile = ''):
566 Pcds = {}
567 SkuInfoList = {}
568 if Type == DataType.TAB_PCDS_DYNAMIC_DEFAULT:
569 Model = MODEL_PCD_DYNAMIC_DEFAULT
570 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT:
571 Model = MODEL_PCD_DYNAMIC_EX_DEFAULT
572 else:
573 pass
574 EdkLogger.debug(2, "Generate %s ..." % Type)
575
576 #
577 # Get all include files
578 #
579 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
580
581 #
582 # Get all DynamicDefaultPcds
583 #
584 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
585
586 #
587 # Go through each arch
588 #
589 for Arch in DataType.ARCH_LIST:
590 for IncludeFile in IncludeFiles:
591 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
592 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
593 for NewItem in open(Filename, 'r').readlines():
594 if CleanString(NewItem) == '':
595 continue
596 (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(NewItem, Type, Filename, -1)
597 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, IncludeFile[4]), Arch)
598 self.PcdToken[Record[3]] = (K2, K1)
599
600 for Record in RecordSet:
601 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
602 (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(Record[0], Type, ContainerFile, Record[2])
603 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Record[4]), Arch)
604 self.PcdToken[Record[3]] = (K2, K1)
605
606 for Key in Pcds:
607 (Status, SkuInfoList) = self.GenSkuInfoList(Key[6], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2])
608 if Status == False:
609 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
610 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
611 Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], SkuInfoList, [])
612 Pcd.SupArchList = Pcds[Key]
613 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
614
615 ## Gen DynamicHiiPcds
616 #
617 # Gen DynamicHiiPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<String>|<VariableGuidCName>|<VariableOffset>[|<DefaultValue>[|<MaximumDatumSize>]]
618 #
619 # @param Type: The type of Pcd
620 # @param ContainerFile: The file which describes the pcd, used for error report
621 #
622 def GenDynamicHiiPcds(self, Type = '', ContainerFile = ''):
623 Pcds = {}
624 SkuInfoList = {}
625 if Type == DataType.TAB_PCDS_DYNAMIC_HII:
626 Model = MODEL_PCD_DYNAMIC_HII
627 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_HII:
628 Model = MODEL_PCD_DYNAMIC_EX_HII
629 else:
630 pass
631 EdkLogger.debug(2, "Generate %s ..." % Type)
632
633 #
634 # Get all include files
635 #
636 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
637
638 #
639 # Get all DynamicHiiPcds
640 #
641 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
642
643 #
644 # Go through each arch
645 #
646 for Arch in DataType.ARCH_LIST:
647 for IncludeFile in IncludeFiles:
648 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
649 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
650 for NewItem in open(Filename, 'r').readlines():
651 if CleanString(NewItem) == '':
652 continue
653 (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(NewItem, Type, Filename, -1)
654 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, IncludeFile[4]), Arch)
655 self.PcdToken[Record[3]] = (K2, K1)
656
657 for Record in RecordSet:
658 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
659 (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(Record[0], Type, ContainerFile, Record[2])
660 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, Record[4]), Arch)
661 self.PcdToken[Record[3]] = (K2, K1)
662
663 for Key in Pcds:
664 (Status, SkuInfoList) = self.GenSkuInfoList(Key[8], self.Platform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '')
665 if Status == False:
666 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
667 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
668 Pcd = PcdClass(Key[0], '', Key[1], '', Key[6], Key[5], Key[7], [], SkuInfoList, [])
669 Pcd.SupArchList = Pcds[Key]
670 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
671
672 ## Gen DynamicVpdPcds
673 #
674 # Gen DynamicVpdPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<VpdOffset>[|<MaximumDatumSize>]
675 #
676 # @param Type: The type of Pcd
677 # @param ContainerFile: The file which describes the pcd, used for error report
678 #
679 def GenDynamicVpdPcds(self, Type = '', ContainerFile = ''):
680 Pcds = {}
681 SkuInfoList = {}
682 if Type == DataType.TAB_PCDS_DYNAMIC_VPD:
683 Model = MODEL_PCD_DYNAMIC_VPD
684 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_VPD:
685 Model = MODEL_PCD_DYNAMIC_EX_VPD
686 else:
687 pass
688 EdkLogger.debug(2, "Generate %s ..." % Type)
689
690 #
691 # Get all include files
692 #
693 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
694
695 #
696 # Get all DynamicVpdPcds
697 #
698 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
699
700 #
701 # Go through each arch
702 #
703 for Arch in DataType.ARCH_LIST:
704 for IncludeFile in IncludeFiles:
705 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
706 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
707 for NewItem in open(Filename, 'r').readlines():
708 if CleanString(NewItem) == '':
709 continue
710 (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(NewItem, Type, Filename, -1)
711 MergeArches(Pcds, (K1, K2, K3, K4, K5, IncludeFile[4]), Arch)
712 self.PcdToken[Record[3]] = (K2, K1)
713
714 for Record in RecordSet:
715 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
716 (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(Record[0], Type, ContainerFile, Record[2])
717 MergeArches(Pcds, (K1, K2, K3, K4, K5, Record[4]), Arch)
718 self.PcdToken[Record[3]] = (K2, K1)
719
720 for Key in Pcds:
721 (Status, SkuInfoList) = self.GenSkuInfoList(Key[5], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '')
722 if Status == False:
723 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
724 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
725 Pcd = PcdClass(Key[0], '', Key[1], '', Key[3], '', Key[4], [], SkuInfoList, [])
726 Pcd.SupArchList = Pcds[Key]
727 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
728
729
730 ## Get Component
731 #
732 # Get Component section defined in Dsc file
733 #
734 # @param ContainerFile: The file which describes the Components, used for error report
735 #
736 # @retval PlatformModuleClass() A instance for PlatformModuleClass
737 #
738 def GenComponents(self, ContainerFile):
739 EdkLogger.debug(2, "Generate %s ..." % TAB_COMPONENTS)
740 Components = sdict()
741 #
742 # Get all include files
743 #
744 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_COMPONENT, self.FileID)
745
746 #
747 # Get all Components
748 #
749 RecordSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_COMPONENT, -1, self.FileID)
750
751 #
752 # Go through each arch
753 #
754 for Arch in DataType.ARCH_LIST:
755 for IncludeFile in IncludeFiles:
756 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
757 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_COMPONENTS, '', IncludeFile[2])
758 for NewItem in open(Filename, 'r').readlines():
759 if CleanString(NewItem) == '':
760 continue
761 NewItems = []
762 GetComponents(open(Filename, 'r').read(), TAB_COMPONENTS, NewItems, TAB_COMMENT_SPLIT)
763 for NewComponent in NewItems:
764 MergeArches(Components, self.GenComponent(NewComponent, Filename), Arch)
765
766 for Record in RecordSet:
767 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
768 Lib, Bo, Pcd = [], [], []
769
770 SubLibSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, Record[3], self.FileID)
771 for SubLib in SubLibSet:
772 Lib.append(TAB_VALUE_SPLIT.join([SubLib[0],SubLib[4]]))
773
774 SubBoSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTION, Record[3], self.FileID)
775 for SubBo in SubBoSet:
776 Bo.append(SubBo[0])
777
778 SubPcdSet1 = QueryDscItem(self.TblDsc, MODEL_PCD_FIXED_AT_BUILD, Record[3], self.FileID)
779 SubPcdSet2 = QueryDscItem(self.TblDsc, MODEL_PCD_PATCHABLE_IN_MODULE, Record[3], self.FileID)
780 SubPcdSet3 = QueryDscItem(self.TblDsc, MODEL_PCD_FEATURE_FLAG, Record[3], self.FileID)
781 SubPcdSet4 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_EX_DEFAULT, Record[3], self.FileID)
782 SubPcdSet5 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_DEFAULT, Record[3], self.FileID)
783 for SubPcd in SubPcdSet1:
784 Pcd.append([DataType.TAB_PCDS_FIXED_AT_BUILD, SubPcd[0], SubPcd[3]])
785 for SubPcd in SubPcdSet2:
786 Pcd.append([DataType.TAB_PCDS_PATCHABLE_IN_MODULE, SubPcd[0], SubPcd[3]])
787 for SubPcd in SubPcdSet3:
788 Pcd.append([DataType.TAB_PCDS_FEATURE_FLAG, SubPcd[0], SubPcd[3]])
789 for SubPcd in SubPcdSet4:
790 Pcd.append([DataType.TAB_PCDS_DYNAMIC_EX, SubPcd[0], SubPcd[3]])
791 for SubPcd in SubPcdSet5:
792 Pcd.append([DataType.TAB_PCDS_DYNAMIC, SubPcd[0], SubPcd[3]])
793 Item = [Record[0], Lib, Bo, Pcd]
794 MergeArches(Components, self.GenComponent(Item, ContainerFile), Arch)
795
796 for Key in Components.keys():
797 Key.SupArchList = Components[Key]
798 self.Platform.Modules.ModuleList.append(Key)
799
800 ## Get Component
801 #
802 # Get Component section defined in Dsc file
803 #
804 # @param Item: Contents includes a component block
805 # @param ContainerFile: The file which describes the library class, used for error report
806 #
807 # @retval PlatformModuleClass() A instance for PlatformModuleClass
808 #
809 def GenComponent(self, Item, ContainerFile, LineNo = -1):
810 (InfFilename, ExecFilename) = GetExec(Item[0])
811 LibraryClasses = Item[1]
812 BuildOptions = Item[2]
813 Pcds = Item[3]
814 Component = PlatformModuleClass()
815 Component.FilePath = NormPath(InfFilename)
816 Component.ExecFilePath = NormPath(ExecFilename)
817 CheckFileType(Component.FilePath, '.Inf', ContainerFile, 'component name', Item[0], LineNo)
818 CheckFileExist(self.WorkspaceDir, Component.FilePath, ContainerFile, 'component', Item[0], LineNo)
819 for Lib in LibraryClasses:
820 List = GetSplitValueList(Lib)
821 if len(List) != 2:
822 RaiseParserError(Lib, 'LibraryClasses', ContainerFile, '<ClassName>|<InfFilename>')
823 LibName = List[0]
824 LibFile = NormPath(List[1])
825 if LibName == "" or LibName == "NULL":
826 LibName = "NULL%d" % self._NullClassIndex
827 self._NullClassIndex += 1
828 CheckFileType(List[1], '.Inf', ContainerFile, 'library instance of component ', Lib, LineNo)
829 CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'library instance of component', Lib, LineNo)
830 Component.LibraryClasses.LibraryList.append(PlatformLibraryClass(LibName, LibFile))
831 for BuildOption in BuildOptions:
832 Key = GetBuildOption(BuildOption, ContainerFile)
833 Component.ModuleSaBuildOption.BuildOptionList.append(BuildOptionClass(Key[0], Key[1], Key[2]))
834 for Pcd in Pcds:
835 Type = Pcd[0]
836 List = GetSplitValueList(Pcd[1])
837 PcdId = Pcd[2]
838
839 TokenInfo = None
840 #
841 # For FeatureFlag
842 #
843 if Type == DataType.TAB_PCDS_FEATURE_FLAG:
844 if len(List) != 2:
845 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|TRUE/FALSE')
846
847 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
848 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
849 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', List[1], Type, [], {}, []))
850 #
851 # For FixedAtBuild or PatchableInModule
852 #
853 if Type == DataType.TAB_PCDS_FIXED_AT_BUILD or Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:
854 List.append('')
855 if len(List) != 3 and len(List) != 4:
856 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|<Value>[|<MaxDatumSize>]')
857
858 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
859 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
860 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', List[2], List[1], Type, [], {}, []))
861
862 #
863 # For Dynamic or DynamicEx
864 #
865 if Type == DataType.TAB_PCDS_DYNAMIC or Type == DataType.TAB_PCDS_DYNAMIC_EX:
866 if len(List) != 1:
867 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>')
868
869 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
870 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
871 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', '', Type, [], {}, []))
872
873 #
874 # Add to PcdToken
875 #
876 self.PcdToken[PcdId] = (TokenInfo[0], TokenInfo[1])
877
878 return Component
879 #End of GenComponent
880
881 ## Gen SkuInfoList
882 #
883 # Gen SkuInfoList section defined in Dsc file
884 #
885 # @param SkuNameList: Input value for SkuNameList
886 # @param SkuInfo: Input value for SkuInfo
887 # @param VariableName: Input value for VariableName
888 # @param VariableGuid: Input value for VariableGuid
889 # @param VariableOffset: Input value for VariableOffset
890 # @param HiiDefaultValue: Input value for HiiDefaultValue
891 # @param VpdOffset: Input value for VpdOffset
892 # @param DefaultValue: Input value for DefaultValue
893 #
894 # @retval (False, SkuName) Not found in section SkuId Dsc file
895 # @retval (True, SkuInfoList) Found in section SkuId of Dsc file
896 #
897 def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName = '', VariableGuid = '', VariableOffset = '', HiiDefaultValue = '', VpdOffset = '', DefaultValue = ''):
898 SkuNameList = GetSplitValueList(SkuNameList)
899 if SkuNameList == None or SkuNameList == [] or SkuNameList == ['']:
900 SkuNameList = ['DEFAULT']
901 SkuInfoList = {}
902 for Item in SkuNameList:
903 if Item not in SkuInfo:
904 return False, Item
905 Sku = SkuInfoClass(Item, SkuInfo[Item], VariableName, VariableGuid, VariableOffset, HiiDefaultValue, VpdOffset, DefaultValue)
906 SkuInfoList[Item] = Sku
907
908 return True, SkuInfoList
909
910 ## Parse Include statement
911 #
912 # Get include file path
913 #
914 # 1. Insert a record into TblFile ???
915 # 2. Insert a record into TblDsc
916 # Value1: IncludeFilePath
917 #
918 # @param LineValue: The line of incude statement
919 def ParseInclude(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
920 EdkLogger.debug(EdkLogger.DEBUG_2, "!include statement '%s' found in section %s" % (LineValue, SectionName))
921 SectionModel = Section[SectionName.upper()]
922 IncludeFile = CleanString(LineValue[LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ])
923 Table.Insert(Model, IncludeFile, '', '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)
924
925 ## Parse DEFINE statement
926 #
927 # Get DEFINE macros
928 #
929 # 1. Insert a record into TblDsc
930 # Value1: Macro Name
931 # Value2: Macro Value
932 #
933 def ParseDefine(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
934 EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in section %s" % (LineValue, SectionName))
935 SectionModel = Section[SectionName.upper()]
936 Define = GetSplitValueList(CleanString(LineValue[LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' ') : ]), TAB_EQUAL_SPLIT, 1)
937 Table.Insert(Model, Define[0], Define[1], '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)
938
939 ## Parse Defines section
940 #
941 # Get one item in defines section
942 #
943 # Value1: Item Name
944 # Value2: Item Value
945 #
946 def ParseDefinesSection(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
947 EdkLogger.debug(EdkLogger.DEBUG_2, "Parse '%s' found in section %s" % (LineValue, SectionName))
948 Defines = GetSplitValueList(LineValue, TAB_EQUAL_SPLIT, 1)
949 if len(Defines) != 2:
950 RaiseParserError(LineValue, SectionName, Filename, '', StartLine)
951 self.TblDsc.Insert(Model, Defines[0], Defines[1], '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
952
953 ## Insert conditional statements
954 #
955 # Pop an item from IfDefList
956 # Insert conditional statements to database
957 #
958 # @param Filename: Path of parsing file
959 # @param IfDefList: A list stored current conditional statements
960 # @param EndLine: The end line no
961 # @param ArchList: Support arch list
962 #
963 def InsertConditionalStatement(self, Filename, FileID, BelongsToItem, IfDefList, EndLine, ArchList):
964 (Value1, Value2, Value3, Model, StartColumn, EndColumn, Enabled) = ('', '', '', -1, -1, -1, 0)
965 if IfDefList == []:
966 ErrorMsg = 'Not suited conditional statement in file %s' % Filename
967 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError = EdkLogger.IsRaiseError)
968 else:
969 #
970 # Get New Dsc item ID
971 #
972 DscID = self.TblDsc.GetCount() + 1
973
974 #
975 # Pop the conditional statements which is closed
976 #
977 PreviousIf = IfDefList.pop()
978 EdkLogger.debug(EdkLogger.DEBUG_5, 'Previous IfDef: ' + str(PreviousIf))
979
980 #
981 # !ifdef and !ifndef
982 #
983 if PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF):
984 Value1 = PreviousIf[0]
985 Model = PreviousIf[2]
986 self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
987 #
988 # !if and !elseif
989 #
990 elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, Model):
991 List = PreviousIf[0].split(' ')
992 Value1, Value2, Value3 = '', '==', '0'
993 if len(List) == 3:
994 Value1 = List[0]
995 Value2 = List[1]
996 Value3 = List[2]
997 Value3 = SplitString(Value3)
998 if len(List) == 1:
999 Value1 = List[0]
1000 Model = PreviousIf[2]
1001 self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
1002 #
1003 # !else
1004 #
1005 elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, Model):
1006 Value1 = PreviousIf[0].strip()
1007 Model = PreviousIf[2]
1008 self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
1009
1010 ## Load Dsc file
1011 #
1012 # Load the file if it exists
1013 #
1014 # @param Filename: Input value for filename of Dsc file
1015 #
1016 def LoadDscFile(self, Filename):
1017 #
1018 # Insert a record for file
1019 #
1020 Filename = NormPath(Filename)
1021 self.Identification.FileFullPath = Filename
1022 (self.Identification.FileRelativePath, self.Identification.FileName) = os.path.split(Filename)
1023 self.FileID = self.TblFile.InsertFile(Filename, MODEL_FILE_DSC)
1024
1025 #
1026 # Init DscTable
1027 #
1028 #self.TblDsc.Table = "Dsc%s" % FileID
1029 #self.TblDsc.Create()
1030
1031 #
1032 # Init common datas
1033 #
1034 IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \
1035 [], [], TAB_UNKNOWN, [], [], []
1036 LineNo = 0
1037
1038 #
1039 # Parse file content
1040 #
1041 IsFindBlockComment = False
1042 ReservedLine = ''
1043 for Line in open(Filename, 'r'):
1044 LineNo = LineNo + 1
1045 #
1046 # Remove comment block
1047 #
1048 if Line.find(TAB_COMMENT_EDK_START) > -1:
1049 ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]
1050 IsFindBlockComment = True
1051 if Line.find(TAB_COMMENT_EDK_END) > -1:
1052 Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]
1053 ReservedLine = ''
1054 IsFindBlockComment = False
1055 if IsFindBlockComment:
1056 continue
1057
1058 #
1059 # Remove comments at tail and remove spaces again
1060 #
1061 Line = CleanString(Line)
1062 if Line == '':
1063 continue
1064
1065 #
1066 # Find a new section tab
1067 # First insert previous section items
1068 # And then parse the content of the new section
1069 #
1070 if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SECTION_END):
1071 #
1072 # Insert items data of previous section
1073 #
1074 self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)
1075 #
1076 # Parse the new section
1077 #
1078 SectionItemList = []
1079 ArchList = []
1080 ThirdList = []
1081
1082 CurrentSection = ''
1083 LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
1084 for Item in LineList:
1085 ItemList = GetSplitValueList(Item, TAB_SPLIT)
1086 if CurrentSection == '':
1087 CurrentSection = ItemList[0]
1088 else:
1089 if CurrentSection != ItemList[0]:
1090 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)
1091 if CurrentSection.upper() not in self.KeyList:
1092 RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
1093 CurrentSection = TAB_UNKNOWN
1094 continue
1095 ItemList.append('')
1096 ItemList.append('')
1097 if len(ItemList) > 5:
1098 RaiseParserError(Line, CurrentSection, Filename, '', LineNo)
1099 else:
1100 if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:
1101 EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
1102 ArchList.append(ItemList[1].upper())
1103 ThirdList.append(ItemList[2])
1104
1105 continue
1106
1107 #
1108 # Not in any defined section
1109 #
1110 if CurrentSection == TAB_UNKNOWN:
1111 ErrorMsg = "%s is not in any defined section" % Line
1112 EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)
1113
1114 #
1115 # Add a section item
1116 #
1117 SectionItemList.append([Line, LineNo])
1118 # End of parse
1119 #End of For
1120
1121 #
1122 # Insert items data of last section
1123 #
1124 self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)
1125
1126 #
1127 # Parse conditional statements
1128 #
1129 self.ParseConditionalStatement()
1130
1131 #
1132 # Replace all DEFINE macros with its actual values
1133 #
1134 #ParseDefineMacro2(self.TblDsc, self.RecordSet, GlobalData.gGlobalDefines)
1135 ParseDefineMacro(self.TblDsc, GlobalData.gGlobalDefines)
1136
1137
1138 ## ParseConditionalStatement
1139 #
1140 # Search all conditional statement and disable no match records
1141 #
1142 def ParseConditionalStatement(self):
1143 #
1144 # Disabled all !if/!elif/!ifdef statements without DEFINE
1145 #
1146 SqlCommand = """select A.StartLine, A.EndLine from %s as A
1147 where A.Model in (%s, %s, %s)
1148 and A.Enabled = 0
1149 and A.BelongsToFile = %s
1150 and A.Value1 not in (select B.Value1 from %s as B
1151 where B.Model = %s
1152 and B.Enabled = 0
1153 and A.StartLine > B.StartLine
1154 and A.Arch = B.Arch
1155 and A.BelongsToItem = B.BelongsToItem
1156 and A.BelongsToFile = B.BelongsToFile) """ % \
1157 (self.TblDsc.Table, \
1158 MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, \
1159 self.FileID, \
1160 self.TblDsc.Table, \
1161 MODEL_META_DATA_DEFINE)
1162 RecordSet = self.TblDsc.Exec(SqlCommand)
1163 for Record in RecordSet:
1164 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])
1165 self.TblDsc.Exec(SqlCommand)
1166
1167 #
1168 # Disabled !ifndef with DEFINE
1169 #
1170 SqlCommand = """select A.StartLine, A.EndLine from %s as A
1171 where A.Model = %s
1172 and A.Enabled = 0
1173 and A.BelongsToFile = %s
1174 and A.Value1 in (select B.Value1 from %s as B
1175 where B.Model = %s
1176 and B.Enabled = 0
1177 and A.StartLine > B.StartLine
1178 and A.Arch = B.Arch
1179 and A.BelongsToItem = B.BelongsToItem
1180 and A.BelongsToFile = B.BelongsToFile)""" % \
1181 (self.TblDsc.Table, \
1182 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF, \
1183 self.FileID, \
1184 self.TblDsc.Table, \
1185 MODEL_META_DATA_DEFINE)
1186 RecordSet = self.TblDsc.Exec(SqlCommand)
1187 for Record in RecordSet:
1188 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])
1189 EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)
1190 self.Cur.execute(SqlCommand)
1191
1192 #
1193 # Disabled !if, !elif and !else with un-match value
1194 #
1195 SqlCommand = """select A.Model, A.Value1, A.Value2, A.Value3, A.StartLine, A.EndLine, B.Value2 from %s as A join %s as B
1196 where A.Model in (%s, %s)
1197 and A.Enabled = 0
1198 and A.BelongsToFile = %s
1199 and B.Enabled = 0
1200 and B.Model = %s
1201 and A.Value1 = B.Value1
1202 and A.StartLine > B.StartLine
1203 and A.BelongsToItem = B.BelongsToItem
1204 and A.BelongsToFile = B.BelongsToFile""" % \
1205 (self.TblDsc.Table, self.TblDsc.Table, \
1206 MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, \
1207 self.FileID, MODEL_META_DATA_DEFINE)
1208 RecordSet = self.TblDsc.Exec(SqlCommand)
1209 DisabledList = []
1210 for Record in RecordSet:
1211 if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_IF:
1212 if not self.Compare(Record[6], Record[2], Record[3]):
1213 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])
1214 self.TblDsc.Exec(SqlCommand)
1215 else:
1216 DisabledList.append(Record[1])
1217 continue
1218 if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE and Record[1] in DisabledList:
1219 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])
1220 self.TblDsc.Exec(SqlCommand)
1221
1222 ## Compare
1223 #
1224 # Compare two values
1225 # @param Value1:
1226 # @param CompareType:
1227 # @param Value2:
1228 #
1229 def Compare(self, Value1, CompareType, Value2):
1230 Command = """Value1 %s Value2""" %CompareType
1231 return eval(Command)
1232
1233 ## First time to insert records to database
1234 #
1235 # Insert item data of a section to database
1236 # @param FileID: The ID of belonging file
1237 # @param Filename: The name of belonging file
1238 # @param CurrentSection: The name of currect section
1239 # @param SectionItemList: A list of items of the section
1240 # @param ArchList: A list of arches
1241 # @param ThirdList: A list of third parameters, ModuleType for LibraryClass and SkuId for Dynamic Pcds
1242 # @param IfDefList: A list of all conditional statements
1243 #
1244 def InsertSectionItemsIntoDatabase(self, FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList):
1245 #
1246 # Insert each item data of a section
1247 #
1248 for Index in range(0, len(ArchList)):
1249 Arch = ArchList[Index]
1250 Third = ThirdList[Index]
1251 if Arch == '':
1252 Arch = TAB_ARCH_COMMON.upper()
1253
1254 Model = Section[CurrentSection.upper()]
1255 #Records = self.RecordSet[Model]
1256
1257 for SectionItem in SectionItemList:
1258 BelongsToItem, EndLine, EndColumn = -1, -1, -1
1259 LineValue, StartLine, EndLine = SectionItem[0], SectionItem[1], SectionItem[1]
1260
1261
1262 EdkLogger.debug(4, "Parsing %s ..." %LineValue)
1263 #
1264 # Parse '!ifdef'
1265 #
1266 if LineValue.upper().find(TAB_IF_DEF.upper()) > -1:
1267 IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF))
1268 continue
1269
1270 #
1271 # Parse '!ifndef'
1272 #
1273 if LineValue.upper().find(TAB_IF_N_DEF.upper()) > -1:
1274 IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF))
1275 continue
1276
1277 #
1278 # Parse '!endif'
1279 #
1280 if LineValue.upper().find(TAB_END_IF.upper()) > -1:
1281 self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine, Arch)
1282 continue
1283 #
1284 # Parse '!if'
1285 #
1286 if LineValue.upper().find(TAB_IF.upper()) > -1:
1287 IfDefList.append((LineValue[len(TAB_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))
1288 continue
1289
1290 #
1291 # Parse '!elseif'
1292 #
1293 if LineValue.upper().find(TAB_ELSE_IF.upper()) > -1:
1294 self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine - 1, Arch)
1295 IfDefList.append((LineValue[len(TAB_ELSE_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))
1296 continue
1297
1298 #
1299 # Parse '!else'
1300 #
1301 if LineValue.upper().find(TAB_ELSE.upper()) > -1:
1302 Key = IfDefList[-1][0].split(' ' , 1)[0].strip()
1303 self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine, Arch)
1304 IfDefList.append((Key, StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE))
1305 continue
1306
1307 #
1308 # Parse !include statement first
1309 #
1310 if LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') > -1:
1311 self.ParseInclude(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_INCLUDE, Arch)
1312 continue
1313
1314 #
1315 # And then parse DEFINE statement
1316 #
1317 if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') > -1:
1318 self.ParseDefine(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_DEFINE, Arch)
1319 continue
1320
1321 #
1322 # At last parse other sections
1323 #
1324 if CurrentSection == TAB_LIBRARY_CLASSES or CurrentSection in TAB_PCD_DYNAMIC_TYPE_LIST or CurrentSection in TAB_PCD_DYNAMIC_EX_TYPE_LIST:
1325 ID = self.TblDsc.Insert(Model, LineValue, Third, '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
1326 #Records.append([LineValue, Arch, StartLine, ID, Third])
1327 continue
1328 elif CurrentSection != TAB_COMPONENTS:
1329 ID = self.TblDsc.Insert(Model, LineValue, '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
1330 #Records.append([LineValue, Arch, StartLine, ID, Third])
1331 continue
1332
1333 #
1334 # Parse COMPONENT section
1335 #
1336 if CurrentSection == TAB_COMPONENTS:
1337 Components = []
1338 GetComponent(SectionItemList, Components)
1339 for Component in Components:
1340 EdkLogger.debug(4, "Parsing component %s ..." %Component)
1341 DscItmeID = self.TblDsc.Insert(MODEL_META_DATA_COMPONENT, Component[0], '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
1342 for Item in Component[1]:
1343 List = GetSplitValueList(Item, MaxSplit = 2)
1344 LibName, LibIns = '', ''
1345 if len(List) == 2:
1346 LibName = List[0]
1347 LibIns = List[1]
1348 else:
1349 LibName = List[0]
1350 self.TblDsc.Insert(MODEL_EFI_LIBRARY_CLASS, LibName, LibIns, '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
1351 for Item in Component[2]:
1352 self.TblDsc.Insert(MODEL_META_DATA_BUILD_OPTION, Item, '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
1353 for Item in Component[3]:
1354 Model = Section[Item[0].upper()]
1355 self.TblDsc.Insert(Model, Item[1], '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
1356
1357 ## Show detailed information of Dsc
1358 #
1359 # Print all members and their values of Dsc class
1360 #
1361 def ShowDsc(self):
1362 print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END
1363 printDict(self.Defines.DefinesDictionary)
1364
1365 for Key in self.KeyList:
1366 for Arch in DataType.ARCH_LIST_FULL:
1367 Command = "printList(TAB_SECTION_START + '" + \
1368 Key + DataType.TAB_SPLIT + Arch + \
1369 "' + TAB_SECTION_END, self.Contents[arch]." + Key + ')'
1370 eval(Command)
1371
1372 ## Show detailed information of Platform
1373 #
1374 # Print all members and their values of Platform class
1375 #
1376 def ShowPlatform(self):
1377 M = self.Platform
1378 for Arch in M.Header.keys():
1379 print '\nArch =', Arch
1380 print 'Filename =', M.Header[Arch].FileName
1381 print 'FullPath =', M.Header[Arch].FullPath
1382 print 'BaseName =', M.Header[Arch].Name
1383 print 'Guid =', M.Header[Arch].Guid
1384 print 'Version =', M.Header[Arch].Version
1385 print 'DscSpecification =', M.Header[Arch].DscSpecification
1386 print 'SkuId =', M.Header[Arch].SkuIdName
1387 print 'SupArchList =', M.Header[Arch].SupArchList
1388 print 'BuildTargets =', M.Header[Arch].BuildTargets
1389 print 'OutputDirectory =', M.Header[Arch].OutputDirectory
1390 print 'BuildNumber =', M.Header[Arch].BuildNumber
1391 print 'MakefileName =', M.Header[Arch].MakefileName
1392 print 'BsBaseAddress =', M.Header[Arch].BsBaseAddress
1393 print 'RtBaseAddress =', M.Header[Arch].RtBaseAddress
1394 print 'Define =', M.Header[Arch].Define
1395 print 'Fdf =', M.FlashDefinitionFile.FilePath
1396 print '\nBuildOptions =', M.BuildOptions, M.BuildOptions.IncludeFiles
1397 for Item in M.BuildOptions.BuildOptionList:
1398 print '\t', 'ToolChainFamily =', Item.ToolChainFamily, 'ToolChain =', Item.ToolChain, 'Option =', Item.Option, 'Arch =', Item.SupArchList
1399 print '\nSkuIds =', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFiles
1400 print '\nLibraries =', M.Libraries, M.Libraries.IncludeFiles
1401 for Item in M.Libraries.LibraryList:
1402 print '\t', Item.FilePath, Item.SupArchList, Item.Define
1403 print '\nLibraryClasses =', M.LibraryClasses, M.LibraryClasses.IncludeFiles
1404 for Item in M.LibraryClasses.LibraryList:
1405 print '\t', Item.Name, Item.FilePath, Item.SupModuleList, Item.SupArchList, Item.Define
1406 print '\nPcds =', M.DynamicPcdBuildDefinitions
1407 for Item in M.DynamicPcdBuildDefinitions:
1408 print '\tCname=', Item.CName, 'TSG=', Item.TokenSpaceGuidCName, 'Value=', Item.DefaultValue, 'Token=', Item.Token, 'Type=', Item.ItemType, 'Datum=', Item.DatumType, 'Size=', Item.MaxDatumSize, 'Arch=', Item.SupArchList, Item.SkuInfoList
1409 for Sku in Item.SkuInfoList.values():
1410 print '\t\t', str(Sku)
1411 print '\nComponents =', M.Modules.ModuleList, M.Modules.IncludeFiles
1412 for Item in M.Modules.ModuleList:
1413 print '\t', Item.FilePath, Item.ExecFilePath, Item.SupArchList
1414 for Lib in Item.LibraryClasses.LibraryList:
1415 print '\t\tLib:', Lib.Name, Lib.FilePath
1416 for Bo in Item.ModuleSaBuildOption.BuildOptionList:
1417 print '\t\tBuildOption:', Bo.ToolChainFamily, Bo.ToolChain, Bo.Option
1418 for Pcd in Item.PcdBuildDefinitions:
1419 print '\t\tPcd:', Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.MaxDatumSize, Pcd.DefaultValue, Pcd.ItemType
1420
1421 ##
1422 #
1423 # This acts like the main() function for the script, unless it is 'import'ed into another
1424 # script.
1425 #
1426 if __name__ == '__main__':
1427 EdkLogger.Initialize()
1428 EdkLogger.SetLevel(EdkLogger.DEBUG_0)
1429
1430 W = os.getenv('WORKSPACE')
1431 F = os.path.join(W, 'Nt32Pkg/Nt32Pkg.dsc')
1432
1433 Db = Database.Database('Dsc.db')
1434 Db.InitDatabase()
1435
1436 P = Dsc(os.path.normpath(F), True, True, W, Db)
1437 P.ShowPlatform()
1438
1439 Db.Close()