diff options
author | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-09-06 01:58:00 +0000 |
---|---|---|
committer | qhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-09-06 01:58:00 +0000 |
commit | e56468c072e0d53834787f4ad0e292b33cc6be08 (patch) | |
tree | 9b101cd782db879a969041b7bd389ad2b8453b10 /BaseTools/Source/Python/Workspace | |
parent | 034ffda8b2ec8575a9a6f42b1dc9ff6db1621a97 (diff) | |
download | edk2-platforms-e56468c072e0d53834787f4ad0e292b33cc6be08.tar.xz |
Sync EDKII BaseTools to BaseTools project r2042.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10850 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
-rw-r--r-- | BaseTools/Source/Python/Workspace/BuildClassObject.py | 10 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 78 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 73 |
3 files changed, 142 insertions, 19 deletions
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py index f0fef4dda3..7d709d3f0b 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -1,7 +1,7 @@ ## @file
# This file is used to define each component of the build database
#
-# Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.<BR>
+# 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
@@ -31,6 +31,7 @@ from Common.BuildToolError import * # @param MaxDatumSize: Input value for MaxDatumSize of Pcd, default is None
# @param SkuInfoList: Input value for SkuInfoList of Pcd, default is {}
# @param IsOverrided: Input value for IsOverrided of Pcd, default is False
+# @param GuidValue: Input value for TokenSpaceGuidValue of Pcd, default is None
#
# @var TokenCName: To store value for TokenCName
# @var TokenSpaceGuidCName: To store value for TokenSpaceGuidCName
@@ -43,7 +44,7 @@ from Common.BuildToolError import * # @var Phase: To store value for Phase, default is "DXE"
#
class PcdClassObject(object):
- def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, GuidValue = None):
+ def __init__(self, Name = None, Guid = None, Type = None, DatumType = None, Value = None, Token = None, MaxDatumSize = None, SkuInfoList = {}, IsOverrided = False, GuidValue = None):
self.TokenCName = Name
self.TokenSpaceGuidCName = Guid
self.TokenSpaceGuidValue = GuidValue
@@ -55,7 +56,8 @@ class PcdClassObject(object): self.SkuInfoList = SkuInfoList
self.Phase = "DXE"
self.Pending = False
-
+ self.IsOverrided = IsOverrided
+
## Convert the class to a string
#
# Convert each member of the class to string
@@ -73,7 +75,7 @@ class PcdClassObject(object): 'MaxDatumSize=' + str(self.MaxDatumSize) + ', '
for Item in self.SkuInfoList.values():
Rtn = Rtn + 'SkuId=' + Item.SkuId + ', ' + 'SkuIdName=' + Item.SkuIdName
- Rtn = Rtn + str(self.IsOverrided)
+ Rtn = Rtn + ', IsOverrided=' + str(self.IsOverrided)
return Rtn
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 7a6152c8fb..fb66e41fb5 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -82,6 +82,7 @@ class MetaFileParser(object): self.MetaFile = FilePath self._FileDir = os.path.dirname(self.MetaFile) self._Macros = copy.copy(Macros) + self._Macros["WORKSPACE"] = os.environ["WORKSPACE"] # for recursive parsing self._Owner = Owner @@ -490,7 +491,12 @@ class InfParser(MetaFileParser): ## [FixedPcd], [FeaturePcd], [PatchPcd], [Pcd] and [PcdEx] sections parser def _PcdParser(self): TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT, 1) - self._ValueList[0:1] = GetSplitValueList(TokenList[0], TAB_SPLIT) + ValueList = GetSplitValueList(TokenList[0], TAB_SPLIT) + if len(ValueList) != 2: + EdkLogger.error('Parser', FORMAT_INVALID, "Illegal token space GUID and PCD name format", + ExtraData=self._CurrentLine + " (<TokenSpaceGuidCName>.<PcdCName>)", + File=self.MetaFile, Line=self._LineIndex+1) + self._ValueList[0:1] = ValueList if len(TokenList) > 1: self._ValueList[2] = TokenList[1] if self._ValueList[0] == '' or self._ValueList[1] == '': @@ -564,6 +570,7 @@ class DscParser(MetaFileParser): # sections which allow "!include" directive _IncludeAllowedSection = [ + TAB_COMMON_DEFINES.upper(), TAB_LIBRARIES.upper(), TAB_LIBRARY_CLASSES.upper(), TAB_SKUIDS.upper(), @@ -648,7 +655,25 @@ class DscParser(MetaFileParser): continue # file private macros elif Line.upper().startswith('DEFINE '): - self._MacroParser() + (Name, Value) = self._MacroParser() + # Make the defined macro in DSC [Defines] section also + # available for FDF file. + if self._SectionName == TAB_COMMON_DEFINES.upper(): + self._LastItem = self._Store( + MODEL_META_DATA_GLOBAL_DEFINE, + Name, + Value, + '', + 'COMMON', + 'COMMON', + self._Owner, + self._From, + self._LineIndex+1, + -1, + self._LineIndex+1, + -1, + self._Enabled + ) continue elif Line.upper().startswith('EDK_GLOBAL '): (Name, Value) = self._MacroParser() @@ -715,6 +740,22 @@ class DscParser(MetaFileParser): if TokenList[0] in ['FLASH_DEFINITION', 'OUTPUT_DIRECTORY']: TokenList[1] = NormPath(TokenList[1], self._Macros) self._ValueList[0:len(TokenList)] = TokenList + # Treat elements in the [defines] section as global macros for FDF file. + self._LastItem = self._Store( + MODEL_META_DATA_GLOBAL_DEFINE, + TokenList[0], + TokenList[1], + '', + 'COMMON', + 'COMMON', + self._Owner, + self._From, + self._LineIndex+1, + -1, + self._LineIndex+1, + -1, + self._Enabled + ) ## <subsection_header> parser def _SubsectionHeaderParser(self): @@ -762,7 +803,7 @@ class DscParser(MetaFileParser): EdkLogger.error("Parser", FORMAT_INVALID, File=self.MetaFile, Line=self._LineIndex+1, ExtraData="'!include' is not allowed under section [%s]" % self._SectionName) # the included file must be relative to the parsing file - IncludedFile = os.path.join(self._FileDir, self._ValueList[1]) + IncludedFile = os.path.join(self._FileDir, NormPath(self._ValueList[1], self._Macros)) Parser = DscParser(IncludedFile, self._FileType, self._Table, self._Macros, From=self._LastItem) # set the parser status with current status Parser._SectionName = self._SectionName @@ -781,6 +822,7 @@ class DscParser(MetaFileParser): self._SectionType = Parser._SectionType self._Scope = Parser._Scope self._Enabled = Parser._Enabled + self._Macros.update(Parser._Macros) else: if DirectiveName in ["!IF", "!IFDEF", "!IFNDEF"]: # evaluate the expression @@ -965,6 +1007,7 @@ class DecParser(MetaFileParser): # def __init__(self, FilePath, FileType, Table, Macro=None): MetaFileParser.__init__(self, FilePath, FileType, Table, Macro, -1) + self._Comments = [] ## Parser starter def Start(self): @@ -975,27 +1018,34 @@ class DecParser(MetaFileParser): EdkLogger.error("Parser", FILE_READ_FAILURE, ExtraData=self.MetaFile) for Index in range(0, len(self._Content)): - Line = CleanString(self._Content[Index]) + Line, Comment = CleanString2(self._Content[Index]) + self._CurrentLine = Line + self._LineIndex = Index + + # save comment for later use + if Comment: + self._Comments.append((Comment, self._LineIndex+1)) # skip empty line if Line == '': continue - self._CurrentLine = Line - self._LineIndex = Index # section header if Line[0] == TAB_SECTION_START and Line[-1] == TAB_SECTION_END: self._SectionHeaderParser() + self._Comments = [] continue elif Line.startswith('DEFINE '): self._MacroParser() continue elif len(self._SectionType) == 0: + self._Comments = [] continue # section content self._ValueList = ['','',''] self._SectionParser[self._SectionType[0]](self) if self._ValueList == None: + self._Comments = [] continue # @@ -1017,6 +1067,22 @@ class DecParser(MetaFileParser): -1, 0 ) + for Comment, LineNo in self._Comments: + self._Store( + MODEL_META_DATA_COMMENT, + Comment, + self._ValueList[0], + self._ValueList[1], + Arch, + ModuleType, + self._LastItem, + LineNo, + -1, + LineNo, + -1, + 0 + ) + self._Comments = [] self._Done() ## Section header parser diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 3aabd545d5..dad6ecd49a 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -18,6 +18,7 @@ import sqlite3 import os
import os.path
import pickle
+import uuid
import Common.EdkLogger as EdkLogger
import Common.GlobalData as GlobalData
@@ -99,6 +100,10 @@ class DscBuildData(PlatformBuildClassObject): RecordList = self._RawData[MODEL_META_DATA_DEFINE, self._Arch]
for Record in RecordList:
GlobalData.gEdkGlobal[Record[0]] = Record[1]
+
+ RecordList = self._RawData[MODEL_META_DATA_GLOBAL_DEFINE, self._Arch]
+ for Record in RecordList:
+ GlobalData.gGlobalDefines[Record[0]] = Record[1]
## XXX[key] = value
def __setitem__(self, key, value):
@@ -135,6 +140,8 @@ class DscBuildData(PlatformBuildClassObject): self._Pcds = None
self._BuildOptions = None
self._LoadFixAddress = None
+ self._VpdToolGuid = None
+ self._VpdFileName = None
## Get architecture
def _GetArch(self):
@@ -188,6 +195,18 @@ class DscBuildData(PlatformBuildClassObject): self._SkuName = Record[1]
elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS:
self._LoadFixAddress = Record[1]
+ elif Name == TAB_DSC_DEFINES_VPD_TOOL_GUID:
+ #
+ # try to convert GUID to a real UUID value to see whether the GUID is format
+ # for VPD_TOOL_GUID is correct.
+ #
+ try:
+ uuid.UUID(Record[1])
+ except:
+ EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID format for VPD_TOOL_GUID", File=self.MetaFile)
+ self._VpdToolGuid = Record[1]
+ elif Name == TAB_DSC_DEFINES_VPD_FILENAME:
+ self._VpdFileName = Record[1]
# set _Header to non-None in order to avoid database re-querying
self._Header = 'DUMMY'
@@ -267,6 +286,8 @@ class DscBuildData(PlatformBuildClassObject): def _SetSkuName(self, Value):
if Value in self.SkuIds:
self._SkuName = Value
+ # Needs to re-retrieve the PCD information
+ self._Pcds = None
def _GetFdfFile(self):
if self._FlashDefinition == None:
@@ -321,6 +342,24 @@ class DscBuildData(PlatformBuildClassObject): self._LoadFixAddress = ''
return self._LoadFixAddress
+ ## Retrieve the GUID string for VPD tool
+ def _GetVpdToolGuid(self):
+ if self._VpdToolGuid == None:
+ if self._Header == None:
+ self._GetHeaderInfo()
+ if self._VpdToolGuid == None:
+ self._VpdToolGuid = ''
+ return self._VpdToolGuid
+
+ ## Retrieve the VPD file Name, this is optional in DSC file
+ def _GetVpdFileName(self):
+ if self._VpdFileName == None:
+ if self._Header == None:
+ self._GetHeaderInfo()
+ if self._VpdFileName == None:
+ self._VpdFileName = ''
+ return self._VpdFileName
+
## Retrieve [SkuIds] section information
def _GetSkuIds(self):
if self._SkuIds == None:
@@ -418,6 +457,7 @@ class DscBuildData(PlatformBuildClassObject): '',
MaxDatumSize,
{},
+ False,
None
)
Module.Pcds[PcdCName, TokenSpaceGuid] = Pcd
@@ -576,6 +616,7 @@ class DscBuildData(PlatformBuildClassObject): '',
MaxDatumSize,
{},
+ False,
None
)
return Pcds
@@ -619,6 +660,7 @@ class DscBuildData(PlatformBuildClassObject): '',
MaxDatumSize,
{self.SkuName : SkuInfo},
+ False,
None
)
return Pcds
@@ -661,6 +703,7 @@ class DscBuildData(PlatformBuildClassObject): '',
'',
{self.SkuName : SkuInfo},
+ False,
None
)
return Pcds
@@ -686,15 +729,21 @@ class DscBuildData(PlatformBuildClassObject): PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
for PcdCName, TokenSpaceGuid in PcdSet:
- ValueList = ['', '']
+ ValueList = ['', '', '']
Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
TokenList = Setting.split(TAB_VALUE_SPLIT)
ValueList[0:len(TokenList)] = TokenList
- VpdOffset, MaxDatumSize = ValueList
-
- SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', VpdOffset)
+ #
+ # For the VOID* type, it can have optional data of MaxDatumSize and InitialValue
+ # For the Integer & Boolean type, the optional data can only be InitialValue.
+ # At this point, we put all the data into the PcdClssObject for we don't know the PCD's datumtype
+ # until the DEC parser has been called.
+ #
+ VpdOffset, MaxDatumSize, InitialValue = ValueList
+
+ SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', VpdOffset, InitialValue)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
@@ -704,6 +753,7 @@ class DscBuildData(PlatformBuildClassObject): '',
MaxDatumSize,
{self.SkuName : SkuInfo},
+ False,
None
)
return Pcds
@@ -733,7 +783,7 @@ class DscBuildData(PlatformBuildClassObject): #
def AddPcd(self, Name, Guid, Value):
if (Name, Guid) not in self.Pcds:
- self.Pcds[Name, Guid] = PcdClassObject(Name, Guid, '', '', '', '', '', {}, None)
+ self.Pcds[Name, Guid] = PcdClassObject(Name, Guid, '', '', '', '', '', {}, False, None)
self.Pcds[Name, Guid].DefaultValue = Value
Arch = property(_GetArch, _SetArch)
@@ -752,7 +802,8 @@ class DscBuildData(PlatformBuildClassObject): BsBaseAddress = property(_GetBsBaseAddress)
RtBaseAddress = property(_GetRtBaseAddress)
LoadFixAddress = property(_GetLoadFixAddress)
-
+ VpdToolGuid = property(_GetVpdToolGuid)
+ VpdFileName = property(_GetVpdFileName)
SkuIds = property(_GetSkuIds)
Modules = property(_GetModules)
LibraryInstances = property(_GetLibraryInstances)
@@ -760,7 +811,7 @@ class DscBuildData(PlatformBuildClassObject): Pcds = property(_GetPcds)
BuildOptions = property(_GetBuildOptions)
-## Platform build information from DSC file
+## Platform build information from DEC file
#
# This class is used to retrieve information stored in database and convert them
# into PackageBuildClassObject form for easier use for AutoGen.
@@ -789,6 +840,7 @@ class DecBuildData(PackageBuildClassObject): TAB_DEC_DEFINES_PACKAGE_NAME : "_PackageName",
TAB_DEC_DEFINES_PACKAGE_GUID : "_Guid",
TAB_DEC_DEFINES_PACKAGE_VERSION : "_Version",
+ TAB_DEC_DEFINES_PKG_UNI_FILE : "_PkgUniFile",
}
@@ -830,6 +882,7 @@ class DecBuildData(PackageBuildClassObject): self._PackageName = None
self._Guid = None
self._Version = None
+ self._PkgUniFile = None
self._Protocols = None
self._Ppis = None
self._Guids = None
@@ -1063,6 +1116,7 @@ class DecBuildData(PackageBuildClassObject): TokenNumber,
'',
{},
+ False,
None
)
return Pcds
@@ -1914,6 +1968,7 @@ class InfBuildData(ModuleBuildClassObject): '',
'',
{},
+ False,
self.Guids[TokenSpaceGuid]
)
@@ -1927,7 +1982,7 @@ class InfBuildData(ModuleBuildClassObject): # "FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"
#
PcdType = self._PCD_TYPE_STRING_[Type]
- if Type in [MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX]:
+ if Type == MODEL_PCD_DYNAMIC:
Pcd.Pending = True
for T in ["FixedAtBuild", "PatchableInModule", "FeatureFlag", "Dynamic", "DynamicEx"]:
if (PcdCName, TokenSpaceGuid, T) in Package.Pcds:
@@ -1994,7 +2049,7 @@ class InfBuildData(ModuleBuildClassObject): ## Database
#
-# This class defined the build databse for all modules, packages and platform.
+# This class defined the build database for all modules, packages and platform.
# It will call corresponding parser for the given file if it cannot find it in
# the database.
#
|