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:
@ -24,7 +24,8 @@ from . import GenDepex
|
||||
from io import BytesIO
|
||||
|
||||
from .StrGather import *
|
||||
from .BuildEngine import BuildRule
|
||||
from .BuildEngine import BuildRuleObj as BuildRule
|
||||
from .BuildEngine import gDefaultBuildRuleFile,AutoGenReqBuildRuleVerNum
|
||||
import shutil
|
||||
from Common.LongFilePathSupport import CopyLongFilePath
|
||||
from Common.BuildToolError import *
|
||||
@ -78,12 +79,6 @@ gEfiVarStoreGuidPattern = re.compile("\s*guid\s*=\s*({.*?{.*?}\s*})")
|
||||
gMakeTypeMap = {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"}
|
||||
|
||||
|
||||
## Build rule configuration file
|
||||
gDefaultBuildRuleFile = 'build_rule.txt'
|
||||
|
||||
## Build rule default version
|
||||
AutoGenReqBuildRuleVerNum = "0.1"
|
||||
|
||||
## default file name for AutoGen
|
||||
gAutoGenCodeFileName = "AutoGen.c"
|
||||
gAutoGenHeaderFileName = "AutoGen.h"
|
||||
@ -1972,28 +1967,6 @@ class PlatformAutoGen(AutoGen):
|
||||
def EdkIIBuildOption(self):
|
||||
return self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)
|
||||
|
||||
## Parse build_rule.txt in Conf Directory.
|
||||
#
|
||||
# @retval BuildRule object
|
||||
#
|
||||
@cached_property
|
||||
def BuildRule(self):
|
||||
BuildRuleFile = None
|
||||
if TAB_TAT_DEFINES_BUILD_RULE_CONF in self.Workspace.TargetTxt.TargetTxtDictionary:
|
||||
BuildRuleFile = self.Workspace.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
|
||||
|
||||
## Summarize the packages used by modules in this platform
|
||||
@cached_property
|
||||
def PackageList(self):
|
||||
@ -3151,7 +3124,7 @@ class ModuleAutoGen(AutoGen):
|
||||
@cached_property
|
||||
def BuildRules(self):
|
||||
RetVal = {}
|
||||
BuildRuleDatabase = self.PlatformInfo.BuildRule
|
||||
BuildRuleDatabase = BuildRule
|
||||
for Type in BuildRuleDatabase.FileTypeList:
|
||||
#first try getting build rule by BuildRuleFamily
|
||||
RuleObject = BuildRuleDatabase[Type, self.BuildType, self.Arch, self.BuildRuleFamily]
|
||||
|
Reference in New Issue
Block a user