]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTool: Add cache for the result of SkipAutogen.
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index 381dbc0a71fa985a51c90fe24cfa52cdae5a51ff..d100648606f7cbea022007373c4cabbf52e0d737 100644 (file)
@@ -241,7 +241,7 @@ class WorkspaceAutoGen(AutoGen):
             super(WorkspaceAutoGen, self).__init__(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
             self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
             self._Init = True\r
-    \r
+\r
     ## Initialize WorkspaceAutoGen\r
     #\r
     #   @param  WorkspaceDir            Root directory of workspace\r
@@ -310,7 +310,7 @@ class WorkspaceAutoGen(AutoGen):
                             ExtraData="Build target [%s] is not supported by the platform. [Valid target: %s]"\r
                                       % (self.BuildTarget, " ".join(self.Platform.BuildTargets)))\r
 \r
-        \r
+\r
         # parse FDF file to get PCDs in it, if any\r
         if not self.FdfFile:\r
             self.FdfFile = self.Platform.FlashDefinition\r
@@ -763,7 +763,7 @@ class WorkspaceAutoGen(AutoGen):
 \r
     ## _CheckDuplicateInFV() method\r
     #\r
-    # Check whether there is duplicate modules/files exist in FV section. \r
+    # Check whether there is duplicate modules/files exist in FV section.\r
     # The check base on the file GUID;\r
     #\r
     def _CheckDuplicateInFV(self, Fdf):\r
@@ -794,7 +794,7 @@ class WorkspaceAutoGen(AutoGen):
                                                                                                                                    Module.Guid.upper()),\r
                                                     ExtraData=self.FdfFile)\r
                     #\r
-                    # Some INF files not have entity in DSC file. \r
+                    # Some INF files not have entity in DSC file.\r
                     #\r
                     if not InfFoundFlag:\r
                         if FfsFile.InfFileName.find('$') == -1:\r
@@ -804,7 +804,7 @@ class WorkspaceAutoGen(AutoGen):
 \r
                             PathClassObj = PathClass(FfsFile.InfFileName, self.WorkspaceDir)\r
                             #\r
-                            # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use \r
+                            # Here we just need to get FILE_GUID from INF file, use 'COMMON' as ARCH attribute. and use\r
                             # BuildObject from one of AutoGenObjectList is enough.\r
                             #\r
                             InfObj = self.AutoGenObjectList[0].BuildDatabase.WorkspaceDb.BuildObject[PathClassObj, TAB_ARCH_COMMON, self.BuildTarget, self.ToolChain]\r
@@ -823,7 +823,7 @@ class WorkspaceAutoGen(AutoGen):
 \r
                 if FfsFile.NameGuid is not None:\r
                     #\r
-                    # If the NameGuid reference a PCD name. \r
+                    # If the NameGuid reference a PCD name.\r
                     # The style must match: PCD(xxxx.yyy)\r
                     #\r
                     if gPCDAsGuidPattern.match(FfsFile.NameGuid):\r
@@ -900,7 +900,7 @@ class WorkspaceAutoGen(AutoGen):
             for Pcd in Pa.Platform.Pcds:\r
                 PcdType = Pa.Platform.Pcds[Pcd].Type\r
 \r
-                # If no PCD type, this PCD comes from FDF \r
+                # If no PCD type, this PCD comes from FDF\r
                 if not PcdType:\r
                     continue\r
 \r
@@ -992,14 +992,14 @@ class WorkspaceAutoGen(AutoGen):
     ## Check the PCDs token value conflict in each DEC file.\r
     #\r
     # Will cause build break and raise error message while two PCDs conflict.\r
-    # \r
+    #\r
     # @return  None\r
     #\r
     def _CheckAllPcdsTokenValueConflict(self):\r
         for Pa in self.AutoGenObjectList:\r
             for Package in Pa.PackageList:\r
                 PcdList = Package.Pcds.values()\r
-                PcdList.sort(lambda x, y: cmp(int(x.TokenValue, 0), int(y.TokenValue, 0))) \r
+                PcdList.sort(lambda x, y: cmp(int(x.TokenValue, 0), int(y.TokenValue, 0)))\r
                 Count = 0\r
                 while (Count < len(PcdList) - 1) :\r
                     Item = PcdList[Count]\r
@@ -1124,20 +1124,20 @@ class PlatformAutoGen(AutoGen):
             self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch)\r
             self._Init = True\r
     #\r
-    # Used to store all PCDs for both PEI and DXE phase, in order to generate \r
+    # Used to store all PCDs for both PEI and DXE phase, in order to generate\r
     # correct PCD database\r
-    # \r
+    #\r
     _DynaPcdList_ = []\r
     _NonDynaPcdList_ = []\r
     _PlatformPcds = {}\r
-    \r
+\r
     #\r
-    # The priority list while override build option \r
+    # The priority list while override build option\r
     #\r
     PrioList = {"0x11111"  : 16,     #  TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)\r
                 "0x01111"  : 15,     #  ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE\r
                 "0x10111"  : 14,     #  TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE\r
-                "0x00111"  : 13,     #  ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE \r
+                "0x00111"  : 13,     #  ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE\r
                 "0x11011"  : 12,     #  TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE\r
                 "0x01011"  : 11,     #  ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE\r
                 "0x10011"  : 10,     #  TARGET_*********_****_COMMANDTYPE_ATTRIBUTE\r
@@ -1289,9 +1289,9 @@ class PlatformAutoGen(AutoGen):
     #\r
     def CollectFixedAtBuildPcds(self):\r
         for LibAuto in self.LibraryAutoGenList:\r
-            FixedAtBuildPcds = {}  \r
-            ShareFixedAtBuildPcdsSameValue = {} \r
-            for Module in LibAuto._ReferenceModules:                \r
+            FixedAtBuildPcds = {}\r
+            ShareFixedAtBuildPcdsSameValue = {}\r
+            for Module in LibAuto._ReferenceModules:\r
                 for Pcd in Module.FixedAtBuildPcds + LibAuto.FixedAtBuildPcds:\r
                     key = ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
                     if key not in FixedAtBuildPcds:\r
@@ -1299,7 +1299,7 @@ class PlatformAutoGen(AutoGen):
                         FixedAtBuildPcds[key] = Pcd.DefaultValue\r
                     else:\r
                         if FixedAtBuildPcds[key] != Pcd.DefaultValue:\r
-                            ShareFixedAtBuildPcdsSameValue[key] = False      \r
+                            ShareFixedAtBuildPcdsSameValue[key] = False\r
             for Pcd in LibAuto.FixedAtBuildPcds:\r
                 key = ".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName))\r
                 if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in self.NonDynamicPcdDict:\r
@@ -1308,7 +1308,7 @@ class PlatformAutoGen(AutoGen):
                     DscPcd = self.NonDynamicPcdDict[(Pcd.TokenCName, Pcd.TokenSpaceGuidCName)]\r
                     if DscPcd.Type != TAB_PCDS_FIXED_AT_BUILD:\r
                         continue\r
-                if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]:                    \r
+                if key in ShareFixedAtBuildPcdsSameValue and ShareFixedAtBuildPcdsSameValue[key]:\r
                     LibAuto.ConstPcd[key] = FixedAtBuildPcds[key]\r
 \r
     def CollectVariables(self, DynamicPcdSet):\r
@@ -1405,7 +1405,7 @@ class PlatformAutoGen(AutoGen):
         for F in self.Platform.Modules.keys():\r
             M = ModuleAutoGen(self.Workspace, F, self.BuildTarget, self.ToolChain, self.Arch, self.MetaFile)\r
             #GuidValue.update(M.Guids)\r
-            \r
+\r
             self.Platform.Modules[F].M = M\r
 \r
             for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:\r
@@ -1417,27 +1417,27 @@ class PlatformAutoGen(AutoGen):
                 if M.IsBinaryModule == True:\r
                     PcdFromModule.IsFromBinaryInf = True\r
 \r
-                # Check the PCD from DSC or not \r
+                # Check the PCD from DSC or not\r
                 PcdFromModule.IsFromDsc = (PcdFromModule.TokenCName, PcdFromModule.TokenSpaceGuidCName) in self.Platform.Pcds\r
 \r
                 if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET or PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:\r
                     if F.Path not in FdfModuleList:\r
-                        # If one of the Source built modules listed in the DSC is not listed \r
-                        # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic \r
-                        # access method (it is only listed in the DEC file that declares the \r
+                        # If one of the Source built modules listed in the DSC is not listed\r
+                        # in FDF modules, and the INF lists a PCD can only use the PcdsDynamic\r
+                        # access method (it is only listed in the DEC file that declares the\r
                         # PCD as PcdsDynamic), then build tool will report warning message\r
-                        # notify the PI that they are attempting to build a module that must \r
-                        # be included in a flash image in order to be functional. These Dynamic \r
-                        # PCD will not be added into the Database unless it is used by other \r
+                        # notify the PI that they are attempting to build a module that must\r
+                        # be included in a flash image in order to be functional. These Dynamic\r
+                        # PCD will not be added into the Database unless it is used by other\r
                         # modules that are included in the FDF file.\r
                         if PcdFromModule.Type in PCD_DYNAMIC_TYPE_SET and \\r
                             PcdFromModule.IsFromBinaryInf == False:\r
                             # Print warning message to let the developer make a determine.\r
                             continue\r
-                        # If one of the Source built modules listed in the DSC is not listed in \r
-                        # FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx \r
-                        # access method (it is only listed in the DEC file that declares the \r
-                        # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the \r
+                        # If one of the Source built modules listed in the DSC is not listed in\r
+                        # FDF modules, and the INF lists a PCD can only use the PcdsDynamicEx\r
+                        # access method (it is only listed in the DEC file that declares the\r
+                        # PCD as PcdsDynamicEx), then DO NOT break the build; DO NOT add the\r
                         # PCD to the Platform's PCD Database.\r
                         if PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:\r
                             continue\r
@@ -1465,14 +1465,14 @@ class PlatformAutoGen(AutoGen):
                         PcdFromModule.Pending = False\r
                         self._NonDynaPcdList_.append (PcdFromModule)\r
         DscModuleSet = {os.path.normpath(ModuleInf.Path) for ModuleInf in self.Platform.Modules}\r
-        # add the PCD from modules that listed in FDF but not in DSC to Database \r
+        # add the PCD from modules that listed in FDF but not in DSC to Database\r
         for InfName in FdfModuleList:\r
             if InfName not in DscModuleSet:\r
                 InfClass = PathClass(InfName)\r
                 M = self.BuildDatabase[InfClass, self.Arch, self.BuildTarget, self.ToolChain]\r
-                # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source) \r
-                # for different Arch. PCDs in source module for different Arch is already added before, so skip the source module here. \r
-                # For binary module, if in current arch, we need to list the PCDs into database.   \r
+                # If a module INF in FDF but not in current arch's DSC module list, it must be module (either binary or source)\r
+                # for different Arch. PCDs in source module for different Arch is already added before, so skip the source module here.\r
+                # For binary module, if in current arch, we need to list the PCDs into database.\r
                 if not M.IsSupportedArch:\r
                     continue\r
                 # Override the module PCD setting by platform setting\r
@@ -1497,20 +1497,20 @@ class PlatformAutoGen(AutoGen):
                         self._NonDynaPcdList_.append(PcdFromModule)\r
                     if PcdFromModule in self._DynaPcdList_ and PcdFromModule.Phase == 'PEI' and PcdFromModule.Type in PCD_DYNAMIC_EX_TYPE_SET:\r
                         # Overwrite the phase of any the same PCD existing, if Phase is PEI.\r
-                        # It is to solve the case that a dynamic PCD used by a PEM module/PEI \r
+                        # It is to solve the case that a dynamic PCD used by a PEM module/PEI\r
                         # module & DXE module at a same time.\r
                         # Overwrite the type of the PCDs in source INF by the type of AsBuild\r
-                        # INF file as DynamicEx. \r
+                        # INF file as DynamicEx.\r
                         Index = self._DynaPcdList_.index(PcdFromModule)\r
                         self._DynaPcdList_[Index].Phase = PcdFromModule.Phase\r
                         self._DynaPcdList_[Index].Type = PcdFromModule.Type\r
         for PcdFromModule in self._NonDynaPcdList_:\r
-            # If a PCD is not listed in the DSC file, but binary INF files used by \r
-            # this platform all (that use this PCD) list the PCD in a [PatchPcds] \r
-            # section, AND all source INF files used by this platform the build \r
-            # that use the PCD list the PCD in either a [Pcds] or [PatchPcds] \r
+            # If a PCD is not listed in the DSC file, but binary INF files used by\r
+            # this platform all (that use this PCD) list the PCD in a [PatchPcds]\r
+            # section, AND all source INF files used by this platform the build\r
+            # that use the PCD list the PCD in either a [Pcds] or [PatchPcds]\r
             # section, then the tools must NOT add the PCD to the Platform's PCD\r
-            # Database; the build must assign the access method for this PCD as \r
+            # Database; the build must assign the access method for this PCD as\r
             # PcdsPatchableInModule.\r
             if PcdFromModule not in self._DynaPcdList_:\r
                 continue\r
@@ -1533,7 +1533,7 @@ class PlatformAutoGen(AutoGen):
         self._DynamicPcdList = self._DynaPcdList_\r
         #\r
         # Sort dynamic PCD list to:\r
-        # 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should \r
+        # 1) If PCD's datum type is VOID* and value is unicode string which starts with L, the PCD item should\r
         #    try to be put header of dynamicd List\r
         # 2) If PCD is HII type, the PCD item should be put after unicode type PCD\r
         #\r
@@ -1554,7 +1554,7 @@ class PlatformAutoGen(AutoGen):
             if self._PlatformPcds[item].DatumType and self._PlatformPcds[item].DatumType not in [TAB_UINT8, TAB_UINT16, TAB_UINT32, TAB_UINT64, TAB_VOID, "BOOLEAN"]:\r
                 self._PlatformPcds[item].DatumType = TAB_VOID\r
 \r
-        if (self.Workspace.ArchList[-1] == self.Arch): \r
+        if (self.Workspace.ArchList[-1] == self.Arch):\r
             for Pcd in self._DynamicPcdList:\r
                 # just pick the a value to determine whether is unicode string type\r
                 Sku = Pcd.SkuInfoList.values()[0]\r
@@ -1637,7 +1637,7 @@ class PlatformAutoGen(AutoGen):
             #\r
             # Fix the PCDs define in VPD PCD section that never referenced by module.\r
             # An example is PCD for signature usage.\r
-            #            \r
+            #\r
             for DscPcd in PlatformPcds:\r
                 DscPcdEntry = self._PlatformPcds[DscPcd]\r
                 if DscPcdEntry.Type in [TAB_PCDS_DYNAMIC_VPD, TAB_PCDS_DYNAMIC_EX_VPD]:\r
@@ -1659,8 +1659,8 @@ class PlatformAutoGen(AutoGen):
                                 defaultindex = SkuObjList.index((TAB_DEFAULT, DefaultSku))\r
                                 SkuObjList[0], SkuObjList[defaultindex] = SkuObjList[defaultindex], SkuObjList[0]\r
                             for (SkuName, Sku) in SkuObjList:\r
-                                Sku.VpdOffset = Sku.VpdOffset.strip() \r
-                                \r
+                                Sku.VpdOffset = Sku.VpdOffset.strip()\r
+\r
                                 # Need to iterate DEC pcd information to get the value & datumtype\r
                                 for eachDec in self.PackageList:\r
                                     for DecPcd in eachDec.Pcds:\r
@@ -1671,8 +1671,8 @@ class PlatformAutoGen(AutoGen):
                                             EdkLogger.warn("build", "Unreferenced vpd pcd used!",\r
                                                             File=self.MetaFile, \\r
                                                             ExtraData = "PCD: %s.%s used in the DSC file %s is unreferenced." \\r
-                                                            %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path))  \r
-                                                                                  \r
+                                                            %(DscPcdEntry.TokenSpaceGuidCName, DscPcdEntry.TokenCName, self.Platform.MetaFile.Path))\r
+\r
                                             DscPcdEntry.DatumType    = DecPcdEntry.DatumType\r
                                             DscPcdEntry.DefaultValue = DecPcdEntry.DefaultValue\r
                                             DscPcdEntry.TokenValue = DecPcdEntry.TokenValue\r
@@ -1680,7 +1680,7 @@ class PlatformAutoGen(AutoGen):
                                             # Only fix the value while no value provided in DSC file.\r
                                             if not Sku.DefaultValue:\r
                                                 DscPcdEntry.SkuInfoList[DscPcdEntry.SkuInfoList.keys()[0]].DefaultValue = DecPcdEntry.DefaultValue\r
-                                                                                                                    \r
+\r
                                 if DscPcdEntry not in self._DynamicPcdList:\r
                                     self._DynamicPcdList.append(DscPcdEntry)\r
                                 Sku.VpdOffset = Sku.VpdOffset.strip()\r
@@ -1711,7 +1711,7 @@ class PlatformAutoGen(AutoGen):
                                     VpdFile.Add(DscPcdEntry, SkuName, Sku.VpdOffset)\r
                                 SkuValueMap[PcdValue].append(Sku)\r
                                 if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
