]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools: Enable --genfds-multi-thread to default build
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenMake.py
old mode 100644 (file)
new mode 100755 (executable)
index 212ca0f..4f85a93
@@ -906,8 +906,19 @@ cleanlib:
                                     self._AutoGenObject.IncludePathList + self._AutoGenObject.BuildOptionIncPathList\r
                                     )\r
 \r
+        self.DependencyHeaderFileSet = set()\r
+        if FileDependencyDict:\r
+            for Dependency in FileDependencyDict.values():\r
+                self.DependencyHeaderFileSet.update(set(Dependency))\r
+\r
+        # Get a set of unique package includes from MetaFile\r
+        parentMetaFileIncludes = set()\r
+        for aInclude in self._AutoGenObject.PackageIncludePathList:\r
+            aIncludeName = str(aInclude)\r
+            parentMetaFileIncludes.add(aIncludeName.lower())\r
+\r
         # Check if header files are listed in metafile\r
-        # Get a list of unique module header source files from MetaFile\r
+        # Get a set of unique module header source files from MetaFile\r
         headerFilesInMetaFileSet = set()\r
         for aFile in self._AutoGenObject.SourceFileList:\r
             aFileName = str(aFile)\r
@@ -915,36 +926,45 @@ cleanlib:
                 continue\r
             headerFilesInMetaFileSet.add(aFileName.lower())\r
 \r
-        # Get a list of unique module autogen files\r
+        # Get a set 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
+        # Get a set of unique module dependency header files\r
         # Exclude autogen files and files not in the source directory\r
+        # and files that are under the package include list\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
+                # Exclude non-header files\r
                 if not aFileName.endswith('.h'):\r
                     continue\r
+                # Exclude autogen files\r
                 if aFileName in localAutoGenFileSet:\r
                     continue\r
+                # Exclude include out of local scope\r
                 if localSourceDir not in aFileName:\r
                     continue\r
+                # Exclude files covered by package includes\r
+                pathNeeded = True\r
+                for aIncludePath in parentMetaFileIncludes:\r
+                    if aIncludePath in aFileName:\r
+                        pathNeeded = False\r
+                        break\r
+                if not pathNeeded:\r
+                    continue\r
+                # Keep the file to be checked\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
+                GlobalData.gModuleBuildTracking[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
@@ -1026,7 +1046,8 @@ cleanlib:
                         self.FileListMacros[T.FileListMacro].append(NewFile)\r
                     else:\r
                         Deps.append(NewFile)\r
-\r
+                for key in self.FileListMacros:\r
+                    self.FileListMacros[key].sort()\r
                 # Use file list macro as dependency\r
                 if T.GenFileListMacro:\r
                     Deps.append("$(%s)" % T.FileListMacro)\r
@@ -1079,7 +1100,7 @@ cleanlib:
                         CmdTargetDict[CmdSign] = "%s %s" % (CmdTargetDict[CmdSign], SingleCommandList[-1])\r
                     Index = CommandList.index(Item)\r
                     CommandList.pop(Index)\r
-                    if SingleCommandList[-1].endswith("%s%s.c" % (TAB_SLASH, CmdSumDict[CmdSign.lstrip('/Fo').rsplit(TAB_SLASH, 1)[0]])):\r
+                    if SingleCommandList[-1].endswith("%s%s.c" % (TAB_SLASH, CmdSumDict[CmdSign[3:].rsplit(TAB_SLASH, 1)[0]])):\r
                         Cpplist = CmdCppDict[T.Target.SubDir]\r
                         Cpplist.insert(0, '$(OBJLIST_%d): $(COMMON_DEPS)' % list(self.ObjTargetDict.keys()).index(T.Target.SubDir))\r
                         T.Commands[Index] = '%s\n\t%s' % (' \\\n\t'.join(Cpplist), CmdTargetDict[CmdSign])\r
@@ -1095,7 +1116,7 @@ cleanlib:
     ## For creating makefile targets for dependent libraries\r
     def ProcessDependentLibrary(self):\r
         for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:\r
-            if not LibraryAutoGen.IsBinaryModule and not LibraryAutoGen.CanSkipbyHash():\r
+            if not LibraryAutoGen.IsBinaryModule:\r
                 self.LibraryBuildDirectoryList.append(self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros))\r
 \r
     ## Return a list containing source file's dependencies\r
@@ -1109,114 +1130,9 @@ cleanlib:
     def GetFileDependency(self, FileList, ForceInculeList, SearchPathList):\r
         Dependency = {}\r
         for F in FileList:\r
-            Dependency[F] = self.GetDependencyList(F, ForceInculeList, SearchPathList)\r
+            Dependency[F] = GetDependencyList(self._AutoGenObject, self.FileCache, F, ForceInculeList, SearchPathList)\r
         return Dependency\r
 \r
-    ## Find dependencies for one source file\r
-    #\r
-    #  By searching recursively "#include" directive in file, find out all the\r
-    #  files needed by given source file. The dependencies will be only searched\r
-    #  in given search path list.\r
-    #\r
-    #   @param      File            The source file\r
-    #   @param      ForceInculeList The list of files which will be included forcely\r
-    #   @param      SearchPathList  The list of search path\r
-    #\r
-    #   @retval     list            The list of files the given source file depends on\r
-    #\r
-    def GetDependencyList(self, File, ForceList, SearchPathList):\r
-        EdkLogger.debug(EdkLogger.DEBUG_1, "Try to get dependency files for %s" % File)\r
-        FileStack = [File] + ForceList\r
-        DependencySet = set()\r
-\r
-        if self._AutoGenObject.Arch not in gDependencyDatabase:\r
-            gDependencyDatabase[self._AutoGenObject.Arch] = {}\r
-        DepDb = gDependencyDatabase[self._AutoGenObject.Arch]\r
-\r
-        while len(FileStack) > 0:\r
-            F = FileStack.pop()\r
-\r
-            FullPathDependList = []\r
-            if F in self.FileCache:\r
-                for CacheFile in self.FileCache[F]:\r
-                    FullPathDependList.append(CacheFile)\r
-                    if CacheFile not in DependencySet:\r
-                        FileStack.append(CacheFile)\r
-                DependencySet.update(FullPathDependList)\r
-                continue\r
-\r
-            CurrentFileDependencyList = []\r
-            if F in DepDb:\r
-                CurrentFileDependencyList = DepDb[F]\r
-            else:\r
-                try:\r
-                    Fd = open(F.Path, 'rb')\r
-                    FileContent = Fd.read()\r
-                    Fd.close()\r
-                except BaseException as X:\r
-                    EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))\r
-                if len(FileContent) == 0:\r
-                    continue\r
-                try:\r
-                    if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
-                        FileContent = FileContent.decode('utf-16')\r
-                    else:\r
-                        FileContent = FileContent.decode()\r
-                except:\r
-                    # The file is not txt file. for example .mcb file\r
-                    continue\r
-                IncludedFileList = gIncludePattern.findall(FileContent)\r
-\r
-                for Inc in IncludedFileList:\r
-                    Inc = Inc.strip()\r
-                    # if there's macro used to reference header file, expand it\r
-                    HeaderList = gMacroPattern.findall(Inc)\r
-                    if len(HeaderList) == 1 and len(HeaderList[0]) == 2:\r
-                        HeaderType = HeaderList[0][0]\r
-                        HeaderKey = HeaderList[0][1]\r
-                        if HeaderType in gIncludeMacroConversion:\r
-                            Inc = gIncludeMacroConversion[HeaderType] % {"HeaderKey" : HeaderKey}\r
-                        else:\r
-                            # not known macro used in #include, always build the file by\r
-                            # returning a empty dependency\r
-                            self.FileCache[File] = []\r
-                            return []\r
-                    Inc = os.path.normpath(Inc)\r
-                    CurrentFileDependencyList.append(Inc)\r
-                DepDb[F] = CurrentFileDependencyList\r
-\r
-            CurrentFilePath = F.Dir\r
-            PathList = [CurrentFilePath] + SearchPathList\r
-            for Inc in CurrentFileDependencyList:\r
-                for SearchPath in PathList:\r
-                    FilePath = os.path.join(SearchPath, Inc)\r
-                    if FilePath in gIsFileMap:\r
-                        if not gIsFileMap[FilePath]:\r
-                            continue\r
-                    # If isfile is called too many times, the performance is slow down.\r
-                    elif not os.path.isfile(FilePath):\r
-                        gIsFileMap[FilePath] = False\r
-                        continue\r
-                    else:\r
-                        gIsFileMap[FilePath] = True\r
-                    FilePath = PathClass(FilePath)\r
-                    FullPathDependList.append(FilePath)\r
-                    if FilePath not in DependencySet:\r
-                        FileStack.append(FilePath)\r
-                    break\r
-                else:\r
-                    EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\\r
-                                    "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList)))\r
-\r
-            self.FileCache[F] = FullPathDependList\r
-            DependencySet.update(FullPathDependList)\r
-\r
-        DependencySet.update(ForceList)\r
-        if File in DependencySet:\r
-            DependencySet.remove(File)\r
-        DependencyList = list(DependencySet)  # remove duplicate ones\r
-\r
-        return DependencyList\r
 \r
 ## CustomMakefile class\r
 #\r
@@ -1598,7 +1514,7 @@ cleanlib:
     def GetLibraryBuildDirectoryList(self):\r
         DirList = []\r
         for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:\r
-            if not LibraryAutoGen.IsBinaryModule and not LibraryAutoGen.CanSkipbyHash():\r
+            if not LibraryAutoGen.IsBinaryModule:\r
                 DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))\r
         return DirList\r
 \r
@@ -1664,8 +1580,8 @@ class TopLevelMakefile(BuildFile):
 \r
         if GlobalData.gCaseInsensitive:\r
             ExtraOption += " -c"\r
-        if GlobalData.gEnableGenfdsMultiThread:\r
-            ExtraOption += " --genfds-multi-thread"\r
+        if not GlobalData.gEnableGenfdsMultiThread:\r
+            ExtraOption += " --no-genfds-multi-thread"\r
         if GlobalData.gIgnoreSource:\r
             ExtraOption += " --ignore-sources"\r
 \r
