[edk2-devel] [PATCH V3] BaseTools:fixed the incorrect autogen makefile which cause build failure.

Fan, ZhijuX posted 1 patch 5 years ago
Failed in applying to current master (apply log)
BaseTools/Source/Python/AutoGen/GenMake.py | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
[edk2-devel] [PATCH V3] BaseTools:fixed the incorrect autogen makefile which cause build failure.
Posted by Fan, ZhijuX 5 years ago
BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1729

On some build environment, build fails but on the other build machines, 
build success. This is the regression issue introduced by commit 
 05217d210e8da37b47d0be58ec363f7af2fa1c18

As Dict is unordered, an error occurs when extract the index of the Dict
in the order of the keys after the creation of a new item.
Keys are indexed inconsistently before and after adding a new item.
The logic of the program is to store the key's corresponding index as
reference data in the MakeFile and use it as part of the macro.
The data model is: $(LIST_%d) % Dict.keys().index(Key)
So for now, use OrdereDict instead of Dict.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenMake.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 7562dc68b3..3e770ad7c4 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -429,7 +429,7 @@ cleanlib:
         self.CommonFileDependency = []
         self.FileListMacros = {}
         self.ListFileMacros = {}
-        self.ObjTargetDict = {}
+        self.ObjTargetDict = OrderedDict()
         self.FileCache = {}
         self.LibraryBuildCommandList = []
         self.LibraryFileList = []
@@ -943,6 +943,12 @@ cleanlib:
             DependencyDict[File] = list(NewDepSet)
 
         # Convert target description object to target string in makefile
+        if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and TAB_C_CODE_FILE in self._AutoGenObject.Targets:
+            for T in self._AutoGenObject.Targets[TAB_C_CODE_FILE]:
+                NewFile = self.PlaceMacro(str(T), self.Macros)
+                if not self.ObjTargetDict.get(T.Target.SubDir):
+                    self.ObjTargetDict[T.Target.SubDir] = set()
+                self.ObjTargetDict[T.Target.SubDir].add(NewFile)
         for Type in self._AutoGenObject.Targets:
             for T in self._AutoGenObject.Targets[Type]:
                 # Generate related macros if needed
@@ -952,13 +958,6 @@ cleanlib:
                     self.ListFileMacros[T.ListFileMacro] = []
                 if T.GenIncListFile and T.IncListFileMacro not in self.ListFileMacros:
                     self.ListFileMacros[T.IncListFileMacro] = []
-                if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and Type == TAB_C_CODE_FILE:
-                    NewFile = self.PlaceMacro(str(T), self.Macros)
-                    if self.ObjTargetDict.get(T.Target.SubDir):
-                        self.ObjTargetDict[T.Target.SubDir].add(NewFile)
-                    else:
-                        self.ObjTargetDict[T.Target.SubDir] = set()
-                        self.ObjTargetDict[T.Target.SubDir].add(NewFile)
 
                 Deps = []
                 CCodeDeps = []
-- 
2.14.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#39298): https://edk2.groups.io/g/devel/message/39298
Mute This Topic: https://groups.io/mt/31222391/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH V3] BaseTools:fixed the incorrect autogen makefile which cause build failure.
Posted by Bob Feng 5 years ago
Reviewed-by: Bob Feng <bob.c.feng@intel.com>


-----Original Message-----
From: Fan, ZhijuX 
Sent: Thursday, April 18, 2019 7:21 PM
To: devel@edk2.groups.io
Cc: Gao, Liming <liming.gao@intel.com>; Feng, Bob C <bob.c.feng@intel.com>
Subject: [PATCH V3] BaseTools:fixed the incorrect autogen makefile which cause build failure.

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

On some build environment, build fails but on the other build machines, build success. This is the regression issue introduced by commit
 05217d210e8da37b47d0be58ec363f7af2fa1c18

As Dict is unordered, an error occurs when extract the index of the Dict in the order of the keys after the creation of a new item.
Keys are indexed inconsistently before and after adding a new item.
The logic of the program is to store the key's corresponding index as reference data in the MakeFile and use it as part of the macro.
The data model is: $(LIST_%d) % Dict.keys().index(Key) So for now, use OrdereDict instead of Dict.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenMake.py | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py
index 7562dc68b3..3e770ad7c4 100644
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -429,7 +429,7 @@ cleanlib:
         self.CommonFileDependency = []
         self.FileListMacros = {}
         self.ListFileMacros = {}
-        self.ObjTargetDict = {}
+        self.ObjTargetDict = OrderedDict()
         self.FileCache = {}
         self.LibraryBuildCommandList = []
         self.LibraryFileList = []
@@ -943,6 +943,12 @@ cleanlib:
             DependencyDict[File] = list(NewDepSet)
 
         # Convert target description object to target string in makefile
+        if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and TAB_C_CODE_FILE in self._AutoGenObject.Targets:
+            for T in self._AutoGenObject.Targets[TAB_C_CODE_FILE]:
+                NewFile = self.PlaceMacro(str(T), self.Macros)
+                if not self.ObjTargetDict.get(T.Target.SubDir):
+                    self.ObjTargetDict[T.Target.SubDir] = set()
+                self.ObjTargetDict[T.Target.SubDir].add(NewFile)
         for Type in self._AutoGenObject.Targets:
             for T in self._AutoGenObject.Targets[Type]:
                 # Generate related macros if needed @@ -952,13 +958,6 @@ cleanlib:
                     self.ListFileMacros[T.ListFileMacro] = []
                 if T.GenIncListFile and T.IncListFileMacro not in self.ListFileMacros:
                     self.ListFileMacros[T.IncListFileMacro] = []
-                if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and Type == TAB_C_CODE_FILE:
-                    NewFile = self.PlaceMacro(str(T), self.Macros)
-                    if self.ObjTargetDict.get(T.Target.SubDir):
-                        self.ObjTargetDict[T.Target.SubDir].add(NewFile)
-                    else:
-                        self.ObjTargetDict[T.Target.SubDir] = set()
-                        self.ObjTargetDict[T.Target.SubDir].add(NewFile)
 
                 Deps = []
                 CCodeDeps = []
--
2.14.1.windows.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#39354): https://edk2.groups.io/g/devel/message/39354
Mute This Topic: https://groups.io/mt/31222391/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-