-                                    NeedProcessVpdMapFile = True \r
+                                    NeedProcessVpdMapFile = True\r
                             if DscPcdEntry.DatumType == TAB_VOID and PcdValue.startswith("L"):\r
                                 UnicodePcdArray.add(DscPcdEntry)\r
                             elif len(Sku.VariableName) > 0:\r
@@ -1723,7 +1723,7 @@ class PlatformAutoGen(AutoGen):
                             VpdSkuMap[DscPcd] = SkuValueMap\r
             if (self.Platform.FlashDefinition is None or self.Platform.FlashDefinition == '') and \\r
                VpdFile.GetCount() != 0:\r
-                EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, \r
+                EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE,\r
                                 "Fail to get FLASH_DEFINITION definition in DSC file %s which is required when DSC contains VPD PCD." % str(self.Platform.MetaFile))\r
 \r
             if VpdFile.GetCount() != 0:\r
@@ -2071,9 +2071,9 @@ class PlatformAutoGen(AutoGen):
             self._PcdTokenNumber = OrderedDict()\r
             TokenNumber = 1\r
             #\r
-            # Make the Dynamic and DynamicEx PCD use within different TokenNumber area. \r
+            # Make the Dynamic and DynamicEx PCD use within different TokenNumber area.\r
             # Such as:\r
-            # \r
+            #\r
             # Dynamic PCD:\r
             # TokenNumber 0 ~ 10\r
             # DynamicEx PCD:\r
@@ -2388,7 +2388,7 @@ class PlatformAutoGen(AutoGen):
     #   @param  Options     Options to be expanded\r
     #\r
     #   @retval options     Options expanded\r
-    #      \r
+    #\r
     def _ExpandBuildOption(self, Options, ModuleStyle=None):\r
         BuildOptions = {}\r
         FamilyMatch  = False\r
@@ -2414,9 +2414,9 @@ class PlatformAutoGen(AutoGen):
                     if OverrideList.get(Key[1]) is not None:\r
                         OverrideList.pop(Key[1])\r
                     OverrideList[Key[1]] = Options[Key]\r
-        \r
+\r
         #\r
-        # Use the highest priority value. \r
+        # Use the highest priority value.\r
         #\r
         if (len(OverrideList) >= 2):\r
             KeyList = OverrideList.keys()\r
@@ -2427,7 +2427,7 @@ class PlatformAutoGen(AutoGen):
                     NextKey = KeyList[Index1 + Index + 1]\r
                     #\r
                     # Compare two Key, if one is included by another, choose the higher priority one\r
-                    #                    \r
+                    #\r
                     Target2, ToolChain2, Arch2, CommandType2, Attr2 = NextKey.split("_")\r
                     if (Target1 == Target2 or Target1 == "*" or Target2 == "*") and\\r
                         (ToolChain1 == ToolChain2 or ToolChain1 == "*" or ToolChain2 == "*") and\\r
@@ -2441,7 +2441,7 @@ class PlatformAutoGen(AutoGen):
                         else:\r
                             if Options.get((self.BuildRuleFamily, NowKey)) is not None:\r
                                 Options.pop((self.BuildRuleFamily, NowKey))\r
-                                                           \r
+\r
         for Key in Options:\r
             if ModuleStyle is not None and len (Key) > 2:\r
                 # Check Module style is EDK or EDKII.\r
@@ -2639,7 +2639,7 @@ class ModuleAutoGen(AutoGen):
                               % (MetaFile, Arch))\r
             return None\r
         return obj\r
-            \r
+\r
     ## Initialize ModuleAutoGen\r
     #\r
     #   @param      Workspace           EdkIIWorkspaceBuild object\r
@@ -2737,13 +2737,13 @@ class ModuleAutoGen(AutoGen):
 \r
         self.AutoGenDepSet = set()\r
 \r
-        \r
+\r
         ## The Modules referenced to this Library\r
         #  Only Library has this attribute\r
-        self._ReferenceModules        = []        \r
-        \r
+        self._ReferenceModules        = []\r
+\r
         ## Store the FixedAtBuild Pcds\r
-        #  \r
+        #\r
         self._FixedAtBuildPcds         = []\r
         self.ConstPcd                  = {}\r
 \r
@@ -2759,8 +2759,8 @@ class ModuleAutoGen(AutoGen):
                 continue\r
             if Pcd not in self._FixedAtBuildPcds:\r
                 self._FixedAtBuildPcds.append(Pcd)\r
