Fixed NULL library instance issue which will cause unsupported module type error.
authorjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 14 Apr 2008 07:20:15 +0000 (07:20 +0000)
committerjwang36 <jwang36@7335b38e-4728-0410-8992-fb3ffe349368>
Mon, 14 Apr 2008 07:20:15 +0000 (07:20 +0000)
git-svn-id: https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools@1147 7335b38e-4728-0410-8992-fb3ffe349368

Source/Python/Workspace/WorkspaceDatabase.py

index 644c034..eb0e1c2 100644 (file)
@@ -89,6 +89,7 @@ class DscBuildData(PlatformBuildClassObject):
 \r
     # used to compose dummy library class name for those forced library instances\r
     _NullLibraryNumber = 0\r
+    _NullLibraryClass = {}  # file : class\r
 \r
     def __init__(self, FilePath, Table, Db, Arch='COMMON', Macros={}):\r
         self.DescFilePath = FilePath\r
@@ -357,10 +358,20 @@ class DscBuildData(PlatformBuildClassObject):
                 EdkLogger.error('build', FILE_NOT_FOUND, ExtraData=LibraryPath,\r
                                 File=self.DescFilePath, Line=LineNo)\r
             if LibraryClass == '' or LibraryClass == 'NULL':\r
-                self._NullLibraryNumber += 1\r
-                LibraryClass = 'NULL%d' % self._NullLibraryNumber\r
-                LibraryInstance = self._Db.BuildObject[LibraryPath, MODEL_FILE_INF, self._Arch]\r
-                LibraryInstance.LibraryClass.append(LibraryClassObject(LibraryClass, [ModuleType]))\r
+                if LibraryPath not in self._NullLibraryClass:\r
+                    self._NullLibraryNumber += 1\r
+                    LibraryClass = LibraryClassObject('NULL%d' % self._NullLibraryNumber, [ModuleType])\r
+                    LibraryInstance = self._Db.BuildObject[LibraryPath, MODEL_FILE_INF, self._Arch]\r
+                    LibraryInstance.LibraryClass.append(LibraryClass)\r
+                    self._NullLibraryClass[LibraryPath] = LibraryClass\r
+                else:\r
+                    LibraryClass = self._NullLibraryClass[LibraryPath]\r
+                    # add new supported module type\r
+                    if ModuleType not in LibraryClass.SupModList:\r
+                        LibraryClass.SupModList.append(ModuleType)\r
+                    LibraryInstance = self._Db.BuildObject[LibraryPath, MODEL_FILE_INF, self._Arch]\r
+                    LibraryInstance.LibraryClass.append(LibraryClass)\r
+\r
             Module.LibraryClasses[LibraryClass] = LibraryPath\r
 \r
         # R9 module\r