diff options
author | Yunhua Feng <yunhuax.feng@intel.com> | 2018-01-27 00:28:05 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-01-30 22:44:59 +0800 |
commit | 35f613d96ce43c7b23cd77aab063424ec4422e0c (patch) | |
tree | 470967c42683749dcc72a3626fd78192e896c1dc /BaseTools/Source/Python/Workspace | |
parent | b23fc39cd3c32663a0fa5ae11676e4ad4a2dddf9 (diff) | |
download | edk2-35f613d96ce43c7b23cd77aab063424ec4422e0c.tar.gz edk2-35f613d96ce43c7b23cd77aab063424ec4422e0c.tar.bz2 edk2-35f613d96ce43c7b23cd77aab063424ec4422e0c.zip |
BaseTools: Enhance parse performance by optimize ValueExpressionEx
Optimize ValueExpressionEx function to enhance meta-data file parse
performance.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
-rw-r--r-- | BaseTools/Source/Python/Workspace/DscBuildData.py | 21 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 10 |
2 files changed, 12 insertions, 19 deletions
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index f30d3f7e73..012e16a488 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -825,13 +825,14 @@ class DscBuildData(PlatformBuildClassObject): if ValueList[2] == '-1':
EdkLogger.error('build', FORMAT_INVALID, "Pcd format incorrect.", File=self.MetaFile, Line=LineNo,
ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting))
- if ValueList[Index] and PcdType not in [MODEL_PCD_FEATURE_FLAG, MODEL_PCD_FIXED_AT_BUILD]:
+ if ValueList[Index]:
+ DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType
try:
- ValueList[Index] = ValueExpression(ValueList[Index], GlobalData.gPlatformPcds)(True)
- except WrnExpression, Value:
- ValueList[Index] = Value.result
+ ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True)
except BadExpression, Value:
- EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1)
+ EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo,
+ ExtraData="PCD [%s.%s] Value \"%s\" " % (
+ TokenSpaceGuid, PcdCName, ValueList[Index]))
except EvaluationException, Excpt:
if hasattr(Excpt, 'Pcd'):
if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
@@ -845,13 +846,8 @@ class DscBuildData(PlatformBuildClassObject): else:
EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
File=self.MetaFile, Line=LineNo)
+
if ValueList[Index]:
- DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType
- try:
- ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True)
- except BadExpression, Value:
- EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo,
- ExtraData="PCD [%s.%s] Value \"%s\" " % (TokenSpaceGuid, PcdCName, ValueList[Index]))
Valid, ErrStr = CheckPcdDatum(self._DecPcds[PcdCName, TokenSpaceGuid].DatumType, ValueList[Index])
if not Valid:
EdkLogger.error('build', FORMAT_INVALID, ErrStr, File=self.MetaFile, Line=LineNo,
@@ -860,6 +856,9 @@ class DscBuildData(PlatformBuildClassObject): if self._DecPcds[PcdCName, TokenSpaceGuid].DatumType.strip() != ValueList[1].strip():
EdkLogger.error('build', FORMAT_INVALID, ErrStr , File=self.MetaFile, Line=LineNo,
ExtraData="%s.%s|%s" % (TokenSpaceGuid, PcdCName, Setting))
+ if (TokenSpaceGuid + '.' + PcdCName) in GlobalData.gPlatformPcds:
+ if GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] != ValueList[Index]:
+ GlobalData.gPlatformPcds[TokenSpaceGuid + '.' + PcdCName] = ValueList[Index]
return ValueList
def _FilterPcdBySkuUsage(self,Pcds):
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 8f4b5e5cc1..c928cef70f 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1593,6 +1593,8 @@ class DscParser(MetaFileParser): ValList[Index] = ValueExpression(PcdValue, self._Macros)(True)
except WrnExpression, Value:
ValList[Index] = Value.result
+ except:
+ pass
if ValList[Index] == 'True':
ValList[Index] = '1'
@@ -1990,14 +1992,6 @@ class DecParser(MetaFileParser): PcdValue = ValueList[0]
if PcdValue:
try:
- ValueList[0] = ValueExpression(PcdValue, self._AllPcdDict)(True)
- except WrnExpression, Value:
- ValueList[0] = Value.result
- except BadExpression, Value:
- EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=self._LineIndex + 1)
-
- if ValueList[0]:
- try:
ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True)
except BadExpression, Value:
EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
|