1) Fix a bug for PCD autogen tools, see track#115 in PVCS: Module's PCD informtion...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jun 2006 05:46:05 +0000 (05:46 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jun 2006 05:46:05 +0000 (05:46 +0000)
2) Remove PcdEmulatedDriver from PcdAutogen class.

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

Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java
Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java
Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaQuery.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java

index 62bb4c6b59d5a302d902495386f0eba78d775ecb..53f5fa908fcb005c2df47f18da3d619aa2b6abde 100644 (file)
@@ -414,11 +414,11 @@ public class AutoGen {
                                                      null,\r
                                                      this.arch,\r
                                                      null,\r
-                                                     baseName.equalsIgnoreCase("PcdEmulatorPeim"),\r
-                                                     false);\r
+                                                     false,\r
+                                                     SurfaceAreaQuery.getModulePcdEntryNameArray());\r
             this.myPcdAutogen.execute();\r
         } catch (Exception e) {\r
-            throw new BuildException("PCD Autogen failed:" + e.getMessage());\r
+            throw new BuildException("PCD Autogen for module failed:" + e.getMessage());\r
         }\r
 \r
         if (this.myPcdAutogen != null) {\r
@@ -555,11 +555,11 @@ public class AutoGen {
                                                      null,\r
                                                      this.arch,\r
                                                      null,\r
-                                                     baseName.equalsIgnoreCase("PcdEmulatorPeim"), \r
-                                                     true);\r
+                                                     true,\r
+                                                     SurfaceAreaQuery.getModulePcdEntryNameArray());\r
             this.myPcdAutogen.execute();\r
         } catch (Exception e) {\r
-            throw new BuildException(e.getMessage());\r
+            throw new BuildException("Pcd Autogen for library failed! " + e.getMessage());\r
         }\r
 \r
         if (this.myPcdAutogen != null) {\r
@@ -2015,4 +2015,4 @@ public class AutoGen {
 \r
     }\r
 \r
-}
\ No newline at end of file
+}\r
index dae2ca29aa5550df0bf698be902facdb2a4749d5..9354def6ba38b8864d57d4d42516d3ea44410686 100644 (file)
@@ -36,7 +36,7 @@ import org.tianocore.LibrariesDocument;
 import org.tianocore.LibraryClassDefinitionsDocument;\r
 import org.tianocore.MsaHeaderDocument;\r
 import org.tianocore.MsaLibHeaderDocument;\r
-import org.tianocore.PCDsDocument;\r
+import org.tianocore.PcdCodedDocument;\r
 import org.tianocore.PPIsDocument;\r
 import org.tianocore.ProtocolsDocument;\r
 import org.tianocore.SourceFilesDocument;\r
@@ -113,7 +113,7 @@ public class OverrideProcess {
                     "SourceFiles", "Includes", "Libraries", "Protocols",\r
                     "Events", "Hobs", "PPIs", "Variables", "BootModes",\r
                     "SystemTables", "DataHubs", "Formsets", "Guids", "Externs",\r
-                    "PCDs", "BuildOptions" };\r
+                    "PcdCoded", "BuildOptions" };\r
 \r
     ///\r
     /// list of exclusive elements\r
@@ -223,8 +223,8 @@ public class OverrideProcess {
             newMap.put("Externs", ((ExternsDocument) map.get("Externs"))\r
                             .getExterns());\r
         }\r
