public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] BaseTools: Add a build option to treat DynPcd as DynExPcd
@ 2019-04-09  7:58 BobCF
  2019-04-09  9:28 ` Liming Gao
  0 siblings, 1 reply; 2+ messages in thread
From: BobCF @ 2019-04-09  7:58 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao

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.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 .../Python/Workspace/BuildClassObject.py      | 153 ++++++++----------
 .../Source/Python/Workspace/DecBuildData.py   |  16 +-
 .../Source/Python/Workspace/DscBuildData.py   |  16 +-
 .../Source/Python/Workspace/InfBuildData.py   |  15 +-
 4 files changed, 69 insertions(+), 131 deletions(-)

diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index 3213855e70..36201284e7 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -16,10 +16,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
@@ -356,10 +358,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("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
@@ -400,11 +463,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              = ''
@@ -432,38 +495,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
@@ -483,11 +518,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                 = ''
@@ -497,38 +532,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
@@ -553,11 +560,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                 = ''
@@ -572,33 +579,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 149c057b70..53d656335e 100644
--- a/BaseTools/Source/Python/Workspace/DecBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DecBuildData.py
@@ -25,24 +25,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
@@ -51,11 +37,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
@@ -72,10 +57,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 129c0c950b..ce1a62e63e 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -186,24 +186,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
@@ -249,11 +235,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:
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py
index 9fed1198fd..cc547ce9d4 100644
--- a/BaseTools/Source/Python/Workspace/InfBuildData.py
+++ b/BaseTools/Source/Python/Workspace/InfBuildData.py
@@ -63,24 +63,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
@@ -158,10 +144,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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-09  9:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-09  7:58 [Patch] BaseTools: Add a build option to treat DynPcd as DynExPcd BobCF
2019-04-09  9:28 ` Liming Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox