Updated code to get GUID value during parsing stage as much as possible
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 7 Apr 2008 06:30:54 +0000 (06:30 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 7 Apr 2008 06:30:54 +0000 (06:30 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1123 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/AutoGen/AutoGen.py
Source/Python/AutoGen/GenC.py
Source/Python/Workspace/WorkspaceDatabase.py

index 55d5b24..fa44700 100755 (executable)
@@ -226,7 +226,7 @@ class PlatformAutoGen:
         if self.Workspace.Fdf != "":\r
             Info.FdfFile= path.join(self.WorkspaceDir, self.Workspace.Fdf)\r
 \r
-        Info.NonDynamicPcdList, Info.DynamicPcdList = self.GetPcdList(Platform, Arch)\r
+        Info.NonDynamicPcdList, Info.DynamicPcdList, Info.GuidValue = self.GetPcdList(Platform, Arch)\r
         Info.PcdTokenNumber = self.GeneratePcdTokenNumber(Platform, Info.NonDynamicPcdList, Info.DynamicPcdList)\r
         Info.PackageList = self.GetPackageList(Platform, Arch)\r
 \r
@@ -382,7 +382,9 @@ class PlatformAutoGen:
         NotFoundPcdList = set()\r
         NoDatumTypePcdList = set()\r
 \r
+        GuidValue = {}\r
         for F in Platform.Modules:\r
+            GuidValue.update(F.Guids)\r
             M = self.ModuleDatabase[Arch][F]\r
             for Key in M.Pcds:\r
                 PcdFromModule = M.Pcds[Key]\r
@@ -412,7 +414,7 @@ class PlatformAutoGen:
                             ExtraData="\n\tPCD(s) not found in platform:\n\t\t%s"\r
                                       "\n\tPCD(s) without MaxDatumSize:\n\t\t%s\n"\r
                                       % (NotFoundPcdListString, NoDatumTypePcdListString))\r
-        return NonDynamicPcdList, DynamicPcdList\r
+        return NonDynamicPcdList, DynamicPcdList, GuidValue\r
 \r
     ## Generate Token Number for all PCD\r
     #\r
@@ -798,9 +800,9 @@ class ModuleAutoGen(object):
 \r
         Info.PcdIsDriver = self.Module.PcdIsDriver\r
         Info.PcdList = self.GetPcdList(Info.DependentLibraryList)\r
-        Info.GuidList = self.GetGuidList()\r
-        Info.ProtocolList = self.GetProtocolGuidList()\r
-        Info.PpiList = self.GetPpiGuidList()\r
+        Info.GuidList = self.Module.Guids\r
+        Info.ProtocolList = self.Module.Protocols\r
+        Info.PpiList = self.Module.Ppis\r
         Info.Macro = self.GetMacroList()\r
         Info.DepexList = self.GetDepexTokenList(Info)\r
 \r
index c8fb01d..499afd9 100644 (file)
@@ -794,7 +794,7 @@ def GetGuidValue(Packages, CName):
 #   @param      Pcd         The PCD object\r
 #\r
 def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):\r
-    TokenSpaceGuidValue = GetGuidValue(Info.PlatformInfo.PackageList, Pcd.TokenSpaceGuidCName)\r
+    TokenSpaceGuidValue = Info.GuidList[Pcd.TokenSpaceGuidCName]\r
     PcdTokenNumber = Info.PlatformInfo.PcdTokenNumber\r
     #\r
     # Write PCDs\r
@@ -901,7 +901,7 @@ def CreateLibraryPcdCode(Info, AutoGenC, AutoGenH, Pcd):
     PcdTokenNumber = Info.PlatformInfo.PcdTokenNumber\r
     TokenSpaceGuidCName = Pcd.TokenSpaceGuidCName\r
     TokenCName  = Pcd.TokenCName\r
-    TokenSpaceGuidValue = GetGuidValue(Info.PlatformInfo.PackageList, TokenSpaceGuidCName)\r
+    TokenSpaceGuidValue = Info.GuidList[TokenSpaceGuidCName]\r
     if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) not in PcdTokenNumber:\r
         EdkLogger.error("AutoGen", AUTOGEN_ERROR, "No generated token number for %s|%s\n" % (Pcd.TokenCName, Pcd.TokenSpaceGuidCName))\r
     TokenNumber = PcdTokenNumber[TokenCName, TokenSpaceGuidCName]\r
index 3779ccd..6f22f83 100644 (file)
@@ -40,15 +40,15 @@ def ValidFile(File, Dir='.'):
     os.chdir(Wd)\r
     return True\r
 \r
-def ValidGuid(CName, PackageList):\r
+def GuidValue(CName, PackageList):\r
     for P in PackageList:\r
         if CName in P.Guids:\r
-            return True\r
+            return P.Guids[CName]\r
         if CName in P.Protocols:\r
-            return True\r
+            return P.Protocols[CName]\r
         if CName in P.Ppis:\r
-            return True\r
-    return False\r
+            return P.Ppis[CName]\r
+    return None\r
 \r
 class DscBuildData(PlatformBuildClassObject):\r
     #_PROPERTY_ = {\r
