]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenMake.py
BaseTools: Add a checking for Sources section in INF file
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenMake.py
index bf84e6c63fbc6564a0d2688c638c62f4a77fd56d..5c992d7c267437bcfe79c798f40e442f0c5f1c3b 100644 (file)
@@ -2,17 +2,12 @@
 # Create makefile for MS nmake and GNU make\r
 #\r
 # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials\r
-# are licensed and made available under the terms and conditions of the BSD License\r
-# which accompanies this distribution.  The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 \r
 ## Import Modules\r
 #\r
+from __future__ import absolute_import\r
 import Common.LongFilePathOs as os\r
 import sys\r
 import string\r
@@ -29,7 +24,7 @@ from collections import OrderedDict
 from Common.DataType import TAB_COMPILER_MSFT\r
 \r
 ## Regular expression for finding header file inclusions\r
-gIncludePattern = re.compile(r"^[ \t]*#?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)\r
+gIncludePattern = re.compile(r"^[ \t]*[#%]?[ \t]*include(?:[ \t]*(?:\\(?:\r\n|\r|\n))*[ \t]*)*(?:\(?[\"<]?[ \t]*)([-\w.\\/() \t]+)(?:[ \t]*[\">]?\)?)", re.MULTILINE | re.UNICODE | re.IGNORECASE)\r
 \r
 ## Regular expression for matching macro used in header file inclusion\r
 gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)[ \t]*\((.+)\)", re.UNICODE)\r
@@ -166,7 +161,7 @@ class BuildFile(object):
         "gmake" :   "include"\r
     }\r
 \r
-    _INC_FLAG_ = {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : "-I"}\r
+    _INC_FLAG_ = {TAB_COMPILER_MSFT : "/I", "GCC" : "-I", "INTEL" : "-I", "RVCT" : "-I", "NASM" : "-I"}\r
 \r
     ## Constructor of BuildFile\r
     #\r
@@ -434,7 +429,7 @@ cleanlib:
         self.CommonFileDependency = []\r
         self.FileListMacros = {}\r
         self.ListFileMacros = {}\r
-\r
+        self.ObjTargetDict = OrderedDict()\r
         self.FileCache = {}\r
         self.LibraryBuildCommandList = []\r
         self.LibraryFileList = []\r
@@ -475,23 +470,16 @@ cleanlib:
         else:\r
             ModuleEntryPoint = "_ModuleEntryPoint"\r
 \r
-        # Intel EBC compiler enforces EfiMain\r
-        if MyAgo.AutoGenVersion < 0x00010005 and MyAgo.Arch == "EBC":\r
-            ArchEntryPoint = "EfiMain"\r
-        else:\r
-            ArchEntryPoint = ModuleEntryPoint\r
+        ArchEntryPoint = ModuleEntryPoint\r
 \r
         if MyAgo.Arch == "EBC":\r
             # EBC compiler always use "EfiStart" as entry point. Only applies to EdkII modules\r
             ImageEntryPoint = "EfiStart"\r
-        elif MyAgo.AutoGenVersion < 0x00010005:\r
-            # Edk modules use entry point specified in INF file\r
-            ImageEntryPoint = ModuleEntryPoint\r
         else:\r
             # EdkII modules always use "_ModuleEntryPoint" as entry point\r
             ImageEntryPoint = "_ModuleEntryPoint"\r
 \r
-        for k, v in MyAgo.Module.Defines.iteritems():\r
+        for k, v in MyAgo.Module.Defines.items():\r
             if k not in MyAgo.Macros:\r
                 MyAgo.Macros[k] = v\r
 \r
@@ -503,7 +491,7 @@ cleanlib:
             MyAgo.Macros['IMAGE_ENTRY_POINT'] = ImageEntryPoint\r
 \r
         PCI_COMPRESS_Flag = False\r
-        for k, v in MyAgo.Module.Defines.iteritems():\r
+        for k, v in MyAgo.Module.Defines.items():\r
             if 'PCI_COMPRESS' == k and 'TRUE' == v:\r
                 PCI_COMPRESS_Flag = True\r
 \r
@@ -524,6 +512,9 @@ cleanlib:
                     # Remove duplicated include path, if any\r
                     if Attr == "FLAGS":\r
                         Value = RemoveDupOption(Value, IncPrefix, MyAgo.IncludePathList)\r
+                        if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and Tool == 'CC' and '/GM' in Value:\r
+                            Value = Value.replace(' /MP', '')\r
+                            MyAgo.BuildOption[Tool][Attr] = Value\r
                         if Tool == "OPTROM" and PCI_COMPRESS_Flag:\r
                             ValueList = Value.split()\r
                             if ValueList:\r
@@ -554,8 +545,8 @@ cleanlib:
                 NewRespStr = ' '.join(NewStr)\r
                 SaveFileOnChange(RespFile, NewRespStr, False)\r
                 ToolsDef.append("%s = %s" % (Resp, UnexpandMacroStr + ' @' + RespFile))\r
-                RespFileListContent += '@' + RespFile + os.linesep\r
-                RespFileListContent += NewRespStr + os.linesep\r
+                RespFileListContent += '@' + RespFile + TAB_LINE_BREAK\r
+                RespFileListContent += NewRespStr + TAB_LINE_BREAK\r
             SaveFileOnChange(RespFileList, RespFileListContent, False)\r
         else:\r
             if os.path.exists(RespFileList):\r
@@ -595,6 +586,24 @@ cleanlib:
                                                 }\r
                                                 )\r
         FileMacroList.append(FileMacro)\r
+        # Add support when compiling .nasm source files\r
+        for File in self.FileCache.keys():\r
+            if not str(File).endswith('.nasm'):\r
+                continue\r
+            IncludePathList = []\r
+            for P in  MyAgo.IncludePathList:\r
+                IncludePath = self._INC_FLAG_['NASM'] + self.PlaceMacro(P, self.Macros)\r
+                if IncludePath.endswith(os.sep):\r
+                    IncludePath = IncludePath.rstrip(os.sep)\r
+                # When compiling .nasm files, need to add a literal backslash at each path\r
+                # To specify a literal backslash at the end of the line, precede it with a caret (^)\r
+                if P == MyAgo.IncludePathList[-1] and os.sep == '\\':\r
+                    IncludePath = ''.join([IncludePath, '^', os.sep])\r
+                else:\r
+                    IncludePath = os.path.join(IncludePath, '')\r
+                IncludePathList.append(IncludePath)\r
+            FileMacroList.append(self._FILE_MACRO_TEMPLATE.Replace({"macro_name": "NASM_INC", "source_file": IncludePathList}))\r
+            break\r
 \r
         # Generate macros used to represent files containing list of input files\r
         for ListFileMacro in self.ListFileMacros:\r
@@ -606,11 +615,11 @@ cleanlib:
                 False\r
                 )\r
 \r
-        # Edk modules need <BaseName>StrDefs.h for string ID\r
-        #if MyAgo.AutoGenVersion < 0x00010005 and len(MyAgo.UnicodeFileList) > 0:\r
-        #    BcTargetList = ['strdefs']\r
-        #else:\r
-        #    BcTargetList = []\r
+        # Generate objlist used to create .obj file\r
+        for Type in self.ObjTargetDict:\r
+            NewLine = ' '.join(list(self.ObjTargetDict[Type]))\r
+            FileMacroList.append("OBJLIST_%s = %s" % (list(self.ObjTargetDict.keys()).index(Type), NewLine))\r
+\r
         BcTargetList = []\r
 \r
         MakefileName = self._FILE_NAME_[self._FileType]\r
@@ -654,7 +663,7 @@ cleanlib:
             "module_relative_directory" : MyAgo.SourceDir,\r
             "module_dir"                : mws.join (self.Macros["WORKSPACE"], MyAgo.SourceDir),\r
             "package_relative_directory": package_rel_dir,\r
-            "module_extra_defines"      : ["%s = %s" % (k, v) for k, v in MyAgo.Module.Defines.iteritems()],\r
+            "module_extra_defines"      : ["%s = %s" % (k, v) for k, v in MyAgo.Module.Defines.items()],\r
 \r
             "architecture"              : MyAgo.Arch,\r
             "toolchain_tag"             : MyAgo.ToolChain,\r
