BaseTools: Singleton the object to handle build conf file

BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1875

The build config files are target.txt, build rule, tooldef
During a build, the config is not changed, so the object to
handle them need to be singleton.

Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Feng, Bob C
2019-04-13 16:02:02 +08:00
parent 4b1b7c1913
commit db01c8e3d8
8 changed files with 62 additions and 96 deletions

View File

@ -14,7 +14,7 @@ import re
from . import EdkLogger
from .BuildToolError import *
from Common.TargetTxtClassObject import TargetTxtDict
from Common.TargetTxtClassObject import TargetTxt
from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.Misc import PathClass
from Common.StringUtils import NormPath
@ -263,7 +263,7 @@ class ToolDefClassObject(object):
# @retval ToolDef An instance of ToolDefClassObject() with loaded tools_def.txt
#
def ToolDefDict(ConfDir):
Target = TargetTxtDict(ConfDir)
Target = TargetTxt
ToolDef = ToolDefClassObject()
if TAB_TAT_DEFINES_TOOL_CHAIN_CONF in Target.TargetTxtDictionary:
ToolsDefFile = Target.TargetTxtDictionary[TAB_TAT_DEFINES_TOOL_CHAIN_CONF]
@ -275,6 +275,8 @@ def ToolDefDict(ConfDir):
ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(ConfDir, gDefaultToolsDefFile)))
return ToolDef
ToolDef = ToolDefDict((os.path.join(os.getenv("WORKSPACE"),"Conf")))
##
#
# This acts like the main() function for the script, unless it is 'import'ed into another