[edk2] [Patch] BaseTools: DSC Components section support flexible PCD

Yonghong Zhu posted 1 patch 6 years, 1 month ago
Failed in applying to current master (apply log)
There is a newer version of this series
BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py |  3 ++-
BaseTools/Source/Python/Workspace/DscBuildData.py      | 11 +++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
[edk2] [Patch] BaseTools: DSC Components section support flexible PCD
Posted by Yonghong Zhu 6 years, 1 month ago
From: Yunhua Feng <yunhuax.feng@intel.com>

DSC Components section support flexible PCD, and for binary driver, we
need patch this value. Update the split char ',' not ', ' because some
value may have space, while others may not have this space.

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>
---
 BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py |  3 ++-
 BaseTools/Source/Python/Workspace/DscBuildData.py      | 11 +++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
index 882da81..942ba88 100644
--- a/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
+++ b/BaseTools/Source/Python/PatchPcdValue/PatchPcdValue.py
@@ -159,14 +159,15 @@ def PatchBinaryFile(FileName, ValueOffset, TypeName, ValueString, MaxSize=0):
                 Index = Index + 2
         elif ValueString.startswith("{") and ValueString.endswith("}"):
             #
             # Patch {0x1, 0x2, ...} byte by byte
             #
-            ValueList = ValueString[1 : len(ValueString) - 1].split(', ')
+            ValueList = ValueString[1 : len(ValueString) - 1].split(',')
             Index = 0
             try:
                 for ByteString in ValueList:
+                    ByteString = ByteString.strip()
                     if ByteString.upper().startswith('0X'):
                         ByteValue = int(ByteString, 16)
                     else:
                         ByteValue = int(ByteString)
                     ByteList[ValueOffset + Index] = ByteValue % 0x100
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index a5089a9..c7c82fb 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -682,10 +682,21 @@ class DscBuildData(PlatformBuildClassObject):
                 RecordList = self._RawData[Type, self._Arch, None, ModuleId]
                 for TokenSpaceGuid, PcdCName, Setting, Dummy1, Dummy2, Dummy3, Dummy4,Dummy5 in RecordList:
                     TokenList = GetSplitValueList(Setting)
                     DefaultValue = TokenList[0]
                     # the format is PcdName| Value | VOID* | MaxDatumSize
+                    if (PcdCName, TokenSpaceGuid) not in self.DecPcds:
+                        EdkLogger.error('build', PARSER_ERROR,
+                                        "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (TokenSpaceGuid, PcdCName, self._Arch), File=self.MetaFile, Line=LineNo)
+                    else:
+                        DatumType = self.DecPcds[(PcdCName, TokenSpaceGuid)].DatumType
+
+                    try:
+                        DefaultValue = ValueExpressionEx(DefaultValue, DatumType, self._GuidDict)(True)
+                    except BadExpression,Value:
+                        EdkLogger.error('build', PARSER_ERROR,
+                                        "Pcd (%s.%s) defined in DSC is not declared in DEC files. Arch: ['%s']" % (TokenSpaceGuid, PcdCName, self._Arch), File=self.MetaFile, Line=LineNo, ExtraData=Value)
                     if len(TokenList) > 2:
                         MaxDatumSize = TokenList[2]
                     else:
                         MaxDatumSize = ''
                     TypeString = self._PCD_TYPE_STRING_[Type]
-- 
2.6.1.windows.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel