]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/AutoGen.py
Basetools: It went wrong when use os.linesep
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / AutoGen.py
index cef5aeaf3ecb631fdef4a44a4fa4b50621de7249..00ed804e629441f4b43d9c06200f2ec4bb9fc3e1 100644 (file)
@@ -1,8 +1,9 @@
 ## @file\r
 # Generate AutoGen.h, AutoGen.c and *.depex files\r
 #\r
-# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>\r
 # Copyright (c) 2018, Hewlett Packard Enterprise Development, L.P.<BR>\r
+# Copyright (c) 2019, American Megatrends, Inc. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
@@ -30,7 +31,7 @@ from io import BytesIO
 \r
 from .StrGather import *\r
 from .BuildEngine import BuildRule\r
-\r
+import shutil\r
 from Common.LongFilePathSupport import CopyLongFilePath\r
 from Common.BuildToolError import *\r
 from Common.DataType import *\r
@@ -52,6 +53,7 @@ from .GenVar import VariableMgr, var_info
 from collections import OrderedDict\r
 from collections import defaultdict\r
 from Workspace.WorkspaceCommon import OrderedListDict\r
+from Common.ToolDefClassObject import gDefaultToolsDefFile\r
 \r
 from Common.caching import cached_property, cached_class_function\r
 \r
@@ -85,9 +87,6 @@ gMakeTypeMap = {TAB_COMPILER_MSFT:"nmake", "GCC":"gmake"}
 ## Build rule configuration file\r
 gDefaultBuildRuleFile = 'build_rule.txt'\r
 \r
-## Tools definition configuration file\r
-gDefaultToolsDefFile = 'tools_def.txt'\r
-\r
 ## Build rule default version\r
 AutoGenReqBuildRuleVerNum = "0.1"\r
 \r
