MdePkg/BaseLib: Replaced inline assembly for ARMGCC by GCC assembly source file
[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
40d841f6
LG
4# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
5# This program and the accompanying materials\r
30fdf114
LG
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
fd171542 388 if os.path.exists(Filename):\r
389 for NewItem in open(Filename, 'r').readlines():\r
390 if CleanString(NewItem) == '':\r
391 continue\r
392 MergeArches(Libraries, NewItem, Arch)\r
30fdf114
LG
393\r
394 for Record in RecordSet:\r
395 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
396 MergeArches(Libraries, Record[0], Arch)\r
397\r
398 for Key in Libraries.keys():\r
399 Library = PlatformLibraryClass()\r
400 Library.FilePath = NormPath(Key)\r
401 Library.SupArchList = Libraries[Key]\r
402 self.Platform.Libraries.LibraryList.append(Library)\r
403\r
404 ## GenLibraryClasses\r
405 #\r
406 # Get LibraryClasses of Dsc\r
407 # <LibraryClassKeyWord>|<LibraryInstance>\r
408 #\r
409 # @param ContainerFile: The Dsc file full path\r
410 #\r
411 def GenLibraryClasses(self, ContainerFile):\r
412 EdkLogger.debug(2, "Generate %s ..." % TAB_LIBRARY_CLASSES)\r
413 LibraryClasses = {}\r
414 #\r
415 # Get all include files\r
416 #\r
417 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_CLASS, self.FileID)\r
418\r
419 #\r
420 # Get all LibraryClasses\r
421 #\r
422 RecordSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, -1, self.FileID)\r
423\r
424 #\r
425 # Go through each arch\r
426 #\r
427 for Arch in DataType.ARCH_LIST:\r
428 for IncludeFile in IncludeFiles:\r
429 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():\r
430 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARY_CLASSES, '', IncludeFile[2])\r
431 for NewItem in open(Filename, 'r').readlines():\r
432 if CleanString(NewItem) == '':\r
433 continue\r
434 MergeArches(LibraryClasses, GetLibraryClass([NewItem, IncludeFile[4]], Filename, self.WorkspaceDir, -1), Arch)\r
435\r
436 for Record in RecordSet:\r
437 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
438 (LibClassName, LibClassIns, SupModelList) = GetLibraryClass([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])\r
439 MergeArches(LibraryClasses, (LibClassName, LibClassIns, SupModelList), Arch)\r
440 #\r
441 # Update to Database\r
442 #\r
443 if self.IsToDatabase:\r
444 SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'\r
445 where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])\r
446 self.TblDsc.Exec(SqlCommand)\r
447\r
448 for Key in LibraryClasses.keys():\r
449 Library = PlatformLibraryClass()\r
450 Library.Name = Key[0]\r
451 Library.FilePath = NormPath(Key[1])\r
452 Library.SupModuleList = GetSplitValueList(Key[2])\r
453 Library.SupArchList = LibraryClasses[Key]\r
454 self.Platform.LibraryClasses.LibraryList.append(Library)\r
455\r
456 ## Gen Pcds\r
457 #\r
458 # Gen Pcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]\r
459 #\r
460 # @param Type: The type of Pcd\r
461 # @param ContainerFile: The file which describes the pcd, used for error report\r
462 #\r
463 def GenPcds(self, Type = '', ContainerFile = ''):\r
464 Pcds = {}\r
465 if Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:\r
466 Model = MODEL_PCD_PATCHABLE_IN_MODULE\r
467 elif Type == DataType.TAB_PCDS_FIXED_AT_BUILD:\r
468 Model = MODEL_PCD_FIXED_AT_BUILD\r
469 else:\r
470 pass\r
471 EdkLogger.debug(2, "Generate %s ..." % Type)\r
472\r
473 #\r
474 # Get all include files\r
475 #\r
476 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)\r
477\r
478 #\r
479 # Get all Pcds\r
480 #\r
481 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)\r
482\r
483 #\r
484 # Go through each arch\r
485 #\r
486 for Arch in DataType.ARCH_LIST:\r
487 for IncludeFile in IncludeFiles:\r
488 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():\r
489 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])\r
490 for NewItem in open(Filename, 'r').readlines():\r
491 if CleanString(NewItem) == '':\r
492 continue\r
493 (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(NewItem, Type, Filename, -1)\r
494 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)\r
495 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)\r
496\r
497 for Record in RecordSet:\r
498 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
499 (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(Record[0], Type, ContainerFile, Record[2])\r
500 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type), Arch)\r
501 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)\r
502\r
503 for Key in Pcds:\r
504 Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], {}, [])\r
505 Pcd.SupArchList = Pcds[Key]\r
506 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)\r
507\r
508 ## Gen FeatureFlagPcds\r
509 #\r
510 # Gen FeatureFlagPcds of Dsc file as <PcdTokenSpaceGuidCName>.<TokenCName>|TRUE/FALSE\r
511 #\r
512 # @param Type: The type of Pcd\r
513 # @param ContainerFile: The file which describes the pcd, used for error report\r
514 #\r
515 def GenFeatureFlagPcds(self, Type = '', ContainerFile = ''):\r
516 Pcds = {}\r
517 if Type == DataType.TAB_PCDS_FEATURE_FLAG:\r
518 Model = MODEL_PCD_FEATURE_FLAG\r
519 else:\r
520 pass\r
521 EdkLogger.debug(2, "Generate %s ..." % Type)\r
522\r
523 #\r
524 # Get all include files\r
525 #\r
526 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)\r
527\r
528 #\r
529 # Get all FeatureFlagPcds\r
530 #\r
531 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)\r
532\r
533 #\r
534 # Go through each arch\r
535 #\r
536 for Arch in DataType.ARCH_LIST:\r
537 for IncludeFile in IncludeFiles:\r
538 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():\r
539 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])\r
540 for NewItem in open(Filename, 'r').readlines():\r
541 if CleanString(NewItem) == '':\r
542 continue\r
543 (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(NewItem, Type, Filename, -1)\r
544 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)\r
545 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)\r
546\r
547 for Record in RecordSet:\r
548 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
549 (TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(Record[0], Type, ContainerFile, Record[2])\r
550 MergeArches(Pcds, (TokenName, TokenGuidCName, Value, Type), Arch)\r
551 self.PcdToken[Record[3]] = (TokenGuidCName, TokenName)\r
552\r
553 for Key in Pcds:\r
554 Pcd = PcdClass(Key[0], '', Key[1], '', '', Key[2], Key[3], [], {}, [])\r
555 Pcd.SupArchList = Pcds[Key]\r
556 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)\r
557\r
558 ## Gen DynamicDefaultPcds\r
559 #\r
560 # Gen DynamicDefaultPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<DatumTyp>[|<MaxDatumSize>]]\r
561 #\r
562 # @param Type: The type of Pcd\r
563 # @param ContainerFile: The file which describes the pcd, used for error report\r
564 #\r
565 def GenDynamicDefaultPcds(self, Type = '', ContainerFile = ''):\r
566 Pcds = {}\r
567 SkuInfoList = {}\r
568 if Type == DataType.TAB_PCDS_DYNAMIC_DEFAULT:\r
569 Model = MODEL_PCD_DYNAMIC_DEFAULT\r
570 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_DEFAULT:\r
571 Model = MODEL_PCD_DYNAMIC_EX_DEFAULT\r
572 else:\r
573 pass\r
574 EdkLogger.debug(2, "Generate %s ..." % Type)\r
575\r
576 #\r
577 # Get all include files\r
578 #\r
579 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)\r
580\r
581 #\r
582 # Get all DynamicDefaultPcds\r
583 #\r
584 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)\r
585\r
586 #\r
587 # Go through each arch\r
588 #\r
589 for Arch in DataType.ARCH_LIST:\r
590 for IncludeFile in IncludeFiles:\r
591 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():\r
592 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])\r
593 for NewItem in open(Filename, 'r').readlines():\r
594 if CleanString(NewItem) == '':\r
595 continue\r
596 (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(NewItem, Type, Filename, -1)\r
597 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, IncludeFile[4]), Arch)\r
598 self.PcdToken[Record[3]] = (K2, K1)\r
599\r
600 for Record in RecordSet:\r
601 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
602 (K1, K2, K3, K4, K5, K6) = GetDynamicDefaultPcd(Record[0], Type, ContainerFile, Record[2])\r
603 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, Record[4]), Arch)\r
604 self.PcdToken[Record[3]] = (K2, K1)\r
605\r
606 for Key in Pcds:\r
607 (Status, SkuInfoList) = self.GenSkuInfoList(Key[6], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2])\r
608 if Status == False:\r
609 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)\r
610 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)\r
611 Pcd = PcdClass(Key[0], '', Key[1], Key[3], Key[4], Key[2], Key[5], [], SkuInfoList, [])\r
612 Pcd.SupArchList = Pcds[Key]\r
613 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)\r
614\r
615 ## Gen DynamicHiiPcds\r
616 #\r
617 # Gen DynamicHiiPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<String>|<VariableGuidCName>|<VariableOffset>[|<DefaultValue>[|<MaximumDatumSize>]]\r
618 #\r
619 # @param Type: The type of Pcd\r
620 # @param ContainerFile: The file which describes the pcd, used for error report\r
621 #\r
622 def GenDynamicHiiPcds(self, Type = '', ContainerFile = ''):\r
623 Pcds = {}\r
624 SkuInfoList = {}\r
625 if Type == DataType.TAB_PCDS_DYNAMIC_HII:\r
626 Model = MODEL_PCD_DYNAMIC_HII\r
627 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_HII:\r
628 Model = MODEL_PCD_DYNAMIC_EX_HII\r
629 else:\r
630 pass\r
631 EdkLogger.debug(2, "Generate %s ..." % Type)\r
632\r
633 #\r
634 # Get all include files\r
635 #\r
636 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)\r
637\r
638 #\r
639 # Get all DynamicHiiPcds\r
640 #\r
641 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)\r
642\r
643 #\r
644 # Go through each arch\r
645 #\r
646 for Arch in DataType.ARCH_LIST:\r
647 for IncludeFile in IncludeFiles:\r
648 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():\r
649 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])\r
650 for NewItem in open(Filename, 'r').readlines():\r
651 if CleanString(NewItem) == '':\r
652 continue\r
653 (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(NewItem, Type, Filename, -1)\r
654 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, IncludeFile[4]), Arch)\r
655 self.PcdToken[Record[3]] = (K2, K1)\r
656\r
657 for Record in RecordSet:\r
658 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
659 (K1, K2, K3, K4, K5, K6, K7, K8) = GetDynamicHiiPcd(Record[0], Type, ContainerFile, Record[2])\r
660 MergeArches(Pcds, (K1, K2, K3, K4, K5, K6, K7, K8, Record[4]), Arch)\r
661 self.PcdToken[Record[3]] = (K2, K1)\r
662\r
663 for Key in Pcds:\r
664 (Status, SkuInfoList) = self.GenSkuInfoList(Key[8], self.Platform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '')\r
665 if Status == False:\r
666 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)\r
667 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)\r
668 Pcd = PcdClass(Key[0], '', Key[1], '', Key[6], Key[5], Key[7], [], SkuInfoList, [])\r
669 Pcd.SupArchList = Pcds[Key]\r
670 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)\r
671\r
672 ## Gen DynamicVpdPcds\r
673 #\r
674 # Gen DynamicVpdPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<VpdOffset>[|<MaximumDatumSize>]\r
675 #\r
676 # @param Type: The type of Pcd\r
677 # @param ContainerFile: The file which describes the pcd, used for error report\r
678 #\r
679 def GenDynamicVpdPcds(self, Type = '', ContainerFile = ''):\r
680 Pcds = {}\r
681 SkuInfoList = {}\r
682 if Type == DataType.TAB_PCDS_DYNAMIC_VPD:\r
683 Model = MODEL_PCD_DYNAMIC_VPD\r
684 elif Type == DataType.TAB_PCDS_DYNAMIC_EX_VPD:\r
685 Model = MODEL_PCD_DYNAMIC_EX_VPD\r
686 else:\r
687 pass\r
688 EdkLogger.debug(2, "Generate %s ..." % Type)\r
689\r
690 #\r
691 # Get all include files\r
692 #\r
693 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, Model, self.FileID)\r
694\r
695 #\r
696 # Get all DynamicVpdPcds\r
697 #\r
698 RecordSet = QueryDscItem(self.TblDsc, Model, -1, self.FileID)\r
699\r
700 #\r
701 # Go through each arch\r
702 #\r
703 for Arch in DataType.ARCH_LIST:\r
704 for IncludeFile in IncludeFiles:\r
705 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():\r
706 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])\r
707 for NewItem in open(Filename, 'r').readlines():\r
708 if CleanString(NewItem) == '':\r
709 continue\r
710 (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(NewItem, Type, Filename, -1)\r
711 MergeArches(Pcds, (K1, K2, K3, K4, K5, IncludeFile[4]), Arch)\r
712 self.PcdToken[Record[3]] = (K2, K1)\r
713\r
714 for Record in RecordSet:\r
715 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
716 (K1, K2, K3, K4, K5) = GetDynamicVpdPcd(Record[0], Type, ContainerFile, Record[2])\r
717 MergeArches(Pcds, (K1, K2, K3, K4, K5, Record[4]), Arch)\r
718 self.PcdToken[Record[3]] = (K2, K1)\r
719\r
720 for Key in Pcds:\r
721 (Status, SkuInfoList) = self.GenSkuInfoList(Key[5], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '')\r
722 if Status == False:\r
723 ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)\r
724 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError = EdkLogger.IsRaiseError)\r
725 Pcd = PcdClass(Key[0], '', Key[1], '', Key[3], '', Key[4], [], SkuInfoList, [])\r
726 Pcd.SupArchList = Pcds[Key]\r
727 self.Platform.DynamicPcdBuildDefinitions.append(Pcd)\r
728\r
729\r
730 ## Get Component\r
731 #\r
732 # Get Component section defined in Dsc file\r
733 #\r
734 # @param ContainerFile: The file which describes the Components, used for error report\r
735 #\r
736 # @retval PlatformModuleClass() A instance for PlatformModuleClass\r
737 #\r
738 def GenComponents(self, ContainerFile):\r
739 EdkLogger.debug(2, "Generate %s ..." % TAB_COMPONENTS)\r
740 Components = sdict()\r
741 #\r
742 # Get all include files\r
743 #\r
744 IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_COMPONENT, self.FileID)\r
745\r
746 #\r
747 # Get all Components\r
748 #\r
749 RecordSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_COMPONENT, -1, self.FileID)\r
750\r
751 #\r
752 # Go through each arch\r
753 #\r
754 for Arch in DataType.ARCH_LIST:\r
755 for IncludeFile in IncludeFiles:\r
756 if IncludeFile[1] == Arch or IncludeFile[1] == TAB_ARCH_COMMON.upper():\r
757 Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_COMPONENTS, '', IncludeFile[2])\r
758 for NewItem in open(Filename, 'r').readlines():\r
759 if CleanString(NewItem) == '':\r
760 continue\r
761 NewItems = []\r
762 GetComponents(open(Filename, 'r').read(), TAB_COMPONENTS, NewItems, TAB_COMMENT_SPLIT)\r
763 for NewComponent in NewItems:\r
764 MergeArches(Components, self.GenComponent(NewComponent, Filename), Arch)\r
765\r
766 for Record in RecordSet:\r
767 if Record[1] == Arch or Record[1] == TAB_ARCH_COMMON.upper():\r
768 Lib, Bo, Pcd = [], [], []\r
769\r
770 SubLibSet = QueryDscItem(self.TblDsc, MODEL_EFI_LIBRARY_CLASS, Record[3], self.FileID)\r
771 for SubLib in SubLibSet:\r
772 Lib.append(TAB_VALUE_SPLIT.join([SubLib[0],SubLib[4]]))\r
773\r
774 SubBoSet = QueryDscItem(self.TblDsc, MODEL_META_DATA_BUILD_OPTION, Record[3], self.FileID)\r
775 for SubBo in SubBoSet:\r
776 Bo.append(SubBo[0])\r
777\r
778 SubPcdSet1 = QueryDscItem(self.TblDsc, MODEL_PCD_FIXED_AT_BUILD, Record[3], self.FileID)\r
779 SubPcdSet2 = QueryDscItem(self.TblDsc, MODEL_PCD_PATCHABLE_IN_MODULE, Record[3], self.FileID)\r
780 SubPcdSet3 = QueryDscItem(self.TblDsc, MODEL_PCD_FEATURE_FLAG, Record[3], self.FileID)\r
781 SubPcdSet4 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_EX_DEFAULT, Record[3], self.FileID)\r
782 SubPcdSet5 = QueryDscItem(self.TblDsc, MODEL_PCD_DYNAMIC_DEFAULT, Record[3], self.FileID)\r
783 for SubPcd in SubPcdSet1:\r
784 Pcd.append([DataType.TAB_PCDS_FIXED_AT_BUILD, SubPcd[0], SubPcd[3]])\r
785 for SubPcd in SubPcdSet2:\r
786 Pcd.append([DataType.TAB_PCDS_PATCHABLE_IN_MODULE, SubPcd[0], SubPcd[3]])\r
787 for SubPcd in SubPcdSet3:\r
788 Pcd.append([DataType.TAB_PCDS_FEATURE_FLAG, SubPcd[0], SubPcd[3]])\r
789 for SubPcd in SubPcdSet4:\r
790 Pcd.append([DataType.TAB_PCDS_DYNAMIC_EX, SubPcd[0], SubPcd[3]])\r
791 for SubPcd in SubPcdSet5:\r
792 Pcd.append([DataType.TAB_PCDS_DYNAMIC, SubPcd[0], SubPcd[3]])\r
793 Item = [Record[0], Lib, Bo, Pcd]\r
794 MergeArches(Components, self.GenComponent(Item, ContainerFile), Arch)\r
795\r
796 for Key in Components.keys():\r
797 Key.SupArchList = Components[Key]\r
798 self.Platform.Modules.ModuleList.append(Key)\r
799\r
800 ## Get Component\r
801 #\r
802 # Get Component section defined in Dsc file\r
803 #\r
804 # @param Item: Contents includes a component block\r
805 # @param ContainerFile: The file which describes the library class, used for error report\r
806 #\r
807 # @retval PlatformModuleClass() A instance for PlatformModuleClass\r
808 #\r
809 def GenComponent(self, Item, ContainerFile, LineNo = -1):\r
810 (InfFilename, ExecFilename) = GetExec(Item[0])\r
811 LibraryClasses = Item[1]\r
812 BuildOptions = Item[2]\r
813 Pcds = Item[3]\r
814 Component = PlatformModuleClass()\r
815 Component.FilePath = NormPath(InfFilename)\r
816 Component.ExecFilePath = NormPath(ExecFilename)\r
817 CheckFileType(Component.FilePath, '.Inf', ContainerFile, 'component name', Item[0], LineNo)\r
818 CheckFileExist(self.WorkspaceDir, Component.FilePath, ContainerFile, 'component', Item[0], LineNo)\r
819 for Lib in LibraryClasses:\r
820 List = GetSplitValueList(Lib)\r
821 if len(List) != 2:\r
822 RaiseParserError(Lib, 'LibraryClasses', ContainerFile, '<ClassName>|<InfFilename>')\r
823 LibName = List[0]\r
824 LibFile = NormPath(List[1])\r
825 if LibName == "" or LibName == "NULL":\r
826 LibName = "NULL%d" % self._NullClassIndex\r
827 self._NullClassIndex += 1\r
828 CheckFileType(List[1], '.Inf', ContainerFile, 'library instance of component ', Lib, LineNo)\r
829 CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'library instance of component', Lib, LineNo)\r
830 Component.LibraryClasses.LibraryList.append(PlatformLibraryClass(LibName, LibFile))\r
831 for BuildOption in BuildOptions:\r
832 Key = GetBuildOption(BuildOption, ContainerFile)\r
833 Component.ModuleSaBuildOption.BuildOptionList.append(BuildOptionClass(Key[0], Key[1], Key[2]))\r
834 for Pcd in Pcds:\r
835 Type = Pcd[0]\r
836 List = GetSplitValueList(Pcd[1])\r
837 PcdId = Pcd[2]\r
838\r
839 TokenInfo = None\r
840 #\r
841 # For FeatureFlag\r
842 #\r
843 if Type == DataType.TAB_PCDS_FEATURE_FLAG:\r
844 if len(List) != 2:\r
845 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|TRUE/FALSE')\r
846\r
847 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)\r
848 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)\r
849 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', List[1], Type, [], {}, []))\r
850 #\r
851 # For FixedAtBuild or PatchableInModule\r
852 #\r
853 if Type == DataType.TAB_PCDS_FIXED_AT_BUILD or Type == DataType.TAB_PCDS_PATCHABLE_IN_MODULE:\r
854 List.append('')\r
855 if len(List) != 3 and len(List) != 4:\r
856 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|<Value>[|<MaxDatumSize>]')\r
857\r
858 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)\r
859 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)\r
860 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', List[2], List[1], Type, [], {}, []))\r
861\r
862 #\r
863 # For Dynamic or DynamicEx\r
864 #\r
865 if Type == DataType.TAB_PCDS_DYNAMIC or Type == DataType.TAB_PCDS_DYNAMIC_EX:\r
866 if len(List) != 1:\r
867 RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>')\r
868\r
869 CheckPcdTokenInfo(List[0], 'Components', ContainerFile)\r
870 TokenInfo = GetSplitValueList(List[0], DataType.TAB_SPLIT)\r
871 Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', '', Type, [], {}, []))\r
872\r
873 #\r
874 # Add to PcdToken\r
875 #\r
876 self.PcdToken[PcdId] = (TokenInfo[0], TokenInfo[1])\r
877\r
878 return Component\r
879 #End of GenComponent\r
880\r
881 ## Gen SkuInfoList\r
882 #\r
883 # Gen SkuInfoList section defined in Dsc file\r
884 #\r
885 # @param SkuNameList: Input value for SkuNameList\r
886 # @param SkuInfo: Input value for SkuInfo\r
887 # @param VariableName: Input value for VariableName\r
888 # @param VariableGuid: Input value for VariableGuid\r
889 # @param VariableOffset: Input value for VariableOffset\r
890 # @param HiiDefaultValue: Input value for HiiDefaultValue\r
891 # @param VpdOffset: Input value for VpdOffset\r
892 # @param DefaultValue: Input value for DefaultValue\r
893 #\r
894 # @retval (False, SkuName) Not found in section SkuId Dsc file\r
895 # @retval (True, SkuInfoList) Found in section SkuId of Dsc file\r
896 #\r
897 def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName = '', VariableGuid = '', VariableOffset = '', HiiDefaultValue = '', VpdOffset = '', DefaultValue = ''):\r
898 SkuNameList = GetSplitValueList(SkuNameList)\r
899 if SkuNameList == None or SkuNameList == [] or SkuNameList == ['']:\r
900 SkuNameList = ['DEFAULT']\r
901 SkuInfoList = {}\r
902 for Item in SkuNameList:\r
903 if Item not in SkuInfo:\r
904 return False, Item\r
905 Sku = SkuInfoClass(Item, SkuInfo[Item], VariableName, VariableGuid, VariableOffset, HiiDefaultValue, VpdOffset, DefaultValue)\r
906 SkuInfoList[Item] = Sku\r
907\r
908 return True, SkuInfoList\r
909\r
910 ## Parse Include statement\r
911 #\r
912 # Get include file path\r
913 #\r
914 # 1. Insert a record into TblFile ???\r
915 # 2. Insert a record into TblDsc\r
916 # Value1: IncludeFilePath\r
917 #\r
918 # @param LineValue: The line of incude statement\r
919 def ParseInclude(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):\r
920 EdkLogger.debug(EdkLogger.DEBUG_2, "!include statement '%s' found in section %s" % (LineValue, SectionName))\r
921 SectionModel = Section[SectionName.upper()]\r
922 IncludeFile = CleanString(LineValue[LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ])\r
923 Table.Insert(Model, IncludeFile, '', '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)\r
924\r
925 ## Parse DEFINE statement\r
926 #\r
927 # Get DEFINE macros\r
928 #\r
929 # 1. Insert a record into TblDsc\r
930 # Value1: Macro Name\r
931 # Value2: Macro Value\r
932 #\r
933 def ParseDefine(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):\r
934 EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in section %s" % (LineValue, SectionName))\r
935 SectionModel = Section[SectionName.upper()]\r
936 Define = GetSplitValueList(CleanString(LineValue[LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' ') : ]), TAB_EQUAL_SPLIT, 1)\r
937 Table.Insert(Model, Define[0], Define[1], '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)\r
938\r
939 ## Parse Defines section\r
940 #\r
941 # Get one item in defines section\r
942 #\r
943 # Value1: Item Name\r
944 # Value2: Item Value\r
945 #\r
946 def ParseDefinesSection(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):\r
947 EdkLogger.debug(EdkLogger.DEBUG_2, "Parse '%s' found in section %s" % (LineValue, SectionName))\r
948 Defines = GetSplitValueList(LineValue, TAB_EQUAL_SPLIT, 1)\r
949 if len(Defines) != 2:\r
950 RaiseParserError(LineValue, SectionName, Filename, '', StartLine)\r
951 self.TblDsc.Insert(Model, Defines[0], Defines[1], '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)\r
952\r
953 ## Insert conditional statements\r
954 #\r
955 # Pop an item from IfDefList\r
956 # Insert conditional statements to database\r
957 #\r
958 # @param Filename: Path of parsing file\r
959 # @param IfDefList: A list stored current conditional statements\r
960 # @param EndLine: The end line no\r
961 # @param ArchList: Support arch list\r
962 #\r
963 def InsertConditionalStatement(self, Filename, FileID, BelongsToItem, IfDefList, EndLine, ArchList):\r
964 (Value1, Value2, Value3, Model, StartColumn, EndColumn, Enabled) = ('', '', '', -1, -1, -1, 0)\r
965 if IfDefList == []:\r
966 ErrorMsg = 'Not suited conditional statement in file %s' % Filename\r
967 EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError = EdkLogger.IsRaiseError)\r
968 else:\r
969 #\r
970 # Get New Dsc item ID\r
971 #\r
972 DscID = self.TblDsc.GetCount() + 1\r
973\r
974 #\r
975 # Pop the conditional statements which is closed\r
976 #\r
977 PreviousIf = IfDefList.pop()\r
978 EdkLogger.debug(EdkLogger.DEBUG_5, 'Previous IfDef: ' + str(PreviousIf))\r
979\r
980 #\r
981 # !ifdef and !ifndef\r
982 #\r
983 if PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF):\r
984 Value1 = PreviousIf[0]\r
985 Model = PreviousIf[2]\r
986 self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)\r
987 #\r
988 # !if and !elseif\r
989 #\r
990 elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, Model):\r
991 List = PreviousIf[0].split(' ')\r
636f2be6
LG
992 Value1, Value2, Value3 = '', '==', '0'\r
993 if len(List) == 3:\r
994 Value1 = List[0]\r
995 Value2 = List[1]\r
996 Value3 = List[2]\r
997 Value3 = SplitString(Value3)\r
998 if len(List) == 1:\r
999 Value1 = List[0]\r
30fdf114
LG
1000 Model = PreviousIf[2]\r
1001 self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)\r
1002 #\r
1003 # !else\r
1004 #\r
1005 elif PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, Model):\r
1006 Value1 = PreviousIf[0].strip()\r
1007 Model = PreviousIf[2]\r
1008 self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)\r
1009\r
1010 ## Load Dsc file\r
1011 #\r
1012 # Load the file if it exists\r
1013 #\r
1014 # @param Filename: Input value for filename of Dsc file\r
1015 #\r
1016 def LoadDscFile(self, Filename):\r
1017 #\r
1018 # Insert a record for file\r
1019 #\r
1020 Filename = NormPath(Filename)\r
1021 self.Identification.FileFullPath = Filename\r
1022 (self.Identification.FileRelativePath, self.Identification.FileName) = os.path.split(Filename)\r
1023 self.FileID = self.TblFile.InsertFile(Filename, MODEL_FILE_DSC)\r
1024\r
1025 #\r
1026 # Init DscTable\r
1027 #\r
1028 #self.TblDsc.Table = "Dsc%s" % FileID\r
1029 #self.TblDsc.Create()\r
1030\r
1031 #\r
1032 # Init common datas\r
1033 #\r
1034 IfDefList, SectionItemList, CurrentSection, ArchList, ThirdList, IncludeFiles = \\r
1035 [], [], TAB_UNKNOWN, [], [], []\r
1036 LineNo = 0\r
1037\r
1038 #\r
1039 # Parse file content\r
1040 #\r
1041 IsFindBlockComment = False\r
1042 ReservedLine = ''\r
1043 for Line in open(Filename, 'r'):\r
1044 LineNo = LineNo + 1\r
1045 #\r
1046 # Remove comment block\r
1047 #\r
b36d134f
LG
1048 if Line.find(TAB_COMMENT_EDK_START) > -1:\r
1049 ReservedLine = GetSplitValueList(Line, TAB_COMMENT_EDK_START, 1)[0]\r
30fdf114 1050 IsFindBlockComment = True\r
b36d134f
LG
1051 if Line.find(TAB_COMMENT_EDK_END) > -1:\r
1052 Line = ReservedLine + GetSplitValueList(Line, TAB_COMMENT_EDK_END, 1)[1]\r
30fdf114
LG
1053 ReservedLine = ''\r
1054 IsFindBlockComment = False\r
1055 if IsFindBlockComment:\r
1056 continue\r
1057\r
1058 #\r
1059 # Remove comments at tail and remove spaces again\r
1060 #\r
1061 Line = CleanString(Line)\r
1062 if Line == '':\r
1063 continue\r
1064\r
1065 #\r
1066 # Find a new section tab\r
1067 # First insert previous section items\r
1068 # And then parse the content of the new section\r
1069 #\r
1070 if Line.startswith(TAB_SECTION_START) and Line.endswith(TAB_SECTION_END):\r
1071 #\r
1072 # Insert items data of previous section\r
1073 #\r
1074 self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)\r
1075 #\r
1076 # Parse the new section\r
1077 #\r
1078 SectionItemList = []\r
1079 ArchList = []\r
1080 ThirdList = []\r
1081\r
1082 CurrentSection = ''\r
1083 LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)\r
1084 for Item in LineList:\r
1085 ItemList = GetSplitValueList(Item, TAB_SPLIT)\r
1086 if CurrentSection == '':\r
1087 CurrentSection = ItemList[0]\r
1088 else:\r
1089 if CurrentSection != ItemList[0]:\r
1090 EdkLogger.error("Parser", PARSER_ERROR, "Different section names '%s' and '%s' are found in one section definition, this is not allowed." % (CurrentSection, ItemList[0]), File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)\r
1091 if CurrentSection.upper() not in self.KeyList:\r
1092 RaiseParserError(Line, CurrentSection, Filename, '', LineNo)\r
1093 CurrentSection = TAB_UNKNOWN\r
1094 continue\r
1095 ItemList.append('')\r
1096 ItemList.append('')\r
1097 if len(ItemList) > 5:\r
1098 RaiseParserError(Line, CurrentSection, Filename, '', LineNo)\r
1099 else:\r
1100 if ItemList[1] != '' and ItemList[1].upper() not in ARCH_LIST_FULL:\r
1101 EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)\r
1102 ArchList.append(ItemList[1].upper())\r
1103 ThirdList.append(ItemList[2])\r
1104\r
1105 continue\r
1106\r
1107 #\r
1108 # Not in any defined section\r
1109 #\r
1110 if CurrentSection == TAB_UNKNOWN:\r
1111 ErrorMsg = "%s is not in any defined section" % Line\r
1112 EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError = EdkLogger.IsRaiseError)\r
1113\r
1114 #\r
1115 # Add a section item\r
1116 #\r
1117 SectionItemList.append([Line, LineNo])\r
1118 # End of parse\r
1119 #End of For\r
1120\r
1121 #\r
1122 # Insert items data of last section\r
1123 #\r
1124 self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)\r
1125\r
1126 #\r
1127 # Parse conditional statements\r
1128 #\r
1129 self.ParseConditionalStatement()\r
1130\r
1131 #\r
1132 # Replace all DEFINE macros with its actual values\r
1133 #\r
1134 #ParseDefineMacro2(self.TblDsc, self.RecordSet, GlobalData.gGlobalDefines)\r
1135 ParseDefineMacro(self.TblDsc, GlobalData.gGlobalDefines)\r
1136\r
1137\r
1138 ## ParseConditionalStatement\r
1139 #\r
1140 # Search all conditional statement and disable no match records\r
1141 #\r
1142 def ParseConditionalStatement(self):\r
1143 #\r
1144 # Disabled all !if/!elif/!ifdef statements without DEFINE\r
1145 #\r
1146 SqlCommand = """select A.StartLine, A.EndLine from %s as A\r
1147 where A.Model in (%s, %s, %s)\r
1148 and A.Enabled = 0\r
1149 and A.BelongsToFile = %s\r
1150 and A.Value1 not in (select B.Value1 from %s as B\r
1151 where B.Model = %s\r
1152 and B.Enabled = 0\r
1153 and A.StartLine > B.StartLine\r
1154 and A.Arch = B.Arch\r
1155 and A.BelongsToItem = B.BelongsToItem\r
1156 and A.BelongsToFile = B.BelongsToFile) """ % \\r
1157 (self.TblDsc.Table, \\r
1158 MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, \\r
1159 self.FileID, \\r
1160 self.TblDsc.Table, \\r
1161 MODEL_META_DATA_DEFINE)\r
1162 RecordSet = self.TblDsc.Exec(SqlCommand)\r
1163 for Record in RecordSet:\r
1164 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])\r
1165 self.TblDsc.Exec(SqlCommand)\r
1166\r
1167 #\r
1168 # Disabled !ifndef with DEFINE\r
1169 #\r
1170 SqlCommand = """select A.StartLine, A.EndLine from %s as A\r
1171 where A.Model = %s\r
1172 and A.Enabled = 0\r
1173 and A.BelongsToFile = %s\r
1174 and A.Value1 in (select B.Value1 from %s as B\r
1175 where B.Model = %s\r
1176 and B.Enabled = 0\r
1177 and A.StartLine > B.StartLine\r
1178 and A.Arch = B.Arch\r
1179 and A.BelongsToItem = B.BelongsToItem\r
1180 and A.BelongsToFile = B.BelongsToFile)""" % \\r
1181 (self.TblDsc.Table, \\r
1182 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF, \\r
1183 self.FileID, \\r
1184 self.TblDsc.Table, \\r
1185 MODEL_META_DATA_DEFINE)\r
1186 RecordSet = self.TblDsc.Exec(SqlCommand)\r
1187 for Record in RecordSet:\r
1188 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[0], Record[1])\r
1189 EdkLogger.debug(4, "SqlCommand: %s" %SqlCommand)\r
1190 self.Cur.execute(SqlCommand)\r
1191\r
1192 #\r
1193 # Disabled !if, !elif and !else with un-match value\r
1194 #\r
1195 SqlCommand = """select A.Model, A.Value1, A.Value2, A.Value3, A.StartLine, A.EndLine, B.Value2 from %s as A join %s as B\r
1196 where A.Model in (%s, %s)\r
1197 and A.Enabled = 0\r
1198 and A.BelongsToFile = %s\r
1199 and B.Enabled = 0\r
1200 and B.Model = %s\r
1201 and A.Value1 = B.Value1\r
1202 and A.StartLine > B.StartLine\r
1203 and A.BelongsToItem = B.BelongsToItem\r
1204 and A.BelongsToFile = B.BelongsToFile""" % \\r
1205 (self.TblDsc.Table, self.TblDsc.Table, \\r
1206 MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, \\r
1207 self.FileID, MODEL_META_DATA_DEFINE)\r
1208 RecordSet = self.TblDsc.Exec(SqlCommand)\r
1209 DisabledList = []\r
1210 for Record in RecordSet:\r
1211 if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_IF:\r
1212 if not self.Compare(Record[6], Record[2], Record[3]):\r
1213 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])\r
1214 self.TblDsc.Exec(SqlCommand)\r
1215 else:\r
1216 DisabledList.append(Record[1])\r
1217 continue\r
1218 if Record[0] == MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE and Record[1] in DisabledList:\r
1219 SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" %(self.TblDsc.Table, Record[4], Record[5])\r
1220 self.TblDsc.Exec(SqlCommand)\r
1221\r
1222 ## Compare\r
1223 #\r
1224 # Compare two values\r
1225 # @param Value1:\r
1226 # @param CompareType:\r
1227 # @param Value2:\r
1228 #\r
1229 def Compare(self, Value1, CompareType, Value2):\r
1230 Command = """Value1 %s Value2""" %CompareType\r
1231 return eval(Command)\r
1232\r
1233 ## First time to insert records to database\r
1234 #\r
1235 # Insert item data of a section to database\r
1236 # @param FileID: The ID of belonging file\r
1237 # @param Filename: The name of belonging file\r
1238 # @param CurrentSection: The name of currect section\r
1239 # @param SectionItemList: A list of items of the section\r
1240 # @param ArchList: A list of arches\r
1241 # @param ThirdList: A list of third parameters, ModuleType for LibraryClass and SkuId for Dynamic Pcds\r
1242 # @param IfDefList: A list of all conditional statements\r
1243 #\r
1244 def InsertSectionItemsIntoDatabase(self, FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList):\r
1245 #\r
1246 # Insert each item data of a section\r
1247 #\r
1248 for Index in range(0, len(ArchList)):\r
1249 Arch = ArchList[Index]\r
1250 Third = ThirdList[Index]\r
1251 if Arch == '':\r
1252 Arch = TAB_ARCH_COMMON.upper()\r
1253\r
1254 Model = Section[CurrentSection.upper()]\r
1255 #Records = self.RecordSet[Model]\r
1256\r
1257 for SectionItem in SectionItemList:\r
1258 BelongsToItem, EndLine, EndColumn = -1, -1, -1\r
1259 LineValue, StartLine, EndLine = SectionItem[0], SectionItem[1], SectionItem[1]\r
1260\r
1261\r
1262 EdkLogger.debug(4, "Parsing %s ..." %LineValue)\r
1263 #\r
1264 # Parse '!ifdef'\r
1265 #\r
1266 if LineValue.upper().find(TAB_IF_DEF.upper()) > -1:\r
1267 IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF))\r
1268 continue\r
1269\r
1270 #\r
1271 # Parse '!ifndef'\r
1272 #\r
1273 if LineValue.upper().find(TAB_IF_N_DEF.upper()) > -1:\r
1274 IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF))\r
1275 continue\r
1276\r
1277 #\r
1278 # Parse '!endif'\r
1279 #\r
1280 if LineValue.upper().find(TAB_END_IF.upper()) > -1:\r
1281 self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine, Arch)\r
1282 continue\r
1283 #\r
1284 # Parse '!if'\r
1285 #\r
1286 if LineValue.upper().find(TAB_IF.upper()) > -1:\r
1287 IfDefList.append((LineValue[len(TAB_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))\r
1288 continue\r
1289\r
1290 #\r
1291 # Parse '!elseif'\r
1292 #\r
1293 if LineValue.upper().find(TAB_ELSE_IF.upper()) > -1:\r
1294 self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine - 1, Arch)\r
1295 IfDefList.append((LineValue[len(TAB_ELSE_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))\r
1296 continue\r
1297\r
1298 #\r
1299 # Parse '!else'\r
1300 #\r
1301 if LineValue.upper().find(TAB_ELSE.upper()) > -1:\r
1302 Key = IfDefList[-1][0].split(' ' , 1)[0].strip()\r
1303 self.InsertConditionalStatement(Filename, FileID, Model, IfDefList, StartLine, Arch)\r
1304 IfDefList.append((Key, StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE))\r
1305 continue\r
1306\r
1307 #\r
1308 # Parse !include statement first\r
1309 #\r
1310 if LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') > -1:\r
1311 self.ParseInclude(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_INCLUDE, Arch)\r
1312 continue\r
1313\r
1314 #\r
1315 # And then parse DEFINE statement\r
1316 #\r
1317 if LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') > -1:\r
1318 self.ParseDefine(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_DEFINE, Arch)\r
1319 continue\r
1320\r
1321 #\r
1322 # At last parse other sections\r
1323 #\r
1324 if CurrentSection == TAB_LIBRARY_CLASSES or CurrentSection in TAB_PCD_DYNAMIC_TYPE_LIST or CurrentSection in TAB_PCD_DYNAMIC_EX_TYPE_LIST:\r
1325 ID = self.TblDsc.Insert(Model, LineValue, Third, '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)\r
1326 #Records.append([LineValue, Arch, StartLine, ID, Third])\r
1327 continue\r
1328 elif CurrentSection != TAB_COMPONENTS:\r
1329 ID = self.TblDsc.Insert(Model, LineValue, '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)\r
1330 #Records.append([LineValue, Arch, StartLine, ID, Third])\r
1331 continue\r
1332\r
1333 #\r
1334 # Parse COMPONENT section\r
1335 #\r
1336 if CurrentSection == TAB_COMPONENTS:\r
1337 Components = []\r
1338 GetComponent(SectionItemList, Components)\r
1339 for Component in Components:\r
1340 EdkLogger.debug(4, "Parsing component %s ..." %Component)\r
1341 DscItmeID = self.TblDsc.Insert(MODEL_META_DATA_COMPONENT, Component[0], '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)\r
1342 for Item in Component[1]:\r
1343 List = GetSplitValueList(Item, MaxSplit = 2)\r
1344 LibName, LibIns = '', ''\r
1345 if len(List) == 2:\r
1346 LibName = List[0]\r
1347 LibIns = List[1]\r
1348 else:\r
1349 LibName = List[0]\r
1350 self.TblDsc.Insert(MODEL_EFI_LIBRARY_CLASS, LibName, LibIns, '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)\r
1351 for Item in Component[2]:\r
1352 self.TblDsc.Insert(MODEL_META_DATA_BUILD_OPTION, Item, '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)\r
1353 for Item in Component[3]:\r
1354 Model = Section[Item[0].upper()]\r
1355 self.TblDsc.Insert(Model, Item[1], '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)\r
1356\r
1357 ## Show detailed information of Dsc\r
1358 #\r
1359 # Print all members and their values of Dsc class\r
1360 #\r
1361 def ShowDsc(self):\r
1362 print TAB_SECTION_START + TAB_INF_DEFINES + TAB_SECTION_END\r
1363 printDict(self.Defines.DefinesDictionary)\r
1364\r
1365 for Key in self.KeyList:\r
1366 for Arch in DataType.ARCH_LIST_FULL:\r
1367 Command = "printList(TAB_SECTION_START + '" + \\r
1368 Key + DataType.TAB_SPLIT + Arch + \\r
1369 "' + TAB_SECTION_END, self.Contents[arch]." + Key + ')'\r
1370 eval(Command)\r
1371\r
1372 ## Show detailed information of Platform\r
1373 #\r
1374 # Print all members and their values of Platform class\r
1375 #\r
1376 def ShowPlatform(self):\r
1377 M = self.Platform\r
1378 for Arch in M.Header.keys():\r
1379 print '\nArch =', Arch\r
1380 print 'Filename =', M.Header[Arch].FileName\r
1381 print 'FullPath =', M.Header[Arch].FullPath\r
1382 print 'BaseName =', M.Header[Arch].Name\r
1383 print 'Guid =', M.Header[Arch].Guid\r
1384 print 'Version =', M.Header[Arch].Version\r
1385 print 'DscSpecification =', M.Header[Arch].DscSpecification\r
1386 print 'SkuId =', M.Header[Arch].SkuIdName\r
1387 print 'SupArchList =', M.Header[Arch].SupArchList\r
1388 print 'BuildTargets =', M.Header[Arch].BuildTargets\r
1389 print 'OutputDirectory =', M.Header[Arch].OutputDirectory\r
1390 print 'BuildNumber =', M.Header[Arch].BuildNumber\r
1391 print 'MakefileName =', M.Header[Arch].MakefileName\r
1392 print 'BsBaseAddress =', M.Header[Arch].BsBaseAddress\r
1393 print 'RtBaseAddress =', M.Header[Arch].RtBaseAddress\r
1394 print 'Define =', M.Header[Arch].Define\r
1395 print 'Fdf =', M.FlashDefinitionFile.FilePath\r
1396 print '\nBuildOptions =', M.BuildOptions, M.BuildOptions.IncludeFiles\r
1397 for Item in M.BuildOptions.BuildOptionList:\r
1398 print '\t', 'ToolChainFamily =', Item.ToolChainFamily, 'ToolChain =', Item.ToolChain, 'Option =', Item.Option, 'Arch =', Item.SupArchList\r
1399 print '\nSkuIds =', M.SkuInfos.SkuInfoList, M.SkuInfos.IncludeFiles\r
1400 print '\nLibraries =', M.Libraries, M.Libraries.IncludeFiles\r
1401 for Item in M.Libraries.LibraryList:\r
1402 print '\t', Item.FilePath, Item.SupArchList, Item.Define\r
1403 print '\nLibraryClasses =', M.LibraryClasses, M.LibraryClasses.IncludeFiles\r
1404 for Item in M.LibraryClasses.LibraryList:\r
1405 print '\t', Item.Name, Item.FilePath, Item.SupModuleList, Item.SupArchList, Item.Define\r
1406 print '\nPcds =', M.DynamicPcdBuildDefinitions\r
1407 for Item in M.DynamicPcdBuildDefinitions:\r
1408 print '\tCname=', Item.CName, 'TSG=', Item.TokenSpaceGuidCName, 'Value=', Item.DefaultValue, 'Token=', Item.Token, 'Type=', Item.ItemType, 'Datum=', Item.DatumType, 'Size=', Item.MaxDatumSize, 'Arch=', Item.SupArchList, Item.SkuInfoList\r
1409 for Sku in Item.SkuInfoList.values():\r
1410 print '\t\t', str(Sku)\r
1411 print '\nComponents =', M.Modules.ModuleList, M.Modules.IncludeFiles\r
1412 for Item in M.Modules.ModuleList:\r
1413 print '\t', Item.FilePath, Item.ExecFilePath, Item.SupArchList\r
1414 for Lib in Item.LibraryClasses.LibraryList:\r
1415 print '\t\tLib:', Lib.Name, Lib.FilePath\r
1416 for Bo in Item.ModuleSaBuildOption.BuildOptionList:\r
1417 print '\t\tBuildOption:', Bo.ToolChainFamily, Bo.ToolChain, Bo.Option\r
1418 for Pcd in Item.PcdBuildDefinitions:\r
1419 print '\t\tPcd:', Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.MaxDatumSize, Pcd.DefaultValue, Pcd.ItemType\r
1420\r
1421##\r
1422#\r
1423# This acts like the main() function for the script, unless it is 'import'ed into another\r
1424# script.\r
1425#\r
1426if __name__ == '__main__':\r
1427 EdkLogger.Initialize()\r
1428 EdkLogger.SetLevel(EdkLogger.DEBUG_0)\r
1429\r
1430 W = os.getenv('WORKSPACE')\r
1431 F = os.path.join(W, 'Nt32Pkg/Nt32Pkg.dsc')\r
1432\r
1433 Db = Database.Database('Dsc.db')\r
1434 Db.InitDatabase()\r
1435\r
1436 P = Dsc(os.path.normpath(F), True, True, W, Db)\r
1437 P.ShowPlatform()\r
1438\r
1439 Db.Close()\r