public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch V2] BaseTools: Fix the bug for Pcd used in command line's override
@ 2018-10-24 14:05 Yonghong Zhu
  2018-10-25  0:29 ` Gao, Liming
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Zhu @ 2018-10-24 14:05 UTC (permalink / raw)
  To: edk2-devel

V2: remove the not used parameter i

Fix the bug for Pcd used in command line not override the Pcd used
in the [component] driver's sub-section.

Case:
DSC file:
[PcdsFixedAtBuild]
TokenSpaceGuid.PcdTest

[Components]
 TestPkg/TestDriver.inf {
  <PcdsFixedAtBuild>
  TokenSpaceGuid.PcdTest|"b"
  }

build command with --pcd TokenSpaceGuid.PcdTest="AAAABB"

Then we found the Pcd value in the AutoGen.c file is incorrect,
because of the incorrect logic that use the pcd in the [component]
section to re-override it.

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

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 804f579..84645e3 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -2118,10 +2118,17 @@ class PlatformAutoGen(AutoGen):
 
         # override PCD settings with module specific setting
         if Module in self.Platform.Modules:
             PlatformModule = self.Platform.Modules[str(Module)]
             for Key  in PlatformModule.Pcds:
+                if GlobalData.BuildOptionPcd:
+                    for pcd in GlobalData.BuildOptionPcd:
+                        (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _) = pcd
+                        if (TokenCName, TokenSpaceGuidCName) == Key and FieldName =="":
+                            PlatformModule.Pcds[Key].DefaultValue = pcdvalue
+                            PlatformModule.Pcds[Key].PcdValueFromComm = pcdvalue
+                            break
                 Flag = False
                 if Key in Pcds:
                     ToPcd = Pcds[Key]
                     Flag = True
                 elif Key in GlobalData.MixedPcd:
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index b0e88a9..162360c 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -1058,11 +1058,16 @@ class DscBuildData(PlatformBuildClassObject):
                     IsValid, Cause = CheckPcdDatum(PcdDatumType, pcdvalue)
                     if not IsValid:
                         EdkLogger.error("build", FORMAT_INVALID, Cause, ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))
                 GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, ("build command options", 1))
 
+        if GlobalData.BuildOptionPcd:
+            for pcd in GlobalData.BuildOptionPcd:
+                (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _) = pcd
                 for BuildData in self._Bdb._CACHE_.values():
+                    if BuildData.Arch != self.Arch:
+                        continue
                     if BuildData.MetaFile.Ext == '.dec' or BuildData.MetaFile.Ext == '.dsc':
                         continue
                     for key in BuildData.Pcds:
                         PcdItem = BuildData.Pcds[key]
                         if (TokenSpaceGuidCName, TokenCName) == (PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName =="":
-- 
2.6.1.windows.1



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

* Re: [Patch V2] BaseTools: Fix the bug for Pcd used in command line's override
  2018-10-24 14:05 [Patch V2] BaseTools: Fix the bug for Pcd used in command line's override Yonghong Zhu
@ 2018-10-25  0:29 ` Gao, Liming
  0 siblings, 0 replies; 2+ messages in thread
From: Gao, Liming @ 2018-10-25  0:29 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: Wednesday, October 24, 2018 10:06 PM
>To: edk2-devel@lists.01.org
>Subject: [edk2] [Patch V2] BaseTools: Fix the bug for Pcd used in command
>line's override
>
>V2: remove the not used parameter i
>
>Fix the bug for Pcd used in command line not override the Pcd used
>in the [component] driver's sub-section.
>
>Case:
>DSC file:
>[PcdsFixedAtBuild]
>TokenSpaceGuid.PcdTest
>
>[Components]
> TestPkg/TestDriver.inf {
>  <PcdsFixedAtBuild>
>  TokenSpaceGuid.PcdTest|"b"
>  }
>
>build command with --pcd TokenSpaceGuid.PcdTest="AAAABB"
>
>Then we found the Pcd value in the AutoGen.c file is incorrect,
>because of the incorrect logic that use the pcd in the [component]
>section to re-override it.
>
>Contributed-under: TianoCore Contribution Agreement 1.1
>Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
>---
> BaseTools/Source/Python/AutoGen/AutoGen.py        | 7 +++++++
> BaseTools/Source/Python/Workspace/DscBuildData.py | 5 +++++
> 2 files changed, 12 insertions(+)
>
>diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py
>b/BaseTools/Source/Python/AutoGen/AutoGen.py
>index 804f579..84645e3 100644
>--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
>+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
>@@ -2118,10 +2118,17 @@ class PlatformAutoGen(AutoGen):
>
>         # override PCD settings with module specific setting
>         if Module in self.Platform.Modules:
>             PlatformModule = self.Platform.Modules[str(Module)]
>             for Key  in PlatformModule.Pcds:
>+                if GlobalData.BuildOptionPcd:
>+                    for pcd in GlobalData.BuildOptionPcd:
>+                        (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _)
>= pcd
>+                        if (TokenCName, TokenSpaceGuidCName) == Key and
>FieldName =="":
>+                            PlatformModule.Pcds[Key].DefaultValue = pcdvalue
>+                            PlatformModule.Pcds[Key].PcdValueFromComm = pcdvalue
>+                            break
>                 Flag = False
>                 if Key in Pcds:
>                     ToPcd = Pcds[Key]
>                     Flag = True
>                 elif Key in GlobalData.MixedPcd:
>diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
>b/BaseTools/Source/Python/Workspace/DscBuildData.py
>index b0e88a9..162360c 100644
>--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
>+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
>@@ -1058,11 +1058,16 @@ class DscBuildData(PlatformBuildClassObject):
>                     IsValid, Cause = CheckPcdDatum(PcdDatumType, pcdvalue)
>                     if not IsValid:
>                         EdkLogger.error("build", FORMAT_INVALID, Cause,
>ExtraData="%s.%s" % (TokenSpaceGuidCName, TokenCName))
>                 GlobalData.BuildOptionPcd[i] = (TokenSpaceGuidCName,
>TokenCName, FieldName, pcdvalue, ("build command options", 1))
>
>+        if GlobalData.BuildOptionPcd:
>+            for pcd in GlobalData.BuildOptionPcd:
>+                (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _) =
>pcd
>                 for BuildData in self._Bdb._CACHE_.values():
>+                    if BuildData.Arch != self.Arch:
>+                        continue
>                     if BuildData.MetaFile.Ext == '.dec' or BuildData.MetaFile.Ext ==
>'.dsc':
>                         continue
>                     for key in BuildData.Pcds:
>                         PcdItem = BuildData.Pcds[key]
>                         if (TokenSpaceGuidCName, TokenCName) ==
>(PcdItem.TokenSpaceGuidCName, PcdItem.TokenCName) and FieldName
>=="":
>--
>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-10-25  0:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-24 14:05 [Patch V2] BaseTools: Fix the bug for Pcd used in command line's override Yonghong Zhu
2018-10-25  0:29 ` Gao, Liming

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