-        if (map.get("PCDs") != null) {\r
-            newMap.put("PCDs", ((PCDsDocument) map.get("PCDs")).getPCDs());\r
+        if (map.get("PcdCoded") != null) {\r
+            newMap.put("PcdCoded", ((PcdCodedDocument) map.get("PcdCoded")).getPcdCoded());\r
         }\r
         if (map.get("BuildOptions") != null) {\r
             newMap.put("BuildOptions", ((BuildOptionsDocument) map\r
index 96003c2e717ddf046bc6280e90a385c99298baf5..a2780e626c6086344ee002444c4aacf30aeb29ad 100644 (file)
@@ -91,18 +91,14 @@ public class SurfaceAreaParser {
         msaMap.put("Variables", doc.getModuleSurfaceArea().getVariables());\r
         msaMap.put("BootModes", doc.getModuleSurfaceArea().getBootModes());\r
 \r
-        msaMap\r
-                        .put("SystemTables", doc.getModuleSurfaceArea()\r
-                                        .getSystemTables());\r
+        msaMap.put("SystemTables", doc.getModuleSurfaceArea().getSystemTables());\r
         msaMap.put("DataHubs", doc.getModuleSurfaceArea().getDataHubs());\r
         msaMap.put("Formsets", doc.getModuleSurfaceArea().getFormsets());\r
         msaMap.put("Guids", doc.getModuleSurfaceArea().getGuids());\r
         msaMap.put("Externs", doc.getModuleSurfaceArea().getExterns());\r
 \r
-        msaMap.put("PCDs", doc.getModuleSurfaceArea().getPCDs());\r
-        msaMap\r
-                        .put("BuildOptions", doc.getModuleSurfaceArea()\r
-                                        .getBuildOptions());\r
+        msaMap.put("PcdCoded", doc.getModuleSurfaceArea().getPcdCoded());\r
+        msaMap.put("BuildOptions", doc.getModuleSurfaceArea().getBuildOptions());\r
     }\r
 \r
     /**\r
@@ -132,7 +128,6 @@ public class SurfaceAreaParser {
         mbdMap.put("Guids", doc.getModuleBuildDescription().getGuids());\r
         mbdMap.put("Externs", doc.getModuleBuildDescription().getExterns());\r
 \r
-        mbdMap.put("PCDs", doc.getModuleBuildDescription().getPCDs());\r
         mbdMap.put("BuildOptions", doc.getModuleBuildDescription()\r
                         .getBuildOptions());\r
     }\r
@@ -168,7 +163,7 @@ public class SurfaceAreaParser {
         msaMap.put("Guids", doc.getLibraryModuleSurfaceArea().getGuids());\r
         msaMap.put("Externs", doc.getLibraryModuleSurfaceArea().getExterns());\r
 \r
-        msaMap.put("PCDs", doc.getLibraryModuleSurfaceArea().getPCDs());\r
+        msaMap.put("PcdCoded", doc.getLibraryModuleSurfaceArea().getPcdCoded());\r
         msaMap.put("BuildOptions", doc.getLibraryModuleSurfaceArea()\r
                         .getBuildOptions());\r
     }\r
@@ -211,7 +206,6 @@ public class SurfaceAreaParser {
         mbdMap.put("Externs", doc.getLibraryModuleBuildDescription()\r
                         .getExterns());\r
 \r
-        mbdMap.put("PCDs", doc.getLibraryModuleBuildDescription().getPCDs());\r
         mbdMap.put("BuildOptions", doc.getLibraryModuleBuildDescription()\r
                         .getBuildOptions());\r
     }\r
index 03c8d4328d6e8a4fef1f33b90bee6039a3c16074..ed6d0a2f183364970d6440a046f6b8d2bbdaddb3 100644 (file)
@@ -43,7 +43,7 @@ import org.tianocore.OutputDirectoryDocument;
 import org.tianocore.PPIsDocument;\r
 import org.tianocore.PackageNameDocument;\r
 import org.tianocore.ProtocolsDocument;\r
-import org.tianocore.PCDsDocument.PCDs;\r
+import org.tianocore.PcdCodedDocument.PcdCoded;\r
 \r
 /**\r
   SurfaceAreaQuery class is used to query Surface Area information from msa, mbd,\r
@@ -1029,81 +1029,27 @@ public class SurfaceAreaQuery {
     }\r
     \r
     /**\r
-     Retrieve PCD tokens\r
-\r
-     @returns   CName/ItemType pairs list   if elements are found at the known xpath\r
-     @returns   null                        if nothing is there\r
-     **/\r
-    public static String[][] getPcdTokenArray() {\r
-        String[] xPath = new String[] {"/PcdData"};\r
-        \r
-        XmlObject[] returns = get("PCDs", xPath);\r
-        if (returns == null || returns.length == 0) {\r
+       Get name array of PCD in a module. In one module, token space\r
+       is same, and token name should not be conflicted.\r
+       \r
+       @return String[]\r
+    **/\r
+    public static String[] getModulePcdEntryNameArray() {\r
+        PcdCoded.PcdEntry[] pcdEntries  = null;\r
+        String[]            results;\r
+        int                 index;\r
+        String[]            xPath       = new String[] {"/PcdEntry"};\r
+        XmlObject[]         returns     = get ("PcdCoded", xPath);\r
+        if (returns == null) {\r
             return null;\r
         }\r
-        \r
-        PCDs.PcdData[] pcds = (PCDs.PcdData[]) returns;\r
-        String[][] result = new String[pcds.length][2];\r
-        for (int i = 0; i < returns.length; ++i) {\r
-            if (pcds[i].getItemType() != null) {\r
-                result[i][1] = pcds[i].getItemType().toString();\r
-            } else {\r
-                result[i][1] = null;\r
-            }\r
-            result[i][0] = pcds[i].getCName();\r
-        }\r
-            \r
-        return result;\r
-    }\r
 \r
-    /**\r
-     Get the PcdToken array from module's surface area document.\r
-     The array should contains following data:\r
-     <p>-------------------------------------------------------------------</p>\r
-     <p>CName | ItemType | TokenspaceName | DefaultValue | Usage | HelpText</p>\r
-     <p>-------------------------------------------------------------------</p>\r
-     <p>Note: Until new schema applying, now we can only get CName, ItemType,</p>\r
-     \r
-     @return  2-array table contains all information of PCD token retrieved from MSA.\r
-     **/\r
-    public static Object[][] getModulePCDTokenArray () {\r
-      int             index;\r
-      Object[][]      result;\r
-      PCDs.PcdData[]  pcds;\r
-      String[]        xPath   = new String[] {"/PcdData"};\r
-      XmlObject[]     returns = get ("PCDs", xPath);\r
-\r
-      if ((returns == null) || (returns.length == 0)) {\r
-        return null;\r
-      }\r
-\r
-      pcds     = (PCDs.PcdData[]) returns;\r
-      result   = new Object[pcds.length][6];\r
-      for (index = 0; index < pcds.length; index ++) {\r
-        //\r
-        // Get CName\r
-        //\r
-        result [index][0] = pcds[index].getCName();\r
-        //\r
-        // Get ItemType: FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODLE, DYNAMIC, DYNAMIC_EX\r
-        //\r
-        if (pcds[index].getItemType() != null) {\r
-          result [index][1] = pcds[index].getItemType().toString();\r
-        } else {\r
-          result [index][1] = null;\r
-        }\r
+        pcdEntries = (PcdCoded.PcdEntry[])returns;\r
+        results    = new String[pcdEntries.length];\r
         \r
-        //\r
-        // BUGBUG: following field can *not* be got from current MSA until schema changed.\r
-        //\r
-        //result [index][2] = pcds[index].getTokenSpaceName();\r
-        result [index][2] = null;\r
-        result [index][3] = pcds[index].getDefaultValue();\r
-        //result [index][4] = pcds[index].getUsage ();\r
-        result [index][4] = null;\r
-        //result [index][5] = pcds[index].getHelpText ();\r
-        result [index][5] = null;\r
-      }\r
-      return result;\r
+        for (index = 0; index < pcdEntries.length; index ++) {\r
+            results[index] = pcdEntries[index].getCName();\r
+        }\r
+        return results;\r
     }\r
 }\r
index 278e58ceaee0b76a734abe00b9237b7e03d126c5..796aff62c3ef1350d3d1fd2528847ed13ad5ab0d 100644 (file)
@@ -18,9 +18,14 @@ package org.tianocore.build.pcd.action;
 \r
 import java.io.File;\r
 import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
 import java.util.UUID;\r
+import java.util.ArrayList;\r
 \r
+import org.apache.xmlbeans.XmlObject;\r
 import org.tianocore.build.global.GlobalData;\r
+import org.tianocore.build.global.SurfaceAreaQuery;\r
 import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r
 import org.tianocore.build.pcd.entity.Token;\r
 import org.tianocore.build.pcd.entity.UsageInstance;\r
@@ -60,11 +65,6 @@ public class PCDAutoGenAction extends BuildAction {
     /// \r
     private String                version;\r
     ///\r
-    /// Wheter current module is PCD emulated driver. It is only for \r
-    /// emulated PCD driver and will be kept until PCD IMAGE tool ready.\r
-    ///\r
-    private boolean               isEmulatedPCDDriver;\r
-    ///\r
     /// Whether current autogen is for building library used by current module.\r
     /// \r
     private boolean               isBuildUsedLibrary;\r
@@ -75,8 +75,11 @@ public class PCDAutoGenAction extends BuildAction {
     ///\r
     /// The generated string for C code file.\r
     ///\r
-    private String                cAutoGenString;       \r
-\r
+    private String                cAutoGenString;\r
+    ///\r
+    /// The name array of <PcdCoded> in a module.\r
+    /// \r
+    private String[]              pcdNameArray;\r
     /**\r
       Set parameter ModuleName\r
   \r
@@ -86,38 +89,67 @@ public class PCDAutoGenAction extends BuildAction {
         this.moduleName = moduleName;\r
     }\r
 \r
+    /**\r
+       set the moduleGuid parameter.\r
+       \r
+       @param moduleGuid\r
+    **/\r
     public void setModuleGuid(UUID moduleGuid) {\r
         this.moduleGuid = moduleGuid;\r
     }\r
 \r
+    /**\r
+       set packageName parameter.\r
+       \r
+       @param packageName\r
+    **/\r
     public void setPackageName(String packageName) {\r
         this.packageName = packageName;\r
     }\r
 \r
+    /**\r
+        set packageGuid parameter.\r
+       \r
+       @param packageGuid\r
+    **/\r
     public void setPackageGuid(UUID packageGuid) {\r
         this.packageGuid = packageGuid;\r
     }\r
 \r
+    /**\r
+       set Arch parameter.\r
+       \r
+       @param arch\r
+    **/\r
     public void setArch(String arch) {\r
         this.arch = arch;\r
     }\r
 \r
+    /**\r
+       set version parameter\r
+       \r
+       @param version\r
+     */\r
     public void setVersion(String version) {\r
         this.version = version;\r
     }\r
 \r
     /**\r
-      Set parameter isEmulatedPCDDriver\r
-  \r
-      @param isEmulatedPCDDriver  whether this module is PeiEmulatedPCD driver\r
-    **/\r
-    public void setIsEmulatedPCDDriver(boolean isEmulatedPCDDriver) {\r
-        this.isEmulatedPCDDriver = isEmulatedPCDDriver;\r
-    }\r
-\r
+       set isBuildUsedLibrary parameter.\r
+       \r
+       @param isBuildUsedLibrary\r
+     */\r
     public void setIsBuildUsedLibrary(boolean isBuildUsedLibrary) {\r
         this.isBuildUsedLibrary = isBuildUsedLibrary;\r
     }\r
+    /**\r
+       set pcdNameArray parameter.\r
+       \r
+       @param pcdNameArray\r
+     */\r
+    public void setPcdNameArray(String[] pcdNameArray) {\r
+        this.pcdNameArray = pcdNameArray;\r
+    }\r
 \r
     /**\r
       Get the output of generated string for header file.\r
@@ -145,23 +177,23 @@ public class PCDAutoGenAction extends BuildAction {
       @param moduleName            Parameter of this action class.\r
       @param isEmulatedPCDDriver   Parameter of this action class.\r
     **/\r
-    public PCDAutoGenAction(String  moduleName, \r
-                            UUID    moduleGuid, \r
-                            String  packageName,\r
-                            UUID    packageGuid,\r
-                            String  arch,\r
-                            String  version,\r
-                            boolean isEmulatedPCDDriver, \r
-                            boolean isBuildUsedLibrary) {\r
+    public PCDAutoGenAction(String   moduleName, \r
+                            UUID     moduleGuid, \r
+                            String   packageName,\r
+                            UUID     packageGuid,\r
+                            String   arch,\r
+                            String   version,\r
+                            boolean  isBuildUsedLibrary,\r
+                            String[] pcdNameArray) {\r
         dbManager       = null;\r
         hAutoGenString  = "";\r
         cAutoGenString  = "";\r
 \r
-        setIsEmulatedPCDDriver(isEmulatedPCDDriver);\r
         setModuleName(moduleName);\r
         setModuleGuid(moduleGuid);\r
         setPackageName(packageName);\r
         setPackageGuid(packageGuid);\r
+        setPcdNameArray(pcdNameArray);\r
         setArch(arch);\r
         setVersion(version);\r
         setIsBuildUsedLibrary(isBuildUsedLibrary);\r
@@ -173,13 +205,7 @@ public class PCDAutoGenAction extends BuildAction {
       @throws BuildActionException Bad parameter.\r
     **/\r
     void checkParameter() throws BuildActionException {\r
-        if(!isEmulatedPCDDriver &&(moduleName == null)) {\r
-            throw new BuildActionException("Wrong module name parameter for PCDAutoGenAction tool!");\r
-        }\r
-\r
-        if(!isEmulatedPCDDriver && moduleName.length() == 0) {\r
-            throw new BuildActionException("Wrong module name parameter for PCDAutoGenAction tool!");\r
-        }\r
+        \r
     }\r
 \r
     /**\r
@@ -224,8 +250,8 @@ public class PCDAutoGenAction extends BuildAction {
     **/\r
     private void generateAutogenForModule()\r
     {\r
-        int                   index;\r
-        List<UsageInstance>   usageInstanceArray;\r
+        int                   index, index2;\r
+        List<UsageInstance>   usageInstanceArray, usageContext;\r
 \r
         if (!isBuildUsedLibrary) {\r
             usageInstanceArray  = dbManager.getUsageInstanceArrayByModuleName(moduleName,\r
@@ -237,21 +263,39 @@ public class PCDAutoGenAction extends BuildAction {
             dbManager.UsageInstanceContext = usageInstanceArray;\r
             dbManager.CurrentModuleName    = moduleName; \r
         } else {\r
-            usageInstanceArray = dbManager.UsageInstanceContext;\r
+            usageContext = dbManager.UsageInstanceContext;\r
             //\r
             // For building MDE package, although all module are library, but PCD entries of \r
             // these library should be used to autogen.\r
             // \r
-            if (usageInstanceArray == null) {\r
+            if (usageContext == null) {\r
                 usageInstanceArray  = dbManager.getUsageInstanceArrayByModuleName(moduleName,\r
                                                                                   moduleGuid,\r
                                                                                   packageName,\r
                                                                                   packageGuid,\r
                                                                                   arch,\r
                                                                                   version);\r
+            } else {\r
+                usageInstanceArray = new ArrayList<UsageInstance>();\r
+                //\r
+                // Remove PCD entries which are not belong to this library.\r
+                // \r
+                for (index = 0; index < usageContext.size(); index++) {\r
+                    if ((pcdNameArray == null) || (pcdNameArray.length == 0)){\r
+                        break;\r
+                    }\r
+\r
+                    for (index2 = 0; index2 < pcdNameArray.length; index2 ++) {\r
+                        if (pcdNameArray[index2].equalsIgnoreCase(usageContext.get(index).parentToken.cName)) {\r
+                            usageInstanceArray.add(usageContext.get(index));\r
+                            break;\r
+                        }\r
+                    }\r
+                }\r
             }\r
         }\r
 \r
+\r
         if(usageInstanceArray.size() != 0) {\r
             //\r
             // Add "#include 'PcdLib.h'" for Header file\r
@@ -301,6 +345,7 @@ public class PCDAutoGenAction extends BuildAction {
 \r
         String WorkSpace = "M:/ForPcd/edk2";\r
         String logFilePath = WorkSpace  + "/MdePkg/MdePkg.fpd";\r
+        String[] nameArray = null;\r
 \r
         //\r
         // At first, CollectPCDAction should be invoked to collect\r
@@ -328,8 +373,7 @@ public class PCDAutoGenAction extends BuildAction {
                                                               null,\r
                                                               null,\r
                                                               false,\r
-                                                              false\r
-                                                              );\r
+                                                              nameArray);\r
         autogenAction.execute();\r
 \r
         System.out.println(autogenAction.OutputH());\r