## @file
# This file is used to define each component of DSC file
#
# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>
# This program and the accompanying materials
# are licensed and made available under the terms and conditions of the BSD License
# which accompanies this distribution. The full text of the license may be found at
#
# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#
##
# Import Modules
#
import os
import Database
from String import *
from Parsing import *
from DataType import *
from Identification import *
from Dictionary import *
from CommonDataClass.PlatformClass import *
from BuildToolError import *
import GlobalData
#
# Global variable
#
}
## DscObject
#
# This class defined basic Dsc object which is used by inheriting
#
# @param object: Inherited from object class
#
## Dsc
#
# This class defined the structure used in Dsc object
#
# @param DscObject: Inherited from InfObject class
# @param Ffilename: Input value for Ffilename of Inf file, default is None
# @param IsMergeAllArches: Input value for IsMergeAllArches
# True is to merge all arches
# Fales is not to merge all arches
# default is False
# @param IsToPlatform: Input value for IsToPlatform
# True is to transfer to ModuleObject automatically
# False is not to transfer to ModuleObject automatically
# default is False
# @param WorkspaceDir: Input value for current workspace directory, default is None
#
# @var _NullClassIndex: To store value for _NullClassIndex, default is 0
# @var Identification: To store value for Identification, it is a structure as Identification
# @var Defines: To store value for Defines, it is a structure as DscDefines
# @var Contents: To store value for Contents, it is a structure as DscContents
# @var UserExtensions: To store value for UserExtensions
# @var Platform: To store value for Platform, it is a structure as PlatformClass
# @var WorkspaceDir: To store value for WorkspaceDir
# @var KeyList: To store value for KeyList, a list for all Keys used in Dec
#
def __init__(self, Filename=None, IsToDatabase=False, IsToPlatform=False, WorkspaceDir=None, Database=None):
]
#
# Upper all KEYs to ignore case sensitive when parsing
#
#
# Init RecordSet
#
# self.RecordSet = {}
# for Key in self.KeyList:
# self.RecordSet[Section[Key]] = []
#
# Load Dsc file if filename is not None
#
if Filename != None:
#
# Transfer to Platform Object if IsToPlatform is True
#
if IsToPlatform:
## Transfer to Platform Object
#
# Transfer all contents of an Inf file to a standard Module Object
#
#
# Init global information for the file
#
#
# Generate Platform Header
#
#
# Generate BuildOptions
#
#
# Generate SkuInfos
#
#
# Generate Libraries
#
#
# Generate LibraryClasses
#
#
# Generate Pcds
#
#
# Generate Components
#
#
# Update to database
#
if self.IsToDatabase:
SqlCommand = """update %s set Value2 = '%s' where ID = %s""" % (self.TblDsc.Table, ".".join((self.PcdToken[Key][0], self.PcdToken[Key][1])), Key)
#End of DscToPlatform
## Get Platform Header
#
# Gen Platform Header of Dsc as <Key> = <Value>
#
# @param ContainerFile: The Dsc file full path
#
#
# Update all defines item in database
#
SqlCommand = """select ID, Value1, Arch, StartLine from %s
where Model = %s
and BelongsToFile = %s
SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Value1), ConvertToSqlString2(Value2), ID)
#
# Get detailed information
#
PlatformHeader.Name = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_NAME, Arch, self.FileID)[0]
PlatformHeader.Guid = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_GUID, Arch, self.FileID)[0]
PlatformHeader.Version = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_PLATFORM_VERSION, Arch, self.FileID)[0]
PlatformHeader.DscSpecification = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_DSC_SPECIFICATION, Arch, self.FileID)[0]
PlatformHeader.SkuIdName = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_SKUID_IDENTIFIER, Arch, self.FileID)
PlatformHeader.SupArchList = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES, Arch, self.FileID)
PlatformHeader.BuildTargets = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BUILD_TARGETS, Arch, self.FileID)
PlatformHeader.OutputDirectory = NormPath(QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_OUTPUT_DIRECTORY, Arch, self.FileID)[0])
PlatformHeader.BuildNumber = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BUILD_NUMBER, Arch, self.FileID)[0]
PlatformHeader.MakefileName = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_MAKEFILE_NAME, Arch, self.FileID)[0]
PlatformHeader.BsBaseAddress = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_BS_BASE_ADDRESS, Arch, self.FileID)[0]
PlatformHeader.RtBaseAddress = QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_RT_BASE_ADDRESS, Arch, self.FileID)[0]
Fdf.FilePath = NormPath(QueryDefinesItem(self.TblDsc, TAB_DSC_DEFINES_FLASH_DEFINITION, Arch, self.FileID)[0])
## GenBuildOptions
#
# Gen BuildOptions of Dsc
# [<Family>:]<ToolFlag>=Flag
#
# @param ContainerFile: The Dsc file full path
#
BuildOptions = {}
#
# Get all include files
#
IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_BUILD_OPTION, self.FileID)
#
# Get all BuildOptions
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_BUILD_OPTIONS, '', IncludeFile[2])
continue
#
# Update to Database
#
if self.IsToDatabase:
SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(Family), ConvertToSqlString2(ToolChain), ConvertToSqlString2(Flag), Record[3])
## GenSkuInfos
#
# Gen SkuInfos of Dsc
# <Integer>|<UiName>
#
# @param ContainerFile: The Dsc file full path
#
#
# SkuIds
# <Integer>|<UiName>
#
#
# Get all include files
#
#
# Get all SkuInfos
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_SKUIDS, '', IncludeFile[2])
continue
else:
else:
#
# Update to Database
#
if self.IsToDatabase:
SqlCommand = """update %s set Value1 = '%s', Value2 = '%s'
where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(List[0]), ConvertToSqlString2(List[1]), Record[3])
## GenLibraries
#
# Gen Libraries of Dsc
# <PathAndFilename>
#
# @param ContainerFile: The Dsc file full path
#
Libraries = {}
#
# Get all include files
#
IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_INSTANCE, self.FileID)
#
# Get all Libraries
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARIES, '', IncludeFile[2])
continue
## GenLibraryClasses
#
# Get LibraryClasses of Dsc
# <LibraryClassKeyWord>|<LibraryInstance>
#
# @param ContainerFile: The Dsc file full path
#
LibraryClasses = {}
#
# Get all include files
#
IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_EFI_LIBRARY_CLASS, self.FileID)
#
# Get all LibraryClasses
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_LIBRARY_CLASSES, '', IncludeFile[2])
continue
MergeArches(LibraryClasses, GetLibraryClass([NewItem, IncludeFile[4]], Filename, self.WorkspaceDir, -1), Arch)
(LibClassName, LibClassIns, SupModelList) = GetLibraryClass([Record[0], Record[4]], ContainerFile, self.WorkspaceDir, Record[2])
#
# Update to Database
#
if self.IsToDatabase:
SqlCommand = """update %s set Value1 = '%s', Value2 = '%s', Value3 = '%s'
where ID = %s""" % (self.TblDsc.Table, ConvertToSqlString2(LibClassName), ConvertToSqlString2(LibClassIns), ConvertToSqlString2(SupModelList), Record[3])
## Gen Pcds
#
# Gen Pcd of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<Type>|<MaximumDatumSize>]
#
# @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
Pcds = {}
else:
pass
#
# Get all include files
#
#
# Get all Pcds
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
continue
(TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(NewItem, Type, Filename, -1)
(TokenName, TokenGuidCName, Value, DatumType, MaxDatumSize, Type) = GetPcd(Record[0], Type, ContainerFile, Record[2])
## Gen FeatureFlagPcds
#
#
# @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
Pcds = {}
else:
pass
#
# Get all include files
#
#
# Get all FeatureFlagPcds
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
continue
(TokenName, TokenGuidCName, Value, Type) = GetFeatureFlagPcd(Record[0], Type, ContainerFile, Record[2])
## Gen DynamicDefaultPcds
#
# Gen DynamicDefaultPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<Value>[|<DatumTyp>[|<MaxDatumSize>]]
#
# @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
Pcds = {}
SkuInfoList = {}
else:
pass
#
# Get all include files
#
#
# Get all DynamicDefaultPcds
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
continue
(Status, SkuInfoList) = self.GenSkuInfoList(Key[6], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', '', Key[2])
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError=EdkLogger.IsRaiseError)
## Gen DynamicHiiPcds
#
# Gen DynamicHiiPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<String>|<VariableGuidCName>|<VariableOffset>[|<DefaultValue>[|<MaximumDatumSize>]]
#
# @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
Pcds = {}
SkuInfoList = {}
else:
pass
#
# Get all include files
#
#
# Get all DynamicHiiPcds
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
continue
(Status, SkuInfoList) = self.GenSkuInfoList(Key[8], self.Platform.SkuInfos.SkuInfoList, Key[2], Key[3], Key[4], Key[5], '', '')
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError=EdkLogger.IsRaiseError)
## Gen DynamicVpdPcds
#
# Gen DynamicVpdPcds of Dsc as <PcdTokenSpaceGuidCName>.<TokenCName>|<VpdOffset>[|<MaximumDatumSize>]
#
# @param Type: The type of Pcd
# @param ContainerFile: The file which describes the pcd, used for error report
#
Pcds = {}
SkuInfoList = {}
else:
pass
#
# Get all include files
#
#
# Get all DynamicVpdPcds
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, Type, '', IncludeFile[2])
continue
(Status, SkuInfoList) = self.GenSkuInfoList(Key[5], self.Platform.SkuInfos.SkuInfoList, '', '', '', '', Key[2], '')
ErrorMsg = "The SKUID '%s' used in section '%s' is not defined in section [SkuIds]" % (SkuInfoList, Type)
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, ContainerFile, RaiseError=EdkLogger.IsRaiseError)
## Get Component
#
# Get Component section defined in Dsc file
#
# @param ContainerFile: The file which describes the Components, used for error report
#
# @retval PlatformModuleClass() A instance for PlatformModuleClass
#
Components = sdict()
#
# Get all include files
#
IncludeFiles = QueryDscItem(self.TblDsc, MODEL_META_DATA_INCLUDE, MODEL_META_DATA_COMPONENT, self.FileID)
#
# Get all Components
#
#
# Go through each arch
#
for IncludeFile in IncludeFiles:
Filename = CheckFileExist(self.WorkspaceDir, IncludeFile[0], ContainerFile, TAB_COMPONENTS, '', IncludeFile[2])
continue
NewItems = []
for NewComponent in NewItems:
for SubPcd in SubPcdSet1:
for SubPcd in SubPcdSet2:
for SubPcd in SubPcdSet3:
for SubPcd in SubPcdSet4:
for SubPcd in SubPcdSet5:
## Get Component
#
# Get Component section defined in Dsc file
#
# @param Item: Contents includes a component block
# @param ContainerFile: The file which describes the library class, used for error report
#
# @retval PlatformModuleClass() A instance for PlatformModuleClass
#
for Lib in LibraryClasses:
CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'library instance of component', Lib, LineNo)
for BuildOption in BuildOptions:
TokenInfo = None
#
# For FeatureFlag
#
RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|TRUE/FALSE')
Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', List[1], Type, [], {}, []))
#
# For FixedAtBuild or PatchableInModule
#
RaiseParserError(Pcd[1], 'Components', ContainerFile, '<PcdTokenSpaceGuidCName>.<PcdTokenName>|<Value>[|<MaxDatumSize>]')
Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', List[2], List[1], Type, [], {}, []))
#
# For Dynamic or DynamicEx
#
Component.PcdBuildDefinitions.append(PcdClass(TokenInfo[1], '', TokenInfo[0], '', '', '', Type, [], {}, []))
#
# Add to PcdToken
#
return Component
#End of GenComponent
## Gen SkuInfoList
#
# Gen SkuInfoList section defined in Dsc file
#
# @param SkuNameList: Input value for SkuNameList
# @param SkuInfo: Input value for SkuInfo
# @param VariableName: Input value for VariableName
# @param VariableGuid: Input value for VariableGuid
# @param VariableOffset: Input value for VariableOffset
# @param HiiDefaultValue: Input value for HiiDefaultValue
# @param VpdOffset: Input value for VpdOffset
# @param DefaultValue: Input value for DefaultValue
#
# @retval (False, SkuName) Not found in section SkuId Dsc file
# @retval (True, SkuInfoList) Found in section SkuId of Dsc file
#
def GenSkuInfoList(self, SkuNameList, SkuInfo, VariableName='', VariableGuid='', VariableOffset='', HiiDefaultValue='', VpdOffset='', DefaultValue=''):
SkuNameList = ['DEFAULT']
SkuInfoList = {}
for Item in SkuNameList:
Sku = SkuInfoClass(Item, SkuInfo[Item], VariableName, VariableGuid, VariableOffset, HiiDefaultValue, VpdOffset, DefaultValue)
return True, SkuInfoList
## Parse Include statement
#
# Get include file path
#
# 1. Insert a record into TblFile ???
# 2. Insert a record into TblDsc
# Value1: IncludeFilePath
#
# @param LineValue: The line of incude statement
EdkLogger.debug(EdkLogger.DEBUG_2, "!include statement '%s' found in section %s" % (LineValue, SectionName))
IncludeFile = CleanString(LineValue[LineValue.upper().find(DataType.TAB_INCLUDE.upper() + ' ') + len(DataType.TAB_INCLUDE + ' ') : ])
Table.Insert(Model, IncludeFile, '', '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)
## Parse DEFINE statement
#
# Get DEFINE macros
#
# 1. Insert a record into TblDsc
# Value1: Macro Name
# Value2: Macro Value
#
EdkLogger.debug(EdkLogger.DEBUG_2, "DEFINE statement '%s' found in section %s" % (LineValue, SectionName))
Define = GetSplitValueList(CleanString(LineValue[LineValue.upper().find(DataType.TAB_DEFINE.upper() + ' ') + len(DataType.TAB_DEFINE + ' ') : ]), TAB_EQUAL_SPLIT, 1)
Table.Insert(Model, Define[0], Define[1], '', Arch, SectionModel, FileID, StartLine, -1, StartLine, -1, 0)
## Parse Defines section
#
# Get one item in defines section
#
# Value1: Item Name
# Value2: Item Value
#
def ParseDefinesSection(self, LineValue, StartLine, Table, FileID, Filename, SectionName, Model, Arch):
self.TblDsc.Insert(Model, Defines[0], Defines[1], '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
## Insert conditional statements
#
# Pop an item from IfDefList
# Insert conditional statements to database
#
# @param Filename: Path of parsing file
# @param IfDefList: A list stored current conditional statements
# @param EndLine: The end line no
# @param ArchList: Support arch list
#
def InsertConditionalStatement(self, Filename, FileID, BelongsToItem, IfDefList, EndLine, ArchList):
if IfDefList == []:
EdkLogger.error("DSC File Parser", PARSER_ERROR, ErrorMsg, Filename, RaiseError=EdkLogger.IsRaiseError)
else:
#
# Get New Dsc item ID
#
#
# Pop the conditional statements which is closed
#
#
# !ifdef and !ifndef
#
if PreviousIf[2] in (MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF):
self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
#
# !if and !elseif
#
self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
#
# !else
#
self.TblDsc.Insert(Model, Value1, Value2, Value3, ArchList, BelongsToItem, self.FileID, PreviousIf[1], StartColumn, EndLine, EndColumn, Enabled)
## Load Dsc file
#
# Load the file if it exists
#
# @param Filename: Input value for filename of Dsc file
#
#
# Insert a record for file
#
#
# Init DscTable
#
#self.TblDsc.Table = "Dsc%s" % FileID
#self.TblDsc.Create()
#
# Init common datas
#
[], [], TAB_UNKNOWN, [], [], []
LineNo = 0
#
# Parse file content
#
ReservedLine = ''
#
# Remove comment block
#
ReservedLine = ''
continue
#
# Remove comments at tail and remove spaces again
#
if Line == '':
continue
#
# Find a new section tab
# First insert previous section items
# And then parse the content of the new section
#
#
# Insert items data of previous section
#
self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)
#
# Parse the new section
#
SectionItemList = []
ArchList = []
ThirdList = []
CurrentSection = ''
LineList = GetSplitValueList(Line[len(TAB_SECTION_START):len(Line) - len(TAB_SECTION_END)], TAB_COMMA_SPLIT)
if CurrentSection == '':
else:
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)
continue
else:
EdkLogger.error("Parser", PARSER_ERROR, "Invalid Arch definition '%s' found" % ItemList[1], File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
continue
#
# Not in any defined section
#
if CurrentSection == TAB_UNKNOWN:
EdkLogger.error("Parser", PARSER_ERROR, ErrorMsg, File=Filename, Line=LineNo, RaiseError=EdkLogger.IsRaiseError)
#
# Add a section item
#
# End of parse
#End of For
#
# Insert items data of last section
#
self.InsertSectionItemsIntoDatabase(self.FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList)
#
# Parse conditional statements
#
#
# Replace all DEFINE macros with its actual values
#
#ParseDefineMacro2(self.TblDsc, self.RecordSet, GlobalData.gGlobalDefines)
## ParseConditionalStatement
#
# Search all conditional statement and disable no match records
#
#
# Disabled all !if/!elif/!ifdef statements without DEFINE
#
SqlCommand = """select A.StartLine, A.EndLine from %s as A
where A.Model in (%s, %s, %s)
and A.Enabled = 0
and A.BelongsToFile = %s
and A.Value1 not in (select B.Value1 from %s as B
where B.Model = %s
and B.Enabled = 0
and A.StartLine > B.StartLine
and A.Arch = B.Arch
and A.BelongsToItem = B.BelongsToItem
and A.BelongsToFile = B.BelongsToFile) """ % \
MODEL_META_DATA_CONDITIONAL_STATEMENT_IF, MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF, \
SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[0], Record[1])
#
# Disabled !ifndef with DEFINE
#
SqlCommand = """select A.StartLine, A.EndLine from %s as A
where A.Model = %s
and A.Enabled = 0
and A.BelongsToFile = %s
and A.Value1 in (select B.Value1 from %s as B
where B.Model = %s
and B.Enabled = 0
and A.StartLine > B.StartLine
and A.Arch = B.Arch
and A.BelongsToItem = B.BelongsToItem
and A.BelongsToFile = B.BelongsToFile)""" % \
SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[0], Record[1])
#
# Disabled !if, !elif and !else with un-match value
#
SqlCommand = """select A.Model, A.Value1, A.Value2, A.Value3, A.StartLine, A.EndLine, B.Value2 from %s as A join %s as B
where A.Model in (%s, %s)
and A.Enabled = 0
and A.BelongsToFile = %s
and B.Enabled = 0
and B.Model = %s
and A.Value1 = B.Value1
and A.StartLine > B.StartLine
and A.BelongsToItem = B.BelongsToItem
and A.BelongsToFile = B.BelongsToFile""" % \
DisabledList = []
SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[4], Record[5])
else:
continue
SqlCommand = """Update %s set Enabled = -1 where StartLine >= %s and EndLine <= %s""" % (self.TblDsc.Table, Record[4], Record[5])
## Compare
#
# Compare two values
# @param Value1:
# @param CompareType:
# @param Value2:
#
## First time to insert records to database
#
# Insert item data of a section to database
# @param FileID: The ID of belonging file
# @param Filename: The name of belonging file
# @param CurrentSection: The name of currect section
# @param SectionItemList: A list of items of the section
# @param ArchList: A list of arches
# @param ThirdList: A list of third parameters, ModuleType for LibraryClass and SkuId for Dynamic Pcds
# @param IfDefList: A list of all conditional statements
#
def InsertSectionItemsIntoDatabase(self, FileID, Filename, CurrentSection, SectionItemList, ArchList, ThirdList, IfDefList):
#
# Insert each item data of a section
#
if Arch == '':
#Records = self.RecordSet[Model]
for SectionItem in SectionItemList:
#
# Parse '!ifdef'
#
IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF))
continue
#
# Parse '!ifndef'
#
IfDefList.append((LineValue[len(TAB_IF_N_DEF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF))
continue
#
# Parse '!endif'
#
continue
#
# Parse '!if'
#
IfDefList.append((LineValue[len(TAB_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))
continue
#
# Parse '!elseif'
#
IfDefList.append((LineValue[len(TAB_ELSE_IF):].strip(), StartLine, MODEL_META_DATA_CONDITIONAL_STATEMENT_IF))
continue
#
# Parse '!else'
#
continue
#
# Parse !include statement first
#
self.ParseInclude(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_INCLUDE, Arch)
continue
#
# And then parse DEFINE statement
#
self.ParseDefine(LineValue, StartLine, self.TblDsc, FileID, Filename, CurrentSection, MODEL_META_DATA_DEFINE, Arch)
continue
#
# At last parse other sections
#
if CurrentSection == TAB_LIBRARY_CLASSES or CurrentSection in TAB_PCD_DYNAMIC_TYPE_LIST or CurrentSection in TAB_PCD_DYNAMIC_EX_TYPE_LIST:
ID = self.TblDsc.Insert(Model, LineValue, Third, '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
#Records.append([LineValue, Arch, StartLine, ID, Third])
continue
elif CurrentSection != TAB_COMPONENTS:
ID = self.TblDsc.Insert(Model, LineValue, '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
#Records.append([LineValue, Arch, StartLine, ID, Third])
continue
#
# Parse COMPONENT section
#
if CurrentSection == TAB_COMPONENTS:
Components = []
for Component in Components:
DscItmeID = self.TblDsc.Insert(MODEL_META_DATA_COMPONENT, Component[0], '', '', Arch, -1, FileID, StartLine, -1, StartLine, -1, 0)
else:
self.TblDsc.Insert(MODEL_EFI_LIBRARY_CLASS, LibName, LibIns, '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
self.TblDsc.Insert(MODEL_META_DATA_BUILD_OPTION, Item, '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
self.TblDsc.Insert(Model, Item[1], '', '', Arch, DscItmeID, FileID, StartLine, -1, StartLine, -1, 0)
## Show detailed information of Dsc
#
# Print all members and their values of Dsc class
#
Command = "printList(TAB_SECTION_START + '" + \
## Show detailed information of Platform
#
# Print all members and their values of Platform class
#
print '\nArch =', Arch
print '\t', 'ToolChainFamily =', Item.ToolChainFamily, 'ToolChain =', Item.ToolChain, 'Option =', Item.Option, 'Arch =', Item.SupArchList
print '\nPcds =', M.DynamicPcdBuildDefinitions
for Item in M.DynamicPcdBuildDefinitions:
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
print '\t\tPcd:', Pcd.CName, Pcd.TokenSpaceGuidCName, Pcd.MaxDatumSize, Pcd.DefaultValue, Pcd.ItemType
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another
# script.
#
if __name__ == '__main__':
P.ShowPlatform()