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>
This commit is contained in:
committed by
mergify[bot]
parent
072b9c2839
commit
4465cd124f
@ -10,7 +10,7 @@
|
||||
#
|
||||
from __future__ import print_function
|
||||
from __future__ import absolute_import
|
||||
from Common.buildoptions import BuildOption,BuildTarget
|
||||
|
||||
import Common.GlobalData as GlobalData
|
||||
import Common.LongFilePathOs as os
|
||||
from . import EdkLogger
|
||||
@ -144,29 +144,47 @@ class TargetTxtClassObject(object):
|
||||
#
|
||||
# @retval Target An instance of TargetTxtClassObject() with loaded target.txt
|
||||
#
|
||||
def TargetTxtDict():
|
||||
Target = TargetTxtClassObject()
|
||||
if BuildOption.ConfDirectory:
|
||||
# Get alternate Conf location, if it is absolute, then just use the absolute directory name
|
||||
ConfDirectoryPath = os.path.normpath(BuildOption.ConfDirectory)
|
||||
|
||||
if not os.path.isabs(ConfDirectoryPath):
|
||||
# Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE
|
||||
# This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf
|
||||
ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], ConfDirectoryPath)
|
||||
else:
|
||||
if "CONF_PATH" in os.environ:
|
||||
ConfDirectoryPath = os.path.normcase(os.path.normpath(os.environ["CONF_PATH"]))
|
||||
class TargetTxtDict():
|
||||
|
||||
def __new__(cls, *args, **kw):
|
||||
if not hasattr(cls, '_instance'):
|
||||
orig = super(TargetTxtDict, cls)
|
||||
cls._instance = orig.__new__(cls, *args, **kw)
|
||||
return cls._instance
|
||||
|
||||
def __init__(self):
|
||||
if not hasattr(self, 'Target'):
|
||||
self.TxtTarget = None
|
||||
|
||||
@property
|
||||
def Target(self):
|
||||
if not self.TxtTarget:
|
||||
self._GetTarget()
|
||||
return self.TxtTarget
|
||||
|
||||
def _GetTarget(self):
|
||||
Target = TargetTxtClassObject()
|
||||
ConfDirectory = GlobalData.gCmdConfDir
|
||||
if ConfDirectory:
|
||||
# Get alternate Conf location, if it is absolute, then just use the absolute directory name
|
||||
ConfDirectoryPath = os.path.normpath(ConfDirectory)
|
||||
|
||||
if not os.path.isabs(ConfDirectoryPath):
|
||||
# Since alternate directory name is not absolute, the alternate directory is located within the WORKSPACE
|
||||
# This also handles someone specifying the Conf directory in the workspace. Using --conf=Conf
|
||||
ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], ConfDirectoryPath)
|
||||
else:
|
||||
# Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf
|
||||
ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 'Conf')
|
||||
GlobalData.gConfDirectory = ConfDirectoryPath
|
||||
targettxt = os.path.normpath(os.path.join(ConfDirectoryPath, gDefaultTargetTxtFile))
|
||||
if os.path.exists(targettxt):
|
||||
Target.LoadTargetTxtFile(targettxt)
|
||||
return Target
|
||||
|
||||
TargetTxt = TargetTxtDict()
|
||||
if "CONF_PATH" in os.environ:
|
||||
ConfDirectoryPath = os.path.normcase(os.path.normpath(os.environ["CONF_PATH"]))
|
||||
else:
|
||||
# Get standard WORKSPACE/Conf use the absolute path to the WORKSPACE/Conf
|
||||
ConfDirectoryPath = mws.join(os.environ["WORKSPACE"], 'Conf')
|
||||
GlobalData.gConfDirectory = ConfDirectoryPath
|
||||
targettxt = os.path.normpath(os.path.join(ConfDirectoryPath, gDefaultTargetTxtFile))
|
||||
if os.path.exists(targettxt):
|
||||
Target.LoadTargetTxtFile(targettxt)
|
||||
self.TxtTarget = Target
|
||||
|
||||
##
|
||||
#
|
||||
|
Reference in New Issue
Block a user