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