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