1) use decorators 2) also change some private functions to public when all callers are external 3) change external callers to use functions instead of directly accessing private data.
Cc: Liming Gao <liming....@intel.com> Cc: Yonghong Zhu <yonghong....@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.car...@intel.com> --- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 4 +- BaseTools/Source/Python/Workspace/DecBuildData.py | 58 +++--- BaseTools/Source/Python/Workspace/DscBuildData.py | 151 +++++++------- BaseTools/Source/Python/Workspace/InfBuildData.py | 212 ++++++++++---------- BaseTools/Source/Python/Workspace/MetaFileParser.py | 18 +- BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 16 +- BaseTools/Source/Python/build/build.py | 4 +- 7 files changed, 228 insertions(+), 235 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index 56bb966698ad..6149bc81b4ef 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -341,9 +341,7 @@ class FfsInfStatement(FfsInfStatementClassObject): self.InfModule = Inf self.PcdIsDriver = Inf.PcdIsDriver self.IsBinaryModule = Inf.IsBinaryModule - Inf._GetDepex() - Inf._GetDepexExpression() - if len(Inf._Depex.data) > 0 and len(Inf._DepexExpression.data) > 0: + if len(Inf.Depex.data) > 0 and len(Inf.DepexExpression.data) > 0: self.Depex = True GenFdsGlobalVariable.VerboseLogger("BaseName : %s" % self.BaseName) diff --git a/BaseTools/Source/Python/Workspace/DecBuildData.py b/BaseTools/Source/Python/Workspace/DecBuildData.py index 45beaebc63ef..1f74e898f2ef 100644 --- a/BaseTools/Source/Python/Workspace/DecBuildData.py +++ b/BaseTools/Source/Python/Workspace/DecBuildData.py @@ -99,21 +99,22 @@ class DecBuildData(PackageBuildClassObject): self._CommonIncludes = None self._LibraryClasses = None self._Pcds = None - self.__Macros = None + self._MacroDict = None self._PrivateProtocols = None self._PrivatePpis = None self._PrivateGuids = None self._PrivateIncludes = None ## Get current effective macros - def _GetMacros(self): - if self.__Macros is None: - self.__Macros = {} - self.__Macros.update(GlobalData.gGlobalDefines) - return self.__Macros + @property + def _Macros(self): + if self._MacroDict is None: + self._MacroDict = dict(GlobalData.gGlobalDefines) + return self._MacroDict ## Get architecture - def _GetArch(self): + @property + def Arch(self): return self._Arch ## Retrieve all information in [Defines] section @@ -129,7 +130,8 @@ class DecBuildData(PackageBuildClassObject): self._Header = 'DUMMY' ## Retrieve package name - def _GetPackageName(self): + @property + def PackageName(self): if self._PackageName is None: if self._Header is None: self._GetHeaderInfo() @@ -138,7 +140,8 @@ class DecBuildData(PackageBuildClassObject): return self._PackageName ## Retrieve file guid - def _GetFileGuid(self): + @property + def PackageName(self): if self._Guid is None: if self._Header is None: self._GetHeaderInfo() @@ -147,7 +150,8 @@ class DecBuildData(PackageBuildClassObject): return self._Guid ## Retrieve package version - def _GetVersion(self): + @property + def Version(self): if self._Version is None: if self._Header is None: self._GetHeaderInfo() @@ -156,7 +160,8 @@ class DecBuildData(PackageBuildClassObject): return self._Version ## Retrieve protocol definitions (name/value pairs) - def _GetProtocol(self): + @property + def Protocols(self): if self._Protocols is None: # # tdict is a special kind of dict, used for selecting correct @@ -198,7 +203,8 @@ class DecBuildData(PackageBuildClassObject): return self._Protocols ## Retrieve PPI definitions (name/value pairs) - def _GetPpi(self): + @property + def Ppis(self): if self._Ppis is None: # # tdict is a special kind of dict, used for selecting correct @@ -240,7 +246,8 @@ class DecBuildData(PackageBuildClassObject): return self._Ppis ## Retrieve GUID definitions (name/value pairs) - def _GetGuid(self): + @property + def Guids(self): if self._Guids is None: # # tdict is a special kind of dict, used for selecting correct @@ -282,7 +289,8 @@ class DecBuildData(PackageBuildClassObject): return self._Guids ## Retrieve public include paths declared in this package - def _GetInclude(self): + @property + def Includes(self): if self._Includes is None or self._CommonIncludes is None: self._CommonIncludes = [] self._Includes = [] @@ -317,7 +325,8 @@ class DecBuildData(PackageBuildClassObject): return self._Includes ## Retrieve library class declarations (not used in build at present) - def _GetLibraryClass(self): + @property + def LibraryClasses(self): if self._LibraryClasses is None: # # tdict is a special kind of dict, used for selecting correct @@ -341,7 +350,8 @@ class DecBuildData(PackageBuildClassObject): return self._LibraryClasses ## Retrieve PCD declarations - def _GetPcds(self): + @property + def Pcds(self): if self._Pcds is None: self._Pcds = OrderedDict() self._Pcds.update(self._GetPcd(MODEL_PCD_FIXED_AT_BUILD)) @@ -351,7 +361,6 @@ class DecBuildData(PackageBuildClassObject): self._Pcds.update(self._GetPcd(MODEL_PCD_DYNAMIC_EX)) return self._Pcds - def ProcessStructurePcd(self, StructurePcdRawDataSet): s_pcd_set = OrderedDict() for s_pcd, LineNo in StructurePcdRawDataSet: @@ -446,22 +455,9 @@ class DecBuildData(PackageBuildClassObject): EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR, "The structure Pcd %s.%s header file is not found in %s line %s \n" % (struct_pcd.TokenSpaceGuidCName, struct_pcd.TokenCName, struct_pcd.DefinitionPosition[0], struct_pcd.DefinitionPosition[1] )) return Pcds + @property def CommonIncludes(self): if self._CommonIncludes is None: self.Includes return self._CommonIncludes - - - _Macros = property(_GetMacros) - Arch = property(_GetArch) - PackageName = property(_GetPackageName) - Guid = property(_GetFileGuid) - Version = property(_GetVersion) - - Protocols = property(_GetProtocol) - Ppis = property(_GetPpi) - Guids = property(_GetGuid) - Includes = property(_GetInclude) - LibraryClasses = property(_GetLibraryClass) - Pcds = property(_GetPcds) diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index aaef404772e9..ffc71a9f2dc9 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -222,6 +222,7 @@ class DscBuildData(PlatformBuildClassObject): self.WorkspaceDir = os.getenv("WORKSPACE") if os.getenv("WORKSPACE") else "" self.DefaultStores = None self.SkuIdMgr = SkuClass(self.SkuName, self.SkuIds) + @property def OutputPath(self): if os.getenv("WORKSPACE"): @@ -273,10 +274,9 @@ class DscBuildData(PlatformBuildClassObject): self._RFCLanguages = None self._ISOLanguages = None self._VpdToolGuid = None - self.__Macros = None + self._MacroDict = None self.DefaultStores = None - ## handle Override Path of Module def _HandleOverridePath(self): RecordList = self._RawData[MODEL_META_DATA_COMPONENT, self._Arch] @@ -296,16 +296,18 @@ class DscBuildData(PlatformBuildClassObject): GlobalData.gOverrideDir[ModuleFile.Key] = SourceOverridePath ## Get current effective macros - def _GetMacros(self): - if self.__Macros is None: - self.__Macros = {} - self.__Macros.update(GlobalData.gPlatformDefines) - self.__Macros.update(GlobalData.gGlobalDefines) - self.__Macros.update(GlobalData.gCommandLineDefines) - return self.__Macros + @property + def _Macros(self): + if self._MacroDict is None: + self._MacroDict = {} + self._MacroDict.update(GlobalData.gPlatformDefines) + self._MacroDict.update(GlobalData.gGlobalDefines) + self._MacroDict.update(GlobalData.gCommandLineDefines) + return self._MacroDict ## Get architecture - def _GetArch(self): + @property + def Arch(self): return self._Arch ## Retrieve all information in [Defines] section @@ -410,7 +412,8 @@ class DscBuildData(PlatformBuildClassObject): self._Header = 'DUMMY' ## Retrieve platform name - def _GetPlatformName(self): + @property + def PlatformName(self): if self._PlatformName is None: if self._Header is None: self._GetHeaderInfo() @@ -418,8 +421,13 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No PLATFORM_NAME", File=self.MetaFile) return self._PlatformName + @property + def Platform(self): + return self.PlatformName + ## Retrieve file guid - def _GetFileGuid(self): + @property + def Guid(self): if self._Guid is None: if self._Header is None: self._GetHeaderInfo() @@ -428,7 +436,8 @@ class DscBuildData(PlatformBuildClassObject): return self._Guid ## Retrieve platform version - def _GetVersion(self): + @property + def Version(self): if self._Version is None: if self._Header is None: self._GetHeaderInfo() @@ -437,7 +446,8 @@ class DscBuildData(PlatformBuildClassObject): return self._Version ## Retrieve platform description file version - def _GetDscSpec(self): + @property + def DscSpecification(self): if self._DscSpecification is None: if self._Header is None: self._GetHeaderInfo() @@ -446,7 +456,8 @@ class DscBuildData(PlatformBuildClassObject): return self._DscSpecification ## Retrieve OUTPUT_DIRECTORY - def _GetOutpuDir(self): + @property + def OutputDirectory(self): if self._OutputDirectory is None: if self._Header is None: self._GetHeaderInfo() @@ -455,7 +466,8 @@ class DscBuildData(PlatformBuildClassObject): return self._OutputDirectory ## Retrieve SUPPORTED_ARCHITECTURES - def _GetSupArch(self): + @property + def SupArchList(self): if self._SupArchList is None: if self._Header is None: self._GetHeaderInfo() @@ -464,7 +476,8 @@ class DscBuildData(PlatformBuildClassObject): return self._SupArchList ## Retrieve BUILD_TARGETS - def _GetBuildTarget(self): + @property + def BuildTargets(self): if self._BuildTargets is None: if self._Header is None: self._GetHeaderInfo() @@ -472,14 +485,17 @@ class DscBuildData(PlatformBuildClassObject): EdkLogger.error('build', ATTRIBUTE_NOT_AVAILABLE, "No BUILD_TARGETS", File=self.MetaFile) return self._BuildTargets - def _GetPcdInfoFlag(self): + @property + def PcdInfoFlag(self): if self._PcdInfoFlag is None or self._PcdInfoFlag.upper() == 'FALSE': return False elif self._PcdInfoFlag.upper() == 'TRUE': return True else: return False - def _GetVarCheckFlag(self): + + @property + def VarCheckFlag(self): if self._VarCheckFlag is None or self._VarCheckFlag.upper() == 'FALSE': return False elif self._VarCheckFlag.upper() == 'TRUE': @@ -488,7 +504,8 @@ class DscBuildData(PlatformBuildClassObject): return False # # Retrieve SKUID_IDENTIFIER - def _GetSkuName(self): + @property + def SkuName(self): if self._SkuName is None: if self._Header is None: self._GetHeaderInfo() @@ -497,10 +514,12 @@ class DscBuildData(PlatformBuildClassObject): return self._SkuName ## Override SKUID_IDENTIFIER - def _SetSkuName(self, Value): + @SkuName.setter + def SkuName(self, Value): self._SkuName = Value - def _GetFdfFile(self): + @property + def FlashDefinition(self): if self._FlashDefinition is None: if self._Header is None: self._GetHeaderInfo() @@ -508,7 +527,8 @@ class DscBuildData(PlatformBuildClassObject): self._FlashDefinition = '' return self._FlashDefinition - def _GetPrebuild(self): + @property + def Prebuild(self): if self._Prebuild is None: if self._Header is None: self._GetHeaderInfo() @@ -516,7 +536,8 @@ class DscBuildData(PlatformBuildClassObject): self._Prebuild = '' return self._Prebuild - def _GetPostbuild(self): + @property + def Postbuild(self): if self._Postbuild is None: if self._Header is None: self._GetHeaderInfo() @@ -525,7 +546,8 @@ class DscBuildData(PlatformBuildClassObject): return self._Postbuild ## Retrieve FLASH_DEFINITION - def _GetBuildNumber(self): + @property + def BuildNumber(self): if self._BuildNumber is None: if self._Header is None: self._GetHeaderInfo() @@ -534,7 +556,8 @@ class DscBuildData(PlatformBuildClassObject): return self._BuildNumber ## Retrieve MAKEFILE_NAME - def _GetMakefileName(self): + @property + def MakefileName(self): if self._MakefileName is None: if self._Header is None: self._GetHeaderInfo() @@ -543,7 +566,8 @@ class DscBuildData(PlatformBuildClassObject): return self._MakefileName ## Retrieve BsBaseAddress - def _GetBsBaseAddress(self): + @property + def BsBaseAddress(self): if self._BsBaseAddress is None: if self._Header is None: self._GetHeaderInfo() @@ -552,7 +576,8 @@ class DscBuildData(PlatformBuildClassObject): return self._BsBaseAddress ## Retrieve RtBaseAddress - def _GetRtBaseAddress(self): + @property + def RtBaseAddress(self): if self._RtBaseAddress is None: if self._Header is None: self._GetHeaderInfo() @@ -561,7 +586,8 @@ class DscBuildData(PlatformBuildClassObject): return self._RtBaseAddress ## Retrieve the top address for the load fix address - def _GetLoadFixAddress(self): + @property + def LoadFixAddress(self): if self._LoadFixAddress is None: if self._Header is None: self._GetHeaderInfo() @@ -591,7 +617,8 @@ class DscBuildData(PlatformBuildClassObject): return self._LoadFixAddress ## Retrieve RFCLanguage filter - def _GetRFCLanguages(self): + @property + def RFCLanguages(self): if self._RFCLanguages is None: if self._Header is None: self._GetHeaderInfo() @@ -600,15 +627,18 @@ class DscBuildData(PlatformBuildClassObject): return self._RFCLanguages ## Retrieve ISOLanguage filter - def _GetISOLanguages(self): + @property + def ISOLanguages(self): if self._ISOLanguages is None: if self._Header is None: self._GetHeaderInfo() if self._ISOLanguages is None: self._ISOLanguages = [] return self._ISOLanguages + ## Retrieve the GUID string for VPD tool - def _GetVpdToolGuid(self): + @property + def VpdToolGuid(self): if self._VpdToolGuid is None: if self._Header is None: self._GetHeaderInfo() @@ -617,7 +647,8 @@ class DscBuildData(PlatformBuildClassObject): return self._VpdToolGuid ## Retrieve [SkuIds] section information - def _GetSkuIds(self): + @property + def SkuIds(self): if self._SkuIds is None: self._SkuIds = OrderedDict() RecordList = self._RawData[MODEL_EFI_SKU_ID, self._Arch] @@ -669,7 +700,8 @@ class DscBuildData(PlatformBuildClassObject): return self.DefaultStores ## Retrieve [Components] section information - def _GetModules(self): + @property + def Modules(self): if self._Modules is not None: return self._Modules @@ -768,13 +800,15 @@ class DscBuildData(PlatformBuildClassObject): return self._Modules ## Retrieve all possible library instances used in this platform - def _GetLibraryInstances(self): + @property + def LibraryInstances(self): if self._LibraryInstances is None: - self._GetLibraryClasses() + self.LibraryClasses return self._LibraryInstances ## Retrieve [LibraryClasses] information - def _GetLibraryClasses(self): + @property + def LibraryClasses(self): if self._LibraryClasses is None: self._LibraryInstances = [] # @@ -922,6 +956,7 @@ class DscBuildData(PlatformBuildClassObject): if isinstance(pcd, StructurePcd) and pcd.SkuOverrideValues: Pcds[pcdname].SkuOverrideValues = {skuid:pcd.SkuOverrideValues[skuid] for skuid in pcd.SkuOverrideValues if skuid in available_sku} return Pcds + def CompleteHiiPcdsDefaultStores(self, Pcds): HiiPcd = [Pcds[pcd] for pcd in Pcds if Pcds[pcd].Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII], self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]] DefaultStoreMgr = DefaultStore(self.DefaultStores) @@ -1102,7 +1137,8 @@ class DscBuildData(PlatformBuildClassObject): return PcdValue ## Retrieve all PCD settings in platform - def _GetPcds(self): + @property + def Pcds(self): if self._Pcds is None: self._Pcds = OrderedDict() self.__ParsePcdFromCommandLine() @@ -1127,7 +1163,8 @@ class DscBuildData(PlatformBuildClassObject): return self._Pcds ## Retrieve [BuildOptions] - def _GetBuildOptions(self): + @property + def BuildOptions(self): if self._BuildOptions is None: self._BuildOptions = OrderedDict() # @@ -1226,7 +1263,6 @@ class DscBuildData(PlatformBuildClassObject): Pcd.PcdFieldValueFromComm[field][2] = FieldValues[field][1][1] return StruPcds - def OverrideByCommOverAll(self,AllPcds): def CheckStructureInComm(commpcds): if not commpcds: @@ -2789,7 +2825,8 @@ class DscBuildData(PlatformBuildClassObject): Module.MetaFile = FilePath self.Modules.append(Module) - def _GetToolChainFamily(self): + @property + def ToolChainFamily(self): self._ToolChainFamily = TAB_COMPILER_MSFT BuildConfigurationFile = os.path.normpath(os.path.join(GlobalData.gConfDirectory, "target.txt")) if os.path.isfile(BuildConfigurationFile) == True: @@ -2824,6 +2861,7 @@ class DscBuildData(PlatformBuildClassObject): if (Name, Guid) not in self.Pcds: self.Pcds[Name, Guid] = PcdClassObject(Name, Guid, '', '', '', '', '', {}, False, None) self.Pcds[Name, Guid].DefaultValue = Value + @property def DecPcds(self): if self._DecPcds is None: @@ -2839,34 +2877,3 @@ class DscBuildData(PlatformBuildClassObject): PkgSet.update(ModuleData.Packages) self._DecPcds, self._GuidDict = GetDeclaredPcd(self, self._Bdb, self._Arch, self._Target, self._Toolchain, PkgSet) return self._DecPcds - _Macros = property(_GetMacros) - Arch = property(_GetArch) - Platform = property(_GetPlatformName) - PlatformName = property(_GetPlatformName) - Guid = property(_GetFileGuid) - Version = property(_GetVersion) - DscSpecification = property(_GetDscSpec) - OutputDirectory = property(_GetOutpuDir) - SupArchList = property(_GetSupArch) - BuildTargets = property(_GetBuildTarget) - SkuName = property(_GetSkuName, _SetSkuName) - PcdInfoFlag = property(_GetPcdInfoFlag) - VarCheckFlag = property(_GetVarCheckFlag) - FlashDefinition = property(_GetFdfFile) - Prebuild = property(_GetPrebuild) - Postbuild = property(_GetPostbuild) - BuildNumber = property(_GetBuildNumber) - MakefileName = property(_GetMakefileName) - BsBaseAddress = property(_GetBsBaseAddress) - RtBaseAddress = property(_GetRtBaseAddress) - LoadFixAddress = property(_GetLoadFixAddress) - RFCLanguages = property(_GetRFCLanguages) - ISOLanguages = property(_GetISOLanguages) - VpdToolGuid = property(_GetVpdToolGuid) - SkuIds = property(_GetSkuIds) - Modules = property(_GetModules) - LibraryInstances = property(_GetLibraryInstances) - LibraryClasses = property(_GetLibraryClasses) - Pcds = property(_GetPcds) - BuildOptions = property(_GetBuildOptions) - ToolChainFamily = property(_GetToolChainFamily) diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index d666c092a6de..0016cd30ce7a 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -157,40 +157,42 @@ class InfBuildData(ModuleBuildClassObject): self._BuildOptions = None self._Depex = None self._DepexExpression = None - self.__Macros = None + self._MacroDict = None ## Get current effective macros - def _GetMacros(self): - if self.__Macros is None: - self.__Macros = {} + @property + def _Macros(self): + if self._MacroDict is None: + self._MacroDict = {} # EDK_GLOBAL defined macros can be applied to EDK module if self.AutoGenVersion < 0x00010005: - self.__Macros.update(GlobalData.gEdkGlobal) - self.__Macros.update(GlobalData.gGlobalDefines) - return self.__Macros + self._MacroDict.update(GlobalData.gEdkGlobal) + self._MacroDict.update(GlobalData.gGlobalDefines) + return self._MacroDict ## Get architecture - def _GetArch(self): + @property + def Arch(self): return self._Arch ## Return the name of platform employing this module - def _GetPlatform(self): + @property + def Platform(self): return self._Platform - def _GetHeaderComments(self): + + @property + def HeaderComments(self): if not self._HeaderComments: - self._HeaderComments = [] - RecordList = self._RawData[MODEL_META_DATA_HEADER_COMMENT] - for Record in RecordList: - self._HeaderComments.append(Record[0]) + self._HeaderComments = [a[0] for a in self._RawData[MODEL_META_DATA_HEADER_COMMENT]] return self._HeaderComments - def _GetTailComments(self): + + @property + def TailComments(self): if not self._TailComments: - self._TailComments = [] - RecordList = self._RawData[MODEL_META_DATA_TAIL_COMMENT] - for Record in RecordList: - self._TailComments.append(Record[0]) + self._TailComments = [a[0] for a in self._RawData[MODEL_META_DATA_TAIL_COMMENT]] return self._TailComments + ## Retrieve all information in [Defines] section # # (Retriving all [Defines] information in one-shot is just to save time.) @@ -371,7 +373,8 @@ class InfBuildData(ModuleBuildClassObject): self._Header_ = 'DUMMY' ## Retrieve file version - def _GetInfVersion(self): + @property + def AutoGenVersion(self): if self._AutoGenVersion is None: RecordList = self._RawData[MODEL_META_DATA_HEADER, self._Arch, self._Platform] for Record in RecordList: @@ -389,7 +392,8 @@ class InfBuildData(ModuleBuildClassObject): return self._AutoGenVersion ## Retrieve BASE_NAME - def _GetBaseName(self): + @property + def BaseName(self): if self._BaseName is None: if self._Header_ is None: self._GetHeaderInfo() @@ -398,7 +402,8 @@ class InfBuildData(ModuleBuildClassObject): return self._BaseName ## Retrieve DxsFile - def _GetDxsFile(self): + @property + def DxsFile(self): if self._DxsFile is None: if self._Header_ is None: self._GetHeaderInfo() @@ -407,7 +412,8 @@ class InfBuildData(ModuleBuildClassObject): return self._DxsFile ## Retrieve MODULE_TYPE - def _GetModuleType(self): + @property + def ModuleType(self): if self._ModuleType is None: if self._Header_ is None: self._GetHeaderInfo() @@ -418,7 +424,8 @@ class InfBuildData(ModuleBuildClassObject): return self._ModuleType ## Retrieve COMPONENT_TYPE - def _GetComponentType(self): + @property + def ComponentType(self): if self._ComponentType is None: if self._Header_ is None: self._GetHeaderInfo() @@ -427,7 +434,8 @@ class InfBuildData(ModuleBuildClassObject): return self._ComponentType ## Retrieve "BUILD_TYPE" - def _GetBuildType(self): + @property + def BuildType(self): if self._BuildType is None: if self._Header_ is None: self._GetHeaderInfo() @@ -436,7 +444,8 @@ class InfBuildData(ModuleBuildClassObject): return self._BuildType ## Retrieve file guid - def _GetFileGuid(self): + @property + def Guid(self): if self._Guid is None: if self._Header_ is None: self._GetHeaderInfo() @@ -445,7 +454,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Guid ## Retrieve module version - def _GetVersion(self): + @property + def Version(self): if self._Version is None: if self._Header_ is None: self._GetHeaderInfo() @@ -454,7 +464,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Version ## Retrieve PCD_IS_DRIVER - def _GetPcdIsDriver(self): + @property + def PcdIsDriver(self): if self._PcdIsDriver is None: if self._Header_ is None: self._GetHeaderInfo() @@ -463,7 +474,8 @@ class InfBuildData(ModuleBuildClassObject): return self._PcdIsDriver ## Retrieve SHADOW - def _GetShadow(self): + @property + def Shadow(self): if self._Shadow is None: if self._Header_ is None: self._GetHeaderInfo() @@ -474,7 +486,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Shadow ## Retrieve CUSTOM_MAKEFILE - def _GetMakefile(self): + @property + def CustomMakefile(self): if self._CustomMakefile is None: if self._Header_ is None: self._GetHeaderInfo() @@ -483,7 +496,8 @@ class InfBuildData(ModuleBuildClassObject): return self._CustomMakefile ## Retrieve EFI_SPECIFICATION_VERSION - def _GetSpec(self): + @property + def Specification(self): if self._Specification is None: if self._Header_ is None: self._GetHeaderInfo() @@ -492,7 +506,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Specification ## Retrieve LIBRARY_CLASS - def _GetLibraryClass(self): + @property + def LibraryClass(self): if self._LibraryClass is None: if self._Header_ is None: self._GetHeaderInfo() @@ -501,7 +516,8 @@ class InfBuildData(ModuleBuildClassObject): return self._LibraryClass ## Retrieve ENTRY_POINT - def _GetEntryPoint(self): + @property + def ModuleEntryPointList(self): if self._ModuleEntryPointList is None: if self._Header_ is None: self._GetHeaderInfo() @@ -510,7 +526,8 @@ class InfBuildData(ModuleBuildClassObject): return self._ModuleEntryPointList ## Retrieve UNLOAD_IMAGE - def _GetUnloadImage(self): + @property + def ModuleUnloadImageList(self): if self._ModuleUnloadImageList is None: if self._Header_ is None: self._GetHeaderInfo() @@ -519,7 +536,8 @@ class InfBuildData(ModuleBuildClassObject): return self._ModuleUnloadImageList ## Retrieve CONSTRUCTOR - def _GetConstructor(self): + @property + def ConstructorList(self): if self._ConstructorList is None: if self._Header_ is None: self._GetHeaderInfo() @@ -528,7 +546,8 @@ class InfBuildData(ModuleBuildClassObject): return self._ConstructorList ## Retrieve DESTRUCTOR - def _GetDestructor(self): + @property + def DestructorList(self): if self._DestructorList is None: if self._Header_ is None: self._GetHeaderInfo() @@ -537,7 +556,8 @@ class InfBuildData(ModuleBuildClassObject): return self._DestructorList ## Retrieve definies other than above ones - def _GetDefines(self): + @property + def Defines(self): if len(self._Defs) == 0 and self._Header_ is None: self._GetHeaderInfo() return self._Defs @@ -571,7 +591,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Binaries ## Retrieve binary files with error check. - def _GetBinaryFiles(self): + @property + def Binaries(self): Binaries = self._GetBinaries() if GlobalData.gIgnoreSource and Binaries == []: ErrorInfo = "The INF file does not contain any Binaries to use in creating the image\n" @@ -580,7 +601,8 @@ class InfBuildData(ModuleBuildClassObject): return Binaries ## Retrieve source files - def _GetSourceFiles(self): + @property + def Sources(self): # Ignore all source files in a binary build mode if GlobalData.gIgnoreSource: self._Sources = [] @@ -626,7 +648,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Sources ## Retrieve library classes employed by this module - def _GetLibraryClassUses(self): + @property + def LibraryClasses(self): if self._LibraryClasses is None: self._LibraryClasses = OrderedDict() RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS, self._Arch, self._Platform] @@ -639,7 +662,8 @@ class InfBuildData(ModuleBuildClassObject): return self._LibraryClasses ## Retrieve library names (for Edk.x style of modules) - def _GetLibraryNames(self): + @property + def Libraries(self): if self._Libraries is None: self._Libraries = [] RecordList = self._RawData[MODEL_EFI_LIBRARY_INSTANCE, self._Arch, self._Platform] @@ -651,11 +675,14 @@ class InfBuildData(ModuleBuildClassObject): self._Libraries.append(LibraryName) return self._Libraries - def _GetProtocolComments(self): - self._GetProtocols() + @property + def ProtocolComments(self): + self.Protocols return self._ProtocolComments + ## Retrieve protocols consumed/produced by this module - def _GetProtocols(self): + @property + def Protocols(self): if self._Protocols is None: self._Protocols = OrderedDict() self._ProtocolComments = OrderedDict() @@ -676,11 +703,14 @@ class InfBuildData(ModuleBuildClassObject): self._ProtocolComments[CName] = Comments return self._Protocols - def _GetPpiComments(self): - self._GetPpis() + @property + def PpiComments(self): + self.Ppis return self._PpiComments + ## Retrieve PPIs consumed/produced by this module - def _GetPpis(self): + @property + def Ppis(self): if self._Ppis is None: self._Ppis = OrderedDict() self._PpiComments = OrderedDict() @@ -701,11 +731,14 @@ class InfBuildData(ModuleBuildClassObject): self._PpiComments[CName] = Comments return self._Ppis - def _GetGuidComments(self): - self._GetGuids() + @property + def GuidComments(self): + self.Guids return self._GuidComments + ## Retrieve GUIDs consumed/produced by this module - def _GetGuids(self): + @property + def Guids(self): if self._Guids is None: self._Guids = OrderedDict() self._GuidComments = OrderedDict() @@ -727,7 +760,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Guids ## Retrieve include paths necessary for this module (for Edk.x style of modules) - def _GetIncludes(self): + @property + def Includes(self): if self._Includes is None: self._Includes = [] if self._SourceOverridePath: @@ -781,7 +815,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Includes ## Retrieve packages this module depends on - def _GetPackages(self): + @property + def Packages(self): if self._Packages is None: self._Packages = [] RecordList = self._RawData[MODEL_META_DATA_PACKAGE, self._Arch, self._Platform] @@ -800,11 +835,14 @@ class InfBuildData(ModuleBuildClassObject): return self._Packages ## Retrieve PCD comments - def _GetPcdComments(self): - self._GetPcds() + @property + def PcdComments(self): + self.Pcds return self._PcdComments + ## Retrieve PCDs used in this module - def _GetPcds(self): + @property + def Pcds(self): if self._Pcds is None: self._Pcds = OrderedDict() self._PcdComments = OrderedDict() @@ -816,7 +854,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Pcds ## Retrieve build options specific to this module - def _GetBuildOptions(self): + @property + def BuildOptions(self): if self._BuildOptions is None: self._BuildOptions = OrderedDict() RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, self._Platform] @@ -833,7 +872,8 @@ class InfBuildData(ModuleBuildClassObject): return self._BuildOptions ## Retrieve dependency expression - def _GetDepex(self): + @property + def Depex(self): if self._Depex is None: self._Depex = tdict(False, 2) RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch] @@ -904,7 +944,8 @@ class InfBuildData(ModuleBuildClassObject): return self._Depex ## Retrieve depedency expression - def _GetDepexExpression(self): + @property + def DepexExpression(self): if self._DepexExpression is None: self._DepexExpression = tdict(False, 2) RecordList = self._RawData[MODEL_EFI_DEPEX, self._Arch] @@ -924,6 +965,7 @@ class InfBuildData(ModuleBuildClassObject): def GetGuidsUsedByPcd(self): return self._GuidsUsedByPcd + ## Retrieve PCD for given type def _GetPcd(self, Type): Pcds = OrderedDict() @@ -1114,54 +1156,8 @@ class InfBuildData(ModuleBuildClassObject): return Pcds ## check whether current module is binary module - def _IsBinaryModule(self): - if self.Binaries and not self.Sources: + @property + def IsBinaryModule(self): + if (self.Binaries and not self.Sources) or GlobalData.gIgnoreSource: return True - elif GlobalData.gIgnoreSource: - return True - else: - return False - - _Macros = property(_GetMacros) - Arch = property(_GetArch) - Platform = property(_GetPlatform) - - HeaderComments = property(_GetHeaderComments) - TailComments = property(_GetTailComments) - AutoGenVersion = property(_GetInfVersion) - BaseName = property(_GetBaseName) - ModuleType = property(_GetModuleType) - ComponentType = property(_GetComponentType) - BuildType = property(_GetBuildType) - Guid = property(_GetFileGuid) - Version = property(_GetVersion) - PcdIsDriver = property(_GetPcdIsDriver) - Shadow = property(_GetShadow) - CustomMakefile = property(_GetMakefile) - Specification = property(_GetSpec) - LibraryClass = property(_GetLibraryClass) - ModuleEntryPointList = property(_GetEntryPoint) - ModuleUnloadImageList = property(_GetUnloadImage) - ConstructorList = property(_GetConstructor) - DestructorList = property(_GetDestructor) - Defines = property(_GetDefines) - DxsFile = property(_GetDxsFile) - - Binaries = property(_GetBinaryFiles) - Sources = property(_GetSourceFiles) - LibraryClasses = property(_GetLibraryClassUses) - Libraries = property(_GetLibraryNames) - Protocols = property(_GetProtocols) - ProtocolComments = property(_GetProtocolComments) - Ppis = property(_GetPpis) - PpiComments = property(_GetPpiComments) - Guids = property(_GetGuids) - GuidComments = property(_GetGuidComments) - Includes = property(_GetIncludes) - Packages = property(_GetPackages) - Pcds = property(_GetPcds) - PcdComments = property(_GetPcdComments) - BuildOptions = property(_GetBuildOptions) - Depex = property(_GetDepex) - DepexExpression = property(_GetDepexExpression) - IsBinaryModule = property(_IsBinaryModule) + return False diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 79e3180d5e77..f1707c06feb9 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -213,11 +213,13 @@ class MetaFileParser(object): self._PostProcessed = True ## Get the parse complete flag - def _GetFinished(self): + @property + def Finished(self): return self._Finished ## Set the complete flag - def _SetFinished(self, Value): + @Finished.setter + def Finished(self, Value): self._Finished = Value ## Remove records that do not match given Filter Arch @@ -416,7 +418,9 @@ class MetaFileParser(object): ) def GetValidExpression(self, TokenSpaceGuid, PcdCName): return self._Table.GetValidExpression(TokenSpaceGuid, PcdCName) - def _GetMacros(self): + + @property + def _Macros(self): Macros = {} Macros.update(self._FileLocalMacros) Macros.update(self._GetApplicableSectionMacro()) @@ -478,9 +482,6 @@ class MetaFileParser(object): return Macros _SectionParser = {} - Finished = property(_GetFinished, _SetFinished) - _Macros = property(_GetMacros) - ## INF file parser class # @@ -1252,7 +1253,8 @@ class DscParser(MetaFileParser): ) ## Override parent's method since we'll do all macro replacements in parser - def _GetMacros(self): + @property + def _Macros(self): Macros = {} Macros.update(self._FileLocalMacros) Macros.update(self._GetApplicableSectionMacro()) @@ -1673,8 +1675,6 @@ class DscParser(MetaFileParser): MODEL_META_DATA_SUBSECTION_HEADER : _SubsectionHeaderParser, } - _Macros = property(_GetMacros) - ## DEC file parser class # # @param FilePath The path of platform description file diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index e2f373745fc0..3bb287b8b24c 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -302,25 +302,21 @@ determine whether database file is out of date!\n") return PackageList ## Summarize all platforms in the database - def _GetPlatformList(self): - PlatformList = [] + def PlatformList(self): + RetVal = [] for PlatformFile in self.TblFile.GetFileList(MODEL_FILE_DSC): try: - Platform = self.BuildObject[PathClass(PlatformFile), TAB_COMMON] + RetVal.append(self.BuildObject[PathClass(PlatformFile), TAB_COMMON]) except: - Platform = None - if Platform is not None: - PlatformList.append(Platform) - return PlatformList + pass + return RetVal - def _MapPlatform(self, Dscfile): + def MapPlatform(self, Dscfile): Platform = self.BuildObject[PathClass(Dscfile), TAB_COMMON] if Platform is None: EdkLogger.error('build', PARSER_ERROR, "Failed to parser DSC file: %s" % Dscfile) return Platform - PlatformList = property(_GetPlatformList) - ## # # This acts like the main() function for the script, unless it is 'import'ed into another diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index e6a9c6ef7199..d74082fc2666 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -1006,7 +1006,7 @@ class Build(): else: self.Db.InitDatabase() self.Db_Flag = True - Platform = self.Db._MapPlatform(str(self.PlatformFile)) + Platform = self.Db.MapPlatform(str(self.PlatformFile)) self.Prebuild = str(Platform.Prebuild) if self.Prebuild: PrebuildList = [] @@ -1045,7 +1045,7 @@ class Build(): if 'POSTBUILD' in GlobalData.gCommandLineDefines: self.Postbuild = GlobalData.gCommandLineDefines.get('POSTBUILD') else: - Platform = self.Db._MapPlatform(str(self.PlatformFile)) + Platform = self.Db.MapPlatform(str(self.PlatformFile)) self.Postbuild = str(Platform.Postbuild) if self.Postbuild: PostbuildList = [] -- 2.16.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel