Added code to check GUID/Protocol/PPI CName against dependent packages
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 3 Apr 2008 09:22:00 +0000 (09:22 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Thu, 3 Apr 2008 09:22:00 +0000 (09:22 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1120 7335b38e-4728-0410-8992-fb3ffe349368

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

index ec9a36b..55d5b24 100755 (executable)
@@ -228,7 +228,7 @@ class PlatformAutoGen:
 \r
         Info.NonDynamicPcdList, Info.DynamicPcdList = self.GetPcdList(Platform, Arch)\r
         Info.PcdTokenNumber = self.GeneratePcdTokenNumber(Platform, Info.NonDynamicPcdList, Info.DynamicPcdList)\r
-        Info.PackageList = self.PackageDatabase[Arch].values()\r
+        Info.PackageList = self.GetPackageList(Platform, Arch)\r
 \r
         self.GetToolDefinition(Info)\r
         Info.BuildRule = self.GetBuildRule()\r
@@ -349,6 +349,22 @@ class PlatformAutoGen:
             if Tool not in Info.BuildOption:\r
                 Info.BuildOption[Tool] = ""\r
 \r
+    def GetPackageList(self, Platform, Arch):\r
+        PackageList = []\r
+        for F in Platform.Modules:\r
+            M = self.ModuleDatabase[Arch][F]\r
+            for P in M.Packages:\r
+                if P in PackageList:\r
+                    continue\r
+                PackageList.append(P)\r
+        for F in Platform.LibraryInstances:\r
+            M = self.ModuleDatabase[Arch][F]\r
+            for P in M.Packages:\r
+                if P in PackageList:\r
+                    continue\r
+                PackageList.append(P)\r
+        return PackageList\r
+\r
     ## Collect dynamic PCDs\r
     #\r
     #  Gather dynamic PCDs list from each module and their settings from platform\r
index f9cf137..b257657 100644 (file)
@@ -40,6 +40,16 @@ def ValidFile(File, Dir='.'):
     os.chdir(Wd)\r
     return True\r
 \r
+def ValidGuid(CName, PackageList):\r
+    for P in PackageList:\r
+        if CName in P.Guids:\r
+            return True\r
+        if CName in P.Protocols:\r
+            return True\r
+        if CName in P.Ppis:\r
+            return True\r
+    return False\r
+\r
 class DscBuildData(PlatformBuildClassObject):\r
     #_PROPERTY_ = {\r
     #    TAB_DSC_DEFINES_PLATFORM_NAME           : '_PlatformName'\r
@@ -363,7 +373,7 @@ class DscBuildData(PlatformBuildClassObject):
         for LibraryClassName in LibraryInstance:\r
             M = LibraryInstance[LibraryClassName]\r
             if M == None:\r
-                EdkLogger.error("AutoGen", AUTOGEN_ERROR,\r
+                EdkLogger.error("build", AUTOGEN_ERROR,\r
                                 "Library instance for library class [%s] is not found" % LibraryClassName,\r
                                 ExtraData="\t%s [%s]" % (str(Module), self.Arch))\r
             LibraryList.append(M)\r
@@ -372,12 +382,12 @@ class DscBuildData(PlatformBuildClassObject):
             #\r
             for Lc in M.LibraryClass:\r
                 if Lc.SupModList != None and ModuleType not in Lc.SupModList:\r
-                    EdkLogger.error("AutoGen", AUTOGEN_ERROR,\r
+                    EdkLogger.error("build", AUTOGEN_ERROR,\r
                                     "Module type [%s] is not supported by library instance [%s]" % (ModuleType, str(M)),\r
                                     ExtraData="\t%s" % str(Module))\r
 \r
                 if Lc.LibraryClass in LibraryInstance and str(M) != str(LibraryInstance[Lc.LibraryClass]):\r
-                    EdkLogger.error("AutoGen", AUTOGEN_ERROR,\r
+                    EdkLogger.error("build", AUTOGEN_ERROR,\r
                                     "More than one library instance found for library class [%s] in module [%s]" % (Lc.LibraryClass, Module),\r
                                     ExtraData="\t%s\n\t%s" % (LibraryInstance[Lc.LibraryClass], str(M))\r
                                     )\r
@@ -487,7 +497,7 @@ class DscBuildData(PlatformBuildClassObject):
             M = LibraryConsumerList.pop()\r
             for LibraryName in M.Libraries:\r
                 if LibraryName not in self.Libraries:\r
-                    EdkLogger.warn("AutoGen", "Library [%s] is not found" % LibraryName,\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
@@ -1306,7 +1316,7 @@ class InfBuildData(ModuleBuildClassObject):
                 else:\r
                     ToolList = self._NMAKE_FLAG_PATTERN_.findall(Name)\r
                     if len(ToolList) == 0 or len(ToolList) != 1:\r
-                        EdkLogger.warn("\nbuild", "Don't know how to do with macro [%s]" % Name, \r
+                        EdkLogger.warn("build", "Don't know how to do with macro [%s]" % Name, \r
                                        File=self.DescFilePath, Line=LineNo)\r
                     else:\r
                         if self._BuildOptions == None:\r
@@ -1509,7 +1519,12 @@ class InfBuildData(ModuleBuildClassObject):
             self._Protocols = []\r
             RecordList = self._Table.Query(MODEL_EFI_PROTOCOL, Arch=self._Arch, Platform=self._Platform)\r
             for Record in RecordList:\r
-                self._Protocols.append(Record[0])\r
+                CName = Record[0]\r
+                if not ValidGuid(CName, self.Packages):\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
         return self._Protocols\r
 \r
     def _GetPpis(self):\r
@@ -1517,7 +1532,12 @@ class InfBuildData(ModuleBuildClassObject):
             self._Ppis = []\r
             RecordList = self._Table.Query(MODEL_EFI_PPI, Arch=self._Arch, Platform=self._Platform)\r
             for Record in RecordList:\r
-                self._Ppis.append(Record[0])\r
+                CName = Record[0]\r
+                if not ValidGuid(CName, self.Packages):\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
         return self._Ppis\r
 \r
     def _GetGuids(self):\r
@@ -1525,7 +1545,12 @@ class InfBuildData(ModuleBuildClassObject):
             self._Guids = []\r
             RecordList = self._Table.Query(MODEL_EFI_GUID, Arch=self._Arch, Platform=self._Platform)\r
             for Record in RecordList:\r
-                self._Guids.append(Record[0])\r
+                CName = Record[0]\r
+                if not ValidGuid(CName, self.Packages):\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
         return self._Guids\r
 \r
     def _GetIncludes(self):\r