@@ -502,19 +502,19 @@ class DscBuildData(PlatformBuildClassObject):
             #\r
             for CName in L.Guids:\r
                 if CName not in Module.Guids:\r
-                    Module.Guids.append(CName)\r
+                    Module.Guids[CName] = L.Guids[CName]\r
             #\r
             # Merge Protocols from library instance\r
             #\r
             for CName in L.Protocols:\r
                 if CName not in Module.Protocols:\r
-                    Module.Protocols.append(CName)\r
+                    Module.Protocols[CName] = L.Protocols[CName]\r
             #\r
             # Merge Ppis from library instance\r
             #\r
             for CName in L.Ppis:\r
                 if CName not in Module.Ppis:\r
-                    Module.Ppis.append(CName)\r
+                    Module.Ppis[CName] = L.Ppis[CName]\r
 \r
     ##\r
     # for R8.x modules\r
@@ -1552,41 +1552,44 @@ class InfBuildData(ModuleBuildClassObject):
 \r
     def _GetProtocols(self):\r
         if self._Protocols == None:\r
-            self._Protocols = []\r
+            self._Protocols = sdict()\r
             RecordList = self._Table.Query(MODEL_EFI_PROTOCOL, Arch=self._Arch, Platform=self._Platform)\r
             for Record in RecordList:\r
                 CName = Record[0]\r
-                if not ValidGuid(CName, self.Packages):\r
+                Value = GuidValue(CName, self.Packages)\r
+                if Value == None:\r
                     PackageList = '\t' + "\n\t".join([str(P) for P in self.Packages])\r
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Value of [%s] is not found in" % CName,\r
                                     ExtraData=PackageList, File=self.DescFilePath, Line=Record[-1])\r
-                self._Protocols.append(CName)\r
+                self._Protocols[CName] = Value\r
         return self._Protocols\r
 \r
     def _GetPpis(self):\r
         if self._Ppis == None:\r
-            self._Ppis = []\r
+            self._Ppis = sdict()\r
             RecordList = self._Table.Query(MODEL_EFI_PPI, Arch=self._Arch, Platform=self._Platform)\r
             for Record in RecordList:\r
                 CName = Record[0]\r
-                if not ValidGuid(CName, self.Packages):\r
+                Value = GuidValue(CName, self.Packages)\r
+                if Value == None:\r
                     PackageList = '\t' + "\n\t".join([str(P) for P in self.Packages])\r
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Value of [%s] is not found in " % CName,\r
                                     ExtraData=PackageList, File=self.DescFilePath, Line=Record[-1])\r
-                self._Ppis.append(CName)\r
+                self._Ppis[CName] = Value\r
         return self._Ppis\r
 \r
     def _GetGuids(self):\r
         if self._Guids == None:\r
-            self._Guids = []\r
+            self._Guids = sdict()\r
             RecordList = self._Table.Query(MODEL_EFI_GUID, Arch=self._Arch, Platform=self._Platform)\r
             for Record in RecordList:\r
                 CName = Record[0]\r
-                if not ValidGuid(CName, self.Packages):\r
+                Value = GuidValue(CName, self.Packages)\r
+                if Value == None:\r
                     PackageList = '\t' + "\n\t".join([str(P) for P in self.Packages])\r
                     EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Value of [%s] is not found in" % CName,\r
                                     ExtraData=PackageList, File=self.DescFilePath, Line=Record[-1])\r
-                self._Guids.append(CName)\r
+                self._Guids[CName] = Value\r
         return self._Guids\r
 \r
     def _GetIncludes(self):\r
@@ -1659,9 +1662,16 @@ class InfBuildData(ModuleBuildClassObject):
         PcdDict = tdict(True, 4)\r
         PcdSet = set()\r
         RecordList = self._Table.Query(Type, Arch=self.Arch, Platform=self.Platform)\r
-        for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Dummy1, Dummy2 in RecordList:\r
+        for TokenSpaceGuid, PcdCName, Setting, Arch, Platform, Dummy1, LineNo in RecordList:\r
             PcdDict[Arch, Platform, PcdCName, TokenSpaceGuid] = Setting\r
             PcdSet.add((PcdCName, TokenSpaceGuid))\r
+            if TokenSpaceGuid not in self.Guids:\r
+                Value = GuidValue(TokenSpaceGuid, self.Packages)\r
+                if Value == None:\r
+                    PackageList = '\t' + "\n\t".join([str(P) for P in self.Packages])\r
+                    EdkLogger.error('build', RESOURCE_NOT_AVAILABLE, "Value of [%s] is not found in" % CName,\r
+                                    ExtraData=PackageList, File=self.DescFilePath, Line=LineNo)\r
+                self._Guids[TokenSpaceGuid] = Value\r
 \r
         for PcdCName, TokenSpaceGuid in PcdSet:\r
             ValueList = ['', '']\r
@@ -1682,6 +1692,7 @@ class InfBuildData(ModuleBuildClassObject):
                     {},\r
                     True\r
                     )\r
+\r
             # get necessary info from package declaring this PCD\r
             for Package in self.Packages:\r
                 # \r