diff options
author | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-12-26 16:17:13 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2017-12-27 14:43:27 +0800 |
commit | 726c501c2c9a1ef103fab7846e2d1a34506715d8 (patch) | |
tree | 51c6cb2ce0a1a49400d8ef2255327dd330b177f1 /BaseTools/Source/Python/Workspace/MetaFileParser.py | |
parent | 68ba919f7858830cc764b46a00da7e7fdcd1f3ec (diff) | |
download | edk2-726c501c2c9a1ef103fab7846e2d1a34506715d8.tar.gz edk2-726c501c2c9a1ef103fab7846e2d1a34506715d8.tar.bz2 edk2-726c501c2c9a1ef103fab7846e2d1a34506715d8.zip |
BaseTools: Support PCD flexible values format
https://bugzilla.tianocore.org/show_bug.cgi?id=541
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/MetaFileParser.py')
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 3038447850..b2b0e282eb 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -27,7 +27,7 @@ import Common.GlobalData as GlobalData from CommonDataClass.DataClass import *
from Common.DataType import *
from Common.String import *
-from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression
+from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClass, AnalyzePcdData, AnalyzeDscPcd, AnalyzePcdExpression, ParseFieldValue
from Common.Expression import *
from CommonDataClass.Exceptions import *
from Common.LongFilePathSupport import OpenLongFilePath as open
@@ -182,6 +182,7 @@ class MetaFileParser(object): self._PostProcessed = False
# Different version of meta-file has different way to parse.
self._Version = 0
+ self._GuidDict = {} # for Parser PCD value {GUID(gTokeSpaceGuidName)}
## Store the parsed data in table
def _Store(self, *Args):
@@ -1871,6 +1872,8 @@ class DecParser(MetaFileParser): File=self.MetaFile, Line=self._LineIndex + 1)
self._ValueList[0] = TokenList[0]
self._ValueList[1] = TokenList[1]
+ if self._ValueList[0] not in self._GuidDict:
+ self._GuidDict[self._ValueList[0]] = self._ValueList[1]
## PCD sections parser
#
@@ -1987,12 +1990,14 @@ class DecParser(MetaFileParser): 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] == 'True':
- ValueList[0] = '1'
- if ValueList[0] == 'False':
- ValueList[0] = '0'
-
+ 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)
# check format of default value against the datum type
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])
if not IsValid:
|