-                \r
-        return self._FixedAtBuildPcds        \r
+\r
+        return self._FixedAtBuildPcds\r
 \r
     def _GetUniqueBaseName(self):\r
         BaseName = self.Name\r
@@ -2780,7 +2780,7 @@ class ModuleAutoGen(AutoGen):
             self._Macro = OrderedDict()\r
             self._Macro["WORKSPACE"             ] = self.WorkspaceDir\r
             self._Macro["MODULE_NAME"           ] = self.Name\r
-            self._Macro["MODULE_NAME_GUID"      ] = self._GetUniqueBaseName()\r
+            self._Macro["MODULE_NAME_GUID"      ] = self.UniqueBaseName\r
             self._Macro["MODULE_GUID"           ] = self.Guid\r
             self._Macro["MODULE_VERSION"        ] = self.Version\r
             self._Macro["MODULE_TYPE"           ] = self.ModuleType\r
@@ -2959,7 +2959,7 @@ class ModuleAutoGen(AutoGen):
                     continue\r
                 PackageList.append(Package)\r
         return PackageList\r
-    \r
+\r
     ## Get the depex string\r
     #\r
     # @return : a string contain all depex expresion.\r
@@ -2988,7 +2988,7 @@ class ModuleAutoGen(AutoGen):
                           (Arch.upper() == self.Arch.upper() and \\r
                           ModuleType.upper() in [TAB_ARCH_COMMON, self.ModuleType.upper()]):\r
                             DepexList.append({(Arch, ModuleType): DepexExpr})\r
-        \r
+\r
         #the type of build module is USER_DEFINED.\r
         if self.ModuleType.upper() == SUP_MODULE_USER_DEFINED:\r
             for Depex in DepexList:\r
@@ -2999,7 +2999,7 @@ class ModuleAutoGen(AutoGen):
             if not DepexStr:\r
                 return '[Depex.%s]\n' % self.Arch\r
             return DepexStr\r
-        \r
+\r
         #the type of build module not is USER_DEFINED.\r
         Count = 0\r
         for Depex in DepexList:\r
@@ -3019,7 +3019,7 @@ class ModuleAutoGen(AutoGen):
         if not DepexStr:\r
             return '[Depex.%s]\n' % self.Arch\r
         return '[Depex.%s]\n#  ' % self.Arch + DepexStr\r
-    \r
+\r
     ## Merge dependency expression\r
     #\r
     #   @retval     list    The token list of the dependency expression after parsed\r
@@ -3155,14 +3155,14 @@ class ModuleAutoGen(AutoGen):
                 #\r
                 self._BuildOptionIncPathList = []\r
                 return self._BuildOptionIncPathList\r
-            \r
+\r
             BuildOptionIncPathList = []\r
             for Tool in ('CC', 'PP', 'VFRPP', 'ASLPP', 'ASLCC', 'APP', 'ASM'):\r
                 try:\r
                     FlagOption = self.BuildOption[Tool]['FLAGS']\r
                 except KeyError:\r
                     FlagOption = ''\r
-                \r
+\r
                 if self.PlatformInfo.ToolChainFamily != 'RVCT':\r
                     IncPathList = [NormPath(Path, self.Macros) for Path in BuildOptIncludeRegEx.findall(FlagOption)]\r
                 else:\r
@@ -3175,7 +3175,7 @@ class ModuleAutoGen(AutoGen):
                         IncPathList.extend(NormPath(PathEntry, self.Macros) for PathEntry in PathList)\r
 \r
                 #\r
-                # EDK II modules must not reference header files outside of the packages they depend on or \r
+                # EDK II modules must not reference header files outside of the packages they depend on or\r
                 # within the module's directory tree. Report error if violation.\r
                 #\r
                 if self.AutoGenVersion >= 0x00010005:\r
@@ -3187,13 +3187,13 @@ class ModuleAutoGen(AutoGen):
                                             ExtraData=ErrMsg,\r
                                             File=str(self.MetaFile))\r
 \r
-                \r
+\r
                 BuildOptionIncPathList += IncPathList\r
-            \r
+\r
             self._BuildOptionIncPathList = BuildOptionIncPathList\r
-        \r
+\r
         return self._BuildOptionIncPathList\r
