diff options
author | Fan, ZhijuX <zhijux.fan@intel.com> | 2020-01-10 16:29:45 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-01-13 02:08:46 +0000 |
commit | 4465cd124fbcf5490faad6a1a834299b30b5d009 (patch) | |
tree | 4260973bb45c8d922ad21172553ac44afb07b61a /BaseTools/Source/Python/Common/ToolDefClassObject.py | |
parent | 072b9c28393d191733187e701307cdab166a4c4d (diff) | |
download | edk2-4465cd124fbcf5490faad6a1a834299b30b5d009.tar.gz edk2-4465cd124fbcf5490faad6a1a834299b30b5d009.tar.bz2 edk2-4465cd124fbcf5490faad6a1a834299b30b5d009.zip |
BaseTools:Fix GenFds issue for BuildOption replace GenFdsOption
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=2455
BuildOption is used by TargetTxtClassObj.py
GenFdsOption is used by GenFds.py
When the GenFds tool is used alone (e.g. python3 -m GenFds.GenFds -h)
With the OptionParser function, the first detected function
prints the help message
import TargetTxtClassObj to GenFds,
The BuildOption will be executed and replace GenFdsOption
We removed all objects associated with this problem that
were created directly during the import process
(e.g. BuildOption, BuildTarget = MyOptionParser(),
TargetTxt = TargetTxtDict())
The Patch is going to fix this issue
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Common/ToolDefClassObject.py')
-rw-r--r-- | BaseTools/Source/Python/Common/ToolDefClassObject.py | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py index 063fa00584..8e70407cb9 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -14,7 +14,7 @@ import re from . import EdkLogger
from .BuildToolError import *
-from Common.TargetTxtClassObject import TargetTxt
+from Common.TargetTxtClassObject import TargetTxtDict
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.Misc import PathClass
from Common.StringUtils import NormPath
@@ -262,20 +262,40 @@ class ToolDefClassObject(object): #
# @retval ToolDef An instance of ToolDefClassObject() with loaded tools_def.txt
#
-def ToolDefDict(ConfDir):
- Target = TargetTxt
- ToolDef = ToolDefClassObject()
- if TAB_TAT_DEFINES_TOOL_CHAIN_CONF in Target.TargetTxtDictionary:
- ToolsDefFile = Target.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
- if ToolsDefFile:
- ToolDef.LoadToolDefFile(os.path.normpath(ToolsDefFile))
- else:
- ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(ConfDir, gDefaultToolsDefFile)))
- else:
- ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(ConfDir, gDefaultToolsDefFile)))
- return ToolDef
-ToolDef = ToolDefDict((os.path.join(os.getenv("WORKSPACE"),"Conf")))
+
+class ToolDefDict():
+
+ def __new__(cls, ConfDir, *args, **kw):
+ if not hasattr(cls, '_instance'):
+ orig = super(ToolDefDict, cls)
+ cls._instance = orig.__new__(cls, *args, **kw)
+ return cls._instance
+
+ def __init__(self, ConfDir):
+ self.ConfDir = ConfDir
+ if not hasattr(self, 'ToolDef'):
+ self._ToolDef = None
+
+ @property
+ def ToolDef(self):
+ if not self._ToolDef:
+ self._GetToolDef()
+ return self._ToolDef
+
+ def _GetToolDef(self):
+ TargetObj = TargetTxtDict()
+ Target = TargetObj.Target
+ ToolDef = ToolDefClassObject()
+ if TAB_TAT_DEFINES_TOOL_CHAIN_CONF in Target.TargetTxtDictionary:
+ ToolsDefFile = Target.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
+ if ToolsDefFile:
+ ToolDef.LoadToolDefFile(os.path.normpath(ToolsDefFile))
+ else:
+ ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(self.ConfDir, gDefaultToolsDefFile)))
+ else:
+ ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(self.ConfDir, gDefaultToolsDefFile)))
+ self._ToolDef = ToolDef
##
#
|