@@ -668,8 +677,8 @@ cleanlib:
             "separator"                 : Separator,\r
             "module_tool_definitions"   : ToolsDef,\r
 \r
-            "shell_command_code"        : self._SHELL_CMD_[self._FileType].keys(),\r
-            "shell_command"             : self._SHELL_CMD_[self._FileType].values(),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
 \r
             "module_entry_point"        : ModuleEntryPoint,\r
             "image_entry_point"         : ImageEntryPoint,\r
@@ -709,7 +718,7 @@ cleanlib:
             for index, Str in enumerate(FfsCmdList):\r
                 if '-o' == Str:\r
                     OutputFile = FfsCmdList[index + 1]\r
-                if '-i' == Str:\r
+                if '-i' == Str or "-oi" == Str:\r
                     if DepsFileList == []:\r
                         DepsFileList = [FfsCmdList[index + 1]]\r
                     else:\r
@@ -896,6 +905,44 @@ 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
+        # 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
+            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
@@ -920,6 +967,10 @@ cleanlib:
         for File in DepSet:\r
             self.CommonFileDependency.append(self.PlaceMacro(File.Path, self.Macros))\r
 \r
+        CmdSumDict = {}\r
+        CmdTargetDict = {}\r
+        CmdCppDict = {}\r
+        DependencyDict = FileDependencyDict.copy()\r
         for File in FileDependencyDict:\r
             # skip non-C files\r
             if File.Ext not in [".c", ".C"] or File.Name == "AutoGen.c":\r
@@ -927,8 +978,15 @@ cleanlib:
             NewDepSet = set(FileDependencyDict[File])\r
             NewDepSet -= DepSet\r
             FileDependencyDict[File] = ["$(COMMON_DEPS)"] + list(NewDepSet)\r
+            DependencyDict[File] = list(NewDepSet)\r
 \r
         # Convert target description object to target string in makefile\r
+        if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and TAB_C_CODE_FILE in self._AutoGenObject.Targets:\r
+            for T in self._AutoGenObject.Targets[TAB_C_CODE_FILE]:\r
+                NewFile = self.PlaceMacro(str(T), self.Macros)\r
+                if not self.ObjTargetDict.get(T.Target.SubDir):\r
+                    self.ObjTargetDict[T.Target.SubDir] = set()\r
+                self.ObjTargetDict[T.Target.SubDir].add(NewFile)\r
         for Type in self._AutoGenObject.Targets:\r
             for T in self._AutoGenObject.Targets[Type]:\r
                 # Generate related macros if needed\r
@@ -940,9 +998,12 @@ cleanlib:
                     self.ListFileMacros[T.IncListFileMacro] = []\r
 \r
                 Deps = []\r
+                CCodeDeps = []\r
                 # Add force-dependencies\r
                 for Dep in T.Dependencies:\r
                     Deps.append(self.PlaceMacro(str(Dep), self.Macros))\r
+                    if Dep != '$(MAKE_FILE)':\r
+                        CCodeDeps.append(self.PlaceMacro(str(Dep), self.Macros))\r
                 # Add inclusion-dependencies\r
                 if len(T.Inputs) == 1 and T.Inputs[0] in FileDependencyDict:\r
                     for F in FileDependencyDict[T.Inputs[0]]:\r
@@ -952,7 +1013,7 @@ cleanlib:
                     NewFile = self.PlaceMacro(str(F), self.Macros)\r
                     # In order to use file list macro as dependency\r
                     if T.GenListFile:\r
-                        # gnu tools need forward slash path separater, even on Windows\r
+                        # gnu tools need forward slash path separator, even on Windows\r
                         self.ListFileMacros[T.ListFileMacro].append(str(F).replace ('\\', '/'))\r
                         self.FileListMacros[T.FileListMacro].append(NewFile)\r
                     elif T.GenFileListMacro:\r
@@ -966,17 +1027,69 @@ cleanlib:
                     if Type in [TAB_OBJECT_FILE, TAB_STATIC_LIBRARY]:\r
                         Deps.append("$(%s)" % T.ListFileMacro)\r
 \r
