Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Michael Zimmermann <[email protected]>
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py
b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index 07e6696..500375a 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -29,7 +29,7 @@ from Common.LongFilePathSupport import OpenLongFilePath
as open
gMacroRefPattern = re.compile('(DEF\([^\(\)]+\))')
gEnvRefPattern = re.compile('(ENV\([^\(\)]+\))')
gMacroDefPattern = re.compile("DEFINE\s+([^\s]+)")
-gDefaultToolsDefFile = "tools_def.txt"
+gDefaultToolsDefFile = "tools_def.template"
## ToolDefClassObject
#
@@ -58,6 +58,23 @@ class ToolDefClassObject(object):
# @param Filename: Input value for full path of tools_def.txt
#
def LoadToolDefFile(self, FileName):
+ self.ToolsDefTxtDatabase = {
+ TAB_TOD_DEFINES_TARGET : [],
+ TAB_TOD_DEFINES_TOOL_CHAIN_TAG : [],
+ TAB_TOD_DEFINES_TARGET_ARCH : [],
+ TAB_TOD_DEFINES_COMMAND_TYPE : []
+ }
+
+ self.IncludeToolDefFile(FileName)
+
+
+ ## IncludeToolDefFile
+ #
+ # Load target.txt file and parse it as if it's contents were inside
the main file
+ #
+ # @param Filename: Input value for full path of tools_def.txt
+ #
+ def IncludeToolDefFile(self, FileName):
FileContent = []
if os.path.isfile(FileName):
try:
@@ -68,17 +85,21 @@ class ToolDefClassObject(object):
else:
EdkLogger.error("tools_def.txt parser", FILE_NOT_FOUND,
ExtraData=FileName)
- self.ToolsDefTxtDatabase = {
- TAB_TOD_DEFINES_TARGET : [],
- TAB_TOD_DEFINES_TOOL_CHAIN_TAG : [],
- TAB_TOD_DEFINES_TARGET_ARCH : [],
- TAB_TOD_DEFINES_COMMAND_TYPE : []
- }
-
for Index in range(len(FileContent)):
Line = FileContent[Index].strip()
if Line == "" or Line[0] == '#':
continue
+
+ if Line.startswith("!include"):
+ IncFile = Line[8:].strip()
+ Done, IncFile = self.ExpandMacros(IncFile)
+ if not Done:
+ EdkLogger.error("tools_def.txt parser",
ATTRIBUTE_NOT_AVAILABLE,
+ "Macro or Environment has not been
defined",
+ ExtraData=IncFile[4:-1], File=FileName,
Line=Index+1)
+ self.IncludeToolDefFile(IncFile)
+ continue
+
NameValuePair = Line.split("=", 1)
if len(NameValuePair) != 2:
EdkLogger.warn("tools_def.txt parser", "Line %d: not
correct assignment statement, skipped" % (Index + 1))
@@ -203,16 +224,8 @@ class ToolDefClassObject(object):
# @retval ToolDef An instance of ToolDefClassObject() with loaded
tools_def.txt
#
def ToolDefDict(ConfDir):
- Target = TargetTxtDict(ConfDir)
ToolDef = ToolDefClassObject()
- if DataType.TAB_TAT_DEFINES_TOOL_CHAIN_CONF in
Target.TargetTxtDictionary:
- ToolsDefFile =
Target.TargetTxtDictionary[DataType.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)))
+ ToolDef.LoadToolDefFile(os.path.normpath(os.path.join(ConfDir,
gDefaultToolsDefFile)))
return ToolDef
##
@@ -221,5 +234,7 @@ def ToolDefDict(ConfDir):
# script.
#
if __name__ == '__main__':
+ EdkLogger.Initialize()
+ EdkLogger.SetLevel(EdkLogger.VERBOSE)
ToolDef = ToolDefDict(os.getenv("WORKSPACE"))
pass
--
2.8.2
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel