diff options
author | Yi Li <yi1.li@intel.com> | 2022-03-22 15:26:11 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2022-03-26 00:59:18 +0000 |
commit | bf9230a9f3dde065c3c8b4175ccd32e44e8f0362 (patch) | |
tree | 8c005e0d609d13c709ed72a129626df7a6ccf98a /BaseTools/Source/Python/Workspace/InfBuildData.py | |
parent | 69218d5d2854acaa7a11c777244de4a297d2fbb9 (diff) | |
download | edk2-bf9230a9f3dde065c3c8b4175ccd32e44e8f0362.tar.gz edk2-bf9230a9f3dde065c3c8b4175ccd32e44e8f0362.tar.bz2 edk2-bf9230a9f3dde065c3c8b4175ccd32e44e8f0362.zip |
BaseTools: Add the FeatureFlagExpression usage to the Source Section
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3828
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 <gaoliming@byosoft.com.cn>
Cc: Heng Luo <heng.luo@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Signed-off-by: Yi Li <yi1.li@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace/InfBuildData.py')
-rw-r--r-- | BaseTools/Source/Python/Workspace/InfBuildData.py | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index 45b8ef4716..cd23065b0c 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -14,6 +14,7 @@ from types import * from .MetaFileParser import *
from collections import OrderedDict
from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject
+from Common.Expression import ValueExpressionEx, PcdPattern
## Get Protocol value from given packages
#
@@ -528,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:
@@ -1046,6 +1053,43 @@ class InfBuildData(ModuleBuildClassObject): if (self.Binaries and not self.Sources) or GlobalData.gIgnoreSource:
return True
return False
+ def CheckFeatureFlagPcd(self,Instance):
+ Pcds = {}
+ if GlobalData.gPlatformFinalPcds.get(self.Arch):
+ Pcds = GlobalData.gPlatformFinalPcds[self.Arch].copy()
+ if PcdPattern.search(Instance):
+ PcdTuple = tuple(Instance.split('.')[::-1])
+ if PcdTuple in self.Pcds:
+ if not (self.Pcds[PcdTuple].Type == 'FeatureFlag' or self.Pcds[PcdTuple].Type == 'FixedAtBuild') and Instance not in Pcds:
+ EdkLogger.error('build', FORMAT_INVALID,
+ "\nit must be defined in a [PcdsFeatureFlag] or [PcdsFixedAtBuild] section of Dsc or Dec file or [FeaturePcd] or [FixedPcd] of Inf file",
+ File=str(self), ExtraData=Instance)
+ Pcds[Instance] = self.Pcds[PcdTuple].DefaultValue
+ if Instance in Pcds:
+ if Pcds[Instance] == '0':
+ return False
+ elif Pcds[Instance] == '1':
+ return True
+ try:
+ Value = ValueExpression(Instance, Pcds)()
+ if Value == True:
+ return True
+ return False
+ except:
+ EdkLogger.warn('build', FORMAT_INVALID,"The FeatureFlagExpression cannot be evaluated", File=str(self), ExtraData=Instance)
+ return False
+ else:
+ for Name, Guid in self.Pcds:
+ if self.Pcds[(Name, Guid)].Type == 'FeatureFlag' or self.Pcds[(Name, Guid)].Type == 'FixedAtBuild':
+ Pcds['%s.%s' % (Guid, Name)] = self.Pcds[(Name, Guid)].DefaultValue
+ try:
+ Value = ValueExpression(Instance, Pcds)()
+ if Value == True:
+ return True
+ return False
+ except:
+ EdkLogger.warn('build', FORMAT_INVALID, "The FeatureFlagExpression cannot be evaluated", File=str(self), ExtraData=Instance)
+ return False
def ExtendCopyDictionaryLists(CopyToDict, CopyFromDict):
for Key in CopyFromDict:
CopyToDict[Key].extend(CopyFromDict[Key])
|