[edk2-devel] [PATCH] BaseTools: Fix build option overrides Pcd Feature Flag issue

Yuwei Chen posted 1 patch 1 year, 5 months ago
Failed in applying to current master (apply log)
edk2basetools/Workspace/InfBuildData.py | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
[edk2-devel] [PATCH] BaseTools: Fix build option overrides Pcd Feature Flag issue
Posted by Yuwei Chen 1 year, 5 months ago
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4081

INF [Sources] section Feature Flag Expressions do not use
override values from build --pcd option currently.
This patch fix this issue.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yuwei Chen <yuwei.chen@intel.com>
---
 edk2basetools/Workspace/InfBuildData.py | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/edk2basetools/Workspace/InfBuildData.py b/edk2basetools/Workspace/InfBuildData.py
index c97a70e..8631373 100644
--- a/edk2basetools/Workspace/InfBuildData.py
+++ b/edk2basetools/Workspace/InfBuildData.py
@@ -1055,6 +1055,7 @@ def IsBinaryModule(self):
         return False
     def CheckFeatureFlagPcd(self,Instance):
         Pcds = GlobalData.gPlatformFinalPcds.copy()
+        BuildOptionPcds = GlobalData.BuildOptionPcd
         if PcdPattern.search(Instance):
             PcdTuple = tuple(Instance.split('.')[::-1])
             if PcdTuple in self.Pcds:
@@ -1062,6 +1063,14 @@ def CheckFeatureFlagPcd(self,Instance):
                     EdkLogger.error('build', FORMAT_INVALID,
                                     "\nFeatureFlagPcd must be defined in a [PcdsFeatureFlag] or [PcdsFixedAtBuild] section of Dsc or Dec file",
                                     File=str(self), ExtraData=Instance)
+                for item in BuildOptionPcds:
+                    if self.Pcds[PcdTuple].TokenCName in item:
+                        if type(item) == type(()):
+                            # ('gEfiCryptoPkgTokenSpaceGuid', 'PcdOpensslEcEnabled', '', '1', ('build command options', 1)
+                            Pcds[Instance] = list(item)[3]
+                        elif type(item) == type(''):
+                            # gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled=1
+                            Pcds[Instance] = item.split('=')[1]
                 if not Instance in Pcds:
                     Pcds[Instance] = self.Pcds[PcdTuple].DefaultValue
             else: #if PcdTuple not in self.Pcds:
@@ -1085,6 +1094,14 @@ def CheckFeatureFlagPcd(self,Instance):
             for Name, Guid in self.Pcds:
                 if self.Pcds[(Name, Guid)].Type == 'FeatureFlag' or self.Pcds[(Name, Guid)].Type == 'FixedAtBuild':
                     PcdFullName = '%s.%s' % (Guid, Name);
+                    for item in BuildOptionPcds:
+                        if Name in item:
+                            if type(item) == type(()):
+                                # ('gEfiCryptoPkgTokenSpaceGuid', 'PcdOpensslEcEnabled', '', '1', ('build command options', 1)
+                                Pcds[PcdFullName] = list(item)[3]
+                            elif type(item) == type(''):
+                                # gEfiCryptoPkgTokenSpaceGuid.PcdOpensslEcEnabled=1
+                                Pcds[PcdFullName] = item.split('=')[1]
                     if not PcdFullName in Pcds:
                         Pcds[PcdFullName] = self.Pcds[(Name, Guid)].DefaultValue
             try:
-- 
2.27.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#95553): https://edk2.groups.io/g/devel/message/95553
Mute This Topic: https://groups.io/mt/94554387/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-