Fix the track EDKT187: If a module do not use PCD, PcdLib library class need not...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / autogen / AutoGen.java
index f3b1077..28e72af 100644 (file)
@@ -83,6 +83,11 @@ public class AutoGen {
     /// \r
     private CommonDefinition.PCD_DRIVER_TYPE pcdDriverType;\r
 \r
+    ///\r
+    /// Judge whether this module's library instance use PcdLib library class \r
+    /// \r
+    private boolean isModuleLibraryInstanceUsePcd;\r
+\r
     ///\r
     /// The protocl list which records in module or library surface area and\r
     /// it's dependence on library instance surface area.\r
@@ -328,6 +333,28 @@ public class AutoGen {
         //\r
         String[] libClassList = SurfaceAreaQuery\r
                                 .getLibraryClasses(CommonDefinition.AlwaysConsumed,this.arch);\r
+        boolean  isModuleConsumePcdLib = false;\r
+        List<String> libClassArray     = new ArrayList<String>();\r
+        for (int index = 0; index < libClassList.length; index++) {\r
+            libClassArray.add(libClassList[index]);\r
+            //\r
+            // Search all library class of a module for PcdLib\r
+            // \r
+            if (libClassList[index].equalsIgnoreCase(CommonDefinition.pcdLibName)) {\r
+                isModuleConsumePcdLib = true;\r
+            }\r
+        }\r
+\r
+        //\r
+        // If module do not use PCD but module's library use PCD.\r
+        // \r
+        if (!isModuleConsumePcdLib && this.isModuleLibraryInstanceUsePcd) {\r
+            libClassArray.add(CommonDefinition.pcdLibName);\r
+        }\r
+\r
+        libClassList = new String[libClassArray.size()];\r
+        libClassArray.toArray(libClassList);\r
+\r
         if (libClassList != null) {\r
             libClassIncludeH = LibraryClassToAutogenH(libClassList);\r
             item = libClassIncludeH.iterator();\r
@@ -679,7 +706,6 @@ public class AutoGen {
         // Get include file from GlobalData's SPDTable according to\r
         // library class name.\r
         //\r
-\r
         for (int i = 0; i < libClassList.length; i++) {\r
             includerName = GlobalData.getLibraryClassHeaderFiles(\r
                                                                 SurfaceAreaQuery.getDependencePkg(this.arch),\r
@@ -2050,8 +2076,7 @@ public class AutoGen {
                         // Get override map\r
                         //\r
 \r
-                        Map<String, XmlObject> libDoc = GlobalData.getDoc(\r
-                                                                         libInstanceId, this.arch);\r
+                        Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
                         SurfaceAreaQuery.push(libDoc);\r
                         //\r
                         // Get <PPis>, <Protocols>, <Guids> list of this library\r
@@ -2066,6 +2091,9 @@ public class AutoGen {
                                                       .getProtocolNotifyArray(this.arch);\r
                         String[] guidList = SurfaceAreaQuery\r
                                             .getGuidEntryArray(this.arch);\r
+                        String[] libraryClassList = SurfaceAreaQuery.getLibraryClasses(\r
+                                                        CommonDefinition.AlwaysConsumed, \r
+                                                        this.arch);\r
                         PackageIdentification[] pkgList = SurfaceAreaQuery.getDependencePkg(this.arch);\r
 \r
                         //\r
@@ -2097,7 +2125,11 @@ public class AutoGen {
                                 this.mDepPkgList.add(pkgList[index]);\r
                             }\r
                         }\r
-\r
+                        for (index = 0; index < libraryClassList.length; index++) {\r
+                            if (libraryClassList[index].equalsIgnoreCase(CommonDefinition.pcdLibName)) {\r
+                                this.isModuleLibraryInstanceUsePcd = true;\r
+                            }\r
+                        }\r
                         //\r
                         // If not yet parse this library instance's constructor\r
                         // element,parse it.\r