]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/Common/DscClassObject.py
Check In tool source code based on Build tool project revision r1655.
[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 ~ 2008, Intel Corporation
5 # All rights reserved. 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 for NewItem in open(Filename, 'r').readlines():
389 if CleanString(NewItem) == '':
390 continue
391 MergeArches(Libraries, NewItem, Arch)
392
393 for Record in RecordSet:
394 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
395 MergeArches(Libraries, Record[0], Arch)
396
397 for Key in Libraries.keys():
398 Library = PlatformLibraryClass()
399 Library.FilePath = NormPath(Key)
400 Library.SupArchList = Libraries[Key]
401 self.Platform.Libraries.LibraryList.append(Library)
402
403 ## GenLibraryClasses
404 #
405 # Get LibraryClasses of Dsc
406 # <LibraryClassKeyWord>|<LibraryInstance>
407 #
408 # @param ContainerFile: The Dsc file full path
409 #
410 def GenLibraryClasses(self, ContainerFile):
411 EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)
412 LibraryClasses = {}
413 #
414 # Get all include files
415 #
416 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_CLASS, self.FileID)
417
418 #
419 # Get all LibraryClasses
420 #
421 RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, -1, self.FileID)
422
423 #
424 # Go through each arch
425 #
426 for Arch in DataType.ARCH_LIST:
427 for IncludeFile in IncludeFiles:
428 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
429 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARY_CLASSES, '', IncludeFile[2])
430 for NewItem in open(Filename, 'r').readlines():
431 if CleanString(NewItem) == '':
432 continue
433 MergeArches(LibraryClasses, GetLibraryClass([NewItem, IncludeFile[4]], Filename, self.WorkspaceDir, -1), Arch)
434
435 for Record in RecordSet:
436 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
437 (LibClassName, LibClassIns, SupModelList) = GetLibraryClass([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
438 MergeArches(LibraryClasses, (LibClassName, LibClassIns, SupModelList), Arch)
439 #
440 # Update to Database
441 #
442 if self.IsToDatabase:
443 SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
444 where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])
445 self.TblDsc.Exec(SqlCommand)
446
447 for Key in LibraryClasses.keys():
448 Library = PlatformLibraryClass()
449 Library.Name = Key[0]
450 Library.FilePath = NormPath(Key[1])
451 Library.SupModuleList = GetSplitValueList(Key[2])
452 Library.SupArchList = LibraryClasses[Key]
453 self.Platform.LibraryClasses.LibraryList.append(Library)
454
455 ## Gen Pcds
456 #
457 # Gen Pcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]
458 #
459 # @param Type: The type of Pcd
460 # @param ContainerFile: The file which describes the pcd, used for error report
461 #
462 def GenPcds(self, Type = '', ContainerFile = ''):
463 Pcds = {}
464 if Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:
465 Model = MODEL_PCD_PATCHABLE_IN_MODULE
466 elif Type == DataType.TAB_PCDS_FIXED_AT_BUILD:
467 Model = MODEL_PCD_FIXED_AT_BUILD
468 else:
469 pass
470 EdkLogger.debug(2, "Generate %s ..." % Type)
471
472 #
473 # Get all include files
474 #
475 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
476
477 #
478 # Get all Pcds
479 #
480 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
481
482 #
483 # Go through each arch
484 #
485 for Arch in DataType.ARCH_LIST:
486 for IncludeFile in IncludeFiles:
487 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
488 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
489 for NewItem in open(Filename, 'r').readlines():
490 if CleanString(NewItem) == '':
491 continue
492 (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(NewItem, Type, Filename, -1)
493 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)
494 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
495
496 for Record in RecordSet:
497 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
498 (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(Record[0], Type, ContainerFile, Record[2])
499 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)
500 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
501
502 for Key in Pcds:
503 Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], {}, [])
504 Pcd.SupArchList = Pcds[Key]
505 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
506
507 ## Gen FeatureFlagPcds
508 #
509 # Gen FeatureFlagPcds of Dsc file as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE
510 #
511 # @param Type: The type of Pcd
512 # @param ContainerFile: The file which describes the pcd, used for error report
513 #
514 def GenFeatureFlagPcds(self, Type = '', ContainerFile = ''):
515 Pcds = {}
516 if Type == DataType.TAB_PCDS_FEATURE_FLAG:
517 Model = MODEL_PCD_FEATURE_FLAG
518 else:
519 pass
520 EdkLogger.debug(2, "Generate %s ..." % Type)
521
522 #
523 # Get all include files
524 #
525 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
526
527 #
528 # Get all FeatureFlagPcds
529 #
530 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
531
532 #
533 # Go through each arch
534 #
535 for Arch in DataType.ARCH_LIST:
536 for IncludeFile in IncludeFiles:
537 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
538 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
539 for NewItem in open(Filename, 'r').readlines():
540 if CleanString(NewItem) == '':
541 continue
542 (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(NewItem, Type, Filename, -1)
543 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)
544 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
545
546 for Record in RecordSet:
547 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
548 (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(Record[0], Type, ContainerFile, Record[2])
549 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)
550 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)
551
552 for Key in Pcds:
553 Pcd = PcdClass(Key[0], '', Key[1], '', '', Key[2], Key[3], [], {}, [])
554 Pcd.SupArchList = Pcds[Key]
555 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
556
557 ## Gen DynamicDefaultPcds
558 #
559 # Gen DynamicDefaultPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<DatumTyp>[|<MaxDatumSize>]]
560 #
561 # @param Type: The type of Pcd
562 # @param ContainerFile: The file which describes the pcd, used for error report
563 #
564 def GenDynamicDefaultPcds(self, Type = '', ContainerFile = ''):
565 Pcds = {}
566 SkuInfoList = {}
567 if Type == DataType.TAB_PCDS_DYNAMIC_DEFAULT:
568 Model = MODEL_PCD_DYNAMIC_DEFAULT
569 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT:
570 Model = MODEL_PCD_DYNAMIC_EX_DEFAULT
571 else:
572 pass
573 EdkLogger.debug(2, "Generate %s ..." % Type)
574
575 #
576 # Get all include files
577 #
578 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
579
580 #
581 # Get all DynamicDefaultPcds
582 #
583 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
584
585 #
586 # Go through each arch
587 #
588 for Arch in DataType.ARCH_LIST:
589 for IncludeFile in IncludeFiles:
590 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
591 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
592 for NewItem in open(Filename, 'r').readlines():
593 if CleanString(NewItem) == '':
594 continue
595 (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(NewItem, Type, Filename, -1)
596 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, IncludeFile[4]), Arch)
597 self.PcdToken[Record[3]] = (K2, K1)
598
599 for Record in RecordSet:
600 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
601 (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(Record[0], Type, ContainerFile, Record[2])
602 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Record[4]), Arch)
603 self.PcdToken[Record[3]] = (K2, K1)
604
605 for Key in Pcds:
606 (Status, SkuInfoList) = self.GenSkuInfoList(Key[6], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2])
607 if Status == False:
608 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
609 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
610 Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], SkuInfoList, [])
611 Pcd.SupArchList = Pcds[Key]
612 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
613
614 ## Gen DynamicHiiPcds
615 #
616 # Gen DynamicHiiPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<String>|<VariableGuidCName>|<VariableOffset>[|<DefaultValue>[|<MaximumDatumSize>]]
617 #
618 # @param Type: The type of Pcd
619 # @param ContainerFile: The file which describes the pcd, used for error report
620 #
621 def GenDynamicHiiPcds(self, Type = '', ContainerFile = ''):
622 Pcds = {}
623 SkuInfoList = {}
624 if Type == DataType.TAB_PCDS_DYNAMIC_HII:
625 Model = MODEL_PCD_DYNAMIC_HII
626 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_HII:
627 Model = MODEL_PCD_DYNAMIC_EX_HII
628 else:
629 pass
630 EdkLogger.debug(2, "Generate %s ..." % Type)
631
632 #
633 # Get all include files
634 #
635 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
636
637 #
638 # Get all DynamicHiiPcds
639 #
640 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
641
642 #
643 # Go through each arch
644 #
645 for Arch in DataType.ARCH_LIST:
646 for IncludeFile in IncludeFiles:
647 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
648 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
649 for NewItem in open(Filename, 'r').readlines():
650 if CleanString(NewItem) == '':
651 continue
652 (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(NewItem, Type, Filename, -1)
653 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, IncludeFile[4]), Arch)
654 self.PcdToken[Record[3]] = (K2, K1)
655
656 for Record in RecordSet:
657 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
658 (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(Record[0], Type, ContainerFile, Record[2])
659 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, Record[4]), Arch)
660 self.PcdToken[Record[3]] = (K2, K1)
661
662 for Key in Pcds:
663 (Status, SkuInfoList) = self.GenSkuInfoList(Key[8], self.Platform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '')
664 if Status == False:
665 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
666 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
667 Pcd = PcdClass(Key[0], '', Key[1], '', Key[6], Key[5], Key[7], [], SkuInfoList, [])
668 Pcd.SupArchList = Pcds[Key]
669 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
670
671 ## Gen DynamicVpdPcds
672 #
673 # Gen DynamicVpdPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<VpdOffset>[|<MaximumDatumSize>]
674 #
675 # @param Type: The type of Pcd
676 # @param ContainerFile: The file which describes the pcd, used for error report
677 #
678 def GenDynamicVpdPcds(self, Type = '', ContainerFile = ''):
679 Pcds = {}
680 SkuInfoList = {}
681 if Type == DataType.TAB_PCDS_DYNAMIC_VPD:
682 Model = MODEL_PCD_DYNAMIC_VPD
683 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_VPD:
684 Model = MODEL_PCD_DYNAMIC_EX_VPD
685 else:
686 pass
687 EdkLogger.debug(2, "Generate %s ..." % Type)
688
689 #
690 # Get all include files
691 #
692 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)
693
694 #
695 # Get all DynamicVpdPcds
696 #
697 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)
698
699 #
700 # Go through each arch
701 #
702 for Arch in DataType.ARCH_LIST:
703 for IncludeFile in IncludeFiles:
704 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
705 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
706 for NewItem in open(Filename, 'r').readlines():
707 if CleanString(NewItem) == '':
708 continue
709 (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(NewItem, Type, Filename, -1)
710 MergeArches(Pcds, (K1, K2, K3, K4, K5, IncludeFile[4]), Arch)
711 self.PcdToken[Record[3]] = (K2, K1)
712
713 for Record in RecordSet:
714 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
715 (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(Record[0], Type, ContainerFile, Record[2])
716 MergeArches(Pcds, (K1, K2, K3, K4, K5, Record[4]), Arch)
717 self.PcdToken[Record[3]] = (K2, K1)
718
719 for Key in Pcds:
720 (Status, SkuInfoList) = self.GenSkuInfoList(Key[5], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '')
721 if Status == False:
722 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
723 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)
724 Pcd = PcdClass(Key[0], '', Key[1], '', Key[3], '', Key[4], [], SkuInfoList, [])
725 Pcd.SupArchList = Pcds[Key]
726 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)
727
728
729 ## Get Component
730 #
731 # Get Component section defined in Dsc file
732 #
733 # @param ContainerFile: The file which describes the Components, used for error report
734 #
735 # @retval PlatformModuleClass() A instance for PlatformModuleClass
736 #
737 def GenComponents(self, ContainerFile):
738 EdkLogger.debug(2, "Generate %s ..." % TAB_COMPONENTS)
739 Components = sdict()
740 #
741 # Get all include files
742 #
743 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_COMPONENT, self.FileID)
744
745 #
746 # Get all Components
747 #
748 RecordSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_COMPONENT, -1, self.FileID)
749
750 #
751 # Go through each arch
752 #
753 for Arch in DataType.ARCH_LIST:
754 for IncludeFile in IncludeFiles:
755 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():
756 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_COMPONENTS, '', IncludeFile[2])
757 for NewItem in open(Filename, 'r').readlines():
758 if CleanString(NewItem) == '':
759 continue
760 NewItems = []
761 GetComponents(open(Filename, 'r').read(), TAB_COMPONENTS, NewItems, TAB_COMMENT_SPLIT)
762 for NewComponent in NewItems:
763 MergeArches(Components, self.GenComponent(NewComponent, Filename), Arch)
764
765 for Record in RecordSet:
766 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():
767 Lib, Bo, Pcd = [], [], []
768
769 SubLibSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, Record[3], self.FileID)
770 for SubLib in SubLibSet:
771 Lib.append(TAB_VALUE_SPLIT.join([SubLib[0],SubLib[4]]))
772
773 SubBoSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTION, Record[3], self.FileID)
774 for SubBo in SubBoSet:
775 Bo.append(SubBo[0])
776
777 SubPcdSet1 = QueryDscItem(self.TblDsc, MODEL_PCD_FIXED_AT_BUILD, Record[3], self.FileID)
778 SubPcdSet2 = QueryDscItem(self.TblDsc, MODEL_PCD_PATCHABLE_IN_MODULE, Record[3], self.FileID)
779 SubPcdSet3 = QueryDscItem(self.TblDsc, MODEL_PCD_FEATURE_FLAG, Record[3], self.FileID)
780 SubPcdSet4 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_EX_DEFAULT, Record[3], self.FileID)
781 SubPcdSet5 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_DEFAULT, Record[3], self.FileID)
782 for SubPcd in SubPcdSet1:
783 Pcd.append([DataType.TAB_PCDS_FIXED_AT_BUILD, SubPcd[0], SubPcd[3]])
784 for SubPcd in SubPcdSet2:
785 Pcd.append([DataType.TAB_PCDS_PATCHABLE_IN_MODULE, SubPcd[0], SubPcd[3]])
786 for SubPcd in SubPcdSet3:
787 Pcd.append([DataType.TAB_PCDS_FEATURE_FLAG, SubPcd[0], SubPcd[3]])
788 for SubPcd in SubPcdSet4:
789 Pcd.append([DataType.TAB_PCDS_DYNAMIC_EX, SubPcd[0], SubPcd[3]])
790 for SubPcd in SubPcdSet5:
791 Pcd.append([DataType.TAB_PCDS_DYNAMIC, SubPcd[0], SubPcd[3]])
792 Item = [Record[0], Lib, Bo, Pcd]
793 MergeArches(Components, self.GenComponent(Item, ContainerFile), Arch)
794
795 for Key in Components.keys():
796 Key.SupArchList = Components[Key]
797 self.Platform.Modules.ModuleList.append(Key)
798
799 ## Get Component
800 #
801 # Get Component section defined in Dsc file
802 #
803 # @param Item: Contents includes a component block
804 # @param ContainerFile: The file which describes the library class, used for error report
805 #
806 # @retval PlatformModuleClass() A instance for PlatformModuleClass
807 #
808 def GenComponent(self, Item, ContainerFile, LineNo = -1):
809 (InfFilename, ExecFilename) = GetExec(Item[0])
810 LibraryClasses = Item[1]
811 BuildOptions = Item[2]
812 Pcds = Item[3]
813 Component = PlatformModuleClass()
814 Component.FilePath = NormPath(InfFilename)
815 Component.ExecFilePath = NormPath(ExecFilename)
816 CheckFileType(Component.FilePath, '.Inf', ContainerFile, 'component name', Item[0], LineNo)
817 CheckFileExist(self.WorkspaceDir, Component.FilePath, ContainerFile, 'component', Item[0], LineNo)
818 for Lib in LibraryClasses:
819 List = GetSplitValueList(Lib)
820 if len(List) != 2:
821 RaiseParserError(Lib, 'LibraryClasses', ContainerFile, '<ClassName>|<InfFilename>')
822 LibName = List[0]
823 LibFile = NormPath(List[1])
824 if LibName == "" or LibName == "NULL":
825 LibName = "NULL%d" % self._NullClassIndex
826 self._NullClassIndex += 1
827 CheckFileType(List[1], '.Inf', ContainerFile, 'library instance of component ', Lib, LineNo)
828 CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'library instance of component', Lib, LineNo)
829 Component.LibraryClasses.LibraryList.append(PlatformLibraryClass(LibName, LibFile))
830 for BuildOption in BuildOptions:
831 Key = GetBuildOption(BuildOption, ContainerFile)
832 Component.ModuleSaBuildOption.BuildOptionList.append(BuildOptionClass(Key[0], Key[1], Key[2]))
833 for Pcd in Pcds:
834 Type = Pcd[0]
835 List = GetSplitValueList(Pcd[1])
836 PcdId = Pcd[2]
837
838 TokenInfo = None
839 #
840 # For FeatureFlag
841 #
842 if Type == DataType.TAB_PCDS_FEATURE_FLAG:
843 if len(List) != 2:
844 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|TRUE/FALSE')
845
846 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
847 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
848 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', List[1], Type, [], {}, []))
849 #
850 # For FixedAtBuild or PatchableInModule
851 #
852 if Type == DataType.TAB_PCDS_FIXED_AT_BUILD or Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:
853 List.append('')
854 if len(List) != 3 and len(List) != 4:
855 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|<Value>[|<MaxDatumSize>]')
856
857 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
858 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
859 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', List[2], List[1], Type, [], {}, []))
860
861 #
862 # For Dynamic or DynamicEx
863 #
864 if Type == DataType.TAB_PCDS_DYNAMIC or Type == DataType.TAB_PCDS_DYNAMIC_EX:
865 if len(List) != 1:
866 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>')
867
868 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)
869 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)
870 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', '', Type, [], {}, []))
871
872 #
873 # Add to PcdToken
874 #
875 self.PcdToken[PcdId] = (TokenInfo[0], TokenInfo[1])
876
877 return Component
878 #End of GenComponent
879
880 ## Gen SkuInfoList
881 #
882 # Gen SkuInfoList section defined in Dsc file
883 #
884 # @param SkuNameList: Input value for SkuNameList
885 # @param SkuInfo: Input value for SkuInfo
886 # @param VariableName: Input value for VariableName
887 # @param VariableGuid: Input value for VariableGuid
888 # @param VariableOffset: Input value for VariableOffset
889 # @param HiiDefaultValue: Input value for HiiDefaultValue
890 # @param VpdOffset: Input value for VpdOffset
891 # @param DefaultValue: Input value for DefaultValue
892 #
893 # @retval (False, SkuName) Not found in section SkuId Dsc file
894 # @retval (True, SkuInfoList) Found in section SkuId of Dsc file
895 #
896 def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName = '', VariableGuid = '', VariableOffset = '', HiiDefaultValue = '', VpdOffset = '', DefaultValue = ''):
897 SkuNameList = GetSplitValueList(SkuNameList)
898 if SkuNameList == None or SkuNameList == [] or SkuNameList == ['']:
899 SkuNameList = ['DEFAULT']
900 SkuInfoList = {}
901 for Item in SkuNameList:
902 if Item not in SkuInfo:
903 return False, Item
904 Sku = SkuInfoClass(Item, SkuInfo[Item], VariableName, VariableGuid, VariableOffset, HiiDefaultValue, VpdOffset, DefaultValue)
905 SkuInfoList[Item] = Sku
906
907 return True, SkuInfoList
908
909 ## Parse Include statement
910 #
911 # Get include file path
912 #
913 # 1. Insert a record into TblFile ???
914 # 2. Insert a record into TblDsc
915 # Value1: IncludeFilePath
916 #
917 # @param LineValue: The line of incude statement
918 def ParseInclude(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
919 EdkLogger.debug(EdkLogger.DEBUG_2, "!include statement '%s' found in section %s" % (LineValue, SectionName))
920 SectionModel = Section[SectionName.upper()]
921 IncludeFile = CleanString(LineValue[LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ])
922 Table.Insert(Model, IncludeFile, '', '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)
923
924 ## Parse DEFINE statement
925 #
926 # Get DEFINE macros
927 #
928 # 1. Insert a record into TblDsc
929 # Value1: Macro Name
930 # Value2: Macro Value
931 #
932 def ParseDefine(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
933 EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in section %s" % (LineValue, SectionName))
934 SectionModel = Section[SectionName.upper()]
935 Define = GetSplitValueList(CleanString(LineValue[LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' ') : ]), TAB_EQUAL_SPLIT, 1)
936 Table.Insert(Model, Define[0], Define[1], '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)
937
938 ## Parse Defines section
939 #
940 # Get one item in defines section
941 #
942 # Value1: Item Name
943 # Value2: Item Value
944 #
945 def ParseDefinesSection(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
946 EdkLogger.debug(EdkLogger.DEBUG_2, "Parse '%s' found in section %s" % (LineValue, SectionName))
947 Defines = GetSplitValueList(LineValue, TAB_EQUAL_SPLIT, 1)
948 if len(Defines) != 2:
949 RaiseParserError(LineValue, SectionName, Filename, '', StartLine)
950 self.TblDsc.Insert(Model, Defines[0], Defines[1], '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
951
952 ## Insert conditional statements
953 #
954 # Pop an item from IfDefList
955 # Insert conditional statements to database
956 #
957 # @param Filename: Path of parsing file
958 # @param IfDefList: A list stored current conditional statements
959 # @param EndLine: The end line no
960 # @param ArchList: Support arch list
961 #
962 def InsertConditionalStatement(self, Filename, FileID, BelongsToItem, IfDefList, EndLine, ArchList):
963 (Value1, Value2, Value3, Model, StartColumn, EndColumn, Enabled) = ('', '', '', -1, -1, -1, 0)
964 if IfDefList == []:
965 ErrorMsg = 'Not suited conditional statement in file %s' % Filename
966 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError = EdkLogger.IsRaiseError)
967 else:
968 #
969 # Get New Dsc item ID
970 #
971 DscID = self.TblDsc.GetCount() + 1
972
973 #
974 # Pop the conditional statements which is closed
975 #
976 PreviousIf = IfDefList.pop()
977 EdkLogger.debug(EdkLogger.DEBUG_5, 'Previous IfDef: ' + str(PreviousIf))
978
979 #
980 # !ifdef and !ifndef
981 #
982 if PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF):
983 Value1 = PreviousIf[0]
984 Model = PreviousIf[2]
985 self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
986 #
987 # !if and !elseif
988 #
989 elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, Model):
990 List = PreviousIf[0].split(' ')
991 Value1 = List[0]
992 Value2 = List[1]
993 Value3 = List[2]
994 Value3 = SplitString(Value3)
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_R8_START) > -1:
1044 ReservedLine = GetSplitValueList(Line, TAB_COMMENT_R8_START, 1)[0]
1045 IsFindBlockComment = True
1046 if Line.find(TAB_COMMENT_R8_END) > -1:
1047 Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_R8_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()