a. Enabled building R8 modules
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Sat, 22 Dec 2007 16:49:31 +0000 (16:49 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Sat, 22 Dec 2007 16:49:31 +0000 (16:49 +0000)
b. Always inherit library's [depex] if there's no dxs file declared in module's inf file

git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@926 7335b38e-4728-0410-8992-fb3ffe349368

14 files changed:
Source/Python/AutoGen/AutoGen.py
Source/Python/AutoGen/BuildInfo.py
Source/Python/AutoGen/GenC.py
Source/Python/AutoGen/GenDepex.py
Source/Python/AutoGen/GenMake.py
Source/Python/AutoGen/StrGather.py
Source/Python/Common/DataType.py
Source/Python/Common/DecClassObject.py
Source/Python/Common/DscClassObject.py
Source/Python/Common/EdkIIWorkspaceBuild.py
Source/Python/Common/InfClassObject.py
Source/Python/Common/String.py
Source/Python/Common/ToolDefClassObject.py
Source/Python/build/build.py

index dcd321d..558f3b5 100755 (executable)
@@ -425,7 +425,7 @@ class PlatformAutoGen:
     def CreateModuleAutoGen(self):\r
         for Arch in self.BuildInfo:\r
             Info = self.BuildInfo[Arch]\r
-            for ModuleFile in Info.Platform.Libraries:\r
+            for ModuleFile in Info.Platform.LibraryInstances:\r
                 ModuleAutoGen.New(self.Workspace, Info.Platform, ModuleFile,\r
                                          Info.BuildTarget, Info.ToolChain, Info.Arch)\r
 \r
@@ -442,7 +442,7 @@ class PlatformAutoGen:
         if CreateModuleMakeFile:\r
             for Arch in self.BuildInfo:\r
                 Info = self.BuildInfo[Arch]\r
-                for ModuleFile in Info.Platform.Libraries:\r
+                for ModuleFile in Info.Platform.LibraryInstances:\r
                     AutoGenObject = ModuleAutoGen.New(self.Workspace, Info.Platform, ModuleFile,\r
                                                       Info.BuildTarget, Info.ToolChain, Info.Arch)\r
                     AutoGenObject.CreateMakeFile(False)\r
@@ -481,7 +481,7 @@ class PlatformAutoGen:
 \r
         for Arch in self.BuildInfo:\r
             Info = self.BuildInfo[Arch]\r
-            for ModuleFile in Info.Platform.Libraries:\r
+            for ModuleFile in Info.Platform.LibraryInstances:\r
                 AutoGenObject = ModuleAutoGen.New(self.Workspace, Info.Platform, ModuleFile,\r
                                                   Info.BuildTarget, Info.ToolChain, Info.Arch)\r
                 AutoGenObject.CreateCodeFile()\r
@@ -775,13 +775,13 @@ class ModuleAutoGen(object):
         Info.GuidList = self.GetGuidList()\r
         Info.ProtocolList = self.GetProtocolGuidList()\r
         Info.PpiList = self.GetPpiGuidList()\r
-        Info.MacroList = self.GetMacroList()\r
+        Info.Macro = self.GetMacroList()\r
         Info.DepexList = self.GetDepexTokenList(Info)\r
 \r
         Info.IncludePathList = [Info.SourceDir, Info.DebugDir]\r
         Info.IncludePathList.extend(self.GetIncludePathList(Info.DependentPackageList))\r
 \r
-        Info.SourceFileList = self.GetBuildFileList(Info.PlatformInfo)\r
+        Info.SourceFileList = self.GetBuildFileList(Info)\r
         Info.AutoGenFileList = self.GetAutoGenFileList(Info)\r
 \r
         return Info\r
@@ -819,15 +819,16 @@ class ModuleAutoGen(object):
     #\r
     def GetDepexTokenList(self, Info):\r
         Dxs = self.Module.Depex\r
-        if Dxs == None or Dxs == "":\r
-            return []\r
-\r
+        EdkLogger.verbose("DEPEX string = %s" % Dxs)\r
         #\r
         # Append depex from dependent libraries\r
         #\r
         for Lib in Info.DependentLibraryList:\r
             if Lib.Depex != None and Lib.Depex != "":\r
-                Dxs += " AND (" + Lib.Depex + ")"\r
+                if Dxs == None or Dxs == "":\r
+                    Dxs = Lib.Depex\r
+                else:\r
+                    Dxs += " AND (" + Lib.Depex + ")"\r
                 EdkLogger.verbose("DEPEX string (+%s) = %s" % (Lib.BaseName, Dxs))\r
         if Dxs == "":\r
             return []\r
@@ -868,7 +869,8 @@ class ModuleAutoGen(object):
     #   @retval     list    The list of macro defined in module file\r
     #\r
     def GetMacroList(self):\r
-        return ["%s %s" % (Name, self.Module.Specification[Name]) for Name in self.Module.Specification]\r
+        # return ["%s %s" % (Name, self.Module.Specification[Name]) for Name in self.Module.Specification]\r
+        return self.Module.Specification\r
 \r
     ## Tool option for the module build\r
     #\r
@@ -907,10 +909,10 @@ class ModuleAutoGen(object):
     #   @param      PlatformInfo    The object of PlatformBuildInfo\r
     #   @retval     list            The list of files which can be built later\r
     #\r
-    def GetBuildFileList(self, PlatformInfo):\r
+    def GetBuildFileList(self, Info):\r
         # use toolchain family of CC as the primary toolchain family\r
-        ToolChainFamily = PlatformInfo.ToolChainFamily["CC"]\r
-        BuildRule = PlatformInfo.BuildRule\r
+        ToolChainFamily = Info.PlatformInfo.ToolChainFamily["CC"]\r
+        BuildRule = Info.PlatformInfo.BuildRule\r
         BuildFileList = []\r
         for F in self.Module.Sources:\r
             SourceFile = F.SourceFile\r
@@ -946,6 +948,10 @@ class ModuleAutoGen(object):
                 self.BuildInfo.UnicodeFileList.append(os.path.join(self.WorkspaceDir, self.BuildInfo.SourceDir, SourceFile))\r
                 continue\r
 \r
+            # if there's dxs file, don't use content in [depex] section to generate .depex file\r
+            if FileType == "Dependency-Expression-File":\r
+                Info.DepexList = []\r
+\r
             # no command, no build\r
             if RuleObject == None or RuleObject.CommandList == []:\r
                 Buildable = False\r
@@ -1088,7 +1094,11 @@ class ModuleAutoGen(object):
     def GetIncludePathList(self, DependentPackageList):\r
         IncludePathList = []\r
         for Inc in self.Module.Includes:\r
+            if Inc == ".":\r
+                continue\r
             IncludePathList.append(Inc)\r
+            # for r8 modules\r
+            IncludePathList.append(os.path.join(Inc, self.Arch.capitalize()))\r
 \r
         for Package in DependentPackageList:\r
             PackageDir = path.dirname(Package.DescFilePath)\r
index d7dc052..e98dee3 100644 (file)
@@ -50,6 +50,7 @@ class ModuleBuildInfo(BuildInfo):
     def __init__(self, Module):
         BuildInfo.__init__(self, Module)
         self.Module     = Module
+        self.AutoGenVersion = Module.AutoGenVersion
 
         self.Name       = Module.BaseName
         self.Guid       = Module.Guid
@@ -97,7 +98,7 @@ class ModuleBuildInfo(BuildInfo):
         self.ProtocolList = []
         self.PpiList = []
 
-        self.MacroList = []
+        self.Macro = {}
         self.DepexList = []
 
 ## Build information of a package
index 99efaff..0fb9d54 100644 (file)
@@ -745,7 +745,8 @@ ${FunctionCall}${END}
 \r
 gSpecificationString = """\r
 ${BEGIN}\r
-#define ${Specification}\r
+#undef ${SpecificationName}\r
+#define ${SpecificationName} ${SpecificationValue}\r
 ${END}\r
 """\r
 \r
@@ -1577,27 +1578,32 @@ def CreateHeaderCode(Info, AutoGenC, AutoGenH):
     AutoGenH.Append(gAutoGenHeaderString,   {'FileName':'AutoGen.h'})\r
     # header file Prologue\r
     AutoGenH.Append(gAutoGenHPrologueString,{'Guid':Info.Guid.replace('-','_')})\r
-    # specification macros\r
-    AutoGenH.Append(gSpecificationString,   {'Specification':Info.MacroList})\r
-    # header files includes\r
-    AutoGenH.Append("#include <%s>\n\n" % gBasicHeaderFile)\r
-    AutoGenH.Append('\nextern GUID  gEfiCallerIdGuid;\n\n')\r
-\r
+    if Info.AutoGenVersion >= 0x00010005:\r
+        # specification macros\r
+        AutoGenH.Append(gSpecificationString,   {'SpecificationName':Info.Macro.keys(), \r
+                                                 'SpecificationValue':Info.Macro.values()})\r
+        # header files includes\r
+        AutoGenH.Append("#include <%s>\n\n" % gBasicHeaderFile)\r
+        AutoGenH.Append('\nextern GUID  gEfiCallerIdGuid;\n\n')\r
+    \r
+        if Info.IsLibrary:\r
+            return\r
+    \r
+        AutoGenH.Append("#define EFI_CALLER_ID_GUID \\\n  %s\n" % GuidStringToGuidStructureString(Info.Guid))\r
+    \r
     if Info.IsLibrary:\r
         return\r
-\r
-    AutoGenH.Append("#define EFI_CALLER_ID_GUID \\\n  %s\n" % GuidStringToGuidStructureString(Info.Guid))\r
-\r
     # C file header\r
     AutoGenC.Append(gAutoGenHeaderString, {'FileName':'AutoGen.c'})\r
-    # C file header files includes\r
-    for Inc in gModuleTypeHeaderFile[Info.ModuleType]:\r
-        AutoGenC.Append("#include <%s>\n" % Inc)\r
-\r
-    #\r
-    # Publish the CallerId Guid\r
-    #\r
-    AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = %s;\n' % GuidStringToGuidStructureString(Info.Guid))\r
+    if Info.AutoGenVersion >= 0x00010005:\r
+        # C file header files includes\r
+        for Inc in gModuleTypeHeaderFile[Info.ModuleType]:\r
+            AutoGenC.Append("#include <%s>\n" % Inc)\r
+    \r
+        #\r
+        # Publish the CallerId Guid\r
+        #\r
+        AutoGenC.Append('\nGLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = %s;\n' % GuidStringToGuidStructureString(Info.Guid))\r
 \r
 ## Create common code for header file\r
 #\r
@@ -1617,14 +1623,15 @@ def CreateFooterCode(Info, AutoGenC, AutoGenH):
 def CreateCode(Info, AutoGenC, AutoGenH):\r
     CreateHeaderCode(Info, AutoGenC, AutoGenH)\r
 \r
-    CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH)\r
-    CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH)\r
-    CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH)\r
-    CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH)\r
-    CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH)\r
-    CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH)\r
-    CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH)\r
-    CreatePcdCode(Info, AutoGenC, AutoGenH)\r
+    if Info.AutoGenVersion >= 0x00010005:\r
+        CreateLibraryConstructorCode(Info, AutoGenC, AutoGenH)\r
+        CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH)\r
+        CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH)\r
+        CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH)\r
+        CreateGuidDefinitionCode(Info, AutoGenC, AutoGenH)\r
+        CreateProtocolDefinitionCode(Info, AutoGenC, AutoGenH)\r
+        CreatePpiDefinitionCode(Info, AutoGenC, AutoGenH)\r
+        CreatePcdCode(Info, AutoGenC, AutoGenH)\r
     CreateUnicodeStringCode(Info, AutoGenC, AutoGenH)\r
 \r
     CreateFooterCode(Info, AutoGenC, AutoGenH)\r
