diff options
author | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-15 02:51:34 +0000 |
---|---|---|
committer | lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-11-15 02:51:34 +0000 |
commit | 6780eef1f9ed0af24795708c3be7adafd7113691 (patch) | |
tree | 1a9fd2fca0bd71c4a64a8bf3f10e492f45a232d8 /BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | |
parent | 5460c4bbc5aa9d99d25c55c6b936166bea3dbea0 (diff) | |
download | edk2-platforms-6780eef1f9ed0af24795708c3be7adafd7113691.tar.xz |
Sync EDKII BaseTools to BaseTools project r2093.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11057 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Workspace/WorkspaceDatabase.py')
-rw-r--r-- | BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 166 |
1 files changed, 132 insertions, 34 deletions
diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 9d53fa8e68..4b00dff84d 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -74,6 +74,8 @@ class DscBuildData(PlatformBuildClassObject): TAB_DSC_DEFINES_MAKEFILE_NAME : "_MakefileName",
TAB_DSC_DEFINES_BS_BASE_ADDRESS : "_BsBaseAddress",
TAB_DSC_DEFINES_RT_BASE_ADDRESS : "_RtBaseAddress",
+ #TAB_DSC_DEFINES_RFC_LANGUAGES : "_RFCLanguages",
+ #TAB_DSC_DEFINES_ISO_LANGUAGES : "_ISOLanguages",
}
# used to compose dummy library class name for those forced library instances
@@ -140,6 +142,8 @@ class DscBuildData(PlatformBuildClassObject): self._Pcds = None
self._BuildOptions = None
self._LoadFixAddress = None
+ self._RFCLanguages = None
+ self._ISOLanguages = None
self._VpdToolGuid = None
## Get architecture
@@ -194,6 +198,35 @@ class DscBuildData(PlatformBuildClassObject): self._SkuName = Record[1]
elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS:
self._LoadFixAddress = Record[1]
+ elif Name == TAB_DSC_DEFINES_RFC_LANGUAGES:
+ if not Record[1] or Record[1][0] != '"' or Record[1][-1] != '"' or len(Record[1]) == 1:
+ EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'language code for RFC_LANGUAGES must have double quotes around it, for example: RFC_LANGUAGES = "en-us;zh-hans"',
+ File=self.MetaFile, Line=Record[-1])
+ LanguageCodes = Record[1][1:-1]
+ if not LanguageCodes:
+ EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or more RFC4646 format language code must be provided for RFC_LANGUAGES statement',
+ File=self.MetaFile, Line=Record[-1])
+ LanguageList = GetSplitValueList(LanguageCodes, TAB_SEMI_COLON_SPLIT)
+ # check whether there is empty entries in the list
+ if None in LanguageList:
+ EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or more empty language code is in RFC_LANGUAGES statement',
+ File=self.MetaFile, Line=Record[-1])
+ self._RFCLanguages = LanguageList
+ elif Name == TAB_DSC_DEFINES_ISO_LANGUAGES:
+ if not Record[1] or Record[1][0] != '"' or Record[1][-1] != '"' or len(Record[1]) == 1:
+ EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'language code for ISO_LANGUAGES must have double quotes around it, for example: ISO_LANGUAGES = "engchn"',
+ File=self.MetaFile, Line=Record[-1])
+ LanguageCodes = Record[1][1:-1]
+ if not LanguageCodes:
+ EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'one or more ISO639-2 format language code must be provided for ISO_LANGUAGES statement',
+ File=self.MetaFile, Line=Record[-1])
+ if len(LanguageCodes)%3:
+ EdkLogger.error('build', FORMAT_NOT_SUPPORTED, 'bad ISO639-2 format for ISO_LANGUAGES',
+ File=self.MetaFile, Line=Record[-1])
+ LanguageList = []
+ for i in range(0, len(LanguageCodes), 3):
+ LanguageList.append(LanguageCodes[i:i+3])
+ self._ISOLanguages = LanguageList
elif Name == TAB_DSC_DEFINES_VPD_TOOL_GUID:
#
# try to convert GUID to a real UUID value to see whether the GUID is format
@@ -339,6 +372,24 @@ class DscBuildData(PlatformBuildClassObject): self._LoadFixAddress = ''
return self._LoadFixAddress
+ ## Retrieve RFCLanguage filter
+ def _GetRFCLanguages(self):
+ if self._RFCLanguages == None:
+ if self._Header == None:
+ self._GetHeaderInfo()
+ if self._RFCLanguages == None:
+ self._RFCLanguages = []
+ return self._RFCLanguages
+
+ ## Retrieve ISOLanguage filter
+ def _GetISOLanguages(self):
+ if self._ISOLanguages == None:
+ if self._Header == None:
+ self._GetHeaderInfo()
+ if self._ISOLanguages == None:
+ self._ISOLanguages = []
+ return self._ISOLanguages
+
## Retrieve the GUID string for VPD tool
def _GetVpdToolGuid(self):
if self._VpdToolGuid == None:
@@ -588,13 +639,10 @@ class DscBuildData(PlatformBuildClassObject): PcdDict[Arch, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates
for PcdCName, TokenSpaceGuid in PcdSet:
- ValueList = ['', '', '']
Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- TokenList = Setting.split(TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- PcdValue, DatumType, MaxDatumSize = ValueList
+ PcdValue, DatumType, MaxDatumSize = AnalyzePcdData(Setting)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
@@ -622,22 +670,20 @@ class DscBuildData(PlatformBuildClassObject): # PCD settings for certain ARCH and SKU
#
PcdDict = tdict(True, 4)
- PcdSet = set()
+ PcdList = []
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdSet.add((PcdCName, TokenSpaceGuid))
+ PcdList.append((PcdCName, TokenSpaceGuid))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid in PcdSet:
- ValueList = ['', '', '']
+ for PcdCName, TokenSpaceGuid in PcdList:
Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- TokenList = Setting.split(TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- PcdValue, DatumType, MaxDatumSize = ValueList
-
+
+ PcdValue, DatumType, MaxDatumSize = AnalyzePcdData(Setting)
+
SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', '', PcdValue)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
@@ -674,13 +720,10 @@ class DscBuildData(PlatformBuildClassObject): PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
for PcdCName, TokenSpaceGuid in PcdSet:
- ValueList = ['', '', '', '']
Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- TokenList = Setting.split(TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- VariableName, VariableGuid, VariableOffset, DefaultValue = ValueList
+ VariableName, VariableGuid, VariableOffset, DefaultValue = AnalyzeHiiPcdData(Setting)
SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], VariableName, VariableGuid, VariableOffset, DefaultValue)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
PcdCName,
@@ -709,27 +752,24 @@ class DscBuildData(PlatformBuildClassObject): # PCD settings for certain ARCH and SKU
#
PcdDict = tdict(True, 4)
- PcdSet = set()
+ PcdList = []
# Find out all possible PCD candidates for self._Arch
RecordList = self._RawData[Type, self._Arch]
for TokenSpaceGuid, PcdCName, Setting, Arch, SkuName, Dummy3, Dummy4 in RecordList:
- PcdSet.add((PcdCName, TokenSpaceGuid))
+ PcdList.append((PcdCName, TokenSpaceGuid))
PcdDict[Arch, SkuName, PcdCName, TokenSpaceGuid] = Setting
# Remove redundant PCD candidates, per the ARCH and SKU
- for PcdCName, TokenSpaceGuid in PcdSet:
- ValueList = ['', '', '']
+ for PcdCName, TokenSpaceGuid in PcdList:
Setting = PcdDict[self._Arch, self.SkuName, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- TokenList = Setting.split(TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
#
# 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
+ VpdOffset, MaxDatumSize, InitialValue = AnalyzeVpdPcdData(Setting)
SkuInfo = SkuInfoClass(self.SkuName, self.SkuIds[self.SkuName], '', '', '', '', VpdOffset, InitialValue)
Pcds[PcdCName, TokenSpaceGuid] = PcdClassObject(
@@ -790,6 +830,8 @@ class DscBuildData(PlatformBuildClassObject): BsBaseAddress = property(_GetBsBaseAddress)
RtBaseAddress = property(_GetRtBaseAddress)
LoadFixAddress = property(_GetLoadFixAddress)
+ RFCLanguages = property(_GetRFCLanguages)
+ ISOLanguages = property(_GetISOLanguages)
VpdToolGuid = property(_GetVpdToolGuid)
SkuIds = property(_GetSkuIds)
Modules = property(_GetModules)
@@ -1083,7 +1125,6 @@ class DecBuildData(PackageBuildClassObject): PcdSet.add((PcdCName, TokenSpaceGuid))
for PcdCName, TokenSpaceGuid in PcdSet:
- ValueList = ['', '', '']
#
# limit the ARCH to self._Arch, if no self._Arch found, tdict
# will automatically turn to 'common' ARCH and try again
@@ -1091,9 +1132,9 @@ class DecBuildData(PackageBuildClassObject): Setting = PcdDict[self._Arch, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- TokenList = Setting.split(TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
- DefaultValue, DatumType, TokenNumber = ValueList
+
+ DefaultValue, DatumType, TokenNumber = AnalyzePcdData(Setting)
+
Pcds[PcdCName, TokenSpaceGuid, self._PCD_TYPE_STRING_[Type]] = PcdClassObject(
PcdCName,
TokenSpaceGuid,
@@ -1920,11 +1961,11 @@ class InfBuildData(ModuleBuildClassObject): def _GetPcd(self, Type):
Pcds = {}
PcdDict = tdict(True, 4)
- PcdSet = set()
+ PcdList = []
RecordList = self._RawData[Type, self._Arch, self._Platform]
for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Dummy1, LineNo in RecordList:
PcdDict[Arch, Platform, PcdCName, TokenSpaceGuid] = (Setting, LineNo)
- PcdSet.add((PcdCName, TokenSpaceGuid))
+ PcdList.append((PcdCName, TokenSpaceGuid))
# get the guid value
if TokenSpaceGuid not in self.Guids:
Value = GuidValue(TokenSpaceGuid, self.Packages)
@@ -1936,13 +1977,11 @@ class InfBuildData(ModuleBuildClassObject): self.Guids[TokenSpaceGuid] = Value
# resolve PCD type, value, datum info, etc. by getting its definition from package
- for PcdCName, TokenSpaceGuid in PcdSet:
- ValueList = ['', '']
+ for PcdCName, TokenSpaceGuid in PcdList:
Setting, LineNo = PcdDict[self._Arch, self.Platform, PcdCName, TokenSpaceGuid]
if Setting == None:
continue
- TokenList = Setting.split(TAB_VALUE_SPLIT)
- ValueList[0:len(TokenList)] = TokenList
+ ValueList = AnalyzePcdData(Setting)
DefaultValue = ValueList[0]
Pcd = PcdClassObject(
PcdCName,
@@ -1980,6 +2019,64 @@ class InfBuildData(ModuleBuildClassObject): PcdInPackage = Package.Pcds[PcdCName, TokenSpaceGuid, PcdType]
Pcd.Type = PcdType
Pcd.TokenValue = PcdInPackage.TokenValue
+
+ #
+ # Check whether the token value exist or not.
+ #
+ if Pcd.TokenValue == None or Pcd.TokenValue == "":
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "No TokenValue for PCD [%s.%s] in [%s]!" % (TokenSpaceGuid, PcdCName, str(Package)),
+ File =self.MetaFile, Line=LineNo,
+ ExtraData=None
+ )
+ #
+ # Check hexadecimal token value length and format.
+ #
+ if Pcd.TokenValue.startswith("0x") or Pcd.TokenValue.startswith("0X"):
+ if len(Pcd.TokenValue) < 3 or len(Pcd.TokenValue) > 10:
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd.TokenValue, TokenSpaceGuid, PcdCName, str(Package)),
+ File =self.MetaFile, Line=LineNo,
+ ExtraData=None
+ )
+ try:
+ int (Pcd.TokenValue, 16)
+ except:
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid:" % (Pcd.TokenValue, TokenSpaceGuid, PcdCName, str(Package)),
+ File =self.MetaFile, Line=LineNo,
+ ExtraData=None
+ )
+
+ #
+ # Check decimal token value length and format.
+ #
+ else:
+ try:
+ TokenValueInt = int (Pcd.TokenValue, 10)
+ if (TokenValueInt < 0 or TokenValueInt > 4294967295):
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, as a decimal it should between: 0 - 4294967295!"% (Pcd.TokenValue, TokenSpaceGuid, PcdCName, str(Package)),
+ File =self.MetaFile, Line=LineNo,
+ ExtraData=None
+ )
+ except:
+ EdkLogger.error(
+ 'build',
+ FORMAT_INVALID,
+ "The format of TokenValue [%s] of PCD [%s.%s] in [%s] is invalid, it should be hexadecimal or decimal!"% (Pcd.TokenValue, TokenSpaceGuid, PcdCName, str(Package)),
+ File =self.MetaFile, Line=LineNo,
+ ExtraData=None
+ )
+
Pcd.DatumType = PcdInPackage.DatumType
Pcd.MaxDatumSize = PcdInPackage.MaxDatumSize
Pcd.InfDefaultValue = Pcd.DefaultValue
@@ -1989,12 +2086,13 @@ class InfBuildData(ModuleBuildClassObject): else:
EdkLogger.error(
'build',
- PARSER_ERROR,
+ FORMAT_INVALID,
"PCD [%s.%s] in [%s] is not found in dependent packages:" % (TokenSpaceGuid, PcdCName, self.MetaFile),
File =self.MetaFile, Line=LineNo,
ExtraData="\t%s" % '\n\t'.join([str(P) for P in self.Packages])
)
Pcds[PcdCName, TokenSpaceGuid] = Pcd
+
return Pcds
Arch = property(_GetArch, _SetArch)
|