Fix the track EDKT187: If a module do not use PCD, PcdLib library class need not...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Aug 2006 13:59:00 +0000 (13:59 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 16 Aug 2006 13:59:00 +0000 (13:59 +0000)
The fixing is judge whether the module's library instance use PCD, if use, build tools will add PcdLib into module's autogen.h automatically.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1297 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.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
index 335ff8f..12deec7 100644 (file)
@@ -59,6 +59,8 @@ public class CommonDefinition {
     public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";\r
     public final static String flashMapH = "FlashMap.h";\r
 \r
+    public final static String pcdLibName = "PcdLib";\r
+\r
     //\r
     // The defintions for identifying current module\r
     // is PEI Pcd driver or Dxe Pcd driver.\r
index 4b5e1ff..1086bb8 100644 (file)
@@ -624,10 +624,9 @@ public class SurfaceAreaQuery {
                 libraryClassName.add(libraryClassList[i].getKeyword());\r
                        }\r
         }\r
-               String[] libraryArray = new String[libraryClassName.size()];\r
-               for (int i = 0; i < libraryClassName.size(); i++) {\r
-                       libraryArray[i] = libraryClassName.get(i);\r
-               }\r
+\r
+        String[] libraryArray = new String[libraryClassName.size()];\r
+        libraryClassName.toArray(libraryArray);\r
         return libraryArray;\r
     }\r
 \r