index 1b71492..7769427 100644 (file)
@@ -20,6 +20,7 @@ from struct import pack
 from Common.EdkIIWorkspace import CreateDirectory\r
 from Common.BuildToolError import *\r
 from Common.Misc import SaveFileOnChange\r
+from Common import EdkLogger as EdkLogger\r
 \r
 ## Mapping between module type and EFI phase\r
 gType2Phase = {\r
@@ -89,7 +90,7 @@ class DependencyExpression:
     #\r
     # open and close brace must be taken as individual tokens\r
     #\r
-    TokenPattern = re.compile("(\(|\)|\{[^{}]+\{[^{}]+\}[ ]*\}|\w+)")\r
+    TokenPattern = re.compile("(\(|\)|\{[^{}]+\{?[^{}]+\}?[ ]*\}|\w+)")\r
 \r
     ## Constructor\r
     # \r
@@ -148,12 +149,12 @@ class DependencyExpression:
     def ValidateOpcode(self):\r
         for Op in self.AboveAllOpcode:\r
             if Op in self.OpcodeList and Op != self.OpcodeList[0]:\r
-                EdkLogger.error("DepexParser", PARSER_ERROR, "Opcode=%s should be the first one in the expression" % Op)\r
+                EdkLogger.error("GenDepex", PARSER_ERROR, "Opcode=%s should be the first one in the expression" % Op)\r
         for Op in self.ExclusiveOpcode:\r
             if Op in self.OpcodeList and len(self.OpcodeList) > 1:\r
-                EdkLogger.error("DepexParser", PARSER_ERROR, "Opcode=%s should be the only opcode in the expression" % Op)\r
+                EdkLogger.error("GenDepex", PARSER_ERROR, "Opcode=%s should be the only opcode in the expression" % Op)\r
         if self.TokenList[-1] in self.NonEndingOpcode:\r
-            EdkLogger.error("DepexParser", PARSER_ERROR, "Extra %s at the end of the dependency expression" % self.TokenList[-1])\r
+            EdkLogger.error("GenDepex", PARSER_ERROR, "Extra %s at the end of the dependency expression" % self.TokenList[-1])\r
 \r
     ## Convert a GUID value in C structure format into its binary form\r
     #\r
@@ -165,7 +166,7 @@ class DependencyExpression:
         GuidValueString = Guid.replace("{", "").replace("}", "").replace(" ", "")\r
         GuidValueList = GuidValueString.split(",")\r
         if len(GuidValueList) != 11:\r
-            EdkLogger.error("DepexParser", PARSER_ERROR, "Invalid GUID value string or opcode: %s" % Guid)\r
+            EdkLogger.error("GenDepex", PARSER_ERROR, "Invalid GUID value string or opcode: %s" % Guid)\r
         return pack("1I2H8B", *(int(value, 16) for value in GuidValueList))\r
 \r
     ## Save the binary form of dependency expression in file\r
@@ -233,7 +234,7 @@ def Main():
     Option, Input = GetOptions()\r
     if Option.ModuleType == None or Option.ModuleType not in gType2Phase:\r
         print "Module type is not specified or supported"\r
-        return -1\r
+        return 1\r
 \r
     try:\r
         if len(Input) > 0 and Option.Expression == "":\r
@@ -244,7 +245,7 @@ def Main():
             DxsString = Option.Expression\r
         else:\r
             print "No expression string or file given"\r
-            return -1\r
+            return 1\r
 \r
         Dpx = DependencyExpression(DxsString, Option.ModuleType)\r
 \r
@@ -253,7 +254,8 @@ def Main():
         else:\r
             Dpx.Generate()\r
     except Exception, e:\r
-        return -1\r
+        print e\r
+        return 1\r
 \r
     return 0\r
 \r
index 8c16179..f2e0dd1 100755 (executable)
@@ -27,10 +27,31 @@ from BuildInfo import *
 from BuildEngine import *\r
 \r
 ## Regular expression for finding header file inclusions\r
-gIncludePattern = re.compile("^[ #]*include[ ]+[\"<]*([^\"< >]+)[>\" ]*$", re.MULTILINE | re.UNICODE)\r
+gIncludePattern = re.compile("^[ #]*include[ ]+[\"<]*([^\"< >\s]+)[>\" ]*$", re.MULTILINE | re.UNICODE)\r
 \r
 ## Regular expression for matching macro used in header file inclusion\r
-gMacroPattern = re.compile("[_A-Z][_A-Z0-9]*\(.+\)", re.UNICODE)\r
+gMacroPattern = re.compile("([_A-Z][_A-Z0-9]*)\((.+)\)", re.UNICODE)\r
+\r
+##\r
+gProtocolDefinition = "Protocol/%(HeaderKey)s/%(HeaderKey)s.h"\r
+gGuidDefinition = "Guid/%(HeaderKey)s/%(HeaderKey)s.h"\r
+gArchProtocolDefinition = "ArchProtocol/%(HeaderKey)s/%(HeaderKey)s.h"\r
+gPpiDefinition = "Ppi/%(HeaderKey)s/%(HeaderKey)s.h"\r
+gIncludeMacroConversion = {\r
+  "EFI_PROTOCOL_DEFINITION"         :   gProtocolDefinition,\r
+  "EFI_GUID_DEFINITION"             :   gGuidDefinition,\r
+  "EFI_ARCH_PROTOCOL_DEFINITION"    :   gArchProtocolDefinition,\r
+  "EFI_PROTOCOL_PRODUCER"           :   gProtocolDefinition,\r
+  "EFI_PROTOCOL_CONSUMER"           :   gProtocolDefinition,\r
+  "EFI_PROTOCOL_DEPENDENCY"         :   gProtocolDefinition,\r
+  "EFI_ARCH_PROTOCOL_PRODUCER"      :   gArchProtocolDefinition,\r
+  "EFI_ARCH_PROTOCOL_CONSUMER"      :   gArchProtocolDefinition,\r
+  "EFI_ARCH_PROTOCOL_DEPENDENCY"    :   gArchProtocolDefinition,\r
+  "EFI_PPI_DEFINITION"              :   gPpiDefinition,\r
+  "EFI_PPI_PRODUCER"                :   gPpiDefinition,\r
+  "EFI_PPI_CONSUMER"                :   gPpiDefinition,\r
+  "EFI_PPI_DEPENDENCY"              :   gPpiDefinition,\r
+}\r
 \r
 gMakefileHeader = '''#\r
 # DO NOT EDIT\r
@@ -89,7 +110,7 @@ gShellCommand = {
     },\r
 \r
     "gmake" : {\r
-        "CP"    :   "cp -f",\r
+        "CP"    :   "cp -u -f",\r
         "MV"    :   "mv -f",\r
         "RM"    :   "rm -f",\r
         "MD"    :   "mkdir -p",\r
@@ -318,6 +339,7 @@ LIBS = ${BEGIN}$(BUILD_DIR)${separator}$(ARCH)${separator}${library_file} \\
 COMMON_DEPS = ${BEGIN}$(WORKSPACE)${separator}${common_dependency_file} \\\r
               ${END}\r
 \r
+IMAGE_ENTRY_POINT = ${module_entry_point}\r
 ENTRYPOINT = ${module_entry_point}\r
 \r
 #\r
@@ -359,8 +381,8 @@ fds: mbuild gen_fds
 #\r
 init:\r
 \t-@echo Building ... $(MODULE_NAME) $(MODULE_VERSION) [$(ARCH)] in platform $(PLATFORM_NAME) $(PLATFORM_VERSION)\r
-\t${BEGIN}-@${create_directory_command}\r
-\t${END}\r
+${BEGIN}\t-@${create_directory_command}\n${END}\\r
+${BEGIN}\t-@${copy_autogen_h}\n${END}\r
 \r
 #\r
 # GenLibsTarget\r
@@ -714,9 +736,15 @@ class Makefile(object):
             EdkLogger.debug(EdkLogger.DEBUG_5, "Static library: " + PlatformInfo.ToolStaticLib["DLINK"])\r
             self.SystemLibraryList.append(PlatformInfo.ToolStaticLib["DLINK"])\r
 \r
-        EntryPoint = "_ModuleEntryPoint"\r
         if self.ModuleInfo.Arch == "EBC":\r
+            # EBC compiler always use "EfiStart" as entry point\r
             EntryPoint = "EfiStart"\r
+        elif self.ModuleInfo.AutoGenVersion < 0x00010005 and len(self.ModuleInfo.Module.ModuleEntryPointList) > 0:\r
+            # R8 modules use different entry point functions\r
+            EntryPoint = self.ModuleInfo.Module.ModuleEntryPointList[0]\r
+        else:\r
+            # R9 modules always use "_ModuleEntryPoint" as entry point\r
+            EntryPoint = "_ModuleEntryPoint"\r
 \r
         DefaultToolFlag = PlatformInfo.ToolOption.values()\r
         if self.ModuleInfo.ModuleType == "USER_DEFINED":\r
@@ -753,6 +781,14 @@ class Makefile(object):
                             {"target_file" : self.DestFileDatabase[FileType]})\r
             TargetFileMacroList.append(str(Template))\r
 \r
+        # R8 modules need <BaseName>StrDefs.h for string ID\r
+        if self.ModuleInfo.AutoGenVersion < 0x00010005 and len(self.ModuleInfo.UnicodeFileList) > 0:\r
+            AutoGenHeaderFile = os.path.join("$(DEBUG_DIR)", "AutoGen.h")\r
+            StringHeaderFile = os.path.join("$(DEBUG_DIR)", "%sStrDefs.h" % self.ModuleInfo.BaseName)\r
+            CopyAutoGenHeaderFile = ["$(CP) %s %s" % (AutoGenHeaderFile, StringHeaderFile)]\r
+        else:\r
+            CopyAutoGenHeaderFile = []\r
+\r
         MakefileName = gMakefileName[MakeType]\r
         MakefileTemplateDict = {\r
             "makefile_header"           : gMakefileHeader % MakefileName,\r
@@ -813,6 +849,7 @@ class Makefile(object):
             "source_file_macro_name"    : SourceFileMacroNameList,\r
             "target_file_macro_name"    : TargetFileMacroNameList,\r
             "file_build_target"         : self.BuildTargetList,\r
+            "copy_autogen_h"            : CopyAutoGenHeaderFile,\r
         }\r
 \r
         self.PrepareDirectory()\r
@@ -1094,7 +1131,7 @@ class Makefile(object):
         self.FileDependency = self.GetFileDependency(SourceFileList, ForceIncludedFile, self.ModuleInfo.IncludePathList)\r
         DepSet = None\r
         for File in self.FileDependency:\r
-            # skipt AutoGen.c\r
+            # skip AutoGen.c\r
             if File.endswith("AutoGen.c") or not File.endswith(".c"):\r
                 continue\r
             elif DepSet == None:\r
@@ -1212,6 +1249,17 @@ class Makefile(object):
 \r
                 CurrentFilePath = os.path.dirname(F)\r
                 for Inc in IncludedFileList:\r
+                    # if there's macro used to reference header file, expand it\r
+                    HeaderList = gMacroPattern.findall(Inc)\r
+                    if len(HeaderList) == 1 and len(HeaderList[0]) == 2:\r
+                        HeaderType = HeaderList[0][0]\r
+                        HeaderKey = HeaderList[0][1]\r
+                        if HeaderType in gIncludeMacroConversion:\r
+                            Inc = gIncludeMacroConversion[HeaderType] % {"HeaderKey" : HeaderKey}\r
+                        else:\r
+                            # not known macro used in #include\r
+                            MacroUsedByIncludedFile = True\r
+                            continue\r
                     Inc = os.path.normpath(Inc)\r
                     for SearchPath in [CurrentFilePath] + SearchPathList:\r
                         FilePath = os.path.join(SearchPath, Inc)\r
@@ -1222,9 +1270,8 @@ class Makefile(object):
                             FileStack.append(FilePath)\r
                         break\r
                     else:\r
-                        if gMacroPattern.match(Inc) != None:\r
-                            MacroUsedByIncludedFile = True\r
                         EdkLogger.verbose("%s included by %s was not found in any given path:\n\t%s" % (Inc, F, "\n\t".join(SearchPathList)))\r
+\r
                 if not MacroUsedByIncludedFile:\r
                     if F == File:\r
                         CurrentFileDependencyList += ForceList\r
@@ -1240,7 +1287,7 @@ class Makefile(object):
         # returning a empty dependency\r
         #\r
         if MacroUsedByIncludedFile:\r
-            DependencyList = []\r
+            DependencyList = [""]\r
         else:\r
             DependencyList = list(DependencySet)  # remove duplicate ones\r
             DependencyList.append(File)\r
index e528b66..af23b11 100644 (file)
@@ -196,6 +196,8 @@ def GetFileList(IncludeList, SkipList):
         SkipList = []\r
 \r
     for Dir in IncludeList:\r
+        if not os.path.exists(Dir):\r
+            continue\r
         for File in os.listdir(Dir):\r
             File = os.path.join(Dir, os.path.normcase(File))\r
             #\r
index 70e9402..c6d0139 100644 (file)
@@ -27,6 +27,7 @@ TAB_SLASH = '\\'
 TAB_BACK_SLASH = '/'\r
 \r
 TAB_EDK_SOURCE = '$(EDK_SOURCE)'\r
+TAB_EFI_SOURCE = '$(EFI_SOURCE)'\r
 TAB_WORKSPACE = '$(WORKSPACE)'\r
 \r
 TAB_ARCH_NULL = ''\r
@@ -262,6 +263,7 @@ TAB_INF_DEFINES_FFS_EXT = 'FFS_EXT'
 TAB_INF_DEFINES_FV_EXT = 'FV_EXT'\r
 TAB_INF_DEFINES_SOURCE_FV = 'SOURCE_FV'\r
 TAB_INF_DEFINES_VERSION_NUMBER = 'VERSION_NUMBER'\r
+TAB_INF_DEFINES_VERSION = 'VERSION'          # for R8 inf, the same as VERSION_NUMBER\r
 TAB_INF_DEFINES_VERSION_STRING = 'VERSION_STRING'\r
 TAB_INF_DEFINES_PCD_IS_DRIVER = 'PCD_IS_DRIVER'\r
 TAB_INF_DEFINES_TIANO_R8_FLASHMAP_H = 'TIANO_R8_FLASHMAP_H'\r
@@ -327,3 +329,4 @@ TAB_TOD_DEFINES_TARGET = 'TARGET'
 TAB_TOD_DEFINES_TOOL_CHAIN_TAG = 'TOOL_CHAIN_TAG'\r
 TAB_TOD_DEFINES_TARGET_ARCH = 'TARGET_ARCH'\r
 TAB_TOD_DEFINES_COMMAND_TYPE = 'COMMAND_TYPE'\r
+\r
index 2b51658..ddbc58a 100644 (file)
@@ -232,7 +232,7 @@ class Dec(DecObject):
                 MergeArches(Includes, Item, Arch)\r
         for Key in Includes.keys():\r
             Include = IncludeClass()\r
-            Include.FilePath = Key\r
+            Include.FilePath = NormPath(Key)\r
             Include.SupArchList = Includes[Key]\r
             self.Package.Includes.append(Include)\r
             \r
@@ -311,7 +311,7 @@ class Dec(DecObject):
         for Key in LibraryClasses.keys():\r
             LibraryClass = LibraryClassClass()\r
             LibraryClass.LibraryClass = Key[0]\r
-            LibraryClass.RecommendedInstance = Key[1]\r
+            LibraryClass.RecommendedInstance = NormPath(Key[1])\r
             LibraryClass.SupModuleList = list(Key[2:])\r
             LibraryClass.SupArchList = LibraryClasses[Key]\r
             self.Package.LibraryClassDeclarations.append(LibraryClass)\r
index 82c2806..7910b8e 100755 (executable)
@@ -267,7 +267,7 @@ class Dsc(DscObject):
         self.Platform.Header.SkuIdName = self.Defines.DefinesDictionary[TAB_DSC_DEFINES_SKUID_IDENTIFIER]\r
         self.Platform.Header.SupArchList = self.Defines.DefinesDictionary[TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES]\r
         self.Platform.Header.BuildTargets = self.Defines.DefinesDictionary[TAB_DSC_DEFINES_BUILD_TARGETS]\r
-        self.Platform.Header.OutputDirectory = self.Defines.DefinesDictionary[TAB_DSC_DEFINES_OUTPUT_DIRECTORY][0]\r
+        self.Platform.Header.OutputDirectory = NormPath(self.Defines.DefinesDictionary[TAB_DSC_DEFINES_OUTPUT_DIRECTORY][0])\r
         self.Platform.Header.BuildNumber = self.Defines.DefinesDictionary[TAB_DSC_DEFINES_BUILD_NUMBER][0]\r
         self.Platform.Header.MakefileName = self.Defines.DefinesDictionary[TAB_DSC_DEFINES_MAKEFILE_NAME][0]\r
 \r
@@ -286,7 +286,7 @@ class Dsc(DscObject):
                     self.Platform.Header.Define[CleanString(List[0])] = CleanString(List[1])\r
 \r
         Fdf = PlatformFlashDefinitionFileClass()\r
-        Fdf.FilePath = self.Defines.DefinesDictionary[TAB_DSC_DEFINES_FLASH_DEFINITION][0]\r
+        Fdf.FilePath = NormPath(self.Defines.DefinesDictionary[TAB_DSC_DEFINES_FLASH_DEFINITION][0])\r
         self.Platform.FlashDefinitionFile = Fdf\r
 \r
         #\r
@@ -370,7 +370,7 @@ class Dsc(DscObject):
         self.Platform.Libraries.IncludeFiles = IncludeFiles\r
         for Key in Libraries.keys():\r
             Library = PlatformLibraryClass()\r
-            Library.FilePath = Key\r
+            Library.FilePath = NormPath(Key)\r
             Library.Define = Defines\r
             Library.SupArchList = Libraries[Key]\r
             self.Platform.Libraries.LibraryList.append(Library)\r
@@ -411,7 +411,7 @@ class Dsc(DscObject):
         for Key in LibraryClasses.keys():\r
             Library = PlatformLibraryClass()\r
             Library.Name = Key[0]\r
-            Library.FilePath = Key[1]\r
+            Library.FilePath = NormPath(Key[1])\r
             Library.SupModuleList = list(Key[2:])\r
             Library.Define = Defines\r
             Library.SupArchList = LibraryClasses[Key]\r
@@ -508,19 +508,19 @@ class Dsc(DscObject):
         BuildOptions = Item[2]\r
         Pcds = Item[3]\r
         Component = PlatformModuleClass()\r
-        Component.FilePath = InfFilename\r
-        Component.ExecFilePath = ExecFilename\r
+        Component.FilePath = NormPath(InfFilename)\r
+        Component.ExecFilePath = NormPath(ExecFilename)\r
         for Lib in LibraryClasses:\r
             List = GetSplitValueList(Lib)\r
             if len(List) != 2:\r
                 RaiseParserError(Lib, 'LibraryClasses', ContainerFile, '<ClassName>|<InfFilename>')\r
             LibName = List[0]\r
-            LibFile = List[1]\r
+            LibFile = NormPath(List[1])\r
             if LibName == "" or LibName == "NULL":\r
                 LibName = "NULL%d" % self._NullClassIndex\r
                 self._NullClassIndex += 1\r
-            CheckFileType(LibFile, '.Inf', ContainerFile, 'library instance of component ', Lib)\r
-            CheckFileExist(self.WorkspaceDir, LibFile, ContainerFile, 'library instance of component', Lib)\r
+            CheckFileType(List[1], '.Inf', ContainerFile, 'library instance of component ', Lib)\r
+            CheckFileExist(self.WorkspaceDir, List[1], ContainerFile, 'library instance of component', Lib)\r
             Component.LibraryClasses.LibraryList.append(PlatformLibraryClass(LibName, LibFile))\r
         for BuildOption in BuildOptions:\r
             Key = GetBuildOption(BuildOption, ContainerFile)\r
index d8f4a6f..b91094f 100755 (executable)
@@ -169,6 +169,7 @@ class LibraryClassObject(object):
 #\r
 class ModuleBuildClassObject(object):\r
     def __init__(self):\r
+        self.AutoGenVersion          = 0\r
         self.DescFilePath            = ''\r
         self.BaseName                = ''\r
         self.ModuleType              = ''\r
@@ -188,6 +189,7 @@ class ModuleBuildClassObject(object):
         self.Binaries                = []\r
         self.Sources                 = []\r
         self.LibraryClasses          = {}\r
+        self.Libraries               = []\r
         self.Protocols               = []\r
         self.Ppis                    = []\r
         self.Guids                   = []\r
@@ -332,8 +334,9 @@ class PlatformBuildClassObject(object):
 \r
         self.SkuIds                  = {}\r
         self.Modules                 = []\r
-        self.Libraries               = []\r
+        self.LibraryInstances        = []\r
         self.LibraryClasses          = {}\r
+        self.Libraries               = {}\r
         self.Pcds                    = {}\r
         self.BuildOptions            = {}\r
 \r
@@ -471,7 +474,7 @@ class WorkspaceBuild(object):
             self.SupArchList = Platform.Header.SupArchList\r
             self.BuildTarget = Platform.Header.BuildTargets\r
             self.SkuId = Platform.Header.SkuIdName\r
-            self.Fdf = NormPath(Platform.FlashDefinitionFile.FilePath)\r
+            self.Fdf = Platform.FlashDefinitionFile.FilePath\r
 \r
             #\r
             # Get all inf files\r
@@ -480,6 +483,10 @@ class WorkspaceBuild(object):
                 for Arch in Item.SupArchList:\r
                     self.AddToInfDatabase(Item.FilePath)\r
 \r
+            for Item in Platform.Libraries.LibraryList:\r
+                for Arch in Item.SupArchList:\r
+                    self.AddToInfDatabase(Item.FilePath)\r
+\r
             for Item in Platform.Modules.ModuleList:\r
                 for Arch in Item.SupArchList:\r
                     #\r
@@ -526,8 +533,8 @@ class WorkspaceBuild(object):
                 Pb.Guid = Platform.Header.Guid\r
                 Pb.Version = Platform.Header.Version\r
                 Pb.DscSpecification = Platform.Header.DscSpecification\r
-                Pb.OutputDirectory = NormPath(Platform.Header.OutputDirectory)\r
-                Pb.FlashDefinition = NormPath(Platform.FlashDefinitionFile.FilePath)\r
+                Pb.OutputDirectory = Platform.Header.OutputDirectory\r
+                Pb.FlashDefinition = Platform.FlashDefinitionFile.FilePath\r
                 Pb.BuildNumber = Platform.Header.BuildNumber\r
 \r
                 #\r
@@ -541,7 +548,7 @@ class WorkspaceBuild(object):
                 #\r
                 for Item in Platform.Modules.ModuleList:\r
                     if Arch in Item.SupArchList:\r
-                        Pb.Modules.append(NormPath(Item.FilePath))\r
+                        Pb.Modules.append(Item.FilePath)\r
 \r
                 #\r
                 # BuildOptions\r
@@ -557,8 +564,16 @@ class WorkspaceBuild(object):
                     SupModuleList = self.FindSupModuleListOfLibraryClass(Item, Platform.LibraryClasses.LibraryList, Arch)\r
                     if Arch in Item.SupArchList:\r
                         for ModuleType in SupModuleList:\r
-                            Pb.LibraryClasses[(Item.Name, ModuleType)] = NormPath(Item.FilePath)\r
+                            Pb.LibraryClasses[(Item.Name, ModuleType)] = Item.FilePath\r
 \r
+                #\r
+                # Libraries\r
+                # \r
+                for Item in Platform.Libraries.LibraryList:\r
+                    for Arch in Item.SupArchList:\r
+                        Library = self.InfDatabase[Item.FilePath]\r
+                        Pb.Libraries[Library.Module.Header.Name] = Item.FilePath\r
+                \r
                 #\r
                 # Pcds\r
                 #\r
@@ -625,14 +640,14 @@ class WorkspaceBuild(object):
                 #\r
                 for Item in Package.Includes:\r
                     if Arch in Item.SupArchList:\r
-                        Pb.Includes.append(NormPath(Item.FilePath))\r
+                        Pb.Includes.append(Item.FilePath)\r
 \r
                 #\r
                 # LibraryClasses\r
                 #\r
                 for Item in Package.LibraryClassDeclarations:\r
                     if Arch in Item.SupArchList:\r
-                        Pb.LibraryClasses[Item.LibraryClass] = NormPath(Item.RecommendedInstance)\r
+                        Pb.LibraryClasses[Item.LibraryClass] = Item.RecommendedInstance\r
 \r
                 #\r
                 # Pcds\r
@@ -688,6 +703,7 @@ class WorkspaceBuild(object):
                 Pb.Specification = Module.Header.Specification\r
                 Pb.Specification[TAB_INF_DEFINES_EDK_RELEASE_VERSION] = Module.Header.EdkReleaseVersion\r
                 Pb.Specification[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION] = Module.Header.EfiSpecificationVersion\r
+                Pb.AutoGenVersion = int(Module.Header.InfVersion, 0)\r
 \r
                 #\r
                 # LibraryClass of Defines\r
@@ -714,7 +730,7 @@ class WorkspaceBuild(object):
                 #\r
                 for Item in Module.Binaries:\r
                     if Arch in Item.SupArchList:\r
-                        FileName = NormPath(Item.BinaryFile)\r
+                        FileName = Item.BinaryFile\r
                         FileType = Item.FileType\r
                         Target = Item.Target\r
                         FeatureFlag = Item.FeatureFlag\r
@@ -725,7 +741,7 @@ class WorkspaceBuild(object):
                 #\r
                 for Item in Module.Sources:\r
                     if Arch in Item.SupArchList:\r
-                        SourceFile = NormPath(Item.SourceFile)\r
+                        SourceFile = Item.SourceFile\r
                         TagName = Item.TagName\r
                         ToolCode = Item.ToolCode\r
                         ToolChainFamily = Item.ToolChainFamily\r
@@ -758,14 +774,14 @@ class WorkspaceBuild(object):
                 #\r
                 for Item in Module.Includes:\r
                     if Arch in Item.SupArchList:\r
-                        Pb.Includes.append(NormPath(Item.FilePath))\r
+                        Pb.Includes.append(Item.FilePath)\r
 \r
                 #\r
                 # Packages\r
                 #\r
                 for Item in Module.PackageDependencies:\r
                     if Arch in Item.SupArchList:\r
-                        Pb.Packages.append(NormPath(Item.FilePath))\r
+                        Pb.Packages.append(Item.FilePath)\r
 \r
                 #\r
                 # BuildOptions\r
@@ -799,7 +815,7 @@ class WorkspaceBuild(object):
                                     Instance = self.FindLibraryClassInstanceOfLibrary(Lib, Arch, Type)\r
                                     if Instance == None:\r
                                         Instance = RecommendedInstance\r
-                                    Pb.LibraryClasses[(Lib, Type)] = NormPath(Instance)\r
+                                    Pb.LibraryClasses[(Lib, Type)] = Instance\r
                         else:\r
                             #\r
                             # For Module\r
@@ -807,7 +823,14 @@ class WorkspaceBuild(object):
                             Instance = self.FindLibraryClassInstanceOfModule(Lib, Arch, Pb.ModuleType, Inf)\r
                             if Instance == None:\r
                                 Instance = RecommendedInstance\r
-                            Pb.LibraryClasses[(Lib, Pb.ModuleType)] = NormPath(Instance)\r
+                            Pb.LibraryClasses[(Lib, Pb.ModuleType)] = Instance\r
+\r
+                #\r
+                # Libraries\r
+                #\r
+                for Item in Module.Libraries:\r
+                    if Arch in Item.SupArchList:\r
+                        Pb.Libraries.append(Item.Library)\r
 \r
                 #\r
                 # Pcds\r
@@ -837,25 +860,46 @@ class WorkspaceBuild(object):
                 for Inf in Platform.Modules:\r
                     if not self.IsModuleDefinedInPlatform(Inf, Arch, InfList):\r
                         continue\r
-                    Module = self.Build[Arch].ModuleDatabase[NormPath(Inf)]\r
+                    Module = self.Build[Arch].ModuleDatabase[Inf]\r
                     if Module.LibraryClass == None or Module.LibraryClass == []:\r
-                        self.UpdateLibrariesOfModule(Module, Arch)\r
+                        self.UpdateLibrariesOfModule(Platform, Module, Arch)\r
                         for Key in Module.LibraryClasses:\r
                             Lib = Module.LibraryClasses[Key]\r
-                            if Lib not in Platform.Libraries:\r
-                                Platform.Libraries.append(Lib)\r
+                            if Lib not in Platform.LibraryInstances:\r
+                                Platform.LibraryInstances.append(Lib)\r
+\r
 \r
     ## Update Libraries Of Module Database\r
     #\r
     # @param Module:  The module need to be updated libraries\r
     # @param Arch:    The supportted arch of the module\r
     #\r
-    def UpdateLibrariesOfModule(self, Module, Arch):\r
+    def UpdateLibrariesOfModule(self, Platform, Module, Arch):\r
         ModuleDatabase = self.Build[Arch].ModuleDatabase\r
-\r
         ModuleType = Module.ModuleType\r
-        LibraryConsumerList = [Module]\r
 \r
+        # check R8 module\r
+        if Module.AutoGenVersion < 0x00010005:\r
+            EdkLogger.verbose("")\r
+            EdkLogger.verbose("Library instances of module [%s] [%s]:" % (str(Module), Arch))\r
+            LibraryConsumerList = [Module]\r
+            while len(LibraryConsumerList) > 0:\r
+                M = LibraryConsumerList.pop()\r
+                for LibraryName in M.Libraries:\r
+                    if LibraryName not in Platform.Libraries:\r
+                        EdkLogger.error("AutoGen", AUTOGEN_ERROR,\r
+                                        "Library instance for library class [%s] is not found" % LibraryName,\r
+                                        ExtraData="\t%s [%s]" % (str(Module), Arch))\r
+    \r
+                    LibraryFile = Platform.Libraries[LibraryName]\r
+                    if (LibraryName, ModuleType) not in Module.LibraryClasses:\r
+                        Module.LibraryClasses[LibraryName, ModuleType] = LibraryFile\r
+                        LibraryConsumerList.append(ModuleDatabase[LibraryFile])\r
+                    EdkLogger.verbose("\t" + LibraryName + " : " + LibraryFile)\r
+            return\r
+\r
+        # R9 module\r
+        LibraryConsumerList = [Module]\r
         Constructor         = []\r
         ConsumedByList      = sdict()\r
         LibraryInstance     = sdict()\r
@@ -1035,7 +1079,7 @@ class WorkspaceBuild(object):
         # Add additional inf file defined in Fdf file\r
         #\r
         for InfFile in InfList:\r
-            self.AddToInfDatabase(InfFile)\r
+            self.AddToInfDatabase(NormPath(InfFile))\r
         \r
         #\r
         # Generate PlatformDatabase, PackageDatabase and ModuleDatabase\r
@@ -1099,7 +1143,8 @@ class WorkspaceBuild(object):
         #\r
         # Update the library instance itself to add this libraryclass name\r
         #\r
-        LibList = self.InfDatabase[NormPath(InstanceFilePath)].Module.Header.LibraryClass\r
+        LibraryModule = self.InfDatabase[InstanceFilePath].Module\r
+        LibList = LibraryModule.Header.LibraryClass\r
         NotFound = True\r
         for Lib in LibList:\r
             #\r
@@ -1111,13 +1156,14 @@ class WorkspaceBuild(object):
         if NotFound:\r
             NewLib = LibraryClassClass()\r
             NewLib.LibraryClass = LibraryClass\r
-            NewLib.SupModuleList = self.InfDatabase[NormPath(InstanceFilePath)].Module.Header.ModuleType.split()\r
-            self.InfDatabase[NormPath(InstanceFilePath)].Module.Header.LibraryClass.append(NewLib)\r
+            NewLib.SupModuleList = LibraryModule.Header.ModuleType.split()\r
+            LibraryModule.Header.LibraryClass.append(NewLib)\r
 \r
         #\r
         # Add it to LibraryClasses Section for the module which is using the library\r
         #\r
-        LibList = self.InfDatabase[NormPath(InfFileName)].Module.LibraryClasses\r
+        Module = self.InfDatabase[InfFileName].Module\r
+        LibList = Module.LibraryClasses\r
         NotFound = True\r
         for Lib in LibList:\r
             #\r
@@ -1133,7 +1179,7 @@ class WorkspaceBuild(object):
             Lib = LibraryClassClass()\r
             Lib.LibraryClass = LibraryClass\r
             Lib.SupArchList = [Arch]\r
-            self.InfDatabase[NormPath(InfFileName)].Module.LibraryClasses.append(Lib)\r
+            Module.LibraryClasses.append(Lib)\r
 \r
     ## Add Inf file to InfDatabase\r
     #\r
@@ -1142,7 +1188,6 @@ class WorkspaceBuild(object):
     # @param InfFileName: The InfFileName need to be added to database\r
     #\r
     def AddToInfDatabase(self, InfFileName):\r
-        InfFileName = NormPath(InfFileName)\r
         File = self.WorkspaceFile(InfFileName)\r
         if os.path.exists(File) and os.path.isfile(File):\r
             if InfFileName not in self.InfDatabase:\r
@@ -1157,7 +1202,6 @@ class WorkspaceBuild(object):
     # @param DecFileName: The DecFileName need to be added to database\r
     #\r
     def AddToDecDatabase(self, DecFileName):\r
-        DecFileName = NormPath(DecFileName)\r
         File = self.WorkspaceFile(DecFileName)\r
         if os.path.exists(File) and os.path.isfile(File):\r
             if DecFileName not in self.DecDatabase:\r
@@ -1185,10 +1229,10 @@ class WorkspaceBuild(object):
             Platform = self.DscDatabase[Dsc].Platform\r
             for Module in Platform.Modules.ModuleList:\r
                 if Arch in Module.SupArchList:\r
-                    if NormPath(Module.FilePath) == ModuleName:\r
+                    if Module.FilePath == ModuleName:\r
                         for LibraryClass in Module.LibraryClasses.LibraryList:\r
                             if LibraryClass.Name == Lib:\r
-                                return NormPath(LibraryClass.FilePath)\r
+                                return LibraryClass.FilePath\r
         #\r
         #Second find if exist in <LibraryClass> of <LibraryClasses> from dsc file\r
         #\r
@@ -1233,7 +1277,7 @@ class WorkspaceBuild(object):
             Platform = self.DscDatabase[Dsc].Platform\r
             for Module in Platform.Modules.ModuleList:\r
                 if Arch in Module.SupArchList:\r
-                    if NormPath(Module.FilePath) == ModuleName:\r
+                    if Module.FilePath == ModuleName:\r
                         for BuildOption in Module.ModuleSaBuildOption.BuildOptionList:\r
                             #\r
                             # Add to BuildOptions\r
@@ -1311,7 +1355,7 @@ class WorkspaceBuild(object):
         for Dsc in self.DscDatabase.keys():\r
             for Module in self.DscDatabase[Dsc].Platform.Modules.ModuleList:\r
                 if Arch in Module.SupArchList:\r
-                    if NormPath(Module.FilePath) == ModuleName:\r
+                    if Module.FilePath == ModuleName:\r
                         for Pcd in Module.PcdBuildDefinitions:\r
                             if (Name, Guid) == (Pcd.CName, Pcd.TokenSpaceGuidCName):\r
                                 if Pcd.DefaultValue != '':\r
@@ -1419,7 +1463,7 @@ class WorkspaceBuild(object):
     #\r
     def FindSupModuleListOfLibraryClass(self, LibraryClass, OverridedLibraryClassList, Arch):\r
         Name = LibraryClass.Name\r
-        FilePath = NormPath(LibraryClass.FilePath)\r
+        FilePath = LibraryClass.FilePath\r
         SupModuleList = copy.copy(LibraryClass.SupModuleList)\r
 \r
         #\r
@@ -1464,17 +1508,19 @@ class WorkspaceBuild(object):
     # @retval Flase    Module Not Found\r
     #\r
     def IsModuleDefinedInPlatform(self, Inf, Arch, InfList):\r
-        Inf = NormPath(Inf)\r
         for Dsc in self.DscDatabase.values():\r
             for LibraryClass in Dsc.Platform.LibraryClasses.LibraryList:\r
-                if Inf == NormPath(LibraryClass.FilePath) and Arch in LibraryClass.SupArchList:\r
+                if Inf == LibraryClass.FilePath and Arch in LibraryClass.SupArchList:\r
                     return True\r
             for Module in Dsc.Platform.Modules.ModuleList:\r
-                if Inf == NormPath(Module.FilePath) and Arch in Module.SupArchList:\r
+                if Inf == Module.FilePath and Arch in Module.SupArchList:\r
                     return True\r
                 for Item in Module.LibraryClasses.LibraryList:\r
-                    if Inf == NormPath(Item.FilePath):\r
+                    if Inf == Item.FilePath:\r
                         return True\r
+            for Library in Dsc.Platform.Libraries.LibraryList:\r
+                if Inf == Library.FilePath and Arch in Library.SupArchList:\r
+                    return True\r
 \r
         return False\r
 \r
index ae944c2..1c54789 100755 (executable)
@@ -15,6 +15,7 @@
 # Import Modules\r
 #\r
 import os\r
+import re\r
 import EdkLogger\r
 from CommonDataClass.CommonClass import LibraryClassClass\r
 from CommonDataClass.ModuleClass import *\r
@@ -24,6 +25,28 @@ from Identification import *
 from Dictionary import *\r
 from BuildToolError import *\r
 \r
+gComponentType2ModuleType = {\r
+    "LIBRARY"               :   "BASE",\r
+    "SECURITY_CORE"         :   "SEC",\r
+    "PEI_CORE"              :   "PEI_CORE",\r
+    "COMBINED_PEIM_DRIVER"  :   "PEIM",\r
+    "PIC_PEIM"              :   "PEIM",\r
+    "RELOCATABLE_PEIM"      :   "PEIM",\r
+    "BS_DRIVER"             :   "DXE_DRIVER",\r
+    "RT_DRIVER"             :   "DXE_RUNTIME_DRIVER",\r
+    "SAL_RT_DRIVER"         :   "DXE_SAL_DRIVER",\r
+#    "BS_DRIVER"             :   "DXE_SMM_DRIVER",\r
+#    "BS_DRIVER"             :   "UEFI_DRIVER",\r
+    "APPLICATION"           :   "UEFI_APPLICATION",\r
+}\r
+\r
+gNmakeFlagPattern = re.compile("(?:EBC_)?([A-Z])+_(?:STD_|PROJ_|ARCH_)?FLAGS(?:_DLL|_ASL|_EXE)?", re.UNICODE)\r
+gNmakeFlagName2ToolCode = {\r
+    "C"         :   "CC",\r
+    "LIB"       :   "SLINK",\r
+    "LINK"      :   "DLINK",\r
+}\r
+\r
 ## InfObject\r
 #\r
 # This class defined basic Inf object which is used by inheriting\r
@@ -69,6 +92,7 @@ class InfDefines(InfObject):
             TAB_INF_DEFINES_SOURCE_FV                               : [''],\r
             TAB_INF_DEFINES_VERSION_NUMBER                          : [''],\r
             TAB_INF_DEFINES_VERSION_STRING                          : [''],\r
+            TAB_INF_DEFINES_VERSION                                 : [''],\r
             TAB_INF_DEFINES_PCD_IS_DRIVER                           : [''],\r
             TAB_INF_DEFINES_TIANO_R8_FLASHMAP_H                     : [''],\r
             TAB_INF_DEFINES_ENTRY_POINT                             : [''],\r
@@ -216,29 +240,16 @@ class Inf(InfObject):
         #\r
         # Get value for Header\r
         #\r
+        self.Module.Header.InfVersion = self.Defines.DefinesDictionary[TAB_INF_DEFINES_INF_VERSION][0]\r
         self.Module.Header.Name = self.Defines.DefinesDictionary[TAB_INF_DEFINES_BASE_NAME][0]\r
         self.Module.Header.Guid = self.Defines.DefinesDictionary[TAB_INF_DEFINES_FILE_GUID][0]\r
         \r
-        #\r
-        # Get version of INF\r
-        #\r
-        VersionNumber = self.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_NUMBER][0]\r
-        VersionString = self.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_STRING][0]\r
-        if len(VersionNumber) > 0 and len(VersionString) == 0:\r
-            EdkLogger.warn(2000, 'VERSION_NUMBER depricated; INF file %s should be modified to use VERSION_STRING instead.' % self.Identification.FileFullPath)\r
-            self.Module.Header.Version = VersionNumber\r
-        if len(VersionString) > 0:\r
-            if len(VersionNumber) > 0:\r
-                EdkLogger.warn(2001, 'INF file %s defines both VERSION_NUMBER and VERSION_STRING, using VERSION_STRING' % self.Identification.FileFullPath)\r
-            self.Module.Header.Version = VersionString\r
-        \r
         self.Module.Header.FileName = self.Identification.FileName\r
         self.Module.Header.FullPath = self.Identification.FileFullPath\r
         File = self.Module.Header.FullPath\r
         \r
         self.Module.Header.EfiSpecificationVersion = self.Defines.DefinesDictionary[TAB_INF_DEFINES_EFI_SPECIFICATION_VERSION][0]\r
         self.Module.Header.EdkReleaseVersion = self.Defines.DefinesDictionary[TAB_INF_DEFINES_EDK_RELEASE_VERSION][0]\r
-        self.Module.Header.InfVersion = self.Defines.DefinesDictionary[TAB_INF_DEFINES_INF_VERSION][0]\r
                 \r
         self.Module.Header.ModuleType = self.Defines.DefinesDictionary[TAB_INF_DEFINES_MODULE_TYPE][0]\r
         self.Module.Header.BinaryModule = self.Defines.DefinesDictionary[TAB_INF_DEFINES_BINARY_MODULE][0]\r
@@ -253,6 +264,28 @@ class Inf(InfObject):
         self.Module.Header.TianoR8FlashMap_h = self.Defines.DefinesDictionary[TAB_INF_DEFINES_TIANO_R8_FLASHMAP_H][0]\r
         self.Module.Header.Shadow = self.Defines.DefinesDictionary[TAB_INF_DEFINES_SHADOW][0]\r
         \r
+        #\r
+        # Get version of INF\r
+        #\r
+        if self.Module.Header.InfVersion != "":\r
+            # R9 inf\r
+            VersionNumber = self.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_NUMBER][0]\r
+            VersionString = self.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_STRING][0]\r
+            if len(VersionNumber) > 0 and len(VersionString) == 0:\r
+                EdkLogger.warn(2000, 'VERSION_NUMBER depricated; INF file %s should be modified to use VERSION_STRING instead.' % self.Identification.FileFullPath)\r
+                self.Module.Header.Version = VersionNumber\r
+            if len(VersionString) > 0:\r
+                if len(VersionNumber) > 0:\r
+                    EdkLogger.warn(2001, 'INF file %s defines both VERSION_NUMBER and VERSION_STRING, using VERSION_STRING' % self.Identification.FileFullPath)\r
+                self.Module.Header.Version = VersionString\r
+        else:\r
+            # R8 inf\r
+            self.Module.Header.InfVersion = "0x00010000"\r
+            VersionNumber = self.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION][0]\r
+            VersionString = self.Defines.DefinesDictionary[TAB_INF_DEFINES_VERSION_STRING][0]\r
+            if VersionString == '' and VersionNumber != '':\r
+                VersionString = VersionNumber\r
+            self.Module.Header.ModuleType = gComponentType2ModuleType[self.Module.Header.ComponentType]\r
         #\r
         # LibraryClass of Defines\r
         #\r
@@ -266,6 +299,11 @@ class Inf(InfObject):
                 elif len(List) == 2:\r
                     Lib.SupModuleList = GetSplitValueList(CleanString(List[1]), ' ')\r
                 self.Module.Header.LibraryClass.append(Lib)\r
+        elif self.Module.Header.ComponentType == "LIBRARY":\r
+            Lib = LibraryClassClass()\r
+            Lib.LibraryClass = self.Module.Header.Name\r
+            Lib.SupModuleList = DataType.SUP_MODULE_LIST\r
+            self.Module.Header.LibraryClass.append(Lib)\r
         \r
         #\r
         # Custom makefile of Defines\r
@@ -350,7 +388,7 @@ class Inf(InfObject):
                 MergeArches(Includes, Item, Arch)\r
         for Key in Includes.keys():\r
             Include = IncludeClass()\r
-            Include.FilePath = Key\r
+            Include.FilePath = NormPath(Key)\r
             Include.SupArchList = Includes[Key]\r
             self.Module.Includes.append(Include)\r
         \r
@@ -403,7 +441,7 @@ class Inf(InfObject):
             LibraryClass = LibraryClassClass()\r
             LibraryClass.Define = Defines\r
             LibraryClass.LibraryClass = Key[0]\r
-            LibraryClass.RecommendedInstance = Key[1]\r
+            LibraryClass.RecommendedInstance = NormPath(Key[1])\r
             LibraryClass.FeatureFlag = Key[2]\r
             LibraryClass.SupArchList = LibraryClasses[Key]\r
             if Key[3] != '':\r
@@ -440,7 +478,7 @@ class Inf(InfObject):
         for Key in Packages.keys():\r
             Package = ModulePackageDependencyClass()\r
             Package.Define = Defines\r
-            Package.FilePath = Key\r
+            Package.FilePath = NormPath(Key)\r
             Package.SupArchList = Packages[Key]\r
             self.Module.PackageDependencies.append(Package)\r
             \r
@@ -452,14 +490,36 @@ class Inf(InfObject):
             for Item in self.Contents[Arch].Nmake:\r
                 MergeArches(Nmakes, Item, Arch)\r
         for Key in Nmakes.keys():\r
-            List = GetSplitValueList(Key, DataType.TAB_EQUAL_SPLIT)\r
+            List = GetSplitValueList(Key, DataType.TAB_EQUAL_SPLIT, MaxSplit=1)\r
             if len(List) != 2:\r
-                RaiseParserError(Item[0], 'Nmake', File, 'DEFINE <VarName> = <PATH>')\r
+                RaiseParserError(Item[0], 'Nmake', File, '<MacroName> = <Value>')\r
             Nmake = ModuleNmakeClass()\r
             Nmake.Name = List[0]\r
             Nmake.Value = List[1]\r
             Nmake.SupArchList = Nmakes[Key]\r
             self.Module.Nmake.append(Nmake)\r
+\r
+            # convert R8 format to R9 format\r
+            if Nmake.Name == "IMAGE_ENTRY_POINT":\r
+                Image = ModuleExternImageClass()\r
+                Image.ModuleEntryPoint = Nmake.Value\r
+                self.Module.ExternImages.append(Image)\r
+            elif Nmake.Name == "DPX_SOURCE":\r
+                Source = ModuleSourceFileClass(NormPath(Nmake.Value), "", "", "", "", Nmake.SupArchList)\r
+                self.Module.Sources.append(Source)\r
+            else:\r
+                ToolList = gNmakeFlagPattern.findall(Nmake.Name)\r
+                if len(ToolList) == 0 or len(ToolList) != 1:\r
+                    EdkLogger.warn("\nParser", "Don't know how to do with MACRO: %s" % Nmake.Name, \r
+                                   ExtraData=File)\r
+                else:\r
+                    if ToolList[0] in gNmakeFlagName2ToolCode:\r
+                        Tool = gNmakeFlagName2ToolCode[ToolList[0]]\r
+                    else:\r
+                        Tool = ToolList[0]\r
+                    BuildOption = BuildOptionClass("MSFT", "*_*_*_%s_FLAGS" % Tool, Nmake.Value)\r
+                    BuildOption.SupArchList = Nmake.SupArchList\r
+                    self.Module.BuildOptions.append(BuildOption)\r
         \r
         #\r
         # Pcds\r
@@ -515,7 +575,7 @@ class Inf(InfObject):
                 CheckPcdTokenInfo(List[4], 'Sources', File)\r
                 MergeArches(Sources, (List[0], List[1], List[2], List[3], List[4]), Arch)\r
         for Key in Sources.keys():\r
-            Source = ModuleSourceFileClass(Key[0], Key[2], Key[3], Key[1], Key[4], Sources[Key])\r
+            Source = ModuleSourceFileClass(NormPath(Key[0]), Key[2], Key[3], Key[1], Key[4], Sources[Key])\r
             self.Module.Sources.append(Source)\r
 \r
         #\r
@@ -620,7 +680,7 @@ class Inf(InfObject):
                     CheckPcdTokenInfo(List[3], 'Binaries', File)\r
                     MergeArches(Binaries, (List[0], List[1], List[2], List[3]), Arch)\r
         for Key in Binaries.keys():\r
-            Binary = ModuleBinaryFileClass(Key[1], Key[0], Key[2], Key[3], Binaries[Key])\r
+            Binary = ModuleBinaryFileClass(NormPath(Key[1]), Key[0], Key[2], Key[3], Binaries[Key])\r
             self.Module.Binaries.append(Binary)\r
         \r
     ## Get Pcd Values of Inf\r
@@ -802,7 +862,7 @@ class Inf(InfObject):
 # script.\r
 #\r
 if __name__ == '__main__':\r
-    W = os.getenv('WORKSPACE')\r
-    F = os.path.join(W, 'MdeModulePkg/Application/HelloWorld/HelloWorld.inf')\r
-    P = Inf(os.path.normpath(F), True, True, W)\r
+    import sys\r
+    print os.path.abspath(sys.argv[1])\r
+    P = Inf(os.path.abspath(sys.argv[1]), True, True, os.getenv('WORKSPACE'))\r
     P.ShowModule()\r
index 94b2400..33daeac 100644 (file)
@@ -334,13 +334,29 @@ def NormPath(Path, Defines = {}):
             Path = Path.replace(Key, Defines[Key])\r
 \r
         #\r
-        # Remove ${WORKSPACE}\r
+        # Remove ${WORKSPACE}, $(EDK_SOURCE), $(EFI_SOURCE)\r
         #\r
+        if DataType.TAB_EDK_SOURCE in os.environ:\r
+            EdkSource = os.environ[DataType.TAB_EDK_SOURCE]\r
+        else:\r
+            EdkSource = "EdkCompatibilityPkg"\r
+\r
+        if DataType.TAB_EFI_SOURCE in os.environ:\r
+            EfiSource = os.environ[DataType.TAB_EFI_SOURCE]\r
+        else:\r
+            EfiSource = os.path.join("EdkCompatibilityPkg", "Foundation")\r
+    \r
         if Path.find(DataType.TAB_WORKSPACE) > -1:\r
             Path = Path.replace(DataType.TAB_WORKSPACE, '')\r
-            if Path.find(DataType.TAB_SLASH) == 0:\r
+            if len(Path) > 0 and Path[0] in [DataType.TAB_SLASH, DataType.TAB_BACK_SLASH] == 0:\r
                 Path = Path[1:]\r
-            if Path.find(DataType.TAB_BACK_SLASH) == 0:\r
+        elif Path.find(DataType.TAB_EDK_SOURCE) > -1:\r
+            Path = Path.replace(DataType.TAB_EDK_SOURCE, EdkSource)\r
+            if len(Path) > 0 and Path[0] in [DataType.TAB_SLASH, DataType.TAB_BACK_SLASH] == 0:\r
+                Path = Path[1:]\r
+        elif Path.find(DataType.TAB_EFI_SOURCE) > -1:\r
+            Path = Path.replace(DataType.TAB_EFI_SOURCE, EfiSource)\r
+            if len(Path) > 0 and Path[0] in [DataType.TAB_SLASH, DataType.TAB_BACK_SLASH] == 0:\r
                 Path = Path[1:]\r
 \r
         #\r
@@ -364,7 +380,7 @@ def CleanString(Line, CommentCharacter = DataType.TAB_COMMENT_SPLIT):
     #\r
     # remove whitespace\r
     #\r
-    Line = Line.strip();\r
+    Line = Line.strip();\r
     #\r
     # remove comments\r
     #\r
@@ -592,9 +608,7 @@ def CheckFileType(CheckFilename, ExtName, ContainerFilename, SectionName, Line):
 def CheckFileExist(WorkspaceDir, CheckFilename, ContainerFilename, SectionName, Line):\r
     if CheckFilename != '' and CheckFilename != None:\r
         CheckFile = WorkspaceFile(WorkspaceDir, CheckFilename)\r
-        if os.path.exists(CheckFile) and os.path.isfile(CheckFile):\r
-            pass\r
-        else:\r
+        if not os.path.isfile(CheckFile):\r
             ContainerFile = open(ContainerFilename, 'r').read()\r
             LineNo = GetLineNo(ContainerFile, Line)\r
             ErrorMsg = "Can't find file '%s' defined in section '%s'" % (CheckFile, SectionName)\r
index e7cc869..49a291a 100755 (executable)
@@ -86,7 +86,7 @@ class ToolDefClassObject(object):
             Value = NameValuePair[1].strip()\r
 \r
             if Name == "IDENTIFIER":\r
-                EdkLogger.debug(EdkLogger.DEBUG_9, "Line %d: Found identifier statement, skipped: %s" % ((Index + 1), Value))\r
+                EdkLogger.debug(EdkLogger.DEBUG_8, "Line %d: Found identifier statement, skipped: %s" % ((Index + 1), Value))\r
                 continue\r
 \r
             MacroDefinition = gMacroDefPattern.findall(Name)\r
@@ -95,7 +95,7 @@ class ToolDefClassObject(object):
 \r
                 MacroName = MacroDefinition[0].strip()\r
                 self.MacroDictionary["DEF(%s)" % MacroName] = Value\r
-                EdkLogger.debug(EdkLogger.DEBUG_9, "Line %d: Found macro: %s = %s" % ((Index + 1), MacroName, Value))\r
+                EdkLogger.debug(EdkLogger.DEBUG_8, "Line %d: Found macro: %s = %s" % ((Index + 1), MacroName, Value))\r
                 continue\r
 \r
             Value = self.ExpandMacros(Value)\r
index 9b2dfa0..b752123 100644 (file)
@@ -80,6 +80,12 @@ def CheckEnvVariable():
     if "WORKSPACE" not in os.environ:\r
         EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Please set environment variable: WORKSPACE!\n")\r
 \r
+    if "EDK_SOURCE" not in os.environ:\r
+        os.environ["EDK_SOURCE"] = "EdkCompatibilityPkg"\r
+\r
+    if "EFI_SOURCE" not in os.environ:\r
+        os.environ["EFI_SOURCE"] = os.path.join("EdkCompatibilityPkg", "Foundation")\r
+\r
     # check EDK_TOOLS_PATH\r
     if "EDK_TOOLS_PATH" not in os.environ == None:\r
         EdkLogger.error("build", ATTRIBUTE_NOT_AVAILABLE, "Please set environment variable: EDK_TOOLS_PATH!\n")\r
@@ -359,7 +365,7 @@ class BuildTask:
             #\r
             while (len(BuildTask._PendingQueue) > 0 or len(BuildTask._ReadyQueue) > 0 \\r
                    or not ExitFlag.isSet()) and not BuildTask._ErrorFlag.isSet():\r
-                EdkLogger.debug(EdkLogger.DEBUG_9, "Pending Queue (%d), Ready Queue (%d)"\r
+                EdkLogger.debug(EdkLogger.DEBUG_8, "Pending Queue (%d), Ready Queue (%d)"\r
                                 % (len(BuildTask._PendingQueue), len(BuildTask._ReadyQueue)))\r
                 # get all pending tasks\r
                 BuildTask._PendingQueueLock.acquire()\r
@@ -406,7 +412,7 @@ class BuildTask:
             # while not BuildTask._ErrorFlag.isSet() and \\r
             while len(BuildTask._RunningQueue) > 0:\r
                 EdkLogger.verbose("Waiting for thread ending...(%d)" % len(BuildTask._RunningQueue))\r
-                EdkLogger.debug(EdkLogger.DEBUG_9, "Threads [%s]" % ", ".join([Th.getName() for Th in threading.enumerate()]))\r
+                EdkLogger.debug(EdkLogger.DEBUG_8, "Threads [%s]" % ", ".join([Th.getName() for Th in threading.enumerate()]))\r
                 # avoid tense loop\r
                 time.sleep(0.1)\r
         except BaseException, X:\r