git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@417 7335b...
authorhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 26 Jul 2007 08:21:12 +0000 (08:21 +0000)
committerhche10x <hche10x@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 26 Jul 2007 08:21:12 +0000 (08:21 +0000)
Source/Python/Common/DataType.py
Source/Python/Common/EdkIIWorkspaceBuild.py
Source/Python/Common/InfClassObject.py
Source/Python/Common/String.py

index cdce703..27ba250 100644 (file)
@@ -24,8 +24,8 @@ TAB_SECTION_END = ']'
 TAB_OPTION_START = '<'\r
 TAB_OPTION_END  = '>'\r
 \r
-TAB_WORKSPACE1 = '${WORKSPACE}/'\r
-TAB_WORKSPACE2 = '$(WORKSPACE)/'\r
+TAB_EDK_SOURCE = '$(EDK_SOURCE)/'\r
+TAB_WORKSPACE = '$(WORKSPACE)/'\r
 \r
 TAB_ARCH_NULL = ''\r
 TAB_ARCH_COMMON = 'Common'\r
index 55b5593..c97c74f 100644 (file)
@@ -185,8 +185,8 @@ class PlatformBuildClassObject(object):
         return hash(self.DescFilePath)\r
 \r
 class ItemBuild(object):\r
-    def __init__(self, arch, platform = None, package = None, module = None):\r
-        self.Arch                    = arch\r
+    def __init__(self, Arch, Platform = None, Package = None, Module = None):\r
+        self.Arch                    = Arch\r
         self.PlatformDatabase        = {}        #{ [DscFileName] : PlatformBuildClassObject, ...}\r
         self.PackageDatabase         = {}        #{ [DecFileName] : PacakgeBuildClassObject, ...}\r
         self.ModuleDatabase          = {}        #{ [InfFileName] : ModuleBuildClassObject, ...}\r
@@ -206,58 +206,72 @@ class WorkspaceBuild(object):
         self.DscDatabase             = {}        #{ [DscFileName] : DscClassObject}\r
         \r
         self.Build                   = {}\r
-        for key in DataType.ARCH_LIST:\r
-            self.Build[key] = ItemBuild(key)\r
+        for Arch in DataType.ARCH_LIST:\r
+            self.Build[Arch] = ItemBuild(Arch)\r
         \r
+        #\r
         # Get active platform\r
-        dscFileName = ActivePlatform\r
-        File = self.WorkspaceFile(NormPath(dscFileName))\r
+        #\r
+        DscFileName = ActivePlatform\r
+        File = self.WorkspaceFile(NormPath(DscFileName))\r
         if os.path.exists(File) and os.path.isfile(File):\r
-            self.DscDatabase[dscFileName] = Dsc(File, True)\r
+            self.DscDatabase[DscFileName] = Dsc(File, True, True)\r
         else:\r
             raise ParserError(FILE_NOT_FOUND, name = File)\r
         \r
+        #\r
         # parse platform to get module\r
-        for dsc in self.DscDatabase.keys():\r
-            dscObj = self.DscDatabase[dsc]\r
+        #\r
+        for DscFile in self.DscDatabase.keys():\r
+            Platform = self.DscDatabase[DscFile].Platform\r
             \r
             #\r
             # Get global information\r
             #\r
-            self.SupArchList = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_SUPPORTED_ARCHITECTURES]\r
-            self.BuildTarget = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_BUILD_TARGETS]\r
-            self.SkuId = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_SKUID_IDENTIFIER][0]\r
-            self.Fdf = dscObj.Defines.DefinesDictionary[TAB_DSC_DEFINES_FLASH_DEFINITION][0]\r
+            self.SupArchList = Platform.Header.SupArchList\r
+            self.BuildTarget = Platform.Header.BuildTargets\r
+            self.SkuId = Platform.Header.SkuIdName\r
+            self.Fdf = Platform.FlashDefinitionFile.FilePath\r
             \r
-            #Get all inf\r
-            for key in DataType.ARCH_LIST:\r
-                for index in range(len(dscObj.Contents[key].LibraryClasses)):\r
-                    self.AddToInfDatabase(dscObj.Contents[key].LibraryClasses[index][0].split(DataType.TAB_VALUE_SPLIT, 1)[1])\r
-                for index in range(len(dscObj.Contents[key].Components)):\r
-                    Module = dscObj.Contents[key].Components[index][0]\r
-                    LibList = dscObj.Contents[key].Components[index][1]\r
+            #\r
+            # Get all inf files\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
+                    # Add modules\r
+                    #\r
+                    Module = Item.FilePath\r
                     self.AddToInfDatabase(Module)\r
