public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools: Include headers not mentioned in inf are not hashed
@ 2019-05-09 21:27 Christian Rodriguez
  2019-05-09 23:39 ` [edk2-devel] " Carsey, Jaben
  2019-05-09 23:53 ` Laszlo Ersek
  0 siblings, 2 replies; 18+ messages in thread
From: Christian Rodriguez @ 2019-05-09 21:27 UTC (permalink / raw)
  To: devel; +Cc: Bob Feng, Liming Gao, Yonghong Zhu

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

Get a list of local header files that are not present in the
MetaFile for this module. Add those local header files into
the hashing algorithm for a module. If a local header file is
not present in the MetaFile, the module will still build correctly
though the hashing system didn't know about it before.

Signed-off-by: Christian Rodriguez <christian.rodriguez@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
---
 BaseTools/Source/Python/AutoGen/AutoGen.py | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py
index 31721a6f9f..bd282d3ec1 100644
--- a/BaseTools/Source/Python/AutoGen/AutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/AutoGen.py
@@ -4098,8 +4098,10 @@ class ModuleAutoGen(AutoGen):
         if self.Name in GlobalData.gModuleHash[self.Arch] and GlobalData.gBinCacheSource and self.AttemptModuleCacheCopy():
             return False
         m = hashlib.md5()
+
         # Add Platform level hash
         m.update(GlobalData.gPlatformHash.encode('utf-8'))
+
         # Add Package level hash
         if self.DependentPackageList:
             for Pkg in sorted(self.DependentPackageList, key=lambda x: x.PackageName):
@@ -4118,14 +4120,36 @@ class ModuleAutoGen(AutoGen):
         Content = f.read()
         f.close()
         m.update(Content)
+
         # Add Module's source files
+        localSourceFileList = set()
         if self.SourceFileList:
             for File in sorted(self.SourceFileList, key=lambda x: str(x)):
+                localSourceFileList.add(str(File))
                 f = open(str(File), 'rb')
                 Content = f.read()
                 f.close()
                 m.update(Content)
 
+        # Get a list of Module's local header files not included in metaFile
+        localHeaderList = set()
+        if self.SourceDir:
+            for root, dirs, files in os.walk(self.SourceDir):
+                for aFile in files:
+                    filePath = os.path.join(self.WorkspaceDir, os.path.join(root, aFile))
+                    if not filePath.endswith(('.h', '.H')):
+                        continue
+                    if filePath not in localSourceFileList:
+                        localHeaderList.add(filePath)
+
+        # Add Module's local header files
+        localHeaderList = list(localHeaderList)
+        for File in sorted(localHeaderList):
+            f = open(str(File), 'rb')
+            Content = f.read()
+            f.close()
+            m.update(Content)
+
         ModuleHashFile = path.join(self.BuildDir, self.Name + ".hash")
         if self.Name not in GlobalData.gModuleHash[self.Arch]:
             GlobalData.gModuleHash[self.Arch][self.Name] = m.hexdigest()
-- 
2.19.1.windows.1


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2019-05-14  2:52 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-09 21:27 [PATCH] BaseTools: Include headers not mentioned in inf are not hashed Christian Rodriguez
2019-05-09 23:39 ` [edk2-devel] " Carsey, Jaben
2019-05-10 15:28   ` Christian Rodriguez
2019-05-10 16:14     ` Carsey, Jaben
2019-05-09 23:53 ` Laszlo Ersek
2019-05-10 13:41   ` Felix Polyudov
2019-05-10 19:13     ` Christian Rodriguez
2019-05-10 19:32       ` Felix Polyudov
2019-05-10 19:45         ` Christian Rodriguez
2019-05-13 11:39           ` Laszlo Ersek
2019-05-13 12:23             ` Bob Feng
2019-05-13 18:41               ` Christian Rodriguez
2019-05-14  2:52                 ` Bob Feng
2019-05-13 18:53             ` Christian Rodriguez
2019-05-13 20:19               ` Laszlo Ersek
2019-05-13 20:23                 ` Christian Rodriguez
     [not found]             ` <159E52DAFBF01090.24406@groups.io>
2019-05-13 19:39               ` Christian Rodriguez
2019-05-13 11:41           ` Bob Feng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox