From 688ec2d00651471a7f90537aef973b9c94931fd6 Mon Sep 17 00:00:00 2001
From: "Feng, Bob C" <bob.c.feng@intel.com>
Date: Thu, 27 Jun 2019 16:47:36 +0800
Subject: [PATCH] BaseTools: Detect the change of env variable used in
 tooldef.txt

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

Add TOOLS_DEF.ARCH file to all workspace meta files list.
TOOLS_DEF.ARCH include the evaluated Tool definition information
which is filtered by current tool_chain.

With this change, when the environment variable which
is used in ToolDef.txt is changed, build tool will
rebuild the platform.

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Steven Shi <steven.shi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index a2077c5516..c0d0ca1586 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -794,6 +794,9 @@ class WorkspaceAutoGen(AutoGen):
         #
         AllWorkSpaceMetaFiles.add(os.path.join(self.BuildDir, 'PcdTokenNumber'))
 
+        for Pa in self.AutoGenObjectList:
+            AllWorkSpaceMetaFiles.add(Pa.ToolDefinitionFile)
+
         for Arch in self.ArchList:
             #
             # add dec
@@ -1861,7 +1864,7 @@ class PlatformAutoGen(AutoGen):
         if TAB_TOD_DEFINES_COMMAND_TYPE not in self.Workspace.ToolDef.ToolsDefTxtDatabase:
             EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "No tools found in configuration",
                             ExtraData="[%s]" % self.MetaFile)
-        RetVal = {}
+        RetVal = OrderedDict()
         DllPathList = set()
         for Def in ToolDefinition:
             Target, Tag, Arch, Tool, Attr = Def.split("_")
@@ -1875,7 +1878,7 @@ class PlatformAutoGen(AutoGen):
                 continue
 
             if Tool not in RetVal:
-                RetVal[Tool] = {}
+                RetVal[Tool] = OrderedDict()
             RetVal[Tool][Attr] = Value
 
         ToolsDef = ''