-                    for indexOfLib in range(len(LibList)):\r
-                        Lib = LibList[indexOfLib]\r
-                        if len(Lib.split(DataType.TAB_VALUE_SPLIT)) == 2:\r
-                            self.AddToInfDatabase(CleanString(Lib.split(DataType.TAB_VALUE_SPLIT)[1]))\r
-                            self.UpdateInfDatabase(Module, CleanString(Lib.split(DataType.TAB_VALUE_SPLIT)[0]), key)\r
+                    #\r
+                    # Add library used in modules\r
+                    #\r
+                    for Lib in Item.LibraryClasses.LibraryList:\r
+                        self.AddToInfDatabase(Lib.FilePath)\r
+                        self.UpdateLibraryClassOfModule(Module, Lib.Name, Arch)\r
         #End For of Dsc\r
         \r
         #parse module to get package\r
-        for inf in self.InfDatabase.keys():\r
-            infObj = self.InfDatabase[inf]\r
+        for InfFile in self.InfDatabase.keys():\r
+            Module = self.InfDatabase[InfFile].Module\r
             #Get all dec\r
-            for key in DataType.ARCH_LIST:\r
-                for index in range(len(infObj.Contents[key].Packages)):\r
-                    self.AddToDecDatabase(infObj.Contents[key].Packages[index])\r
+            for Item in Module.PackageDependencies:\r
+                for Arch in Item.SupArchList:\r
+                    self.AddToDecDatabase(Item.FilePath)\r
+#            for key in DataType.ARCH_LIST:\r
+#                for index in range(len(infObj.Contents[key].Packages)):\r
+#                    self.AddToDecDatabase(infObj.Contents[key].Packages[index])\r
     #End of self.Init()\r
     \r
     #\r
     # Return a full path with workspace dir\r
     #\r
     def WorkspaceFile(self, Filename):\r
-        return os.path.join(self.WorkspaceDir, Filename)\r
+        return os.path.join(os.path.normpath(self.WorkspaceDir), os.path.normpath(Filename))\r
     \r
     def GenBuildDatabase(self, PcdsSet = {}):\r
         #Build databases\r
@@ -654,35 +668,52 @@ class WorkspaceBuild(object):
         \r
         #End of Inf Go Through\r
         \r
-        #End of build ModuleDatabase    \r
-    \r
-\r
+        #End of build ModuleDatabase\r
     \r
-    def UpdateInfDatabase(self, infFileName, LibraryClass, Arch):\r
-        infFileName = NormPath(infFileName)\r
-        LibList = self.InfDatabase[infFileName].Contents[Arch].LibraryClasses\r
+    def UpdateLibraryClassOfModule(self, InfFileName, LibraryClass, Arch):\r
+        LibList = self.InfDatabase[NormPath(InfFileName)].Module.LibraryClasses\r
         NotFound = True\r
-        for Item in LibList:\r
-            LibName = Item[0].split(DataType.TAB_VALUE_SPLIT)[0].strip()\r
-            if LibName == LibraryClass:\r
-                return\r
-        \r
+        for Lib in LibList:\r
+            #\r
+            # Find this LibraryClass\r
+            #\r
+            if Lib.LibraryClass == LibraryClass:\r
+                if Arch in Lib.SupArchList:\r
+                    return\r
+                else:\r
+                    Lib.SupArchList.append(Arch)\r
+                    return\r
         if NotFound:\r