-                TargetDict = {\r
-                    "target"    :   self.PlaceMacro(T.Target.Path, self.Macros),\r
-                    "cmd"       :   "\n\t".join(T.Commands),\r
-                    "deps"      :   Deps\r
-                }\r
-                self.BuildTargetList.append(self._BUILD_TARGET_TEMPLATE.Replace(TargetDict))\r
-\r
+                if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and Type == TAB_C_CODE_FILE:\r
+                    T, CmdTarget, CmdTargetDict, CmdCppDict = self.ParserCCodeFile(T, Type, CmdSumDict, CmdTargetDict, CmdCppDict, DependencyDict)\r
+                    TargetDict = {"target": self.PlaceMacro(T.Target.Path, self.Macros), "cmd": "\n\t".join(T.Commands),"deps": CCodeDeps}\r
+                    CmdLine = self._BUILD_TARGET_TEMPLATE.Replace(TargetDict).rstrip().replace('\t$(OBJLIST', '$(OBJLIST')\r
+                    if T.Commands:\r
+                        CmdLine = '%s%s' %(CmdLine, TAB_LINE_BREAK)\r
+                    if CCodeDeps or CmdLine:\r
+                        self.BuildTargetList.append(CmdLine)\r
+                else:\r
+                    TargetDict = {"target": self.PlaceMacro(T.Target.Path, self.Macros), "cmd": "\n\t".join(T.Commands),"deps": Deps}\r
+                    self.BuildTargetList.append(self._BUILD_TARGET_TEMPLATE.Replace(TargetDict))\r
+\r
+    def ParserCCodeFile(self, T, Type, CmdSumDict, CmdTargetDict, CmdCppDict, DependencyDict):\r
+        if not CmdSumDict:\r
+            for item in self._AutoGenObject.Targets[Type]:\r
+                CmdSumDict[item.Target.SubDir] = item.Target.BaseName\r
+                for CppPath in item.Inputs:\r
+                    Path = self.PlaceMacro(CppPath.Path, self.Macros)\r
+                    if CmdCppDict.get(item.Target.SubDir):\r
+                        CmdCppDict[item.Target.SubDir].append(Path)\r
+                    else:\r
+                        CmdCppDict[item.Target.SubDir] = ['$(MAKE_FILE)', Path]\r
+                    if CppPath.Path in DependencyDict:\r
+                        for Temp in DependencyDict[CppPath.Path]:\r
+                            try:\r
+                                Path = self.PlaceMacro(Temp.Path, self.Macros)\r
+                            except:\r
+                                continue\r
+                            if Path not in (self.CommonFileDependency + CmdCppDict[item.Target.SubDir]):\r
+                                CmdCppDict[item.Target.SubDir].append(Path)\r
+        if T.Commands:\r
+            CommandList = T.Commands[:]\r
+            for Item in CommandList[:]:\r
+                SingleCommandList = Item.split()\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
+                            break\r
+                    else: continue\r
+                    if CmdSign not in list(CmdTargetDict.keys()):\r
+                        CmdTargetDict[CmdSign] = Item.replace(Temp, CmdSign)\r
+                    else:\r
+                        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
+                        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
+                    else:\r
+                        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
-            if not LibraryAutoGen.IsBinaryModule:\r
+            if not LibraryAutoGen.IsBinaryModule and not LibraryAutoGen.CanSkipbyHash():\r
                 self.LibraryBuildDirectoryList.append(self.PlaceMacro(LibraryAutoGen.BuildDir, self.Macros))\r
 \r
     ## Return a list containing source file's dependencies\r
@@ -996,7 +1109,7 @@ cleanlib:
     ## 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 dependecies will be only searched\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
@@ -1031,17 +1144,21 @@ cleanlib:
                 CurrentFileDependencyList = DepDb[F]\r
             else:\r
                 try:\r
-                    Fd = open(F.Path, 'r')\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
-\r
-                FileContent = Fd.read()\r
-                Fd.close()\r
                 if len(FileContent) == 0:\r
                     continue\r