@@ -1734,11 +1650,116 @@ class TopLevelMakefile(BuildFile):
     def GetLibraryBuildDirectoryList(self):\r
         DirList = []\r
         for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:\r
-            if not LibraryAutoGen.IsBinaryModule and not LibraryAutoGen.CanSkipbyHash():\r
+            if not LibraryAutoGen.IsBinaryModule:\r
                 DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))\r
         return DirList\r
 \r
+## Find dependencies for one source file\r
+#\r
+#  By searching recursively "#include" directive in file, find out all the\r
+#  files needed by given source file. The dependencies will be only searched\r
+#  in given search path list.\r
+#\r
+#   @param      File            The source file\r
+#   @param      ForceInculeList The list of files which will be included forcely\r
+#   @param      SearchPathList  The list of search path\r
+#\r
+#   @retval     list            The list of files the given source file depends on\r
+#\r
+def GetDependencyList(AutoGenObject, FileCache, File, ForceList, SearchPathList):\r
+    EdkLogger.debug(EdkLogger.DEBUG_1, "Try to get dependency files for %s" % File)\r
+    FileStack = [File] + ForceList\r
+    DependencySet = set()\r
+\r
+    if AutoGenObject.Arch not in gDependencyDatabase:\r
+        gDependencyDatabase[AutoGenObject.Arch] = {}\r
+    DepDb = gDependencyDatabase[AutoGenObject.Arch]\r
+\r
+    while len(FileStack) > 0:\r
+        F = FileStack.pop()\r
+\r
+        FullPathDependList = []\r
+        if F in FileCache:\r
+            for CacheFile in FileCache[F]:\r
+                FullPathDependList.append(CacheFile)\r
+                if CacheFile not in DependencySet:\r
+                    FileStack.append(CacheFile)\r
+            DependencySet.update(FullPathDependList)\r
+            continue\r
+\r
+        CurrentFileDependencyList = []\r
+        if F in DepDb:\r
+            CurrentFileDependencyList = DepDb[F]\r
+        else:\r
+            try:\r
+                Fd = open(F.Path, 'rb')\r
+                FileContent = Fd.read()\r
+                Fd.close()\r
+            except BaseException as X:\r
+                EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F.Path + "\n\t" + str(X))\r
+            if len(FileContent) == 0:\r
+                continue\r
+            try:\r
+                if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
+                    FileContent = FileContent.decode('utf-16')\r
+                else:\r
+                    FileContent = FileContent.decode()\r
+            except:\r
+                # The file is not txt file. for example .mcb file\r
+                continue\r
+            IncludedFileList = gIncludePattern.findall(FileContent)\r
+\r
+            for Inc in IncludedFileList:\r
+                Inc = Inc.strip()\r
+                # if there's macro used to reference header file, expand it\r
+                HeaderList = gMacroPattern.findall(Inc)\r
+                if len(HeaderList) == 1 and len(HeaderList[0]) == 2:\r
+                    HeaderType = HeaderList[0][0]\r
+                    HeaderKey = HeaderList[0][1]\r
+                    if HeaderType in gIncludeMacroConversion:\r
+                        Inc = gIncludeMacroConversion[HeaderType] % {"HeaderKey" : HeaderKey}\r
+                    else:\r
+                        # not known macro used in #include, always build the file by\r
+                        # returning a empty dependency\r
+                        FileCache[File] = []\r
+                        return []\r
+                Inc = os.path.normpath(Inc)\r
+                CurrentFileDependencyList.append(Inc)\r
+            DepDb[F] = CurrentFileDependencyList\r
+\r
+        CurrentFilePath = F.Dir\r
+        PathList = [CurrentFilePath] + SearchPathList\r
+        for Inc in CurrentFileDependencyList:\r
+            for SearchPath in PathList:\r
+                FilePath = os.path.join(SearchPath, Inc)\r
+                if FilePath in gIsFileMap:\r
+                    if not gIsFileMap[FilePath]:\r
+                        continue\r
+                # If isfile is called too many times, the performance is slow down.\r
+                elif not os.path.isfile(FilePath):\r
+                    gIsFileMap[FilePath] = False\r
+                    continue\r
+                else:\r
+                    gIsFileMap[FilePath] = True\r
+                FilePath = PathClass(FilePath)\r
+                FullPathDependList.append(FilePath)\r
+                if FilePath not in DependencySet:\r
+                    FileStack.append(FilePath)\r
+                break\r
+            else:\r
+                EdkLogger.debug(EdkLogger.DEBUG_9, "%s included by %s was not found "\\r
+                                "in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList)))\r
+\r
+        FileCache[F] = FullPathDependList\r
+        DependencySet.update(FullPathDependList)\r
+\r
+    DependencySet.update(ForceList)\r
+    if File in DependencySet:\r
+        DependencySet.remove(File)\r
+    DependencyList = list(DependencySet)  # remove duplicate ones\r
+\r
+    return DependencyList\r
+\r
 # This acts like the main() function for the script, unless it is 'import'ed into another script.\r
 if __name__ == '__main__':\r
-    pass\r
-\r
+    pass\r
\ No newline at end of file