public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH V2] BaseTools: Latter full value should overwrite the former field value.
@ 2018-09-12  9:19 Zhaozh1x
  2018-09-25  1:07 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Zhaozh1x @ 2018-09-12  9:19 UTC (permalink / raw)
  To: edk2-devel; +Cc: Zhaozh1x, Liming Gao, Yonghong Zhu, Bob Feng

For structure Pcd, the latter full assign value in commandLine should
override the former field assign value. For example in commandLine,
build --pcd Token.pcd.field="haha" --pcd Token.pcd=H"{0x01,0x02}",
the former field value "haha" will be ignored and overwrite by the latter
full value "{0x01,0x02}".

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
---
 BaseTools/Source/Python/Workspace/DscBuildData.py | 17 +++++++++++++++++
 BaseTools/Source/Python/build/BuildReport.py      | 20 ++++++++++++++++----
 2 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 88ba415c5a..4e505c1e99 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1032,6 +1032,23 @@ class DscBuildData(PlatformBuildClassObject):
                         PcdItem = BuildData.Pcds[key]
                         if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="":
                             PcdItem.DefaultValue = pcdvalue
+        #In command line, the latter full assign value in commandLine should override the former field assign value.
+        #For example, --pcd Token.pcd.field="" --pcd Token.pcd=H"{}"
+        delete_assign = []
+        field_assign = {}
+        if GlobalData.BuildOptionPcd:
+            for pcdTuple in GlobalData.BuildOptionPcd:
+                TokenSpaceGuid, Token, Field = pcdTuple[0], pcdTuple[1], pcdTuple[2]
+                if Field:
+                    if (TokenSpaceGuid, Token) not in field_assign:
+                        field_assign[TokenSpaceGuid, Token] = []
+                    field_assign[TokenSpaceGuid, Token].append(pcdTuple)
+                else:
+                    if (TokenSpaceGuid, Token) in field_assign:
+                        delete_assign.extend(field_assign[TokenSpaceGuid, Token])
+                        field_assign[TokenSpaceGuid, Token] = []
+            for item in delete_assign:
+                GlobalData.BuildOptionPcd.remove(item)
 
     @staticmethod
     def HandleFlexiblePcd(TokenSpaceGuidCName, TokenCName, PcdValue, PcdDatumType, GuidDict, FieldName=''):
diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index a598d64244..3886a7a55e 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -982,12 +982,16 @@ class PcdReport(object):
                 PcdValue = DecDefaultValue
                 if DscDefaultValue:
                     PcdValue = DscDefaultValue
-                Pcd.DefaultValue = PcdValue
+                #The DefaultValue of StructurePcd already be the latest, no need to update.
+                if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
+                    Pcd.DefaultValue = PcdValue
                 if ModulePcdSet is not None:
                     if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not in ModulePcdSet:
                         continue
                     InfDefaultValue, PcdValue = ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type]
-                    Pcd.DefaultValue = PcdValue
+                    #The DefaultValue of StructurePcd already be the latest, no need to update.
+                    if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
+                        Pcd.DefaultValue = PcdValue
                     if InfDefaultValue:
                         try:
                             InfDefaultValue = ValueExpressionEx(InfDefaultValue, Pcd.DatumType, self._GuidDict)(True)
@@ -1003,7 +1007,9 @@ class PcdReport(object):
                             if pcd[2]:
                                 continue
                             PcdValue = pcd[3]
-                            Pcd.DefaultValue = PcdValue
+                            #The DefaultValue of StructurePcd already be the latest, no need to update.
+                            if not self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
+                                Pcd.DefaultValue = PcdValue
                             BuildOptionMatch = True
                             break
 
@@ -1050,7 +1056,7 @@ class PcdReport(object):
                         DscMatch = (DscDefaultValue.strip() == PcdValue.strip())
 
                 IsStructure = False
-                if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):
+                if self.IsStructurePcd(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):
                     IsStructure = True
                     if TypeName in ('DYNVPD', 'DEXVPD'):
                         SkuInfoList = Pcd.SkuInfoList
@@ -1413,6 +1419,12 @@ class PcdReport(object):
             else:
                 return value
 
+    def IsStructurePcd(self, PcdToken, PcdTokenSpaceGuid):
+        if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd) and ((PcdToken, PcdTokenSpaceGuid) in GlobalData.gStructurePcd[self.Arch]):
+            return True
+        else:
+            return False
+
 ##
 # Reports platform and module Prediction information
 #
-- 
2.14.1.windows.1



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

* Re: [PATCH V2] BaseTools: Latter full value should overwrite the former field value.
  2018-09-12  9:19 [PATCH V2] BaseTools: Latter full value should overwrite the former field value Zhaozh1x
@ 2018-09-25  1:07 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-09-25  1:07 UTC (permalink / raw)
  To: Zhao, ZhiqiangX, edk2-devel@lists.01.org

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

