From 79b74a03e018ecbf03d8d50e6f20301e249c1ba5 Mon Sep 17 00:00:00 2001
From: lgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Date: Tue, 11 Oct 2011 02:49:48 +0000
Subject: Sync BaseTools Branch (version r2362) to EDKII main trunk.
 Signed-off-by: lgao4 Reviewed-by: jsu1 Reviewed-by: ydliu

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12525 6f19259b-4bc3-4df7-8a09-765794883524
---
 .../Source/Python/Workspace/MetaFileParser.py      | 35 +++++++++++++---------
 .../Source/Python/Workspace/WorkspaceDatabase.py   | 17 +++--------
 2 files changed, 25 insertions(+), 27 deletions(-)

(limited to 'BaseTools/Source/Python/Workspace')

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,
-- 
cgit v1.2.3