From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: bob.c.feng@intel.com) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by groups.io with SMTP; Wed, 10 Apr 2019 23:20:15 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2019 23:20:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,336,1549958400"; d="scan'208";a="290565120" Received: from shwdepsi1121.ccr.corp.intel.com ([10.239.158.47]) by orsmga004.jf.intel.com with ESMTP; 10 Apr 2019 23:20:10 -0700 From: "BobCF" To: devel@edk2.groups.io Cc: BobCF , Liming Gao Subject: [Patch V2] BaseTools: Add a build option to treat DynPcd as DynExPcd Date: Thu, 11 Apr 2019 14:20:04 +0800 Message-Id: <20190411062004.27280-1-bob.c.feng@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: BobCF BZ: 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 Cc: Liming Gao --- BaseTools/Source/Python/Common/DataType.py | 1 + .../Python/Workspace/BuildClassObject.py | 153 ++++++++---------- .../Source/Python/Workspace/DecBuildData.py | 16 +- .../Source/Python/Workspace/DscBuildData.py | 19 +-- .../Source/Python/Workspace/InfBuildData.py | 15 +- 5 files changed, 73 insertions(+), 131 deletions(-) diff --git a/BaseTools/Source/Python/Common/DataType.py b/BaseTools/Source/Python/Common/DataType.py index 780711bf8e..96f2d9b290 100644 --- a/BaseTools/Source/Python/Common/DataType.py +++ b/BaseTools/Source/Python/Common/DataType.py @@ -396,10 +396,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 33d88c6921..7ab8a54869 100644 --- a/BaseTools/Source/Python/Workspace/BuildClassObject.py +++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py @@ -10,10 +10,12 @@ from Common.DataType import * import collections import re from collections import OrderedDict from Common.Misc import CopyDict import copy +from CommonDataClass.DataClass import * +import Common.GlobalData as GlobalData StructPattern = re.compile(r'[_a-zA-Z][0-9A-Za-z_\[\]]*$') ArrayIndex = re.compile("\[\s*[0-9a-fA-FxX]*\s*\]") ## PcdClassObject # # This Class is used for PcdObject @@ -350,10 +352,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 @@ -394,11 +457,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 = '' @@ -426,38 +489,10 @@ class ModuleBuildClassObject(object): self.Packages = [] self.Pcds = {} self.BuildOptions = {} self.Depex = {} - ## 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 @@ -477,11 +512,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 = '' @@ -491,38 +526,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 @@ -547,11 +554,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 = '' @@ -566,33 +573,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 d58d88eca7..a8f1b0ebde 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 @@ -45,11 +31,10 @@ class DecBuildData(PackageBuildClassObject): TAB_DEC_DEFINES_PACKAGE_GUID : "_Guid", TAB_DEC_DEFINES_PACKAGE_VERSION : "_Version", TAB_DEC_DEFINES_PKG_UNI_FILE : "_PkgUniFile", } - ## Constructor of DecBuildData # # Initialize object of DecBuildData # # @param FilePath The path of package description file @@ -66,10 +51,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 5431296b5a..f1315bdabc 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -180,24 +180,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 @@ -243,11 +229,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: @@ -412,10 +398,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 e66b7c9832..021aef12a2 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() ## XXX[key] = value def __setitem__(self, key, value): self.__dict__[self._PROPERTY_[key]] = value -- 2.20.1.windows.1