@@ -172,6 +171,73 @@ ${tail_comments}
 ## @AsBuilt${BEGIN}\r
 ##   ${flags_item}${END}\r
 """)\r
+## Split command line option string to list\r
+#\r
+# subprocess.Popen needs the args to be a sequence. Otherwise there's problem\r
+# in non-windows platform to launch command\r
+#\r
+def _SplitOption(OptionString):\r
+    OptionList = []\r
+    LastChar = " "\r
+    OptionStart = 0\r
+    QuotationMark = ""\r
+    for Index in range(0, len(OptionString)):\r
+        CurrentChar = OptionString[Index]\r
+        if CurrentChar in ['"', "'"]:\r
+            if QuotationMark == CurrentChar:\r
+                QuotationMark = ""\r
+            elif QuotationMark == "":\r
+                QuotationMark = CurrentChar\r
+            continue\r
+        elif QuotationMark:\r
+            continue\r
+\r
+        if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:\r
+            if Index > OptionStart:\r
+                OptionList.append(OptionString[OptionStart:Index - 1])\r
+            OptionStart = Index\r
+        LastChar = CurrentChar\r
+    OptionList.append(OptionString[OptionStart:])\r
+    return OptionList\r
+\r
+#\r
+# Convert string to C format array\r
+#\r
+def _ConvertStringToByteArray(Value):\r
+    Value = Value.strip()\r
+    if not Value:\r
+        return None\r
+    if Value[0] == '{':\r
+        if not Value.endswith('}'):\r
+            return None\r
+        Value = Value.replace(' ', '').replace('{', '').replace('}', '')\r
+        ValFields = Value.split(',')\r
+        try:\r
+            for Index in range(len(ValFields)):\r
+                ValFields[Index] = str(int(ValFields[Index], 0))\r
+        except ValueError:\r
+            return None\r
+        Value = '{' + ','.join(ValFields) + '}'\r
+        return Value\r
+\r
+    Unicode = False\r
+    if Value.startswith('L"'):\r
+        if not Value.endswith('"'):\r
+            return None\r
+        Value = Value[1:]\r
+        Unicode = True\r
+    elif not Value.startswith('"') or not Value.endswith('"'):\r
+        return None\r
+\r
+    Value = eval(Value)         # translate escape character\r
+    NewValue = '{'\r
+    for Index in range(0, len(Value)):\r
+        if Unicode:\r
+            NewValue = NewValue + str(ord(Value[Index]) % 0x10000) + ','\r
+        else:\r
+            NewValue = NewValue + str(ord(Value[Index]) % 0x100) + ','\r
+    Value = NewValue + '0}'\r
+    return Value\r
 \r
 ## Base class for AutoGen\r
 #\r
@@ -203,8 +269,6 @@ class AutoGen(object):
         RetVal = cls.__ObjectCache[Key] = super(AutoGen, cls).__new__(cls)\r
         return RetVal\r
 \r
-    def __init__ (self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
-        super(AutoGen, self).__init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
 \r
     ## hash() operator\r
     #\r
@@ -237,7 +301,6 @@ class WorkspaceAutoGen(AutoGen):
     # call super().__init__ then call the worker function with different parameter count\r
     def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
         if not hasattr(self, "_Init"):\r
-            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
@@ -278,10 +341,6 @@ class WorkspaceAutoGen(AutoGen):
         self.FvTargetList   = Fvs if Fvs else []\r
         self.CapTargetList  = Caps if Caps else []\r
         self.AutoGenObjectList = []\r
-        self._BuildDir      = None\r
-        self._FvDir         = None\r
-        self._MakeFileDir   = None\r
-        self._BuildCommand  = None\r
         self._GuidDict = {}\r
 \r
         # there's many relative directory operations, so ...\r
@@ -573,8 +632,8 @@ class WorkspaceAutoGen(AutoGen):
                         'build',\r
                         PARSER_ERROR,\r
                         "PCD (%s.%s) used in FDF is not declared in DEC files." % (Guid, Name),\r
-                        File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],\r
-                        Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]\r
+                        File = self.FdfProfile.PcdFileLineDict[Name, Guid, Fileds][0],\r
+                        Line = self.FdfProfile.PcdFileLineDict[Name, Guid, Fileds][1]\r
                     )\r
                 else:\r
                     # Check whether Dynamic or DynamicEx PCD used in FDF file. If used, build break and give a error message.\r
@@ -587,8 +646,8 @@ class WorkspaceAutoGen(AutoGen):
                                 'build',\r
                                 PARSER_ERROR,\r
                                 "Using Dynamic or DynamicEx type of PCD [%s.%s] in FDF file is not allowed." % (Guid, Name),\r
-                                File = self.FdfProfile.PcdFileLineDict[Name, Guid][0],\r
-                                Line = self.FdfProfile.PcdFileLineDict[Name, Guid][1]\r
+                                File = self.FdfProfile.PcdFileLineDict[Name, Guid, Fileds][0],\r
+                                Line = self.FdfProfile.PcdFileLineDict[Name, Guid, Fileds][1]\r
                         )\r
 \r
             Pa = PlatformAutoGen(self, self.MetaFile, Target, Toolchain, Arch)\r
@@ -622,17 +681,17 @@ class WorkspaceAutoGen(AutoGen):
         #\r
         content = 'gCommandLineDefines: '\r
         content += str(GlobalData.gCommandLineDefines)\r
-        content += os.linesep\r
+        content += TAB_LINE_BREAK\r
         content += 'BuildOptionPcd: '\r
         content += str(GlobalData.BuildOptionPcd)\r
-        content += os.linesep\r
+        content += TAB_LINE_BREAK\r
         content += 'Active Platform: '\r
         content += str(self.Platform)\r
-        content += os.linesep\r
+        content += TAB_LINE_BREAK\r
         if self.FdfFile:\r
             content += 'Flash Image Definition: '\r
             content += str(self.FdfFile)\r
-            content += os.linesep\r
+            content += TAB_LINE_BREAK\r
         SaveFileOnChange(os.path.join(self.BuildDir, 'BuildOptions'), content, False)\r
 \r
         #\r
@@ -642,7 +701,7 @@ class WorkspaceAutoGen(AutoGen):
         if Pa.PcdTokenNumber:\r
             if Pa.DynamicPcdList:\r
                 for Pcd in Pa.DynamicPcdList:\r
-                    PcdTokenNumber += os.linesep\r
+                    PcdTokenNumber += TAB_LINE_BREAK\r
                     PcdTokenNumber += str((Pcd.TokenCName, Pcd.TokenSpaceGuidCName))\r
                     PcdTokenNumber += ' : '\r
                     PcdTokenNumber += str(Pa.PcdTokenNumber[Pcd.TokenCName, Pcd.TokenSpaceGuidCName])\r
@@ -810,54 +869,56 @@ class WorkspaceAutoGen(AutoGen):
         return "%s [%s]" % (self.MetaFile, ", ".join(self.ArchList))\r
 \r
     ## Return the directory to store FV files\r
-    def _GetFvDir(self):\r
-        if self._FvDir is None:\r
-            self._FvDir = path.join(self.BuildDir, TAB_FV_DIRECTORY)\r
-        return self._FvDir\r
+    @cached_property\r
+    def FvDir(self):\r
+        return path.join(self.BuildDir, TAB_FV_DIRECTORY)\r
 \r
     ## Return the directory to store all intermediate and final files built\r
-    def _GetBuildDir(self):\r
-        if self._BuildDir is None:\r
-            return self.AutoGenObjectList[0].BuildDir\r
+    @cached_property\r
+    def BuildDir(self):\r
+        return self.AutoGenObjectList[0].BuildDir\r
 \r
     ## Return the build output directory platform specifies\r
-    def _GetOutputDir(self):\r
+    @cached_property\r
+    def OutputDir(self):\r
         return self.Platform.OutputDirectory\r
 \r
     ## Return platform name\r
-    def _GetName(self):\r
+    @cached_property\r
+    def Name(self):\r
         return self.Platform.PlatformName\r
 \r
     ## Return meta-file GUID\r
-    def _GetGuid(self):\r
+    @cached_property\r
+    def Guid(self):\r
         return self.Platform.Guid\r
 \r
     ## Return platform version\r
-    def _GetVersion(self):\r
+    @cached_property\r
+    def Version(self):\r
         return self.Platform.Version\r
 \r
     ## Return paths of tools\r
-    def _GetToolDefinition(self):\r
+    @cached_property\r
+    def ToolDefinition(self):\r
         return self.AutoGenObjectList[0].ToolDefinition\r
 \r
     ## Return directory of platform makefile\r
     #\r
     #   @retval     string  Makefile directory\r
     #\r
-    def _GetMakeFileDir(self):\r
-        if self._MakeFileDir is None:\r
-            self._MakeFileDir = self.BuildDir\r
-        return self._MakeFileDir\r
+    @cached_property\r
+    def MakeFileDir(self):\r
+        return self.BuildDir\r
 \r
     ## Return build command string\r
     #\r
     #   @retval     string  Build command string\r
     #\r
-    def _GetBuildCommand(self):\r
-        if self._BuildCommand is None:\r
-            # BuildCommand should be all the same. So just get one from platform AutoGen\r
-            self._BuildCommand = self.AutoGenObjectList[0].BuildCommand\r
-        return self._BuildCommand\r
+    @cached_property\r
+    def BuildCommand(self):\r
+        # BuildCommand should be all the same. So just get one from platform AutoGen\r
+        return self.AutoGenObjectList[0].BuildCommand\r
 \r
     ## Check the PCDs token value conflict in each DEC file.\r
     #\r
@@ -933,9 +994,63 @@ class WorkspaceAutoGen(AutoGen):
                                     )\r
                     Count += 1\r
     ## Generate fds command\r
-    def _GenFdsCommand(self):\r
+    @property\r
+    def GenFdsCommand(self):\r
         return (GenMake.TopLevelMakefile(self)._TEMPLATE_.Replace(GenMake.TopLevelMakefile(self)._TemplateDict)).strip()\r
 \r
+    @property\r
+    def GenFdsCommandDict(self):\r
+        FdsCommandDict = {}\r
+        LogLevel = EdkLogger.GetLevel()\r
+        if LogLevel == EdkLogger.VERBOSE:\r
+            FdsCommandDict["verbose"] = True\r
+        elif LogLevel <= EdkLogger.DEBUG_9:\r
+            FdsCommandDict["debug"] = LogLevel - 1\r
+        elif LogLevel == EdkLogger.QUIET:\r
+            FdsCommandDict["quiet"] = True\r
+\r
+        if GlobalData.gEnableGenfdsMultiThread:\r
+            FdsCommandDict["GenfdsMultiThread"] = True\r
+        if GlobalData.gIgnoreSource:\r
+            FdsCommandDict["IgnoreSources"] = True\r
+\r
+        FdsCommandDict["OptionPcd"] = []\r
+        for pcd in GlobalData.BuildOptionPcd:\r
+            if pcd[2]:\r
+                pcdname = '.'.join(pcd[0:3])\r
+            else:\r
+                pcdname = '.'.join(pcd[0:2])\r
+            if pcd[3].startswith('{'):\r
+                FdsCommandDict["OptionPcd"].append(pcdname + '=' + 'H' + '"' + pcd[3] + '"')\r
+            else:\r
+                FdsCommandDict["OptionPcd"].append(pcdname + '=' + pcd[3])\r
+\r
+        MacroList = []\r
+        # macros passed to GenFds\r
+        MacroDict = {}\r
+        MacroDict.update(GlobalData.gGlobalDefines)\r
+        MacroDict.update(GlobalData.gCommandLineDefines)\r
+        for MacroName in MacroDict:\r
+            if MacroDict[MacroName] != "":\r
+                MacroList.append('"%s=%s"' % (MacroName, MacroDict[MacroName].replace('\\', '\\\\')))\r
+            else:\r
+                MacroList.append('"%s"' % MacroName)\r
+        FdsCommandDict["macro"] = MacroList\r
+\r
+        FdsCommandDict["fdf_file"] = [self.FdfFile]\r
+        FdsCommandDict["build_target"] = self.BuildTarget\r
+        FdsCommandDict["toolchain_tag"] = self.ToolChain\r
+        FdsCommandDict["active_platform"] = str(self)\r
+\r
+        FdsCommandDict["conf_directory"] = GlobalData.gConfDirectory\r
+        FdsCommandDict["build_architecture_list"] = ','.join(self.ArchList)\r
+        FdsCommandDict["platform_build_directory"] = self.BuildDir\r
+\r
+        FdsCommandDict["fd"] = self.FdTargetList\r
+        FdsCommandDict["fv"] = self.FvTargetList\r
+        FdsCommandDict["cap"] = self.CapTargetList\r
+        return FdsCommandDict\r
+\r
     ## Create makefile for the platform and modules in it\r
     #\r
     #   @param      CreateDepsMakeFile      Flag indicating if the makefile for\r
@@ -966,18 +1081,6 @@ class WorkspaceAutoGen(AutoGen):
     def CreateAsBuiltInf(self):\r
         return\r
 \r
-    Name                = property(_GetName)\r
-    Guid                = property(_GetGuid)\r
-    Version             = property(_GetVersion)\r
-    OutputDir           = property(_GetOutputDir)\r
-\r
-    ToolDefinition      = property(_GetToolDefinition)       # toolcode : tool path\r
-\r
-    BuildDir            = property(_GetBuildDir)\r
-    FvDir               = property(_GetFvDir)\r
-    MakeFileDir         = property(_GetMakeFileDir)\r
-    BuildCommand        = property(_GetBuildCommand)\r
-    GenFdsCommand       = property(_GenFdsCommand)\r
 \r
 ## AutoGen class for platform\r
 #\r
@@ -988,7 +1091,6 @@ class PlatformAutoGen(AutoGen):
     # call super().__init__ then call the worker function with different parameter count\r
     def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
         if not hasattr(self, "_Init"):\r
-            super(PlatformAutoGen, self).__init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
             self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch)\r
             self._Init = True\r
     #\r
@@ -1098,21 +1200,19 @@ class PlatformAutoGen(AutoGen):
     def GenFdsCommand(self):\r
         return self.Workspace.GenFdsCommand\r
 \r
-    ## Create makefile for the platform and mdoules in it\r
+    ## Create makefile for the platform and modules in it\r
     #\r
     #   @param      CreateModuleMakeFile    Flag indicating if the makefile for\r
     #                                       modules will be created as well\r
     #\r
     def CreateMakeFile(self, CreateModuleMakeFile=False, FfsCommand = {}):\r
         if CreateModuleMakeFile:\r
-            for ModuleFile in self.Platform.Modules:\r
-                Ma = ModuleAutoGen(self.Workspace, ModuleFile, self.BuildTarget,\r
-                                   self.ToolChain, self.Arch, self.MetaFile)\r
-                if (ModuleFile.File, self.Arch) in FfsCommand:\r
-                    Ma.CreateMakeFile(True, FfsCommand[ModuleFile.File, self.Arch])\r
+            for Ma in self._MaList:\r
+                key = (Ma.MetaFile.File, self.Arch)\r
+                if key in FfsCommand:\r
+                    Ma.CreateMakeFile(True, FfsCommand[key])\r
                 else:\r
                     Ma.CreateMakeFile(True)\r
-                #Ma.CreateAsBuiltInf()\r
 \r
         # no need to create makefile for the platform more than once\r
         if self.IsMakeFileCreated:\r
@@ -1168,7 +1268,7 @@ class PlatformAutoGen(AutoGen):
                         VpdRegionBase = FdRegion.Offset\r
                         break\r
 \r
-        VariableInfo = VariableMgr(self.DscBuildDataObj._GetDefaultStores(), self.DscBuildDataObj._GetSkuIds())\r
+        VariableInfo = VariableMgr(self.DscBuildDataObj._GetDefaultStores(), self.DscBuildDataObj.SkuIds)\r
         VariableInfo.SetVpdRegionMaxSize(VpdRegionSize)\r
         VariableInfo.SetVpdRegionOffset(VpdRegionBase)\r
         Index = 0\r
@@ -1180,10 +1280,12 @@ class PlatformAutoGen(AutoGen):
                 if SkuId is None or SkuId == '':\r
                     continue\r
                 if len(Sku.VariableName) > 0:\r
+                    if Sku.VariableAttribute and 'NV' not in Sku.VariableAttribute:\r
+                        continue\r
                     VariableGuidStructure = Sku.VariableGuidValue\r
                     VariableGuid = GuidStructureStringToGuidString(VariableGuidStructure)\r
                     for StorageName in Sku.DefaultStoreDict:\r
-                        VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName], Pcd.DatumType))\r
+                        VariableInfo.append_variable(var_info(Index, pcdname, StorageName, SkuName, StringToArray(Sku.VariableName), VariableGuid, Sku.VariableOffset, Sku.VariableAttribute, Sku.HiiDefaultValue, Sku.DefaultStoreDict[StorageName] if Pcd.DatumType in TAB_PCD_NUMERIC_TYPES else StringToArray(Sku.DefaultStoreDict[StorageName]), Pcd.DatumType, Pcd.CustomAttribute['DscPosition'], Pcd.CustomAttribute.get('IsStru',False)))\r
             Index += 1\r
         return VariableInfo\r
 \r
@@ -1244,16 +1346,12 @@ class PlatformAutoGen(AutoGen):
         for InfName in self._AsBuildInfList:\r
             InfName = mws.join(self.WorkspaceDir, InfName)\r
             FdfModuleList.append(os.path.normpath(InfName))\r
-        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
-            self.Platform.Modules[F].M = M\r
-\r
+        for M in self._MaList:\r
+#            F is the Module for which M is the module autogen\r
             for PcdFromModule in M.ModulePcdList + M.LibraryPcdList:\r
                 # make sure that the "VOID*" kind of datum has MaxDatumSize set\r
                 if PcdFromModule.DatumType == TAB_VOID and not PcdFromModule.MaxDatumSize:\r
-                    NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, F))\r
+                    NoDatumTypePcdList.add("%s.%s [%s]" % (PcdFromModule.TokenSpaceGuidCName, PcdFromModule.TokenCName, M.MetaFile))\r
 \r
                 # Check the PCD from Binary INF or Source INF\r
                 if M.IsBinaryModule == True:\r
@@ -1263,7 +1361,7 @@ class PlatformAutoGen(AutoGen):
                 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 M.MetaFile.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
@@ -1416,6 +1514,13 @@ class PlatformAutoGen(AutoGen):
                 self.VariableInfo = self.CollectVariables(self._DynamicPcdList)\r
                 vardump = self.VariableInfo.dump()\r
                 if vardump:\r
+                    #\r
+                    #According to PCD_DATABASE_INIT in edk2\MdeModulePkg\Include\Guid\PcdDataBaseSignatureGuid.h,\r
+                    #the max size for string PCD should not exceed USHRT_MAX 65535(0xffff).\r
+                    #typedef UINT16 SIZE_INFO;\r
+                    #//SIZE_INFO  SizeTable[];\r
+                    if len(vardump.split(",")) > 0xffff:\r
+                        EdkLogger.error("build", RESOURCE_OVERFLOW, 'The current length of PCD %s value is %d, it exceeds to the max size of String PCD.' %(".".join([PcdNvStoreDfBuffer.TokenSpaceGuidCName,PcdNvStoreDfBuffer.TokenCName]) ,len(vardump.split(","))))\r
                     PcdNvStoreDfBuffer.DefaultValue = vardump\r
                     for skuname in PcdNvStoreDfBuffer.SkuInfoList:\r
                         PcdNvStoreDfBuffer.SkuInfoList[skuname].DefaultValue = vardump\r
@@ -1448,7 +1553,7 @@ class PlatformAutoGen(AutoGen):
                         PcdValue = Sku.DefaultValue\r
                         if PcdValue == "":\r
                             PcdValue  = Pcd.DefaultValue\r
-                        if Sku.VpdOffset != '*':\r
+                        if Sku.VpdOffset != TAB_STAR:\r
                             if PcdValue.startswith("{"):\r
                                 Alignment = 8\r
                             elif PcdValue.startswith("L"):\r
@@ -1472,7 +1577,7 @@ class PlatformAutoGen(AutoGen):
                             VpdFile.Add(Pcd, SkuName, Sku.VpdOffset)\r
                         SkuValueMap[PcdValue].append(Sku)\r
                         # if the offset of a VPD is *, then it need to be fixed up by third party tool.\r
-                        if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
+                        if not NeedProcessVpdMapFile and Sku.VpdOffset == TAB_STAR:\r
                             NeedProcessVpdMapFile = True\r
                             if self.Platform.VpdToolGuid is None or self.Platform.VpdToolGuid == '':\r
                                 EdkLogger.error("Build", FILE_NOT_FOUND, \\r
@@ -1532,7 +1637,7 @@ class PlatformAutoGen(AutoGen):
                                 PcdValue = Sku.DefaultValue\r
                                 if PcdValue == "":\r
                                     PcdValue  = DscPcdEntry.DefaultValue\r
-                                if Sku.VpdOffset != '*':\r
+                                if Sku.VpdOffset != TAB_STAR:\r
                                     if PcdValue.startswith("{"):\r
                                         Alignment = 8\r
                                     elif PcdValue.startswith("L"):\r
@@ -1555,7 +1660,7 @@ class PlatformAutoGen(AutoGen):
                                     SkuValueMap[PcdValue] = []\r
                                     VpdFile.Add(DscPcdEntry, SkuName, Sku.VpdOffset)\r
                                 SkuValueMap[PcdValue].append(Sku)\r
-                                if not NeedProcessVpdMapFile and Sku.VpdOffset == "*":\r
+                                if not NeedProcessVpdMapFile and Sku.VpdOffset == TAB_STAR:\r
                                     NeedProcessVpdMapFile = True\r
                             if DscPcdEntry.DatumType == TAB_VOID and PcdValue.startswith("L"):\r
                                 UnicodePcdArray.add(DscPcdEntry)\r
@@ -1576,6 +1681,12 @@ class PlatformAutoGen(AutoGen):
                 self.FixVpdOffset(VpdFile)\r
 \r
                 self.FixVpdOffset(self.UpdateNVStoreMaxSize(VpdFile))\r
+                PcdNvStoreDfBuffer = [item for item in self._DynamicPcdList if item.TokenCName == "PcdNvStoreDefaultValueBuffer" and item.TokenSpaceGuidCName == "gEfiMdeModulePkgTokenSpaceGuid"]\r
+                if PcdNvStoreDfBuffer:\r
+                    PcdName,PcdGuid = PcdNvStoreDfBuffer[0].TokenCName, PcdNvStoreDfBuffer[0].TokenSpaceGuidCName\r
+                    if (PcdName,PcdGuid) in VpdSkuMap:\r
+                        DefaultSku = PcdNvStoreDfBuffer[0].SkuInfoList.get(TAB_DEFAULT)\r
+                        VpdSkuMap[(PcdName,PcdGuid)] = {DefaultSku.DefaultValue:[DefaultSku]}\r
 \r
                 # Process VPD map file generated by third party BPDG tool\r
                 if NeedProcessVpdMapFile:\r
@@ -1583,7 +1694,7 @@ class PlatformAutoGen(AutoGen):
                     if os.path.exists(VpdMapFilePath):\r
                         VpdFile.Read(VpdMapFilePath)\r
 \r
-                        # Fixup "*" offset\r
+                        # Fixup TAB_STAR offset\r
                         for pcd in VpdSkuMap:\r
                             vpdinfo = VpdFile.GetVpdInfo(pcd)\r
                             if vpdinfo is None:\r
@@ -1721,11 +1832,11 @@ class PlatformAutoGen(AutoGen):
     def BuildCommand(self):\r
         RetVal = []\r
         if "MAKE" in self.ToolDefinition and "PATH" in self.ToolDefinition["MAKE"]:\r
-            RetVal += SplitOption(self.ToolDefinition["MAKE"]["PATH"])\r
+            RetVal += _SplitOption(self.ToolDefinition["MAKE"]["PATH"])\r
             if "FLAGS" in self.ToolDefinition["MAKE"]:\r
                 NewOption = self.ToolDefinition["MAKE"]["FLAGS"].strip()\r
                 if NewOption != '':\r
-                    RetVal += SplitOption(NewOption)\r
+                    RetVal += _SplitOption(NewOption)\r
             if "MAKE" in self.EdkIIBuildOption:\r
                 if "FLAGS" in self.EdkIIBuildOption["MAKE"]:\r
                     Flags = self.EdkIIBuildOption["MAKE"]["FLAGS"]\r
@@ -1893,15 +2004,17 @@ class PlatformAutoGen(AutoGen):
         return {(Pcd.TokenCName, Pcd.TokenSpaceGuidCName):Pcd for Pcd in self.NonDynamicPcdList}\r
 \r
     ## Get list of non-dynamic PCDs\r
-    @cached_property\r
+    @property\r
     def NonDynamicPcdList(self):\r
-        self.CollectPlatformDynamicPcds()\r
+        if not self._NonDynamicPcdList:\r
+            self.CollectPlatformDynamicPcds()\r
         return self._NonDynamicPcdList\r
 \r
     ## Get list of dynamic PCDs\r
-    @cached_property\r
+    @property\r
     def DynamicPcdList(self):\r
-        self.CollectPlatformDynamicPcds()\r
+        if not self._DynamicPcdList:\r
+            self.CollectPlatformDynamicPcds()\r
         return self._DynamicPcdList\r
 \r
     ## Generate Token Number for all PCD\r
@@ -1947,19 +2060,25 @@ class PlatformAutoGen(AutoGen):
             TokenNumber += 1\r
         return RetVal\r
 \r
+    @cached_property\r
+    def _MaList(self):\r
+        for ModuleFile in self.Platform.Modules:\r
+            Ma = ModuleAutoGen(\r
+                  self.Workspace,\r
+                  ModuleFile,\r
+                  self.BuildTarget,\r
+                  self.ToolChain,\r
+                  self.Arch,\r
+                  self.MetaFile\r
+                  )\r
+            self.Platform.Modules[ModuleFile].M = Ma\r
+        return [x.M for x in self.Platform.Modules.values()]\r
+\r
     ## Summarize ModuleAutoGen objects of all modules to be built for this platform\r
     @cached_property\r
     def ModuleAutoGenList(self):\r
         RetVal = []\r
-        for ModuleFile in self.Platform.Modules:\r
-            Ma = ModuleAutoGen(\r
-                    self.Workspace,\r
-                    ModuleFile,\r
-                    self.BuildTarget,\r
-                    self.ToolChain,\r
-                    self.Arch,\r
-                    self.MetaFile\r
-                    )\r
+        for Ma in self._MaList:\r
             if Ma not in RetVal:\r
                 RetVal.append(Ma)\r
         return RetVal\r
@@ -1968,15 +2087,7 @@ class PlatformAutoGen(AutoGen):
     @cached_property\r
     def LibraryAutoGenList(self):\r
         RetVal = []\r
-        for ModuleFile in self.Platform.Modules:\r
-            Ma = ModuleAutoGen(\r
-                    self.Workspace,\r
-                    ModuleFile,\r
-                    self.BuildTarget,\r
-                    self.ToolChain,\r
-                    self.Arch,\r
-                    self.MetaFile\r
-                    )\r
+        for Ma in self._MaList:\r
             for La in Ma.LibraryAutoGenList:\r
                 if La not in RetVal:\r
                     RetVal.append(La)\r
@@ -2078,6 +2189,7 @@ class PlatformAutoGen(AutoGen):
             ToPcd.validateranges = FromPcd.validateranges\r
             ToPcd.validlists = FromPcd.validlists\r
             ToPcd.expressions = FromPcd.expressions\r
+            ToPcd.CustomAttribute = FromPcd.CustomAttribute\r
 \r
         if FromPcd is not None and ToPcd.DatumType == TAB_VOID and not ToPcd.MaxDatumSize:\r
             EdkLogger.debug(EdkLogger.DEBUG_9, "No MaxDatumSize specified for PCD %s.%s" \\r
@@ -2140,6 +2252,13 @@ class PlatformAutoGen(AutoGen):
         if Module in self.Platform.Modules:\r
             PlatformModule = self.Platform.Modules[str(Module)]\r
             for Key  in PlatformModule.Pcds:\r
+                if GlobalData.BuildOptionPcd:\r
+                    for pcd in GlobalData.BuildOptionPcd:\r
+                        (TokenSpaceGuidCName, TokenCName, FieldName, pcdvalue, _) = pcd\r
+                        if (TokenCName, TokenSpaceGuidCName) == Key and FieldName =="":\r
+                            PlatformModule.Pcds[Key].DefaultValue = pcdvalue\r
+                            PlatformModule.Pcds[Key].PcdValueFromComm = pcdvalue\r
+                            break\r
                 Flag = False\r
                 if Key in Pcds:\r
                     ToPcd = Pcds[Key]\r
@@ -2168,42 +2287,7 @@ class PlatformAutoGen(AutoGen):
                     Pcd.MaxDatumSize = str(len(Value) - 1)\r
         return Pcds.values()\r
 \r
-    ## Resolve library names to library modules\r
-    #\r
-    # (for Edk.x modules)\r
-    #\r
-    #   @param  Module  The module from which the library names will be resolved\r
-    #\r
-    #   @retval library_list    The list of library modules\r
-    #\r
-    def ResolveLibraryReference(self, Module):\r
-        EdkLogger.verbose("")\r
-        EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), self.Arch))\r
-        LibraryConsumerList = [Module]\r
-\r
-        # "CompilerStub" is a must for Edk modules\r
-        if Module.Libraries:\r
-            Module.Libraries.append("CompilerStub")\r
-        LibraryList = []\r
-        while len(LibraryConsumerList) > 0:\r
-            M = LibraryConsumerList.pop()\r
-            for LibraryName in M.Libraries:\r
-                Library = self.Platform.LibraryClasses[LibraryName, ':dummy:']\r
-                if Library is None:\r
-                    for Key in self.Platform.LibraryClasses.data:\r
-                        if LibraryName.upper() == Key.upper():\r
-                            Library = self.Platform.LibraryClasses[Key, ':dummy:']\r
-                            break\r
-                    if Library is None:\r
-                        EdkLogger.warn("build", "Library [%s] is not found" % LibraryName, File=str(M),\r
-                            ExtraData="\t%s [%s]" % (str(Module), self.Arch))\r
-                        continue\r
 \r
-                if Library not in LibraryList:\r
-                    LibraryList.append(Library)\r
-                    LibraryConsumerList.append(Library)\r
-                    EdkLogger.verbose("\t" + LibraryName + " : " + str(Library) + ' ' + str(type(Library)))\r
-        return LibraryList\r
 \r
     ## Calculate the priority value of the build option\r
     #\r
@@ -2214,15 +2298,15 @@ class PlatformAutoGen(AutoGen):
     def CalculatePriorityValue(self, Key):\r
         Target, ToolChain, Arch, CommandType, Attr = Key.split('_')\r
         PriorityValue = 0x11111\r
-        if Target == "*":\r
+        if Target == TAB_STAR:\r
             PriorityValue &= 0x01111\r
-        if ToolChain == "*":\r
+        if ToolChain == TAB_STAR:\r
             PriorityValue &= 0x10111\r
-        if Arch == "*":\r
+        if Arch == TAB_STAR:\r
             PriorityValue &= 0x11011\r
-        if CommandType == "*":\r
+        if CommandType == TAB_STAR:\r
             PriorityValue &= 0x11101\r
-        if Attr == "*":\r
+        if Attr == TAB_STAR:\r
             PriorityValue &= 0x11110\r
 \r
         return self.PrioList["0x%0.5x" % PriorityValue]\r
@@ -2257,9 +2341,9 @@ class PlatformAutoGen(AutoGen):
             if (Key[0] == self.BuildRuleFamily and\r
                 (ModuleStyle is None or len(Key) < 3 or (len(Key) > 2 and Key[2] == ModuleStyle))):\r
                 Target, ToolChain, Arch, CommandType, Attr = Key[1].split('_')\r
-                if (Target == self.BuildTarget or Target == "*") and\\r
-                    (ToolChain == self.ToolChain or ToolChain == "*") and\\r
-                    (Arch == self.Arch or Arch == "*") and\\r
+                if (Target == self.BuildTarget or Target == TAB_STAR) and\\r
+                    (ToolChain == self.ToolChain or ToolChain == TAB_STAR) and\\r
+                    (Arch == self.Arch or Arch == TAB_STAR) and\\r
                     Options[Key].startswith("="):\r
 \r
                     if OverrideList.get(Key[1]) is not None:\r
@@ -2280,11 +2364,11 @@ class PlatformAutoGen(AutoGen):
                     # Compare two Key, if one is included by another, choose the higher priority one\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
-                        (Arch1 == Arch2 or Arch1 == "*" or Arch2 == "*") and\\r
-                        (CommandType1 == CommandType2 or CommandType1 == "*" or CommandType2 == "*") and\\r
-                        (Attr1 == Attr2 or Attr1 == "*" or Attr2 == "*"):\r
+                    if (Target1 == Target2 or Target1 == TAB_STAR or Target2 == TAB_STAR) and\\r
+                        (ToolChain1 == ToolChain2 or ToolChain1 == TAB_STAR or ToolChain2 == TAB_STAR) and\\r
+                        (Arch1 == Arch2 or Arch1 == TAB_STAR or Arch2 == TAB_STAR) and\\r
+                        (CommandType1 == CommandType2 or CommandType1 == TAB_STAR or CommandType2 == TAB_STAR) and\\r
+                        (Attr1 == Attr2 or Attr1 == TAB_STAR or Attr2 == TAB_STAR):\r
 \r
                         if self.CalculatePriorityValue(NowKey) > self.CalculatePriorityValue(NextKey):\r
                             if Options.get((self.BuildRuleFamily, NextKey)) is not None:\r
@@ -2313,9 +2397,9 @@ class PlatformAutoGen(AutoGen):
                     continue\r
                 FamilyMatch = True\r
             # expand any wildcard\r
-            if Target == "*" or Target == self.BuildTarget:\r
-                if Tag == "*" or Tag == self.ToolChain:\r
-                    if Arch == "*" or Arch == self.Arch:\r
+            if Target == TAB_STAR or Target == self.BuildTarget:\r
+                if Tag == TAB_STAR or Tag == self.ToolChain:\r
+                    if Arch == TAB_STAR or Arch == self.Arch:\r
                         if Tool not in BuildOptions:\r
                             BuildOptions[Tool] = {}\r
                         if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):\r
@@ -2348,9 +2432,9 @@ class PlatformAutoGen(AutoGen):
                 continue\r
 \r
             # expand any wildcard\r
-            if Target == "*" or Target == self.BuildTarget:\r
-                if Tag == "*" or Tag == self.ToolChain:\r
-                    if Arch == "*" or Arch == self.Arch:\r
+            if Target == TAB_STAR or Target == self.BuildTarget:\r
+                if Tag == TAB_STAR or Tag == self.ToolChain:\r
+                    if Arch == TAB_STAR or Arch == self.Arch:\r
                         if Tool not in BuildOptions:\r
                             BuildOptions[Tool] = {}\r
                         if Attr != "FLAGS" or Attr not in BuildOptions[Tool] or Options[Key].startswith('='):\r
@@ -2371,12 +2455,8 @@ class PlatformAutoGen(AutoGen):
     #\r
     def ApplyBuildOption(self, Module):\r
         # Get the different options for the different style module\r
-        if Module.AutoGenVersion < 0x00010005:\r
-            PlatformOptions = self.EdkBuildOption\r
-            ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDK_NAME, Module.ModuleType)\r
-        else:\r
-            PlatformOptions = self.EdkIIBuildOption\r
-            ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType)\r
+        PlatformOptions = self.EdkIIBuildOption\r
+        ModuleTypeOptions = self.Platform.GetBuildOptionsByModuleType(EDKII_NAME, Module.ModuleType)\r
         ModuleTypeOptions = self._ExpandBuildOption(ModuleTypeOptions)\r
         ModuleOptions = self._ExpandBuildOption(Module.BuildOptions)\r
         if Module in self.Platform.Modules:\r
@@ -2416,11 +2496,6 @@ class PlatformAutoGen(AutoGen):
                         else:\r
                             BuildOptions[Tool][Attr] = mws.handleWsMacro(Value)\r
 \r
-        if Module.AutoGenVersion < 0x00010005 and self.Workspace.UniFlag is not None:\r
-            #\r
-            # Override UNI flag only for EDK module.\r
-            #\r
-            BuildOptions['BUILD']['FLAGS'] = self.Workspace.UniFlag\r
         return BuildOptions, BuildRuleOrder\r
 \r
 #\r
@@ -2447,7 +2522,6 @@ class ModuleAutoGen(AutoGen):
     # call super().__init__ then call the worker function with different parameter count\r
     def __init__(self, Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs):\r
         if not hasattr(self, "_Init"):\r
-            super(ModuleAutoGen, self).__init__(Workspace, MetaFile, Target, Toolchain, Arch, *args, **kwargs)\r
             self._InitWorker(Workspace, MetaFile, Target, Toolchain, Arch, *args)\r
             self._Init = True\r
 \r
@@ -2593,7 +2667,7 @@ class ModuleAutoGen(AutoGen):
     ## Return the module build data object\r
     @cached_property\r
     def Module(self):\r
-        return self.Workspace.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r
+        return self.BuildDatabase[self.MetaFile, self.Arch, self.BuildTarget, self.ToolChain]\r
 \r
     ## Return the module name\r
     @cached_property\r
@@ -2817,10 +2891,10 @@ class ModuleAutoGen(AutoGen):
                     if '.' not in item:\r
                         NewList.append(item)\r
                     else:\r
-                        if item not in self._FixedPcdVoidTypeDict:\r
+                        if item not in self.FixedVoidTypePcds:\r
                             EdkLogger.error("build", FORMAT_INVALID, "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type in the module.".format(item))\r
                         else:\r
-                            Value = self._FixedPcdVoidTypeDict[item]\r
+                            Value = self.FixedVoidTypePcds[item]\r
                             if len(Value.split(',')) != 16:\r
                                 EdkLogger.error("build", FORMAT_INVALID,\r
                                                 "{} used in [Depex] section should be used as FixedAtBuild type and VOID* datum type and 16 bytes in the module.".format(item))\r
@@ -2941,7 +3015,7 @@ class ModuleAutoGen(AutoGen):
             except KeyError:\r
                 FlagOption = ''\r
 \r
-            if self.PlatformInfo.ToolChainFamily != 'RVCT':\r
+            if self.ToolChainFamily != 'RVCT':\r
                 IncPathList = [NormPath(Path, self.Macros) for Path in BuildOptIncludeRegEx.findall(FlagOption)]\r
             else:\r
                 #\r
@@ -2956,14 +3030,13 @@ class ModuleAutoGen(AutoGen):
             # 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
-                for Path in IncPathList:\r
-                    if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir):\r
-                        ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption)\r
-                        EdkLogger.error("build",\r
-                                        PARAMETER_INVALID,\r
-                                        ExtraData=ErrMsg,\r
-                                        File=str(self.MetaFile))\r
+            for Path in IncPathList:\r
+                if (Path not in self.IncludePathList) and (CommonPath([Path, self.MetaFile.Dir]) != self.MetaFile.Dir):\r
+                    ErrMsg = "The include directory for the EDK II module in this line is invalid %s specified in %s FLAGS '%s'" % (Path, Tool, FlagOption)\r
+                    EdkLogger.error("build",\r
+                                    PARAMETER_INVALID,\r
+                                    ExtraData=ErrMsg,\r
+                                    File=str(self.MetaFile))\r
             RetVal += IncPathList\r
         return RetVal\r
 \r
@@ -2975,8 +3048,8 @@ class ModuleAutoGen(AutoGen):
     @cached_property\r
     def SourceFileList(self):\r
         RetVal = []\r
-        ToolChainTagSet = {"", "*", self.ToolChain}\r
-        ToolChainFamilySet = {"", "*", self.ToolChainFamily, self.BuildRuleFamily}\r
+        ToolChainTagSet = {"", TAB_STAR, self.ToolChain}\r
+        ToolChainFamilySet = {"", TAB_STAR, self.ToolChainFamily, self.BuildRuleFamily}\r
         for F in self.Module.Sources:\r
             # match tool chain\r
             if F.TagName not in ToolChainTagSet:\r
@@ -2993,7 +3066,7 @@ class ModuleAutoGen(AutoGen):
                 continue\r
 \r
             # add the file path into search path list for file including\r
-            if F.Dir not in self.IncludePathList and self.AutoGenVersion >= 0x00010005:\r
+            if F.Dir not in self.IncludePathList:\r
                 self.IncludePathList.insert(0, F.Dir)\r
             RetVal.append(F)\r
 \r
@@ -3008,7 +3081,7 @@ class ModuleAutoGen(AutoGen):
         self.BuildOption\r
         for SingleFile in FileList:\r
             if self.BuildRuleOrder and SingleFile.Ext in self.BuildRuleOrder and SingleFile.Ext in self.BuildRules:\r
-                key = SingleFile.Path.split(SingleFile.Ext)[0]\r
+                key = SingleFile.Path.rsplit(SingleFile.Ext,1)[0]\r
                 if key in Order_Dict:\r
                     Order_Dict[key].append(SingleFile.Ext)\r
                 else:\r
@@ -3051,7 +3124,7 @@ class ModuleAutoGen(AutoGen):
     def BinaryFileList(self):\r
         RetVal = []\r
         for F in self.Module.Binaries:\r
-            if F.Target not in [TAB_ARCH_COMMON, '*'] and F.Target != self.BuildTarget:\r
+            if F.Target not in [TAB_ARCH_COMMON, TAB_STAR] and F.Target != self.BuildTarget:\r
                 continue\r
             RetVal.append(F)\r
             self._ApplyBuildRule(F, F.Type, BinaryFileList=RetVal)\r
@@ -3255,8 +3328,6 @@ class ModuleAutoGen(AutoGen):
         # only merge library classes and PCD for non-library module\r
         if self.IsLibrary:\r
             return []\r
-        if self.AutoGenVersion < 0x00010005:\r
-            return self.PlatformInfo.ResolveLibraryReference(self.Module)\r
         return self.PlatformInfo.ApplyLibraryInstance(self.Module)\r
 \r
     ## Get the list of PCDs from current module\r
@@ -3345,19 +3416,8 @@ class ModuleAutoGen(AutoGen):
     @cached_property\r
     def IncludePathList(self):\r
         RetVal = []\r
-        if self.AutoGenVersion < 0x00010005:\r
-            for Inc in self.Module.Includes:\r
-                if Inc not in RetVal:\r
-                    RetVal.append(Inc)\r
-                # for Edk modules\r
-                Inc = path.join(Inc, self.Arch.capitalize())\r
-                if os.path.exists(Inc) and Inc not in RetVal:\r
-                    RetVal.append(Inc)\r
-            # Edk module needs to put DEBUG_DIR at the end of search path and not to use SOURCE_DIR all the time\r
-            RetVal.append(self.DebugDir)\r
-        else:\r
-            RetVal.append(self.MetaFile.Dir)\r
-            RetVal.append(self.DebugDir)\r
+        RetVal.append(self.MetaFile.Dir)\r
+        RetVal.append(self.DebugDir)\r
 \r
         for Package in self.Module.Packages:\r
             PackageDir = mws.join(self.WorkspaceDir, Package.MetaFile.Dir)\r
@@ -3419,7 +3479,7 @@ class ModuleAutoGen(AutoGen):
                 Guid = gEfiVarStoreGuidPattern.search(Content, Pos)\r
                 if not Guid:\r
                     break\r
-                NameArray = ConvertStringToByteArray('L"' + Name.group(1) + '"')\r
+                NameArray = _ConvertStringToByteArray('L"' + Name.group(1) + '"')\r
                 NameGuids.add((NameArray, GuidStructureStringToGuidString(Guid.group(1))))\r
                 Pos = Content.find('efivarstore', Name.end())\r
         if not NameGuids:\r
@@ -3432,7 +3492,7 @@ class ModuleAutoGen(AutoGen):
                 Value = GuidValue(SkuInfo.VariableGuid, self.PlatformInfo.PackageList, self.MetaFile.Path)\r
                 if not Value:\r
                     continue\r
-                Name = ConvertStringToByteArray(SkuInfo.VariableName)\r
+                Name = _ConvertStringToByteArray(SkuInfo.VariableName)\r
                 Guid = GuidStructureStringToGuidString(Value)\r
                 if (Name, Guid) in NameGuids and Pcd not in HiiExPcds:\r
                     HiiExPcds.append(Pcd)\r
@@ -3520,10 +3580,6 @@ class ModuleAutoGen(AutoGen):
         if self.IsAsBuiltInfCreated:\r
             return\r
 \r
-        # Skip the following code for EDK I inf\r
-        if self.AutoGenVersion < 0x00010005:\r
-            return\r
-\r
         # Skip the following code for libraries\r
         if self.IsLibrary:\r
             return\r
@@ -3657,6 +3713,10 @@ class ModuleAutoGen(AutoGen):
                 AsBuiltInfDict['binary_item'].append('PE32|' + self.Name + '.efi')\r
             else:\r
                 AsBuiltInfDict['binary_item'].append('BIN|' + File)\r
+        if not self.DepexGenerated:\r
+            DepexFile = os.path.join(self.OutputDir, self.Name + '.depex')\r
+            if os.path.exists(DepexFile):\r
+                self.DepexGenerated = True\r
         if self.DepexGenerated:\r
             self.OutputFile.add(self.Name + '.depex')\r
             if self.ModuleType in [SUP_MODULE_PEIM]:\r
@@ -3857,7 +3917,7 @@ class ModuleAutoGen(AutoGen):
         if os.path.exists(ModuleFile):\r
             shutil.copy2(ModuleFile, FileDir)\r
         if not self.OutputFile:\r
-            Ma = self.Workspace.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]\r
+            Ma = self.BuildDatabase[PathClass(ModuleFile), self.Arch, self.BuildTarget, self.ToolChain]\r
             self.OutputFile = Ma.Binaries\r
         if self.OutputFile:\r
             for File in self.OutputFile:\r
@@ -3976,17 +4036,10 @@ class ModuleAutoGen(AutoGen):
 \r
         for File in self.AutoGenFileList:\r
             if GenC.Generate(File.Path, self.AutoGenFileList[File], File.IsBinary):\r
-                #Ignore Edk AutoGen.c\r
-                if self.AutoGenVersion < 0x00010005 and File.Name == 'AutoGen.c':\r
-                        continue\r
-\r
                 AutoGenList.append(str(File))\r
             else:\r
                 IgoredAutoGenList.append(str(File))\r
 \r
-        # Skip the following code for EDK I inf\r
-        if self.AutoGenVersion < 0x00010005:\r
-            return\r
 \r
         for ModuleType in self.DepexList:\r
             # Ignore empty [depex] section or [depex] section for SUP_MODULE_USER_DEFINED module\r