From nobody Wed May 15 03:36:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+87820+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87820+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1647933982; cv=none; d=zohomail.com; s=zohoarc; b=MRduv2UAeLbnbX0Ji2ge+7PWJx75St0DL8oE/2pHKBzqDsLSJVYKopMSEWaVNmWJtHLCCnHN4TQQkk+qtB3gYCWYPA7miT2mbw8oR1bOA66Kx00/iUX4FFijm8Qlnam52niEWggdcARLvA0D+wWX09HEwd7Puq1VWu/8UjicB/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1647933982; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=KLk96Yk0AITXbOlFALtwD4z5KdH8d2bs9+6ijUo8ahA=; b=W98u3gJO/bD/5+2E+j1mFfaTSeomGPgvckkAU1qOmTPMMd8nexeJC+OtTjC7LGNwbuPmXDBI5rDZRutM3cUuutcjAClYrl292eOYbf8YTDJA9+wjxhGL5vF5IP27AGNolqKgCzWMc4gydUVqtDhunWkWHnO+8mTW0n2Ybg+j5JY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+87820+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1647933982152882.2730468314718; Tue, 22 Mar 2022 00:26:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id t1LaYY1788612x9wJWxv2Jm9; Tue, 22 Mar 2022 00:26:21 -0700 X-Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.6987.1647933978978811798 for ; Tue, 22 Mar 2022 00:26:21 -0700 X-IronPort-AV: E=McAfee;i="6200,9189,10293"; a="318457745" X-IronPort-AV: E=Sophos;i="5.90,201,1643702400"; d="scan'208";a="318457745" X-Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2022 00:26:20 -0700 X-IronPort-AV: E=Sophos;i="5.90,201,1643702400"; d="scan'208";a="543574221" X-Received: from shwdejointd178.ccr.corp.intel.com ([10.239.153.103]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Mar 2022 00:26:18 -0700 From: "yi1 li" To: devel@edk2.groups.io Cc: Yi Li , Bob Feng , Liming Gao , Heng Luo Subject: [edk2-devel] [PATCH V3 1/1] BaseTools: Add the FeatureFlagExpression usage to the Source Section Date: Tue, 22 Mar 2022 15:26:11 +0800 Message-Id: <3c83168f0201d81502a67024c7c7fc65aca1695e.1647933849.git.yi1.li@intel.com> In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yi1.li@intel.com X-Gm-Message-State: aZnqrauUaCTGV3QkKvesRLMrx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1647933981; bh=P47i6levGLwKkE3hZITBs6skpXVGCSVHmA04GF7w84w=; h=Cc:Date:From:Reply-To:Subject:To; b=EI1wHdLLx2w6YEbxjzun8N6O4t0UNO5U9g5NV78q9DmaZf4SDNQpm1ewFDYj8FTbz6v e9qXPlkAh+Y8Wypq2xlrHMbgZ5YdVGvYbtCtQMDrl1sr0B/9d3ZonCMvRbJHFJx2HWbm9 kzVvkAAIi/oTVLOGWSgZrch4/9CVJA4VOIY= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1647933984009100004 Content-Type: text/plain; charset="utf-8" From: Yi Li REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D3828 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. Change-Id: I5821652330cdba1bfc5544e90f27b32ddf4147fc Cc: Bob Feng Cc: Liming Gao Cc: Heng Luo Signed-off-by: Yi Li Reviewed-by: Bob Feng --- BaseTools/Source/Python/Common/Expression.py | 2 +- BaseTools/Source/Python/Common/GlobalData.py | 1 + .../Source/Python/Workspace/InfBuildData.py | 52 +++++++++++++++++-- .../Source/Python/Workspace/MetaFileParser.py | 4 ++ .../Python/Workspace/WorkspaceCommon.py | 5 ++ 5 files changed, 59 insertions(+), 5 deletions(-) diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Sourc= e/Python/Common/Expression.py index 07ca039a9cf3..31bf0e4b6cf7 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -43,7 +43,7 @@ ERR_IN_OPERAND =3D 'Macro after IN operator can = only be: $(FAMILY), $(ARC __ValidString =3D re.compile(r'[_a-zA-Z][_0-9a-zA-Z]*$') _ReLabel =3D re.compile('LABEL\((\w+)\)') _ReOffset =3D re.compile('OFFSET_OF\((\w+)\)') -PcdPattern =3D re.compile(r'[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]*= $') +PcdPattern =3D re.compile(r'^[_a-zA-Z][0-9A-Za-z_]*\.[_a-zA-Z][0-9A-Za-z_]= *$') =20 ## SplitString # Split string to list according double quote diff --git a/BaseTools/Source/Python/Common/GlobalData.py b/BaseTools/Sourc= e/Python/Common/GlobalData.py index 61ab3f7e24cd..197bd8366682 100755 --- a/BaseTools/Source/Python/Common/GlobalData.py +++ b/BaseTools/Source/Python/Common/GlobalData.py @@ -18,6 +18,7 @@ gGlobalDefines =3D {} gPlatformDefines =3D {} # PCD name and value pair for fixed at build and feature flag gPlatformPcds =3D {} +gPlatformFinalPcds =3D {} # PCDs with type that are not fixed at build and feature flag gPlatformOtherPcds =3D {} gActivePlatform =3D None diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/= Source/Python/Workspace/InfBuildData.py index 45b8ef4716dd..cd23065b0c8e 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, LibraryClas= sObject, PcdClassObject +from Common.Expression import ValueExpressionEx, PcdPattern =20 ## Get Protocol value from given packages # @@ -528,11 +529,17 @@ class InfBuildData(ModuleBuildClassObject): for Record in RecordList: LineNo =3D Record[-1] ToolChainFamily =3D Record[1] - TagName =3D Record[2] - ToolCode =3D Record[3] - + # OptionsList :=3D [TagName, ToolCode, FeatureFlag] + OptionsList =3D ['', '', ''] + TokenList =3D GetSplitValueList(Record[2], TAB_VALUE_SPLIT) + for Index in range(len(TokenList)): + OptionsList[Index] =3D TokenList[Index] + if OptionsList[2]: + FeaturePcdExpression =3D self.CheckFeatureFlagPcd(OptionsL= ist[2]) + if not FeaturePcdExpression: + continue File =3D PathClass(NormPath(Record[0], Macros), self._ModuleDi= r, '', - '', False, self._Arch, ToolChainFamily, '', T= agName, ToolCode) + '', False, self._Arch, ToolChainFamily, '', O= ptionsList[0], OptionsList[1]) # check the file validation ErrorCode, ErrorInfo =3D File.Validate() if ErrorCode !=3D 0: @@ -1046,6 +1053,43 @@ class InfBuildData(ModuleBuildClassObject): if (self.Binaries and not self.Sources) or GlobalData.gIgnoreSourc= e: return True return False + def CheckFeatureFlagPcd(self,Instance): + Pcds =3D {} + if GlobalData.gPlatformFinalPcds.get(self.Arch): + Pcds =3D GlobalData.gPlatformFinalPcds[self.Arch].copy() + if PcdPattern.search(Instance): + PcdTuple =3D tuple(Instance.split('.')[::-1]) + if PcdTuple in self.Pcds: + if not (self.Pcds[PcdTuple].Type =3D=3D 'FeatureFlag' or s= elf.Pcds[PcdTuple].Type =3D=3D 'FixedAtBuild') and Instance not in Pcds: + EdkLogger.error('build', FORMAT_INVALID, + "\nit must be defined in a [PcdsFeatur= eFlag] or [PcdsFixedAtBuild] section of Dsc or Dec file or [FeaturePcd] or = [FixedPcd] of Inf file", + File=3Dstr(self), ExtraData=3DInstance) + Pcds[Instance] =3D self.Pcds[PcdTuple].DefaultValue + if Instance in Pcds: + if Pcds[Instance] =3D=3D '0': + return False + elif Pcds[Instance] =3D=3D '1': + return True + try: + Value =3D ValueExpression(Instance, Pcds)() + if Value =3D=3D True: + return True + return False + except: + EdkLogger.warn('build', FORMAT_INVALID,"The FeatureFlagExp= ression cannot be evaluated", File=3Dstr(self), ExtraData=3DInstance) + return False + else: + for Name, Guid in self.Pcds: + if self.Pcds[(Name, Guid)].Type =3D=3D 'FeatureFlag' or se= lf.Pcds[(Name, Guid)].Type =3D=3D 'FixedAtBuild': + Pcds['%s.%s' % (Guid, Name)] =3D self.Pcds[(Name, Guid= )].DefaultValue + try: + Value =3D ValueExpression(Instance, Pcds)() + if Value =3D=3D True: + return True + return False + except: + EdkLogger.warn('build', FORMAT_INVALID, "The FeatureFlagEx= pression cannot be evaluated", File=3Dstr(self), ExtraData=3DInstance) + return False def ExtendCopyDictionaryLists(CopyToDict, CopyFromDict): for Key in CopyFromDict: CopyToDict[Key].extend(CopyFromDict[Key]) diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTool= s/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 =3D 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] =3D TokenList[2] + '|' + TokenList[extraToken] self._ValueList[0:len(TokenList)] =3D TokenList Macros =3D self._Macros # For Acpi tables, remove macro like ' TABLE_NAME=3DSata1' diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseToo= ls/Source/Python/Workspace/WorkspaceCommon.py index 53027a0e30f5..6564a34ba724 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -75,6 +75,11 @@ def GetDeclaredPcd(Platform, BuildDatabase, Arch, Target= , Toolchain, additionalP break if (PcdCName, PcdTokenName) not in DecPcds: DecPcds[PcdCName, PcdTokenName] =3D Pkg.Pcds[Pcd] + if not GlobalData.gPlatformFinalPcds.get(Arch): + GlobalData.gPlatformFinalPcds[Arch] =3D OrderedDict() + for Name,Guid in DecPcds: + if DecPcds[Name,Guid].Type =3D=3D 'FeatureFlag' or DecPcds[Name, G= uid].Type =3D=3D 'FixedAtBuild': + GlobalData.gPlatformFinalPcds[Arch]['%s.%s'%(Guid, Name)]=3DDe= cPcds[Name, Guid].DefaultValue return DecPcds, GuidDict =20 ## Get all dependent libraries for a module --=20 2.33.0.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#87820): https://edk2.groups.io/g/devel/message/87820 Mute This Topic: https://groups.io/mt/89947426/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-