Re: [Patch V2] BaseTools: Enable the flag to treat dynamic pcd as dynamicEx


Bob Feng
 

Add Mike Turner for review.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bob Feng
Sent: Tuesday, June 8, 2021 10:50 AM
To: devel@edk2.groups.io
Cc: Liming Gao <gaoliming@...>; Chen, Christine <yuwei.chen@...>; Kinney, Michael D <michael.d.kinney@...>; Desimone, Nathaniel L <nathaniel.l.desimone@...>
Subject: [edk2-devel] [Patch V2] BaseTools: Enable the flag to treat dynamic pcd as dynamicEx

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1688

In order to support binary build, build tool add a flag to convert type of Dynamic Pcd to DynamicEx Pcd

User can append -D PCD_DYNAMIC_AS_DYNAMICEX to build command to enable this function.
Also, user can add "PCD_DYNAMIC_AS_DYNAMICEX = TRUE/FALSE"
to the defines section of Dsc file to enable this function.

PCD_DYNAMIC_AS_DYNAMICEX is a new reserved key word for this function.

Signed-off-by: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Nate DeSimone <nathaniel.l.desimone@...> ---Correct Liming's email address.
BaseTools/Source/Python/Common/DataType.py | 1 +
.../Python/Workspace/BuildClassObject.py | 153 ++++++++----------
.../Source/Python/Workspace/DecBuildData.py | 15 +-
.../Source/Python/Workspace/DscBuildData.py | 19 +--
.../Source/Python/Workspace/InfBuildData.py | 15 +-
5 files changed, 73 insertions(+), 130 deletions(-)

diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py
index fb88f20cc4..4e9c9e34af 100644
--- a/BaseTools/Source/Python/Common/DataType.py
+++ b/BaseTools/Source/Python/Common/DataType.py
@@ -402,10 +402,11 @@ TAB_DSC_DEFINES_DSC_SPECIFICATION = 'DSC_SPECIFICATION'
TAB_DSC_DEFINES_OUTPUT_DIRECTORY = 'OUTPUT_DIRECTORY' TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES = 'SUPPORTED_ARCHITECTURES' TAB_DSC_DEFINES_BUILD_TARGETS = 'BUILD_TARGETS' TAB_DSC_DEFINES_SKUID_IDENTIFIER = 'SKUID_IDENTIFIER' TAB_DSC_DEFINES_PCD_INFO_GENERATION = 'PCD_INFO_GENERATION'+TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX = 'PCD_DYNAMIC_AS_DYNAMICEX' TAB_DSC_DEFINES_PCD_VAR_CHECK_GENERATION = 'PCD_VAR_CHECK_GENERATION' TAB_DSC_DEFINES_FLASH_DEFINITION = 'FLASH_DEFINITION' TAB_DSC_DEFINES_BUILD_NUMBER = 'BUILD_NUMBER' TAB_DSC_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME' TAB_DSC_DEFINES_BS_BASE_ADDRESS = 'BsBaseAddress'diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index ebb65fc2fe..88a1d1582c 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -10,11 +10,13 @@ from Common.DataType import * import collections import re from collections import OrderedDict from Common.Misc import CopyDict,ArrayIndex import copy+from CommonDataClass.DataClass import * import Common.EdkLogger as EdkLogger+import Common.GlobalData as GlobalData from Common.BuildToolError import OPTION_VALUE_INVALID from Common.caching import cached_property StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') ## PcdClassObject@@ -396,10 +398,71 @@ class StructurePcd(PcdClassObject):
new_pcd.ValueChain = {item for item in self.ValueChain} return new_pcd LibraryClassObject = namedtuple('LibraryClassObject', ['LibraryClass','SupModList']) +class BuildData(object):+ # dict used to convert PCD type in database to string used by build tool++ _PCD_TYPE_STRING_ = {+ MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,+ MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,+ MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,+ MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,+ MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,+ MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,+ MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,+ MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,+ MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,+ }++ def UpdatePcdTypeDict(self):+ if GlobalData.gCommandLineDefines.get(TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX,"FALSE").upper() == "TRUE":+ self._PCD_TYPE_STRING_ = {+ MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,+ MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,+ MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,+ MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_EX_HII,+ MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_EX_VPD,+ MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,+ MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,+ MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,+ }++ ## Convert the class to a string+ #+ # Convert member MetaFile of the class to a string+ #+ # @retval string Formatted String+ #+ def __str__(self):+ return str(self.MetaFile)++ ## Override __eq__ function+ #+ # Check whether ModuleBuildClassObjects are the same+ #+ # @retval False The two ModuleBuildClassObjects are different+ # @retval True The two ModuleBuildClassObjects are the same+ #+ def __eq__(self, Other):+ return self.MetaFile == Other++ ## Override __hash__ function+ #+ # Use MetaFile as key in hash table+ #+ # @retval string Key for hash table+ #+ def __hash__(self):+ return hash(self.MetaFile)+ ## ModuleBuildClassObject # # This Class defines ModuleBuildClass # # @param object: Inherited from object class@@ -440,11 +503,11 @@ LibraryClassObject = namedtuple('LibraryClassObject', ['LibraryClass','SupModLis
# { [(PcdCName, PcdGuidCName)] : PcdClassObject} # @var BuildOptions: To store value for BuildOptions, it is a set structure as # { [BuildOptionKey] : BuildOptionValue} # @var Depex: To store value for Depex #-class ModuleBuildClassObject(object):+class ModuleBuildClassObject(BuildData): def __init__(self): self.AutoGenVersion = 0 self.MetaFile = '' self.BaseName = '' self.ModuleType = ''@@ -474,38 +537,10 @@ class ModuleBuildClassObject(object):
self.BuildOptions = {} self.Depex = {} self.StrPcdSet = [] self.StrPcdOverallValue = {} - ## Convert the class to a string- #- # Convert member MetaFile of the class to a string- #- # @retval string Formatted String- #- def __str__(self):- return str(self.MetaFile)-- ## Override __eq__ function- #- # Check whether ModuleBuildClassObjects are the same- #- # @retval False The two ModuleBuildClassObjects are different- # @retval True The two ModuleBuildClassObjects are the same- #- def __eq__(self, Other):- return self.MetaFile == Other-- ## Override __hash__ function- #- # Use MetaFile as key in hash table- #- # @retval string Key for hash table- #- def __hash__(self):- return hash(self.MetaFile)- ## PackageBuildClassObject # # This Class defines PackageBuildClass # # @param object: Inherited from object class@@ -525,11 +560,11 @@ class ModuleBuildClassObject(object):
# @var LibraryClasses: To store value for LibraryClasses, it is a set structure as # { [LibraryClassName] : LibraryClassInfFile } # @var Pcds: To store value for Pcds, it is a set structure as # { [(PcdCName, PcdGuidCName)] : PcdClassObject} #-class PackageBuildClassObject(object):+class PackageBuildClassObject(BuildData): def __init__(self): self.MetaFile = '' self.PackageName = '' self.Guid = '' self.Version = ''@@ -539,38 +574,10 @@ class PackageBuildClassObject(object):
self.Guids = {} self.Includes = [] self.LibraryClasses = {} self.Pcds = {} - ## Convert the class to a string- #- # Convert member MetaFile of the class to a string- #- # @retval string Formatted String- #- def __str__(self):- return str(self.MetaFile)-- ## Override __eq__ function- #- # Check whether PackageBuildClassObjects are the same- #- # @retval False The two PackageBuildClassObjects are different- # @retval True The two PackageBuildClassObjects are the same- #- def __eq__(self, Other):- return self.MetaFile == Other-- ## Override __hash__ function- #- # Use MetaFile as key in hash table- #- # @retval string Key for hash table- #- def __hash__(self):- return hash(self.MetaFile)- ## PlatformBuildClassObject # # This Class defines PlatformBuildClass # # @param object: Inherited from object class@@ -595,11 +602,11 @@ class PackageBuildClassObject(object):
# @var Pcds: To store value for Pcds, it is a set structure as # { [(PcdCName, PcdGuidCName)] : PcdClassObject } # @var BuildOptions: To store value for BuildOptions, it is a set structure as # { [BuildOptionKey] : BuildOptionValue } #-class PlatformBuildClassObject(object):+class PlatformBuildClassObject(BuildData): def __init__(self): self.MetaFile = '' self.PlatformName = '' self.Guid = '' self.Version = ''@@ -614,33 +621,5 @@ class PlatformBuildClassObject(object):
self.LibraryInstances = [] self.LibraryClasses = {} self.Libraries = {} self.Pcds = {} self.BuildOptions = {}-- ## Convert the class to a string- #- # Convert member MetaFile of the class to a string- #- # @retval string Formatted String- #- def __str__(self):- return str(self.MetaFile)-- ## Override __eq__ function- #- # Check whether PlatformBuildClassObjects are the same- #- # @retval False The two PlatformBuildClassObjects are different- # @retval True The two PlatformBuildClassObjects are the same- #- def __eq__(self, Other):- return self.MetaFile == Other-- ## Override __hash__ function- #- # Use MetaFile as key in hash table- #- # @retval string Key for hash table- #- def __hash__(self):- return hash(self.MetaFile)diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py
index 30826a3cea..da7a52c5d0 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -19,24 +19,10 @@ from re import compile
# # This class is used to retrieve information stored in database and convert them # into PackageBuildClassObject form for easier use for AutoGen. # class DecBuildData(PackageBuildClassObject):- # dict used to convert PCD type in database to string used by build tool- _PCD_TYPE_STRING_ = {- MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,- MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,- MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,- MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,- MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,- MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,- MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,- } # dict used to convert part of [Defines] to members of DecBuildData directly _PROPERTY_ = { # # Required Fields@@ -66,10 +52,11 @@ class DecBuildData(PackageBuildClassObject):
self._Bdb = BuildDataBase self._Arch = Arch self._Target = Target self._Toolchain = Toolchain self._Clear()+ self.UpdatePcdTypeDict() ## XXX[key] = value def __setitem__(self, key, value): self.__dict__[self._PROPERTY_[key]] = value diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 5f07d3e75c..4d5b1ad4d9 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -177,24 +177,10 @@ def GetDependencyList(FileStack, SearchPathList):
DependencyList = list(DependencySet) # remove duplicate ones return DependencyList class DscBuildData(PlatformBuildClassObject):- # dict used to convert PCD type in database to string used by build tool- _PCD_TYPE_STRING_ = {- MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,- MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,- MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,- MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,- MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,- MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,- MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,- } # dict used to convert part of [Defines] to members of DscBuildData directly _PROPERTY_ = { # # Required Fields@@ -240,11 +226,11 @@ class DscBuildData(PlatformBuildClassObject):
self._ToolChainFamily = None self._Clear() self.WorkspaceDir = os.getenv("WORKSPACE") if os.getenv("WORKSPACE") else "" self.DefaultStores = None self.SkuIdMgr = SkuClass(self.SkuName, self.SkuIds)-+ self.UpdatePcdTypeDict() @property def OutputPath(self): if os.getenv("WORKSPACE"): return os.path.join(os.getenv("WORKSPACE"), self.OutputDirectory, self._Target + "_" + self._Toolchain, PcdValueInitName) else:@@ -409,10 +395,13 @@ class DscBuildData(PlatformBuildClassObject):
try: uuid.UUID(Record[2]) except: EdkLogger.error("build", FORMAT_INVALID, "Invalid GUID format for VPD_TOOL_GUID", File=self.MetaFile) self._VpdToolGuid = Record[2]+ elif Name == TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX:+ if TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX not in gCommandLineDefines:+ gCommandLineDefines[TAB_DSC_DEFINES_PCD_DYNAMIC_AS_DYNAMICEX] = Record[2].strip() elif Name in self: self[Name] = Record[2] # set _Header to non-None in order to avoid database re-querying self._Header = 'DUMMY' diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 7675b0ea00..45b8ef4716 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -57,24 +57,10 @@ def _PpiValue(CName, PackageList, Inffile = None):
# # This class is used to retrieve information stored in database and convert them # into ModuleBuildClassObject form for easier use for AutoGen. # class InfBuildData(ModuleBuildClassObject):- # dict used to convert PCD type in database to string used by build tool- _PCD_TYPE_STRING_ = {- MODEL_PCD_FIXED_AT_BUILD : TAB_PCDS_FIXED_AT_BUILD,- MODEL_PCD_PATCHABLE_IN_MODULE : TAB_PCDS_PATCHABLE_IN_MODULE,- MODEL_PCD_FEATURE_FLAG : TAB_PCDS_FEATURE_FLAG,- MODEL_PCD_DYNAMIC : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_DEFAULT : TAB_PCDS_DYNAMIC,- MODEL_PCD_DYNAMIC_HII : TAB_PCDS_DYNAMIC_HII,- MODEL_PCD_DYNAMIC_VPD : TAB_PCDS_DYNAMIC_VPD,- MODEL_PCD_DYNAMIC_EX : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_DEFAULT : TAB_PCDS_DYNAMIC_EX,- MODEL_PCD_DYNAMIC_EX_HII : TAB_PCDS_DYNAMIC_EX_HII,- MODEL_PCD_DYNAMIC_EX_VPD : TAB_PCDS_DYNAMIC_EX_VPD,- } # dict used to convert part of [Defines] to members of InfBuildData directly _PROPERTY_ = { # # Required Fields@@ -152,10 +138,11 @@ class InfBuildData(ModuleBuildClassObject):
self._GuidsUsedByPcd = OrderedDict() self._GuidComments = None self._PcdComments = None self._BuildOptions = None self._DependencyFileList = None+ self.UpdatePcdTypeDict() self.LibInstances = [] self.ReferenceModules = set() def SetReferenceModule(self,Module): self.ReferenceModules.add(Module)--
2.29.1.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#76176): https://edk2.groups.io/g/devel/message/76176
Mute This Topic: https://groups.io/mt/83388055/1768742
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [bob.c.feng@...] -=-=-=-=-=-=

Join devel@edk2.groups.io to automatically receive all group messages.