]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Fix the bug for CArray PCD override in command line
authorYonghong Zhu <yonghong.zhu@intel.com>
Fri, 12 May 2017 04:12:23 +0000 (12:12 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Fri, 12 May 2017 05:36:20 +0000 (13:36 +0800)
This patch updated the CArray PCD override format from B"{}" to H"{}"
which align to build spec. Besides, it also do the clean up for the
function BuildOptionPcdValueFormat.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools/Source/Python/Common/Misc.py
BaseTools/Source/Python/GenFds/GenFds.py

index 8d8957b3d9134bce308e54fa60c8a17b1cc61223..736c1ae976333f3b3c345866555f006929ae4efe 100644 (file)
@@ -416,7 +416,7 @@ class WorkspaceAutoGen(AutoGen):
                             if HasTokenSpace:\r
                                 if (PcdItem.TokenCName, PcdItem.TokenSpaceGuidCName) == (TokenCName, TokenSpaceGuidCName):\r
                                     PcdDatumType = PcdItem.DatumType\r
-                                    NewValue = self._BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
+                                    NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
                                     FoundFlag = True\r
                             else:\r
                                 if PcdItem.TokenCName == TokenCName:\r
@@ -425,7 +425,7 @@ class WorkspaceAutoGen(AutoGen):
                                             TokenSpaceGuidCNameList.append(PcdItem.TokenSpaceGuidCName)\r
                                             PcdDatumType = PcdItem.DatumType\r
                                             TokenSpaceGuidCName = PcdItem.TokenSpaceGuidCName\r
-                                            NewValue = self._BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
+                                            NewValue = BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, pcdvalue)\r
                                             FoundFlag = True\r
                                         else:\r
                                             EdkLogger.error(\r
@@ -697,31 +697,6 @@ class WorkspaceAutoGen(AutoGen):
                 print >> file, f\r
         return True\r
 \r
-    def _BuildOptionPcdValueFormat(self, TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):\r
-        if PcdDatumType == 'VOID*':\r
-            if Value.startswith('L'):\r
-                if not Value[1]:\r
-                    EdkLogger.error('build', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
-                Value = Value[0] + '"' + Value[1:] + '"'\r
-            elif Value.startswith('B'):\r
-                if not Value[1]:\r
-                    EdkLogger.error('build', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
-                Value = Value[1:]\r
-            else:\r
-                if not Value[0]:\r
-                    EdkLogger.error('build', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
-                Value = '"' + Value + '"'\r
-\r
-        IsValid, Cause = CheckPcdDatum(PcdDatumType, Value)\r
-        if not IsValid:\r
-            EdkLogger.error('build', FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))\r
-        if PcdDatumType == 'BOOLEAN':\r
-            Value = Value.upper()\r
-            if Value == 'TRUE' or Value == '1':\r
-                Value = '1'\r
-            elif Value == 'FALSE' or Value == '0':\r
-                Value = '0'\r
-        return  Value\r
 \r
     def _GetMetaFiles(self, Target, Toolchain, Arch):\r
         AllWorkSpaceMetaFiles = set()\r
index ac24bd8bbe5b21f65ede162885c9d0e2999a15ab..0f3ddd5dd44498258516ec5c6aee79221b3fc98f 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Create makefile for MS nmake and GNU make\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -1453,7 +1453,15 @@ class TopLevelMakefile(BuildFile):
         if GlobalData.BuildOptionPcd:\r
             for index, option in enumerate(GlobalData.gCommand):\r
                 if "--pcd" == option and GlobalData.gCommand[index+1]:\r
-                    ExtraOption += " --pcd " + GlobalData.gCommand[index+1]\r
+                    pcdName, pcdValue = GlobalData.gCommand[index+1].split('=')\r
+                    if pcdValue.startswith('H'):\r
+                        pcdValue = 'H' + '"' + pcdValue[1:] + '"'\r
+                        ExtraOption += " --pcd " + pcdName + '=' + pcdValue\r
+                    elif pcdValue.startswith('L'):\r
+                        pcdValue = 'L' + '"' + pcdValue[1:] + '"'\r
+                        ExtraOption += " --pcd " + pcdName + '=' + pcdValue\r
+                    else:\r
+                        ExtraOption += " --pcd " + GlobalData.gCommand[index+1]\r
 \r
         MakefileName = self._FILE_NAME_[self._FileType]\r
         SubBuildCommandList = []\r
index 390ef3606fb56b02a0be70712a64e4c7dfe65be8..dbb711e96cefa02ea50d4f981c3d46beda31d0d1 100644 (file)
@@ -2062,6 +2062,32 @@ def PackRegistryFormatGuid(Guid):
                 int(Guid[4][-2:], 16)\r
                 )\r
 \r
+def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):\r
+    if PcdDatumType == 'VOID*':\r
+        if Value.startswith('L'):\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
+        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
+            Value = Value[1:]\r
+        else:\r
+            if not Value[0]:\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 + '"'\r
+\r
+    IsValid, Cause = CheckPcdDatum(PcdDatumType, Value)\r
+    if not IsValid:\r
+        EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))\r
+    if PcdDatumType == 'BOOLEAN':\r
+        Value = Value.upper()\r
+        if Value == 'TRUE' or Value == '1':\r
+            Value = '1'\r
+        elif Value == 'FALSE' or Value == '0':\r
+            Value = '0'\r
+    return  Value\r
+\r
 ##\r
 #\r
 # This acts like the main() function for the script, unless it is 'import'ed into another\r
index aa8c04123ac8f6e453668fd999f3ac53dbe38014..277da357af0164b75584c347ddc570eb51f4853b 100644 (file)
@@ -39,6 +39,7 @@ from Common.Misc import SaveFileOnChange
 from Common.Misc import ClearDuplicatedInf\r
 from Common.Misc import GuidStructureStringToGuidString\r
 from Common.Misc import CheckPcdDatum\r
+from Common.Misc import BuildOptionPcdValueFormat\r
 from Common.BuildVersion import gBUILD_VERSION\r
 from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 \r
@@ -408,31 +409,6 @@ def CheckBuildOptionPcd():
 \r
             GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, NewValue)\r
 \r
-def BuildOptionPcdValueFormat(TokenSpaceGuidCName, TokenCName, PcdDatumType, Value):\r
-    if PcdDatumType == 'VOID*':\r
-        if Value.startswith('L'):\r
-            if not Value[1]:\r
-                EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
-            Value = Value[0] + '"' + Value[1:] + '"'\r
-        elif Value.startswith('B'):\r
-            if not Value[1]:\r
-                EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
-            Value = Value[1:]\r
-        else:\r
-            if not Value[0]:\r
-                EdkLogger.error('GenFds', OPTION_VALUE_INVALID, 'For Void* type PCD, when specify the Value in the command line, please use the following format: "string", L"string", B"{...}"')\r
-            Value = '"' + Value + '"'\r
-\r
-    IsValid, Cause = CheckPcdDatum(PcdDatumType, Value)\r
-    if not IsValid:\r
-        EdkLogger.error('build', FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))\r
-    if PcdDatumType == 'BOOLEAN':\r
-        Value = Value.upper()\r
-        if Value == 'TRUE' or Value == '1':\r
-            Value = '1'\r
-        elif Value == 'FALSE' or Value == '0':\r
-            Value = '0'\r
-    return  Value\r
 \r
 ## FindExtendTool()\r
 #\r