-\r
-                if FileContent[0] == 0xff or FileContent[0] == 0xfe:\r
-                    FileContent = unicode(FileContent, "utf-16")\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
@@ -1268,8 +1385,8 @@ ${BEGIN}\t-@${create_directory_command}\n${END}\
             "separator"                 : Separator,\r
             "module_tool_definitions"   : ToolsDef,\r
 \r
-            "shell_command_code"        : self._SHELL_CMD_[self._FileType].keys(),\r
-            "shell_command"             : self._SHELL_CMD_[self._FileType].values(),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
 \r
             "create_directory_command"  : self.GetCreateDirectoryCommand(self.IntermediateDirectoryList),\r
             "custom_makefile_content"   : CustomMakefile\r
@@ -1442,8 +1559,8 @@ cleanlib:
 \r
             "toolchain_tag"             : MyAgo.ToolChain,\r
             "build_target"              : MyAgo.BuildTarget,\r
-            "shell_command_code"        : self._SHELL_CMD_[self._FileType].keys(),\r
-            "shell_command"             : self._SHELL_CMD_[self._FileType].values(),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
             "build_architecture_list"   : MyAgo.Arch,\r
             "architecture"              : MyAgo.Arch,\r
             "separator"                 : Separator,\r
@@ -1475,7 +1592,7 @@ cleanlib:
     def GetLibraryBuildDirectoryList(self):\r
         DirList = []\r
         for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:\r
-            if not LibraryAutoGen.IsBinaryModule:\r
+            if not LibraryAutoGen.IsBinaryModule and not LibraryAutoGen.CanSkipbyHash():\r
                 DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))\r
         return DirList\r
 \r
@@ -1518,13 +1635,9 @@ class TopLevelMakefile(BuildFile):
         if MyAgo.FdfFile is not None and MyAgo.FdfFile != "":\r
             FdfFileList = [MyAgo.FdfFile]\r
             # macros passed to GenFds\r
-            MacroList.append('"%s=%s"' % ("EFI_SOURCE", GlobalData.gEfiSource.replace('\\', '\\\\')))\r
-            MacroList.append('"%s=%s"' % ("EDK_SOURCE", GlobalData.gEdkSource.replace('\\', '\\\\')))\r
             MacroDict = {}\r
             MacroDict.update(GlobalData.gGlobalDefines)\r
             MacroDict.update(GlobalData.gCommandLineDefines)\r
-            MacroDict.pop("EFI_SOURCE", "dummy")\r
-            MacroDict.pop("EDK_SOURCE", "dummy")\r
             for MacroName in MacroDict:\r
                 if MacroDict[MacroName] != "":\r
                     MacroList.append('"%s=%s"' % (MacroName, MacroDict[MacroName].replace('\\', '\\\\')))\r
@@ -1578,8 +1691,8 @@ class TopLevelMakefile(BuildFile):
 \r
             "toolchain_tag"             : MyAgo.ToolChain,\r
             "build_target"              : MyAgo.BuildTarget,\r
-            "shell_command_code"        : self._SHELL_CMD_[self._FileType].keys(),\r
-            "shell_command"             : self._SHELL_CMD_[self._FileType].values(),\r
+            "shell_command_code"        : list(self._SHELL_CMD_[self._FileType].keys()),\r
+            "shell_command"             : list(self._SHELL_CMD_[self._FileType].values()),\r
             'arch'                      : list(MyAgo.ArchList),\r
             "build_architecture_list"   : ','.join(MyAgo.ArchList),\r
             "separator"                 : Separator,\r
@@ -1615,7 +1728,7 @@ class TopLevelMakefile(BuildFile):
     def GetLibraryBuildDirectoryList(self):\r
         DirList = []\r
         for LibraryAutoGen in self._AutoGenObject.LibraryAutoGenList:\r
-            if not LibraryAutoGen.IsBinaryModule:\r
+            if not LibraryAutoGen.IsBinaryModule and not LibraryAutoGen.CanSkipbyHash():\r
                 DirList.append(os.path.join(self._AutoGenObject.BuildDir, LibraryAutoGen.BuildDir))\r
         return DirList\r
 \r