>-----Original Message-----
>From: Zhao, ZhiqiangX
>Sent: Wednesday, September 12, 2018 5:19 PM
>To: edk2-devel@lists.01.org
>Cc: Zhao, ZhiqiangX <zhiqiangx.zhao@intel.com>; Gao, Liming
><liming.gao@intel.com>; Zhu, Yonghong <yonghong.zhu@intel.com>; Feng,
>Bob C <bob.c.feng@intel.com>
>Subject: [PATCH V2] BaseTools: Latter full value should overwrite the former
>field value.
>
>For structure Pcd, the latter full assign value in commandLine should
>override the former field assign value. For example in commandLine,
>build --pcd Token.pcd.field="haha" --pcd Token.pcd=H"{0x01,0x02}",
>the former field value "haha" will be ignored and overwrite by the latter
>full value "{0x01,0x02}".
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: ZhiqiangX Zhao <zhiqiangx.zhao@intel.com>
>Cc: Liming Gao <liming.gao@intel.com>
>Cc: Yonghong Zhu <yonghong.zhu@intel.com>
>Cc: Bob Feng <bob.c.feng@intel.com>
>---
> BaseTools/Source/Python/Workspace/DscBuildData.py | 17
>+++++++++++++++++
> BaseTools/Source/Python/build/BuildReport.py      | 20 ++++++++++++++++-
>---
> 2 files changed, 33 insertions(+), 4 deletions(-)
>
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index 88ba415c5a..4e505c1e99 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -1032,6 +1032,23 @@ class DscBuildData(PlatformBuildClassObject):
>                         PcdItem = BuildData.Pcds[key]
>                         if (TokenSpaceGuidCName, TokenCName) ==
>(PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName
>=="":
>                             PcdItem.DefaultValue = pcdvalue
>+        #In command line, the latter full assign value in commandLine should
>override the former field assign value.
>+        #For example, --pcd Token.pcd.field="" --pcd Token.pcd=H"{}"
>+        delete_assign = []
>+        field_assign = {}
>+        if GlobalData.BuildOptionPcd:
>+            for pcdTuple in GlobalData.BuildOptionPcd:
>+                TokenSpaceGuid, Token, Field = pcdTuple[0], pcdTuple[1],
>pcdTuple[2]
>+                if Field:
>+                    if (TokenSpaceGuid, Token) not in field_assign:
>+                        field_assign[TokenSpaceGuid, Token] = []
>+                    field_assign[TokenSpaceGuid, Token].append(pcdTuple)
>+                else:
>+                    if (TokenSpaceGuid, Token) in field_assign:
>+                        delete_assign.extend(field_assign[TokenSpaceGuid, Token])
>+                        field_assign[TokenSpaceGuid, Token] = []
>+            for item in delete_assign:
>+                GlobalData.BuildOptionPcd.remove(item)
>
>     @staticmethod
>     def HandleFlexiblePcd(TokenSpaceGuidCName, TokenCName, PcdValue,
>PcdDatumType, GuidDict, FieldName=''):
>diff --git a/BaseTools/Source/Python/build/BuildReport.py
>b/BaseTools/Source/Python/build/BuildReport.py
>index a598d64244..3886a7a55e 100644
>--- a/BaseTools/Source/Python/build/BuildReport.py
>+++ b/BaseTools/Source/Python/build/BuildReport.py
>@@ -982,12 +982,16 @@ class PcdReport(object):
>                 PcdValue = DecDefaultValue
>                 if DscDefaultValue:
>                     PcdValue = DscDefaultValue
>-                Pcd.DefaultValue = PcdValue
>+                #The DefaultValue of StructurePcd already be the latest, no need to
>update.
>+                if not self.IsStructurePcd(Pcd.TokenCName,
>Pcd.TokenSpaceGuidCName):
>+                    Pcd.DefaultValue = PcdValue
>                 if ModulePcdSet is not None:
>                     if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type) not in
>ModulePcdSet:
>                         continue
>                     InfDefaultValue, PcdValue = ModulePcdSet[Pcd.TokenCName,
>Pcd.TokenSpaceGuidCName, Type]
>-                    Pcd.DefaultValue = PcdValue
>+                    #The DefaultValue of StructurePcd already be the latest, no need
>to update.
>+                    if not self.IsStructurePcd(Pcd.TokenCName,
>Pcd.TokenSpaceGuidCName):
>+                        Pcd.DefaultValue = PcdValue
>                     if InfDefaultValue:
>                         try:
>                             InfDefaultValue = ValueExpressionEx(InfDefaultValue,
>Pcd.DatumType, self._GuidDict)(True)
>@@ -1003,7 +1007,9 @@ class PcdReport(object):
>                             if pcd[2]:
>                                 continue
>                             PcdValue = pcd[3]
>-                            Pcd.DefaultValue = PcdValue
>+                            #The DefaultValue of StructurePcd already be the latest, no
>need to update.
>+                            if not self.IsStructurePcd(Pcd.TokenCName,
>Pcd.TokenSpaceGuidCName):
>+                                Pcd.DefaultValue = PcdValue
>                             BuildOptionMatch = True
>                             break
>
>@@ -1050,7 +1056,7 @@ class PcdReport(object):
>                         DscMatch = (DscDefaultValue.strip() == PcdValue.strip())
>
>                 IsStructure = False
>-                if GlobalData.gStructurePcd and (self.Arch in
>GlobalData.gStructurePcd) and ((Pcd.TokenCName,
>Pcd.TokenSpaceGuidCName) in GlobalData.gStructurePcd[self.Arch]):
>+                if self.IsStructurePcd(Pcd.TokenCName,
>Pcd.TokenSpaceGuidCName):
>                     IsStructure = True
>                     if TypeName in ('DYNVPD', 'DEXVPD'):
>                         SkuInfoList = Pcd.SkuInfoList
>@@ -1413,6 +1419,12 @@ class PcdReport(object):
>             else:
>                 return value
>
>+    def IsStructurePcd(self, PcdToken, PcdTokenSpaceGuid):
>+        if GlobalData.gStructurePcd and (self.Arch in GlobalData.gStructurePcd)
>and ((PcdToken, PcdTokenSpaceGuid) in GlobalData.gStructurePcd[self.Arch]):
>+            return True
>+        else:
>+            return False
>+
> ##
> # Reports platform and module Prediction information
> #
>--
>2.14.1.windows.1



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

end of thread, other threads:[~2018-09-25  1:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-12  9:19 [PATCH V2] BaseTools: Latter full value should overwrite the former field value Zhaozh1x
2018-09-25  1:07 ` Gao, Liming

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