BaseTools: Fix build argument --pcd for flexible format bugs
authorFeng, YunhuaX </o=Intel/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Recipients/cn=Feng, YunhuaX4e1>
Mon, 5 Feb 2018 03:42:33 +0000 (11:42 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 7 Feb 2018 01:28:17 +0000 (09:28 +0800)
Build argument --pcd flexible format, like as:
1. VOID* type
gTokenSpaceGuid.Test=H"{flexible format}"
gTokenSpaceGuid.Test=L"string"
gTokenSpaceGuid.Test="string"
gTokenSpaceGuid.Test=L'string'
gTokenSpaceGuid.Test='string'
2. UINT8/UINT16/UINT32/UINT64 type
gTokenSpaceGuid.Test=H"{flexible format}"
gTokenSpaceGuid.Test=L"string"
gTokenSpaceGuid.Test="string"
gTokenSpaceGuid.Test=L'string'
gTokenSpaceGuid.Test='string'

In linux, single quotes need escape
gTokenSpaceGuid.Test=L\'string\'
gTokenSpaceGuid.Test=\'string\'

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>
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/Workspace/DscBuildData.py

index 7d3374a493734f661e111acb6c53692618b13587..9df5d8e2d707d946e2b983045ecb62c7d8c31be2 100644 (file)
@@ -1554,6 +1554,8 @@ class TopLevelMakefile(BuildFile):
                     if pcdValue.startswith('H'):\r
                         pcdValue = 'H' + '"' + pcdValue[1:] + '"'\r
                         ExtraOption += " --pcd " + pcdName + '=' + pcdValue\r
+                    elif pcdValue.startswith("L'"):\r
+                        ExtraOption += "--pcd " + pcdName + '=' + pcdValue\r
                     elif pcdValue.startswith('L'):\r
                         pcdValue = 'L' + '"' + pcdValue[1:] + '"'\r
                         ExtraOption += " --pcd " + pcdName + '=' + pcdValue\r
index d80f645d2edd933136c25b7d1f0bbe350ea7a7a9..b8c2ce1ddccf9345671f76fcda4af9468ca10eab 100644 (file)
@@ -2353,10 +2353,10 @@ def PackRegistryFormatGuid(Guid):
 \r
 def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):\r
     if PcdDatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64,'BOOLEAN']:\r
-        if Value.startswith('L'):\r
+        if Value.startswith('L') or Value.startswith('"'):\r
             if not Value[1]:\r
                 EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
-            Value = Value[0] + '"' + Value[1:] + '"'\r
+            Value = Value\r
         elif Value.startswith('H'):\r
             if not Value[1]:\r
                 EdkLogger.error("build", FORMAT_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", H"{...}"')\r
index 1da4f03ab8baa1f0a0a4db3905f9488696edbf5d..d9165f2ac7dd346cbb68838084e140668337d313 100644 (file)
@@ -999,10 +999,39 @@ class DscBuildData(PlatformBuildClassObject):
                                     try:\r
                                         pcdvalue = ValueExpressionEx(pcdvalue[1:], PcdDatumType, self._GuidDict)(True)\r
                                     except BadExpression, Value:\r
-                                        if Value.result > 1:\r
-                                            EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
-                                                            (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
-                                    pcdvalue = 'H' + pcdvalue\r
+                                        EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                        (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                    if PcdDatumType == "VOID*":\r
+                                        pcdvalue = 'H' + pcdvalue\r
+                                elif pcdvalue.startswith("L'"):\r
+                                    try:\r
+                                        pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
+                                    except BadExpression, Value:\r
+                                        EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                        (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                    if pcdvalue.startswith('{'):\r
+                                        pcdvalue = 'H' + pcdvalue\r
+                                elif pcdvalue.startswith("'"):\r
+                                    try:\r
+                                        pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
+                                    except BadExpression, Value:\r
+                                        EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                        (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                    if pcdvalue.startswith('{'):\r
+                                        pcdvalue = 'H' + pcdvalue\r
+                                elif pcdvalue.startswith('L'):\r
+                                    pcdvalue = 'L"' + pcdvalue[1:] + '"'\r
+                                    try:\r
+                                        pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
+                                    except BadExpression, Value:\r
+                                        EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                        (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                else:\r
+                                    try:\r
+                                        pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
+                                    except BadExpression, Value:\r
+                                        EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                        (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
                                 NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
                                 FoundFlag = True\r
                         else:\r
@@ -1018,7 +1047,41 @@ class DscBuildData(PlatformBuildClassObject):
                                             except BadExpression, Value:\r
                                                 EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %\r
                                                                 (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
-                                            pcdvalue = 'H' + pcdvalue\r
+                                            if PcdDatumType == "VOID*":\r
+                                                pcdvalue = 'H' + pcdvalue\r
+                                        elif pcdvalue.startswith("L'"):\r
+                                            try:\r
+                                                pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(\r
+                                                    True)\r
+                                            except BadExpression, Value:\r
+                                                EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                                (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                            if pcdvalue.startswith('{'):\r
+                                                pcdvalue = 'H' + pcdvalue\r
+                                        elif pcdvalue.startswith("'"):\r
+                                            try:\r
+                                                pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(\r
+                                                    True)\r
+                                            except BadExpression, Value:\r
+                                                EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                                (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                            if pcdvalue.startswith('{'):\r
+                                                pcdvalue = 'H' + pcdvalue\r
+                                        elif pcdvalue.startswith('L'):\r
+                                            pcdvalue = 'L"' + pcdvalue[1:] + '"'\r
+                                            try:\r
+                                                pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(\r
+                                                    True)\r
+                                            except BadExpression, Value:\r
+                                                EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s",  %s' %\r
+                                                                (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
+                                        else:\r
+                                            try:\r
+                                                pcdvalue = ValueExpressionEx(pcdvalue, PcdDatumType, self._GuidDict)(True)\r
+                                            except BadExpression, Value:\r
+                                                EdkLogger.error('Parser', FORMAT_INVALID,\r
+                                                                'PCD [%s.%s] Value "%s",  %s' %\r
+                                                                (TokenSpaceGuidCName, TokenCName, pcdvalue, Value))\r
                                         NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
                                         FoundFlag = True\r
                                     else:\r