]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools: Refactor hash tracking after checking for Sources section
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenMake.py
index 3e770ad7c425d1e6b8db3f49d4bccd9ed4905a3c..212ca0fa7f9f16da1eeb8ecfd7aebb35537c9a33 100644 (file)
@@ -905,6 +905,50 @@ cleanlib:
                                     ForceIncludedFile,\r
                                     self._AutoGenObject.IncludePathList + self._AutoGenObject.BuildOptionIncPathList\r
                                     )\r
+\r
+        # Check if header files are listed in metafile\r
+        # Get a list of unique module header source files from MetaFile\r
+        headerFilesInMetaFileSet = set()\r
+        for aFile in self._AutoGenObject.SourceFileList:\r
+            aFileName = str(aFile)\r
+            if not aFileName.endswith('.h'):\r
+                continue\r
+            headerFilesInMetaFileSet.add(aFileName.lower())\r
+\r
+        # Get a list of unique module autogen files\r
+        localAutoGenFileSet = set()\r
+        for aFile in self._AutoGenObject.AutoGenFileList:\r
+            localAutoGenFileSet.add(str(aFile).lower())\r
+\r
+        # Get a list of unique module dependency header files\r
+        # Exclude autogen files and files not in the source directory\r
+        headerFileDependencySet = set()\r
+        localSourceDir = str(self._AutoGenObject.SourceDir).lower()\r
+        for Dependency in FileDependencyDict.values():\r
+            for aFile in Dependency:\r
+                aFileName = str(aFile).lower()\r
+                if not aFileName.endswith('.h'):\r
+                    continue\r
+                if aFileName in localAutoGenFileSet:\r
+                    continue\r
+                if localSourceDir not in aFileName:\r
+                    continue\r
+                headerFileDependencySet.add(aFileName)\r
+\r
+        # Ensure that gModuleBuildTracking has been initialized per architecture\r
+        if self._AutoGenObject.Arch not in GlobalData.gModuleBuildTracking:\r
+            GlobalData.gModuleBuildTracking[self._AutoGenObject.Arch] = dict()\r
+\r
+        # Check if a module dependency header file is missing from the module's MetaFile\r
+        for aFile in headerFileDependencySet:\r
+            if aFile in headerFilesInMetaFileSet:\r
+                continue\r
+            if GlobalData.gUseHashCache:\r
+                GlobalData.gModuleBuildTracking[self._AutoGenObject.Arch][self._AutoGenObject] = 'FAIL_METAFILE'\r
+            EdkLogger.warn("build","Module MetaFile [Sources] is missing local header!",\r
+                        ExtraData = "Local Header: " + aFile + " not found in " + self._AutoGenObject.MetaFile.Path\r
+                        )\r
+\r
         DepSet = None\r
         for File,Dependency in FileDependencyDict.items():\r
             if not Dependency:\r
@@ -1023,7 +1067,7 @@ cleanlib:
             CommandList = T.Commands[:]\r
             for Item in CommandList[:]:\r
                 SingleCommandList = Item.split()\r
-                if len(SingleCommandList) > 0 and '$(CC)' in SingleCommandList[0]:\r
+                if len(SingleCommandList) > 0 and self.CheckCCCmd(SingleCommandList):\r
                     for Temp in SingleCommandList:\r
                         if Temp.startswith('/Fo'):\r
                             CmdSign = '%s%s' % (Temp.rsplit(TAB_SLASH, 1)[0], TAB_SLASH)\r
@@ -1043,6 +1087,11 @@ cleanlib:
                         T.Commands.pop(Index)\r
         return T, CmdSumDict, CmdTargetDict, CmdCppDict\r
 \r
+    def CheckCCCmd(self, CommandList):\r
+        for cmd in CommandList:\r
+            if '$(CC)' in cmd:\r
+                return True\r
+        return False\r
     ## For creating makefile targets for dependent libraries\r
     def ProcessDependentLibrary(self):\r
         for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:\r