public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "yi1 li" <yi1.li@intel.com>
To: devel@edk2.groups.io
Cc: yi1 li <yi1.li@intel.com>, Bob Feng <bob.c.feng@intel.com>,
	Liming Gao <liming.gao@intel.com>, Heng Luo <heng.luo@intel.com>
Subject: [PATCH 2/2] BaseTools:Add the FeatureFlagExpression usage to the Source Section
Date: Tue,  8 Mar 2022 15:07:11 +0800	[thread overview]
Message-ID: <4a24df439a87ae36383a0e14b0b46c4ef63db96c.1646721943.git.yi1.li@intel.com> (raw)
In-Reply-To: <cover.1646721943.git.yi1.li@intel.com>

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=1446

FeatureFlagExpression Support in Source section of INF file. The Pcd
value in the expression is from INF or DEC.
When a FeatureFlagExpression is present,if the expression evaluates
to TRUE,then the entry is valid. If the expression evaluates to FALSE,
then the EDK II build tools must ignore the entry.

This patch is going to add this feature.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Heng Luo <heng.luo@intel.com>
Signed-off-by: yi1 li <yi1.li@intel.com>
---
 .../Source/Python/Workspace/InfBuildData.py      | 16 +++++++++++-----
 .../Source/Python/Workspace/MetaFileParser.py    |  4 ++++
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 9643bf17ac63..da5d3f0dc93c 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -529,11 +529,17 @@ class InfBuildData(ModuleBuildClassObject):
         for Record in RecordList:
             LineNo = Record[-1]
             ToolChainFamily = Record[1]
-            TagName = Record[2]
-            ToolCode = Record[3]
-
+            # OptionsList := [TagName, ToolCode, FeatureFlag]
+            OptionsList = ['','','']
+            TokenList = GetSplitValueList(Record[2], TAB_VALUE_SPLIT)
+            for Index in range(len(TokenList)):
+                OptionsList[Index] = TokenList[Index]
+            if OptionsList[2]:
+                FeaturePcdExpression = self.CheckFeatureFlagPcd(OptionsList[2])
+                if not FeaturePcdExpression:
+                    continue
             File = PathClass(NormPath(Record[0], Macros), self._ModuleDir, '',
-                             '', False, self._Arch, ToolChainFamily, '', TagName, ToolCode)
+                             '', False, self._Arch, ToolChainFamily, '', OptionsList[0], OptionsList[1])
             # check the file validation
             ErrorCode, ErrorInfo = File.Validate()
             if ErrorCode != 0:
@@ -1067,7 +1073,7 @@ class InfBuildData(ModuleBuildClassObject):
             return True
         return False
     def CheckFeatureFlagPcd(self,Instance):
-        Pcds = GlobalData.gPlatformFinalPcds[self.Arch].copy()
+        Pcds = self._GetPcd(MODEL_PCD_FIXED_AT_BUILD)
         if PcdPattern.search(Instance):
             PcdTuple = tuple(Instance.split('.')[::-1])
             if PcdTuple in self.Pcds:
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py
index a3b6edbd15ee..3508591b281e 100644
--- a/BaseTools/Source/Python/Workspace/MetaFileParser.py
+++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py
@@ -736,6 +736,10 @@ class InfParser(MetaFileParser):
     @ParseMacro
     def _SourceFileParser(self):
         TokenList = GetSplitValueList(self._CurrentLine, TAB_VALUE_SPLIT)
+        # Let TokenList[2] be TagName|ToolCode|FeatureFlag
+        if len(TokenList) > 3:
+            for extraToken in range(3, len(TokenList)):
+                TokenList[2] = TokenList[2] + '|' + TokenList[extraToken]
         self._ValueList[0:len(TokenList)] = TokenList
         Macros = self._Macros
         # For Acpi tables, remove macro like ' TABLE_NAME=Sata1'
-- 
2.33.0.windows.2


      parent reply	other threads:[~2022-03-08  7:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-08  7:07 [PATCH 0/2] BaseTools:Add the FeatureFlagExpression usage to the InfBuildData yi1 li
2022-03-08  7:07 ` [PATCH 1/2] " yi1 li
2022-03-08  7:07 ` yi1 li [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4a24df439a87ae36383a0e14b0b46c4ef63db96c.1646721943.git.yi1.li@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox