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