From: Jaben Carsey <jaben.carsey@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>,
Yonghong Zhu <yonghong.zhu@intel.com>,
Bob Feng <bob.c.feng@intel.com>
Subject: [PATCH v1 2/9] BaseTools: AutoGen refactor WorkspaceAutoGen class
Date: Wed, 29 Aug 2018 08:45:37 -0700 [thread overview]
Message-ID: <da4e20736e3e45f69ce264152d597174260b0e34.1535557474.git.jaben.carsey@intel.com> (raw)
In-Reply-To: <cover.1535557474.git.jaben.carsey@intel.com>
In-Reply-To: <cover.1535557474.git.jaben.carsey@intel.com>
Update the WorkspaceAutoGen class to use caching decorators and remove
the no longer needed private variables.
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <jaben.carsey@intel.com>
---
BaseTools/Source/Python/AutoGen/AutoGen.py | 69 ++++++++------------
1 file changed, 28 insertions(+), 41 deletions(-)
diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 8c7bec664cbd..b8ee9980ae39 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -278,10 +278,6 @@ class WorkspaceAutoGen(AutoGen):
self.FvTargetList = Fvs if Fvs else []
self.CapTargetList = Caps if Caps else []
self.AutoGenObjectList = []
- self._BuildDir = None
- self._FvDir = None
- self._MakeFileDir = None
- self._BuildCommand = None
self._GuidDict = {}
# there's many relative directory operations, so ...
@@ -810,54 +806,56 @@ class WorkspaceAutoGen(AutoGen):
return "%s [%s]" % (self.MetaFile, ", ".join(self.ArchList))
## Return the directory to store FV files
- def _GetFvDir(self):
- if self._FvDir is None:
- self._FvDir = path.join(self.BuildDir, TAB_FV_DIRECTORY)
- return self._FvDir
+ @cached_property
+ def FvDir(self):
+ return path.join(self.BuildDir, TAB_FV_DIRECTORY)
## Return the directory to store all intermediate and final files built
- def _GetBuildDir(self):
- if self._BuildDir is None:
- return self.AutoGenObjectList[0].BuildDir
+ @cached_property
+ def BuildDir(self):
+ return self.AutoGenObjectList[0].BuildDir
## Return the build output directory platform specifies
- def _GetOutputDir(self):
+ @cached_property
+ def OutputDir(self):
return self.Platform.OutputDirectory
## Return platform name
- def _GetName(self):
+ @cached_property
+ def Name(self):
return self.Platform.PlatformName
## Return meta-file GUID
- def _GetGuid(self):
+ @cached_property
+ def Guid(self):
return self.Platform.Guid
## Return platform version
- def _GetVersion(self):
+ @cached_property
+ def Version(self):
return self.Platform.Version
## Return paths of tools
- def _GetToolDefinition(self):
+ @cached_property
+ def ToolDefinition(self):
return self.AutoGenObjectList[0].ToolDefinition
## Return directory of platform makefile
#
# @retval string Makefile directory
#
- def _GetMakeFileDir(self):
- if self._MakeFileDir is None:
- self._MakeFileDir = self.BuildDir
- return self._MakeFileDir
+ @cached_property
+ def MakeFileDir(self):
+ return self.BuildDir
## Return build command string
#
# @retval string Build command string
#
- def _GetBuildCommand(self):
- if self._BuildCommand is None:
- # BuildCommand should be all the same. So just get one from platform AutoGen
- self._BuildCommand = self.AutoGenObjectList[0].BuildCommand
- return self._BuildCommand
+ @cached_property
+ def BuildCommand(self):
+ # BuildCommand should be all the same. So just get one from platform AutoGen
+ return self.AutoGenObjectList[0].BuildCommand
## Check the PCDs token value conflict in each DEC file.
#
@@ -933,7 +931,8 @@ class WorkspaceAutoGen(AutoGen):
)
Count += 1
## Generate fds command
- def _GenFdsCommand(self):
+ @property
+ def GenFdsCommand(self):
return (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.TopLevelMakefile(self)._TemplateDict)).strip()
## Create makefile for the platform and modules in it
@@ -966,18 +965,6 @@ class WorkspaceAutoGen(AutoGen):
def CreateAsBuiltInf(self):
return
- Name = property(_GetName)
- Guid = property(_GetGuid)
- Version = property(_GetVersion)
- OutputDir = property(_GetOutputDir)
-
- ToolDefinition = property(_GetToolDefinition) # toolcode : tool path
-
- BuildDir = property(_GetBuildDir)
- FvDir = property(_GetFvDir)
- MakeFileDir = property(_GetMakeFileDir)
- BuildCommand = property(_GetBuildCommand)
- GenFdsCommand = property(_GenFdsCommand)
## AutoGen class for platform
#
@@ -2587,7 +2574,7 @@ class ModuleAutoGen(AutoGen):
## Return the module build data object
@cached_property
def Module(self):
- return self.Workspace.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]
+ return self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]
## Return the module name
@cached_property
@@ -2935,7 +2922,7 @@ class ModuleAutoGen(AutoGen):
except KeyError:
FlagOption = ''
- if self.PlatformInfo.ToolChainFamily != 'RVCT':
+ if self.ToolChainFamily != 'RVCT':
IncPathList = [NormPath(Path, self.Macros) for Path in BuildOptIncludeRegEx.findall(FlagOption)]
else:
#
@@ -3851,7 +3838,7 @@ class ModuleAutoGen(AutoGen):
if os.path.exists(ModuleFile):
shutil.copy2(ModuleFile, FileDir)
if not self.OutputFile:
- Ma = self.Workspace.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]
+ Ma = self.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]
self.OutputFile = Ma.Binaries
if self.OutputFile:
for File in self.OutputFile:
--
2.16.2.windows.1
next prev parent reply other threads:[~2018-08-29 15:50 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-29 15:45 [PATCH v1 0/9] BaseTools: refactor Workspace classes Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 1/9] BaseTools: Refactor PlatformAutoGen Jaben Carsey
2018-08-29 15:45 ` Jaben Carsey [this message]
2018-08-29 15:45 ` [PATCH v1 3/9] BaseTools: AutoGen - refactor class properties Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 4/9] BaseTools: " Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 5/9] BaseTools: Workspace classes refactor properties Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 6/9] BaseTools: refactor Build Database objects Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 7/9] BaseTools: Don't save unused workspace data Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 8/9] BaseTools: refactor to not overcreate ModuleAutoGen objects Jaben Carsey
2018-08-29 15:45 ` [PATCH v1 9/9] BaseTools: refactor to cache InfBuildData data Jaben Carsey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da4e20736e3e45f69ce264152d597174260b0e34.1535557474.git.jaben.carsey@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox