From: Bob Feng Date: Thu, 11 Jul 2019 00:57:58 +0000 (+0800) Subject: BaseTools: Fixed the issue when ToolDefinitionFile is not generated X-Git-Tag: edk2-stable201908~253 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=2d100d1d73a9f9a38f224e87c48276ba1e84d8ce BaseTools: Fixed the issue when ToolDefinitionFile is not generated ToolDefinitionFile is generated by PlatformAutoGen.ToolDefinition() Code assume ToolDefinition is always called before using ToolDefinitionFile, but in some cases, it's not true. This patch is to fix this issue. Cc: Liming Gao Signed-off-by: Bob Feng Reviewed-by: Liming Gao --- diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index c0d0ca1586..5cfaf2141a 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -1912,8 +1912,8 @@ class PlatformAutoGen(AutoGen): else: ToolsDef += "%s_%s = %s\n" % (Tool, Attr, Value) ToolsDef += "\n" - - SaveFileOnChange(self.ToolDefinitionFile, ToolsDef, False) + tool_def_file = os.path.join(self.MakeFileDir, "TOOLS_DEF." + self.Arch) + SaveFileOnChange(tool_def_file, ToolsDef, False) for DllPath in DllPathList: os.environ["PATH"] = DllPath + os.pathsep + os.environ["PATH"] os.environ["MAKE_FLAGS"] = MakeFlags @@ -1923,7 +1923,10 @@ class PlatformAutoGen(AutoGen): ## Return the paths of tools @cached_property def ToolDefinitionFile(self): - return os.path.join(self.MakeFileDir, "TOOLS_DEF." + self.Arch) + tool_def_file = os.path.join(self.MakeFileDir, "TOOLS_DEF." + self.Arch) + if not os.path.exists(tool_def_file): + self.ToolDefinition + return tool_def_file ## Retrieve the toolchain family of given toolchain tag. Default to 'MSFT'. @cached_property