-        \r
+\r
     ## Return a list of files which can be built from source\r
     #\r
     #  What kind of files can be built is determined by build rules in\r
@@ -3202,14 +3202,16 @@ class ModuleAutoGen(AutoGen):
     def _GetSourceFileList(self):\r
         if self._SourceFileList is None:\r
             self._SourceFileList = []\r
+            ToolChainTagSet = {"", "*", self.ToolChain}\r
+            ToolChainFamilySet = {"", "*", self.ToolChainFamily, self.BuildRuleFamily}\r
             for F in self.Module.Sources:\r
                 # match tool chain\r
-                if F.TagName not in ("", "*", self.ToolChain):\r
+                if F.TagName not in ToolChainTagSet:\r
                     EdkLogger.debug(EdkLogger.DEBUG_9, "The toolchain [%s] for processing file [%s] is found, "\r
                                     "but [%s] is needed" % (F.TagName, str(F), self.ToolChain))\r
                     continue\r
                 # match tool chain family or build rule family\r
-                if F.ToolChainFamily not in ("", "*", self.ToolChainFamily, self.BuildRuleFamily):\r
+                if F.ToolChainFamily not in ToolChainFamilySet:\r
                     EdkLogger.debug(\r
                                 EdkLogger.DEBUG_0,\r
                                 "The file [%s] must be built by tools of [%s], " \\r
@@ -3245,7 +3247,7 @@ class ModuleAutoGen(AutoGen):
                 Order_Dict[F].sort(key=lambda i: self.BuildRuleOrder.index(i))\r
                 for Ext in Order_Dict[F][1:]:\r
                     RemoveList.append(F + Ext)\r
-                   \r
+\r
         for item in RemoveList:\r
             FileList.remove(item)\r
 \r
@@ -3688,12 +3690,12 @@ class ModuleAutoGen(AutoGen):
         for SourceFile in self.Module.Sources:\r
             if SourceFile.Type.upper() == ".VFR" :\r
                 #\r
-                # search the .map file to find the offset of vfr binary in the PE32+/TE file. \r
+                # search the .map file to find the offset of vfr binary in the PE32+/TE file.\r
                 #\r
                 VfrUniBaseName[SourceFile.BaseName] = (SourceFile.BaseName + "Bin")\r
             elif SourceFile.Type.upper() == ".UNI" :\r
                 #\r
-                # search the .map file to find the offset of Uni strings binary in the PE32+/TE file. \r
+                # search the .map file to find the offset of Uni strings binary in the PE32+/TE file.\r
                 #\r
                 VfrUniBaseName["UniOffsetName"] = (self.Name + "Strings")\r
 \r
@@ -3725,7 +3727,7 @@ class ModuleAutoGen(AutoGen):
                 #\r
                 UniGuid = [0xe0, 0xc5, 0x13, 0x89, 0xf6, 0x33, 0x86, 0x4d, 0x9b, 0xf1, 0x43, 0xef, 0x89, 0xfc, 0x6, 0x66]\r
                 UniGuid = [chr(ItemGuid) for ItemGuid in UniGuid]\r
-                fStringIO.write(''.join(UniGuid))            \r
+                fStringIO.write(''.join(UniGuid))\r
                 UniValue = pack ('Q', int (Item[1], 16))\r
                 fStringIO.write (UniValue)\r
             else:\r
@@ -3736,13 +3738,13 @@ class ModuleAutoGen(AutoGen):
                 #\r
                 VfrGuid = [0xb4, 0x7c, 0xbc, 0xd0, 0x47, 0x6a, 0x5f, 0x49, 0xaa, 0x11, 0x71, 0x7, 0x46, 0xda, 0x6, 0xa2]\r
                 VfrGuid = [chr(ItemGuid) for ItemGuid in VfrGuid]\r
-                fStringIO.write(''.join(VfrGuid))                   \r
+                fStringIO.write(''.join(VfrGuid))\r
                 VfrValue = pack ('Q', int (Item[1], 16))\r
                 fStringIO.write (VfrValue)\r
         #\r
         # write data into file.\r
         #\r
-        try :  \r
+        try :\r
             fInputfile.write (fStringIO.getvalue())\r
         except:\r
             EdkLogger.error("build", FILE_WRITE_FAILURE, "Write data to file %s failed, please check whether the "\r
@@ -3762,15 +3764,15 @@ class ModuleAutoGen(AutoGen):
 \r
         if self.IsAsBuiltInfCreated:\r
             return\r
-            \r
+\r
         # Skip the following code for EDK I inf\r
         if self.AutoGenVersion < 0x00010005:\r
             return\r
-            \r
+\r
         # Skip the following code for libraries\r
         if self.IsLibrary:\r
             return\r
-            \r
+\r
         # Skip the following code for modules with no source files\r
         if not self.SourceFileList:\r
             return\r
@@ -3778,7 +3780,7 @@ class ModuleAutoGen(AutoGen):
         # Skip the following code for modules without any binary files\r
         if self.BinaryFileList:\r
             return\r
-            \r
+\r
         ### TODO: How to handles mixed source and binary modules\r
 \r
         # Find all DynamicEx and PatchableInModule PCDs used by this module and dependent libraries\r
@@ -4052,7 +4054,7 @@ class ModuleAutoGen(AutoGen):
                             UsageIndex = Index\r
                             break\r
                 if UsageIndex != -1:\r
-                    PcdCommentList[UsageIndex] = '## %s %s %s' % (UsageStr, HiiInfo, PcdCommentList[UsageIndex].replace(UsageStr, '')) \r
+                    PcdCommentList[UsageIndex] = '## %s %s %s' % (UsageStr, HiiInfo, PcdCommentList[UsageIndex].replace(UsageStr, ''))\r
                 else:\r
                     PcdCommentList.append('## UNDEFINED ' + HiiInfo)\r
             PcdComments = '\n  '.join(PcdCommentList)\r
@@ -4067,7 +4069,7 @@ class ModuleAutoGen(AutoGen):
         # Generated LibraryClasses section in comments.\r
         for Library in self.LibraryAutoGenList:\r
             AsBuiltInfDict['libraryclasses_item'].append(Library.MetaFile.File.replace('\\', '/'))\r
-        \r
+\r
         # Generated UserExtensions TianoCore section.\r
         # All tianocore user extensions are copied.\r
         UserExtStr = ''\r
@@ -4081,12 +4083,12 @@ class ModuleAutoGen(AutoGen):
         # Generated depex expression section in comments.\r
         DepexExpresion = self._GetDepexExpresionString()\r
         AsBuiltInfDict['depexsection_item'] = DepexExpresion if DepexExpresion else ''\r
-        \r
+\r
         AsBuiltInf = TemplateString()\r
         AsBuiltInf.Append(gAsBuiltInfHeaderString.Replace(AsBuiltInfDict))\r
-        \r
+\r
         SaveFileOnChange(os.path.join(self.OutputDir, self.Name + '.inf'), str(AsBuiltInf), False)\r
-        \r
+\r
         self.IsAsBuiltInfCreated = True\r
         if GlobalData.gBinCacheDest:\r
             self.CopyModuleToCache()\r
@@ -4307,11 +4309,14 @@ class ModuleAutoGen(AutoGen):
     def CanSkipbyHash(self):\r
         if GlobalData.gUseHashCache:\r
             return not self.GenModuleHash()\r
+        return False\r
 \r
     ## Decide whether we can skip the ModuleAutoGen process\r
     #  If any source file is newer than the module than we cannot skip\r
     #\r
     def CanSkip(self):\r
+        if self.MetaFile in GlobalData.gSikpAutoGenCache:\r
+            return True\r
         if not os.path.exists(self.GetTimeStampPath()):\r
             return False\r
         #last creation time of the module\r
@@ -4330,6 +4335,7 @@ class ModuleAutoGen(AutoGen):
                     ModuleAutoGen.TimeDict[source] = os.stat(source)[8]\r
                 if ModuleAutoGen.TimeDict[source] > DstTimeStamp:\r
                     return False\r
+        GlobalData.gSikpAutoGenCache.add(self.MetaFile)\r
         return True\r
 \r
     def GetTimeStampPath(self):\r
@@ -4406,8 +4412,9 @@ class ModuleAutoGen(AutoGen):
     BuildOption             = property(_GetModuleBuildOption)\r
     BuildOptionIncPathList  = property(_GetBuildOptionIncPathList)\r
     BuildCommand            = property(_GetBuildCommand)\r
-    \r
+\r
     FixedAtBuildPcds         = property(_GetFixedAtBuildPcds)\r
+    UniqueBaseName          = property(_GetUniqueBaseName)\r
 \r
 # This acts like the main() function for the script, unless it is 'import'ed into another script.\r
 if __name__ == '__main__':\r