public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Fix a bug override Pcd by DSC Components section
@ 2018-02-26  7:49 Yonghong Zhu
  2018-02-28  5:25 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-02-26  7:49 UTC (permalink / raw)
  To: edk2-devel

The case is: define a VOID* pcd in DEC file, eg: Value is {0x1}.
then override this PCD on DSC component section, eg: Value is
{0x1, 0x2, 0x3}, the max size of this PCD is calculate wrong
which cause build error.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py        | 15 ++++++++++++++-
 BaseTools/Source/Python/Workspace/DscBuildData.py |  5 +++--
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 405bfa1..19c65b3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2412,11 +2412,11 @@ class PlatformAutoGen(AutoGen):
                                 ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName, TokenCName))
             ToPcd.validateranges = FromPcd.validateranges
             ToPcd.validlists = FromPcd.validlists
             ToPcd.expressions = FromPcd.expressions
 
-        if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:
+        if FromPcd != None and ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:
             EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \
                             % (ToPcd.TokenSpaceGuidCName, TokenCName))
             Value = ToPcd.DefaultValue
             if Value in [None, '']:
                 ToPcd.MaxDatumSize = '1'
@@ -2485,10 +2485,23 @@ class PlatformAutoGen(AutoGen):
                             ToPcd = Pcds[PcdItem]
                             Flag = True
                             break
                 if Flag:
                     self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)
+        # use PCD value to calculate the MaxDatumSize when it is not specified
+        for Name, Guid in Pcds:
+            Pcd = Pcds[Name, Guid]
+            if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:
+                Value = Pcd.DefaultValue
+                if Value in [None, '']:
+                    Pcd.MaxDatumSize = '1'
+                elif Value[0] == 'L':
+                    Pcd.MaxDatumSize = str((len(Value) - 2) * 2)
+                elif Value[0] == '{':
+                    Pcd.MaxDatumSize = str(len(Value.split(',')))
+                else:
+                    Pcd.MaxDatumSize = str(len(Value) - 1)
         return Pcds.values()
 
     ## Resolve library names to library modules
     #
     # (for Edk.x modules)
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 75b877a..32b1df9 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -677,12 +677,13 @@ class DscBuildData(PlatformBuildClassObject):
                          MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX]:
                 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]
-                    if len(TokenList) > 1:
-                        MaxDatumSize = TokenList[1]
+                    # the format is PcdName| Value | VOID* | MaxDatumSize
+                    if len(TokenList) > 2:
+                        MaxDatumSize = TokenList[2]
                     else:
                         MaxDatumSize = ''
                     TypeString = self._PCD_TYPE_STRING_[Type]
                     Pcd = PcdClassObject(
                             PcdCName,
-- 
2.6.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Patch] BaseTools: Fix a bug override Pcd by DSC Components section
  2018-02-26  7:49 [Patch] BaseTools: Fix a bug override Pcd by DSC Components section Yonghong Zhu
@ 2018-02-28  5:25 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-02-28  5:25 UTC (permalink / raw)
  To: Zhu, Yonghong, edk2-devel@lists.01.org

Reviewed-by: Liming Gao <liming.gao@intel.com>

>-----Original Message-----
>From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
>Yonghong Zhu
>Sent: Monday, February 26, 2018 3:49 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [Patch] BaseTools: Fix a bug override Pcd by DSC Components
>section
>
>The case is: define a VOID* pcd in DEC file, eg: Value is {0x1}.
>then override this PCD on DSC component section, eg: Value is
>{0x1, 0x2, 0x3}, the max size of this PCD is calculate wrong
>which cause build error.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py        | 15 ++++++++++++++-
> BaseTools/Source/Python/Workspace/DscBuildData.py |  5 +++--
> 2 files changed, 17 insertions(+), 3 deletions(-)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index 405bfa1..19c65b3 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -2412,11 +2412,11 @@ class PlatformAutoGen(AutoGen):
>                                 ExtraData="%s.%s" % (ToPcd.TokenSpaceGuidCName,
>TokenCName))
>             ToPcd.validateranges = FromPcd.validateranges
>             ToPcd.validlists = FromPcd.validlists
>             ToPcd.expressions = FromPcd.expressions
>
>-        if ToPcd.DatumType == "VOID*" and ToPcd.MaxDatumSize in ['', None]:
>+        if FromPcd != None and ToPcd.DatumType == "VOID*" and
>ToPcd.MaxDatumSize in ['', None]:
>             EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified
>for PCD %s.%s" \
>                             % (ToPcd.TokenSpaceGuidCName, TokenCName))
>             Value = ToPcd.DefaultValue
>             if Value in [None, '']:
>                 ToPcd.MaxDatumSize = '1'
>@@ -2485,10 +2485,23 @@ class PlatformAutoGen(AutoGen):
>                             ToPcd = Pcds[PcdItem]
>                             Flag = True
>                             break
>                 if Flag:
>                     self._OverridePcd(ToPcd, PlatformModule.Pcds[Key], Module)
>+        # use PCD value to calculate the MaxDatumSize when it is not specified
>+        for Name, Guid in Pcds:
>+            Pcd = Pcds[Name, Guid]
>+            if Pcd.DatumType == "VOID*" and Pcd.MaxDatumSize in ['', None]:
>+                Value = Pcd.DefaultValue
>+                if Value in [None, '']:
>+                    Pcd.MaxDatumSize = '1'
>+                elif Value[0] == 'L':
>+                    Pcd.MaxDatumSize = str((len(Value) - 2) * 2)
>+                elif Value[0] == '{':
>+                    Pcd.MaxDatumSize = str(len(Value.split(',')))
>+                else:
>+                    Pcd.MaxDatumSize = str(len(Value) - 1)
>         return Pcds.values()
>
>     ## Resolve library names to library modules
>     #
>     # (for Edk.x modules)
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 75b877a..32b1df9 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -677,12 +677,13 @@ class DscBuildData(PlatformBuildClassObject):
>                          MODEL_PCD_FEATURE_FLAG, MODEL_PCD_DYNAMIC,
>MODEL_PCD_DYNAMIC_EX]:
>                 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]
>-                    if len(TokenList) > 1:
>-                        MaxDatumSize = TokenList[1]
>+                    # the format is PcdName| Value | VOID* | MaxDatumSize
>+                    if len(TokenList) > 2:
>+                        MaxDatumSize = TokenList[2]
>                     else:
>                         MaxDatumSize = ''
>                     TypeString = self._PCD_TYPE_STRING_[Type]
>                     Pcd = PcdClassObject(
>                             PcdCName,
>--
>2.6.1.windows.1
>
>_______________________________________________
>edk2-devel mailing list
>edk2-devel@lists.01.org
>https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-02-28  5:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-26  7:49 [Patch] BaseTools: Fix a bug override Pcd by DSC Components section Yonghong Zhu
2018-02-28  5:25 ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox