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
@ -20,7 +20,7 @@ from Common.BuildToolError import *
|
||||
from Common.Misc import tdict, PathClass
|
||||
from Common.StringUtils import NormPath
|
||||
from Common.DataType import *
|
||||
from Common.TargetTxtClassObject import TargetTxt
|
||||
from Common.TargetTxtClassObject import TargetTxtDict
|
||||
gDefaultBuildRuleFile = 'build_rule.txt'
|
||||
AutoGenReqBuildRuleVerNum = '0.1'
|
||||
|
||||
@ -588,24 +588,42 @@ class BuildRule:
|
||||
_UnknownSection : SkipSection,
|
||||
}
|
||||
|
||||
def GetBuildRule():
|
||||
BuildRuleFile = None
|
||||
if TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:
|
||||
BuildRuleFile = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
|
||||
if not BuildRuleFile:
|
||||
BuildRuleFile = gDefaultBuildRuleFile
|
||||
RetVal = BuildRule(BuildRuleFile)
|
||||
if RetVal._FileVersion == "":
|
||||
RetVal._FileVersion = AutoGenReqBuildRuleVerNum
|
||||
else:
|
||||
if RetVal._FileVersion < AutoGenReqBuildRuleVerNum :
|
||||
# If Build Rule's version is less than the version number required by the tools, halting the build.
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
ExtraData="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\
|
||||
% (RetVal._FileVersion, AutoGenReqBuildRuleVerNum))
|
||||
return RetVal
|
||||
class ToolBuildRule():
|
||||
|
||||
BuildRuleObj = GetBuildRule()
|
||||
def __new__(cls, *args, **kw):
|
||||
if not hasattr(cls, '_instance'):
|
||||
orig = super(ToolBuildRule, cls)
|
||||
cls._instance = orig.__new__(cls, *args, **kw)
|
||||
return cls._instance
|
||||
|
||||
def __init__(self):
|
||||
if not hasattr(self, 'ToolBuildRule'):
|
||||
self._ToolBuildRule = None
|
||||
|
||||
@property
|
||||
def ToolBuildRule(self):
|
||||
if not self._ToolBuildRule:
|
||||
self._GetBuildRule()
|
||||
return self._ToolBuildRule
|
||||
|
||||
def _GetBuildRule(self):
|
||||
BuildRuleFile = None
|
||||
TargetObj = TargetTxtDict()
|
||||
TargetTxt = TargetObj.Target
|
||||
if TAB_TAT_DEFINES_BUILD_RULE_CONF in TargetTxt.TargetTxtDictionary:
|
||||
BuildRuleFile = TargetTxt.TargetTxtDictionary[TAB_TAT_DEFINES_BUILD_RULE_CONF]
|
||||
if not BuildRuleFile:
|
||||
BuildRuleFile = gDefaultBuildRuleFile
|
||||
RetVal = BuildRule(BuildRuleFile)
|
||||
if RetVal._FileVersion == "":
|
||||
RetVal._FileVersion = AutoGenReqBuildRuleVerNum
|
||||
else:
|
||||
if RetVal._FileVersion < AutoGenReqBuildRuleVerNum :
|
||||
# If Build Rule's version is less than the version number required by the tools, halting the build.
|
||||
EdkLogger.error("build", AUTOGEN_ERROR,
|
||||
ExtraData="The version number [%s] of build_rule.txt is less than the version number required by the AutoGen.(the minimum required version number is [%s])"\
|
||||
% (RetVal._FileVersion, AutoGenReqBuildRuleVerNum))
|
||||
self._ToolBuildRule = RetVal
|
||||
|
||||
# This acts like the main() function for the script, unless it is 'import'ed into another
|
||||
# script.
|
||||
|
Reference in New Issue
Block a user