-            self.InfDatabase[infFileName].Contents[Arch].LibraryClasses.extend([LibraryClass])\r
+            Lib = LibraryClassClass()\r
+            Lib.LibraryClass = LibraryClass\r
+            Lib.SupArchList = [Arch]\r
+                \r
+    \r
+#    def UpdateInfDatabase(self, InfFileName, LibraryClass, Arch):\r
+#        InfFileName = NormPath(InfFileName)\r
+#        LibList = self.InfDatabase[InfFileName].Contents[Arch].LibraryClasses\r
+#        LibList = self.InfDatabase[InfFileName].Module.LibraryClasses\r
+#        NotFound = True\r
+#        for Lib in LibList:\r
+#            if Lib.LibraryClass == LibraryClass and Arch in Lib.SupArchList:\r
+#                return\r
+#        \r
+#        if NotFound:\r
+#            self.InfDatabase[infFileName].Module.Contents[Arch].LibraryClasses.extend([LibraryClass])\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
-                self.InfDatabase[infFileName] = Inf(file, True)\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
+                self.InfDatabase[InfFileName] = Inf(File, True, True)\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
-                self.DecDatabase[decFileName] = Dec(file, True)\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
+                self.DecDatabase[DecFileName] = Dec(File, True, True)\r
                 \r
     def FindLibraryClassInstanceOfModule(self, lib, arch, moduleType, moduleName):\r
         for dsc in self.DscDatabase.keys():\r
@@ -769,7 +800,7 @@ if __name__ == '__main__':
 \r
     # Nothing to do here. Could do some unit tests.\r
     w = os.getenv('WORKSPACE')\r
-    ewb = WorkspaceBuild('MdeModulePkg/MdeModulePkg.dsc', w)\r
+    ewb = WorkspaceBuild('Nt32Pkg/Nt32Pkg.dsc', w)\r
     ewb.GenBuildDatabase()\r
     #print ewb.DscDatabase\r
     #print ewb.InfDatabase\r
index 755ee17..3d0abb5 100644 (file)
@@ -468,14 +468,14 @@ class Inf(InfObject):
             tab = (sect.split(TAB_SECTION_END, 1)[0]).upper()\r
             if tab == TAB_INF_DEFINES.upper():\r
                 GetSingleValueOfKeyFromLines(sect, self.Defines.DefinesDictionary, TAB_COMMENT_SPLIT, TAB_EQUAL_SPLIT, False, None)\r
-                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_ENTRY_POINT][0] == '':\r
-                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_ENTRY_POINT] = []\r
-                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_UNLOAD_IMAGE][0] == '':\r
-                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_UNLOAD_IMAGE] = []\r
-                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_CONSTRUCTOR][0] == '':\r
-                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_CONSTRUCTOR] = []\r
-                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_DESTRUCTOR][0] == '':\r
-                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_DESTRUCTOR] = []\r
+#                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_ENTRY_POINT][0] == '':\r
+#                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_ENTRY_POINT] = []\r
+#                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_UNLOAD_IMAGE][0] == '':\r
+#                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_UNLOAD_IMAGE] = []\r
+#                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_CONSTRUCTOR][0] == '':\r
+#                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_CONSTRUCTOR] = []\r
+#                if self.Defines.DefinesDictionary[TAB_INF_DEFINES_DESTRUCTOR][0] == '':\r
+#                    self.Defines.DefinesDictionary[TAB_INF_DEFINES_DESTRUCTOR] = []\r
                 continue\r
             if tab.find(DataType.TAB_USER_EXTENSIONS.upper()) > -1:\r
                 self.UserExtensions = sect\r
index 8f033c4..536fe93 100644 (file)
@@ -217,13 +217,23 @@ def SplitModuleType(Key):
     return ReturnValue\r
     \r
 #\r
-# Replace '\\', '\' with '/'\r
+# Create a normal path\r
+# And replace DFEINE in the path\r
 #\r
-def NormPath(path):\r
-    if path != '':\r
-        return os.path.normpath(path)\r
-    else:\r
-        return path\r
+def NormPath(Path, Defines = {}):\r
+    if Path != '':\r
+        # Replace with Define\r
+        for Key in Defines.keys():\r
+            Path = Path.replace(Key, Defines[Key])\r
+\r
+        # Replace '\\', '\' with '/'\r
+        Path = Path.replace('\\', '/')\r
+        Path = Path.replace('//', '/')\r
+        \r
+        # Remove ${WORKSPACE}\r
+        Path = Path.replace(DataType.TAB_WORKSPACE, '')\r
+\r
+    return Path\r
 \r
 #\r
 # Remove comments in a string\r
@@ -264,8 +274,8 @@ def GetSingleValueOfKeyFromLines(Lines, Dictionary, CommentCharacter, KeySplitCh
     Lines = Lines.split('\n')\r
     Keys = []\r
     Value = ''\r
-    DefineValues = []\r
-    SpecValues = []\r
+    DefineValues = ['']\r
+    SpecValues = ['']\r
     \r
     for Line in Lines:\r
         #\r