diff options
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
-rw-r--r-- | BaseTools/Source/Python/Workspace/MetaFileParser.py | 35 | ||||
-rw-r--r-- | BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 17 |
2 files changed, 25 insertions, 27 deletions
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index fabc7ed986..4bad21298a 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -895,21 +895,28 @@ class DscParser(MetaFileParser): # three operands elif TokenNumber == 3: TokenValue = TokenList[0] - if TokenValue[0] in ["'", '"'] and TokenValue[-1] in ["'", '"']: - TokenValue = TokenValue[1:-1] - if TokenValue.startswith("$(") and TokenValue.endswith(")"): - TokenValue = self._EvaluateToken(TokenValue, Expression) - if TokenValue[0] in ["'", '"'] and TokenValue[-1] in ["'", '"']: - TokenValue = TokenValue[1:-1] - if TokenValue == None: - return False + if TokenValue != "": + if TokenValue[0] in ["'", '"'] and TokenValue[-1] in ["'", '"']: + TokenValue = TokenValue[1:-1] + if TokenValue.startswith("$(") and TokenValue.endswith(")"): + TokenValue = self._EvaluateToken(TokenValue, Expression) + if TokenValue == None: + return False + if TokenValue != "": + if TokenValue[0] in ["'", '"'] and TokenValue[-1] in ["'", '"']: + TokenValue = TokenValue[1:-1] + Value = TokenList[2] - if Value[0] in ["'", '"'] and Value[-1] in ["'", '"']: - Value = Value[1:-1] - if Value.startswith("$(") and Value.endswith(")"): - Value = self._EvaluateToken(Value, Expression) - if Value[0] in ["'", '"'] and Value[-1] in ["'", '"']: - Value = Value[1:-1] + if Value != "": + if Value[0] in ["'", '"'] and Value[-1] in ["'", '"']: + Value = Value[1:-1] + if Value.startswith("$(") and Value.endswith(")"): + Value = self._EvaluateToken(Value, Expression) + if Value == None: + return False + if Value != "": + if Value[0] in ["'", '"'] and Value[-1] in ["'", '"']: + Value = Value[1:-1] Op = TokenList[1] if Op not in self._OP_: EdkLogger.error('Parser', FORMAT_INVALID, "Unsupported operator [%s]" % Op, File=self.MetaFile, diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index 4bfa7d8ffd..ac2ca057cc 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -1896,7 +1896,7 @@ class InfBuildData(ModuleBuildClassObject): ## Retrieve PCDs used in this module
def _GetPcds(self):
if self._Pcds == None:
- self._Pcds = {}
+ self._Pcds = sdict()
self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD))
self._Pcds.update(self._GetPcd(MODEL_PCD_PATCHABLE_IN_MODULE))
self._Pcds.update(self._GetPcd(MODEL_PCD_FEATURE_FLAG))
@@ -1996,7 +1996,7 @@ class InfBuildData(ModuleBuildClassObject): ## Retrieve PCD for given type
def _GetPcd(self, Type):
- Pcds = {}
+ Pcds = sdict()
PcdDict = tdict(True, 4)
PcdList = []
RecordList = self._RawData[Type, self._Arch, self._Platform]
@@ -2071,18 +2071,9 @@ class InfBuildData(ModuleBuildClassObject): #
# Check hexadecimal token value length and format.
#
+ ReIsValidPcdTokenValue = re.compile(r"^[0][x|X][0]*[0-9a-fA-F]{1,8}$", re.DOTALL)
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:
+ if ReIsValidPcdTokenValue.match(Pcd.TokenValue) == None:
EdkLogger.error(
'build',
FORMAT_INVALID,
|