]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1, Make exception string friendly, readable.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Aug 2006 18:22:21 +0000 (18:22 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Aug 2006 18:22:21 +0000 (18:22 +0000)
2, Add new PlatformPcdPreprocessBuildException and PlatformPcdPreprocessException for catching PlatformPcdPreprocessAction.
3, Clean up some code for pcd's action package.

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

13 files changed:
Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java
Tools/Source/GenBuild/org/tianocore/build/exception/PlatformPcdPreprocessBuildException.java [new file with mode: 0644]
Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
Tools/Source/GenBuild/org/tianocore/build/pcd/action/PlatformPcdPreprocessActionForBuilding.java
Tools/Source/PcdTools/org/tianocore/pcd/action/ActionMessage.java
Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java
Tools/Source/PcdTools/org/tianocore/pcd/entity/DynamicTokenValue.java
Tools/Source/PcdTools/org/tianocore/pcd/entity/Token.java
Tools/Source/PcdTools/org/tianocore/pcd/exception/EntityException.java
Tools/Source/PcdTools/org/tianocore/pcd/exception/PlatformPcdPreprocessException.java [new file with mode: 0644]

index a8ec270355146dd8693d376a193171900050f649..d8249dd86cd9f244357eb4077ffca39fc472b84d 100644 (file)
@@ -462,7 +462,7 @@ public class AutoGen {
                 try {\r
                     this.myPcdAutogen.execute();\r
                 } catch (Exception exp) {\r
-                    throw new BuildException (exp.getMessage());\r
+                    throw new PcdAutogenException (exp.getMessage());\r
                 }\r
                \r
                if (this.myPcdAutogen != null) {\r
@@ -594,7 +594,7 @@ public class AutoGen {
         * @throws BuildException\r
         *             Failed to generate AutoGen.c.\r
         */\r
-       void libGenAutogenC() throws BuildException {\r
+       void libGenAutogenC() throws BuildException, PcdAutogenException {\r
                StringBuffer fileBuffer = new StringBuffer(10240);\r
 \r
                //\r
@@ -615,7 +615,7 @@ public class AutoGen {
                try {\r
                     this.myPcdAutogen.execute();\r
                } catch (Exception e) {\r
-                    throw new BuildException(e.getMessage());\r
+                    throw new PcdAutogenException(e.getMessage());\r
                }\r
 \r
                if (this.myPcdAutogen != null) {\r
index d11e041695584b0f699cd6a99f188c2349886c8d..558cff990e97a1874106beb6c77459d98b7b3104 100644 (file)
@@ -26,7 +26,7 @@ public class PcdAutogenException extends AutoGenException {
       @param expStr exception message string.\r
     **/\r
     public PcdAutogenException(String expStr) {\r
-        super("[PcdAutogenException]:" + expStr);\r
+        super("\r\n[PcdAutogenException] #############################\r\n" + expStr);\r
     }\r
     \r
     public PcdAutogenException() {\r
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/PlatformPcdPreprocessBuildException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/PlatformPcdPreprocessBuildException.java
new file mode 100644 (file)
index 0000000..894f25e
--- /dev/null
@@ -0,0 +1,36 @@
+/** @file\r
+  PlatformPcdPreprocessBuildException class.\r
+\r
+  The class handle the exception throwed by PlatformPcdPreprocessActionForBuilding class.\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+package org.tianocore.build.exception;\r
+\r
+public class PlatformPcdPreprocessBuildException extends GenBuildException {\r
+    /**\r
+      serial version ID\r
+       **/\r
+       private static final long serialVersionUID = -1014589090055424954L;\r
+\r
+       /**\r
+      Constructure function\r
+\r
+      @param expStr exception message string.\r
+    **/\r
+    public PlatformPcdPreprocessBuildException(String expStr) {\r
+        super("\r\n[PlatformPcdPreprocess Failure] #############################\r\n" + expStr);\r
+    }\r
+\r
+    public PlatformPcdPreprocessBuildException() {\r
+        super();\r
+    }\r
+}\r
index 37e05fd627425862f2a6adc9ec93d11ee00897ae..23be3307e15294e1a729d4c56891436aa411eabd 100644 (file)
@@ -375,12 +375,8 @@ public class FpdParserTask extends Task {
             //\r
             // Pcd Collection. Call CollectPCDAction to collect pcd info.\r
             //\r
-            try {\r
-                PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
-                ca.perform(GlobalData.getWorkspacePath(),platformId.getFpdFile().getPath(),ActionMessage.NULL_MESSAGE_LEVEL);\r
-            } catch (Exception e){\r
-                throw new BuildException(e.getMessage());\r
-            }\r
+            PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
+            ca.perform(platformId.getFpdFile().getPath(), ActionMessage.NULL_MESSAGE_LEVEL);\r
         } catch (Exception e) {\r
             throw new BuildException("Load FPD file [" + fpdFile.getPath() + "] error. \n" + e.getMessage());\r
         }\r
index b02af3df664656e23442bac756f22bc38dc4fdcc..d078002bfe70fe469e8ab339dec76dd003284ac2 100644 (file)
@@ -107,7 +107,7 @@ public class GlobalData {
     ///\r
     /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.\r
     ///\r
-//    private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();\r
+    private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();\r
 \r
     ///\r
     /// build target + tool chain family/tag name + arch + command types + command options\r
@@ -130,8 +130,6 @@ public class GlobalData {
     private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r
     private static Map<FpdModuleIdentification, ToolChainMap> moduleToolChainFamilyOption = new HashMap<FpdModuleIdentification, ToolChainMap>();\r
 \r
-    private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();\r
-\r
     /**\r
       Parse framework database (DB) and all SPD files listed in DB to initialize\r
       the environment for next build. This method will only be executed only once\r
index 5a429e41175c00507b7fc6c6c7bbca223afafdf1..614bd9e4852a52cc18a48ebcd6228dcccfa42215 100644 (file)
@@ -31,6 +31,7 @@ import org.tianocore.pcd.exception.BuildActionException;
 import org.tianocore.pcd.entity.UsageIdentification;\r
 import org.tianocore.pcd.action.BuildAction;\r
 import org.tianocore.pcd.action.ActionMessage;\r
+import org.tianocore.build.exception.PcdAutogenException;\r
 \r
 /** This class is to manage how to generate the PCD information into Autogen.c and\r
     Autogen.h.\r
@@ -142,7 +143,7 @@ public class PCDAutoGenAction extends BuildAction {
     }\r
 \r
     /**\r
-      check the parameter for action class.\r
+      Override function: check the parameter for action class.\r
 \r
       @throws BuildActionException Bad parameter.\r
     **/\r
@@ -162,12 +163,6 @@ public class PCDAutoGenAction extends BuildAction {
     public void performAction() {\r
         ActionMessage.debug(this,\r
                             "Starting PCDAutoGenAction to generate autogen.h and autogen.c!...");\r
-        //\r
-        // Check the PCD memory database manager is valid.\r
-        //\r
-        if(GlobalData.getPCDMemoryDBManager() == null) {\r
-            throw new BuildActionException("Memory database has not been initlizated!");\r
-        }\r
 \r
         dbManager = GlobalData.getPCDMemoryDBManager();\r
 \r
@@ -233,7 +228,7 @@ public class PCDAutoGenAction extends BuildAction {
                         // All library's PCD should instanted in module's <ModuleSA> who\r
                         // use this library instance. If not, give errors.\r
                         //\r
-                        throw new BuildActionException (String.format("[PCD Autogen Error] Module %s use library instance %s, the PCD %s " +\r
+                        throw new BuildActionException (String.format("Module %s use library instance %s, the PCD %s " +\r
                                                                       "is required by this library instance, but can not find " +\r
                                                                       "it in the %s's <ModuleSA> in FPD file!",\r
                                                                       MemoryDatabaseManager.CurrentModuleName,\r
@@ -336,9 +331,7 @@ public class PCDAutoGenAction extends BuildAction {
                             WorkSpace,null);\r
 \r
         try {\r
-            collectionAction.perform(WorkSpace,\r
-                                     logFilePath,\r
-                                     ActionMessage.MAX_MESSAGE_LEVEL);\r
+            collectionAction.perform(logFilePath, ActionMessage.MAX_MESSAGE_LEVEL);\r
         } catch(Exception e) {\r
             e.printStackTrace();\r
         }\r
index 2e50531d7e6111005301916093ca542cbedf7cbb..fd1ae56eb646bcfd71281f3ce6fa30a753e0a5b4 100644 (file)
@@ -39,6 +39,8 @@ import org.tianocore.pcd.entity.Token;
 import org.tianocore.pcd.entity.UsageIdentification;\r
 import org.tianocore.pcd.exception.EntityException;\r
 import org.tianocore.pcd.action.PlatformPcdPreprocessAction;\r
+import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;\r
+import org.tianocore.pcd.exception.PlatformPcdPreprocessException;\r
 \r
 /**\r
    This action class is to collect PCD information from MSA, SPD, FPD xml file.\r
@@ -46,11 +48,6 @@ import org.tianocore.pcd.action.PlatformPcdPreprocessAction;
    from buildAction or UIAction.\r
 **/\r
 public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreprocessAction {\r
-    ///\r
-    /// Workspacepath hold the workspace information.\r
-    ///\r
-    private String                      workspacePath;\r
-\r
     ///\r
     /// FPD file is the root file.\r
     ///\r
@@ -66,15 +63,6 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     ///\r
     private PlatformSurfaceAreaDocument fpdDocInstance;\r
 \r
-    /**\r
-      Set WorkspacePath parameter for this action class.\r
-\r
-      @param workspacePath parameter for this action\r
-    **/\r
-    public void setWorkspacePath(String workspacePath) {\r
-        this.workspacePath = workspacePath;\r
-    }\r
-\r
     /**\r
       Set action message level for CollectPcdAction tool.\r
 \r
@@ -99,17 +87,16 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     /**\r
       Common function interface for outer.\r
 \r
-      @param workspacePath The path of workspace of current build or analysis.\r
-      @param fpdFilePath   The fpd file path of current build or analysis.\r
-      @param messageLevel  The message level for this Action.\r
+      @param fpdFilePath    The fpd file path of current build or analysis.\r
+      @param messageLevel   The message level for this Action.\r
 \r
-      @throws  Exception The exception of this function. Because it can *not* be predict\r
-                         where the action class will be used. So only Exception can be throw.\r
+      @throws  PlatformPreprocessBuildException \r
+                            The exception of this function. Because it can *not* be predict\r
+                            where the action class will be used. So only Exception can be throw.\r
 \r
     **/\r
-    public void perform(String workspacePath, String fpdFilePath,\r
-                        int messageLevel) throws Exception {\r
-        setWorkspacePath(workspacePath);\r
+    public void perform(String fpdFilePath, int messageLevel) \r
+        throws PlatformPcdPreprocessBuildException {\r
         setFPDFilePath(fpdFilePath);\r
         setActionMessageLevel(messageLevel);\r
         checkParameter();\r
@@ -132,32 +119,34 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
       @throws  EntityException Exception indicate failed to execute this action.\r
 \r
     **/\r
-    public void execute() throws EntityException {\r
-        MemoryDatabaseManager pcdDbManager = null;\r
-\r
+    public void execute() throws PlatformPcdPreprocessBuildException {\r
+        String errorMessageHeader = "Fail to initialize Pcd memory database for building. Because:";\r
         //\r
         // Get memoryDatabaseManager instance from GlobalData.\r
-        // The memoryDatabaseManager should be initialized for whatever build\r
-        // tools or wizard tools\r
+        // The memoryDatabaseManager should be initialized as static variable\r
+        // in some Pre-process class.\r
         //\r
-        if((pcdDbManager = GlobalData.getPCDMemoryDBManager()) == null) {\r
-            throw new EntityException("The instance of PCD memory database manager is null");\r
-        }\r
-\r
-        this.setPcdDbManager(pcdDbManager);\r
+        setPcdDbManager(GlobalData.getPCDMemoryDBManager());\r
 \r
         //\r
         // Collect all PCD information defined in FPD file.\r
         // Evenry token defind in FPD will be created as an token into\r
         // memory database.\r
         //\r
-        initPcdMemoryDbWithPlatformInfo();\r
+        try {\r
+            initPcdMemoryDbWithPlatformInfo();\r
+        } catch (PlatformPcdPreprocessException exp) {\r
+            throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage());\r
+        }\r
 \r
         //\r
         // Generate for PEI, DXE PCD DATABASE's definition and initialization.\r
         //\r
-        genPcdDatabaseSourceCode ();\r
-\r
+        try {\r
+            genPcdDatabaseSourceCode ();\r
+        } catch (EntityException exp) {\r
+            throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage());\r
+        }\r
     }\r
 \r
     /**\r
@@ -166,13 +155,15 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
       @param guidCName      Guid CName string.\r
 \r
       @return String[]      Guid information from SPD file.\r
+      @throws PlatformPcdPreprocessException\r
+                            Fail to get Guid information from SPD file.\r
     **/\r
-    public String[] getGuidInfoFromSpd(String guidCName) throws EntityException {\r
+    public String[] getGuidInfoFromSpd(String guidCName) throws PlatformPcdPreprocessException {\r
         String[] tokenSpaceStrRet = null;\r
         try {\r
             tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(guidCName);\r
         } catch ( Exception e ) {\r
-            throw new EntityException ("Failed get Guid CName " + guidCName + "from SPD file!");\r
+            throw new PlatformPcdPreprocessException ("Failed get Guid CName " + guidCName + "from SPD file!");\r
         }\r
         return tokenSpaceStrRet;\r
     }\r
@@ -180,7 +171,6 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     /**\r
       This function generates source code for PCD Database.\r
 \r
-      @param void\r
       @throws EntityException  If the token does *not* exist in memory database.\r
 \r
     **/\r
@@ -210,11 +200,12 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
 \r
       This function maybe provided by some Global class.\r
 \r
-      @return List<ModuleInfo> the component array.\r
+      @return List<ModuleInfo>                  the component array.\r
+      @throws PlatformPcdPreprocessException    get all modules in <ModuleSA> in FPD file.\r
 \r
-     */\r
+    **/\r
     public List<ModulePcdInfoFromFpd> getComponentsFromFpd()\r
-        throws EntityException {\r
+        throws PlatformPcdPreprocessException {\r
         List<ModulePcdInfoFromFpd>                  allModules          = new ArrayList<ModulePcdInfoFromFpd>();\r
         Map<FpdModuleIdentification, XmlObject>     pcdBuildDefinitions = null;\r
         UsageIdentification                         usageId             = null;\r
@@ -246,15 +237,14 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
        Override function: Verify the datum value according its datum size and datum type, this\r
        function maybe moved to FPD verification tools in future.\r
 \r
-       @param cName\r
-       @param moduleName\r
-       @param datum\r
-       @param datumType\r
-       @param maxDatumSize\r
+       @param cName         The token name\r
+       @param moduleName    The module who use this PCD token\r
+       @param datum         The PCD's datum\r
+       @param datumType     The PCD's datum type\r
+       @param maxDatumSize  The max size for PCD's Datum.\r
 \r
-       @return String\r
+       @return String       exception strings.\r
      */\r
-    /***/\r
     public String verifyDatum(String            cName,\r
                               String            moduleName,\r
                               String            datum,\r
@@ -584,7 +574,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     **/\r
     public DynamicPcdBuildDefinitions.PcdBuildData getDynamicInfoFromFpd(Token     token,\r
                                                                          String    moduleName)\r
-        throws EntityException {\r
+        throws PlatformPcdPreprocessException {\r
         int    index             = 0;\r
         String exceptionString   = null;\r
         String dynamicPrimaryKey = null;\r
@@ -600,9 +590,9 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
             try {\r
                 fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath));\r
             } catch(IOException ioE) {\r
-                throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());\r
+                throw new PlatformPcdPreprocessException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());\r
             } catch(XmlException xmlE) {\r
-                throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());\r
+                throw new PlatformPcdPreprocessException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());\r
             }\r
         }\r
 \r
@@ -612,7 +602,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
                                             "PCD entry %s in module %s!",\r
                                             token.cName,\r
                                             moduleName);\r
-            throw new EntityException(exceptionString);\r
+            throw new PlatformPcdPreprocessException(exceptionString);\r
         }\r
 \r
         dynamicPcdBuildDataArray = dynamicPcdBuildDefinitions.getPcdBuildDataList();\r
@@ -620,11 +610,11 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
             try {\r
                 tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(dynamicPcdBuildDataArray.get(index).getTokenSpaceGuidCName());\r
             } catch (Exception e) {\r
-                throw new EntityException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName());\r
+                throw new PlatformPcdPreprocessException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName());\r
             }\r
 \r
             if (tokenSpaceStrRet == null) {\r
-                throw new EntityException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName());\r
+                throw new PlatformPcdPreprocessException ("Fail to get token space guid for token " + dynamicPcdBuildDataArray.get(index).getCName());\r
             }\r
 \r
             dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),\r
@@ -640,11 +630,13 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     /**\r
        Override function: get all <DynamicPcdBuildDefinition> from FPD file.\r
 \r
-       @return List<DynamicPcdBuildDefinitions.PcdBuildData>\r
+       @return List<DynamicPcdBuildDefinitions.PcdBuildData>    All DYNAMIC PCD list in <DynamicPcdBuildDefinitions> in FPD file.\r
+       @throws PlatformPcdPreprocessBuildException              Failure to get dynamic information list.\r
+\r
     **/\r
     public List<DynamicPcdBuildDefinitions.PcdBuildData>\r
                                             getAllDynamicPcdInfoFromFpd()\r
-        throws EntityException {\r
+        throws PlatformPcdPreprocessException {\r
         DynamicPcdBuildDefinitions dynamicPcdBuildDefinitions = null;\r
 \r
         //\r
@@ -655,9 +647,9 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
             try {\r
                 fpdDocInstance = (PlatformSurfaceAreaDocument)XmlObject.Factory.parse(new File(fpdFilePath));\r
             } catch(IOException ioE) {\r
-                throw new EntityException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());\r
+                throw new PlatformPcdPreprocessException("File IO error for xml file:" + fpdFilePath + "\n" + ioE.getMessage());\r
             } catch(XmlException xmlE) {\r
-                throw new EntityException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());\r
+                throw new PlatformPcdPreprocessException("Can't parse the FPD xml fle:" + fpdFilePath + "\n" + xmlE.getMessage());\r
             }\r
         }\r
 \r
@@ -672,28 +664,23 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     /**\r
       check parameter for this action.\r
 \r
-      @throws EntityException  Bad parameter.\r
+      @throws PlatformPcdPreprocessBuildException  Bad parameter.\r
     **/\r
-    private void checkParameter() throws EntityException {\r
+    private void checkParameter() throws PlatformPcdPreprocessBuildException {\r
         File file = null;\r
 \r
-        if((fpdFilePath    == null) ||(workspacePath  == null)) {\r
-            throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
+        if (fpdFilePath == null) {\r
+            throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
         }\r
 \r
-        if(fpdFilePath.length() == 0 || workspacePath.length() == 0) {\r
-            throw new EntityException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
-        }\r
-\r
-        file = new File(workspacePath);\r
-        if(!file.exists()) {\r
-            throw new EntityException("WorkpacePath " + workspacePath + " does not exist!");\r
+        if (fpdFilePath.length() == 0) {\r
+            throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
         }\r
 \r
         file = new File(fpdFilePath);\r
 \r
         if(!file.exists()) {\r
-            throw new EntityException("FPD File " + fpdFilePath + " does not exist!");\r
+            throw new PlatformPcdPreprocessBuildException("FPD File " + fpdFilePath + " does not exist!");\r
         }\r
     }\r
 \r
@@ -702,10 +689,9 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
 \r
       @param argv  parameter from command line\r
     **/\r
-    public static void main(String argv[]) throws EntityException {\r
+    public static void main(String argv[]) throws PlatformPcdPreprocessBuildException {\r
         PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
         String projectDir = "x:/edk2";\r
-        ca.setWorkspacePath(projectDir);\r
         ca.setFPDFilePath(projectDir + "/EdkNt32Pkg/Nt32.fpd");\r
         ca.setActionMessageLevel(ActionMessage.MAX_MESSAGE_LEVEL);\r
         GlobalData.initInfo("Tools" + File.separator + "Conf" + File.separator + "FrameworkDatabase.db",\r
index 3c4b467f7fa5fbb39903b5dfeee57dbbb2670f35..1e26eff26bec62e1a77efd5e86f7537d3275dc08 100644 (file)
@@ -17,7 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 package org.tianocore.pcd.action;\r
 \r
 import org.apache.tools.ant.Task;\r
-import org.tianocore.logger.EdkLog;\r
 \r
 /** ActionMessage class take over all message for loging and waning. This class\r
     should dispatch message into different Action class according to instance\r
index 90c9ca0f31d774acf3259697f86f37cb190c8530..04ebf89684d3d146396e638c8697831d22fca715 100644 (file)
@@ -25,10 +25,10 @@ import java.util.regex.Pattern;
 \r
 import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions;\r
 import org.tianocore.PcdBuildDefinitionDocument.PcdBuildDefinition;\r
-import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
-import org.tianocore.pcd.exception.EntityException;\r
 import org.tianocore.pcd.entity.*;\r
 import org.tianocore.pcd.entity.Token;\r
+import org.tianocore.pcd.entity.MemoryDatabaseManager;\r
+import org.tianocore.pcd.exception.PlatformPcdPreprocessException;\r
 \r
 /**\r
    The abstract parent class PlatformPcdPreprocessAction, This class is to collect platform's\r
@@ -53,7 +53,7 @@ public abstract class PlatformPcdPreprocessAction {
 \r
     /**\r
        Get parameter pcdDbManager\r
-         \r
+\r
        @return MemoryDatabaseManager\r
     **/\r
     public MemoryDatabaseManager getPcdDbManager() {\r
@@ -64,10 +64,12 @@ public abstract class PlatformPcdPreprocessAction {
 \r
        In building environement, this function will be implementated by FpdParserTask.\r
 \r
-       @return List<ModuleInfoFromFpd>\r
+       @return List<ModuleInfo>                  the component array.\r
+       @throws PlatformPcdPreprocessException    get all modules in <ModuleSA> in FPD file.\r
+\r
     **/\r
     public abstract List<ModulePcdInfoFromFpd> getComponentsFromFpd()\r
-                                               throws EntityException;\r
+                                               throws PlatformPcdPreprocessException;\r
 \r
     /**\r
        Abstract function to get GUID string from SPD file.\r
@@ -76,10 +78,12 @@ public abstract class PlatformPcdPreprocessAction {
 \r
        @param guidCName the CName of GUID\r
 \r
-       @return String[] Guid Info array contains CName and Guid String\r
+       @return String[]      Guid information from SPD file.\r
+       @throws PlatformPcdPreprocessException\r
+                            Fail to get Guid information from SPD file.\r
     **/\r
     public abstract String[]                getGuidInfoFromSpd(String guidCName)\r
-                                            throws EntityException;\r
+                                            throws PlatformPcdPreprocessException;\r
 \r
     /**\r
        Abstract function: Verification the PCD data.\r
@@ -87,13 +91,14 @@ public abstract class PlatformPcdPreprocessAction {
        In different environment, such as building environment and wizard environment,\r
        it has different implementation according to optimization.\r
 \r
-       @param cName\r
-       @param moduleName\r
-       @param datum\r
-       @param datumType\r
-       @param maxDatumSize\r
+       @param cName         The token name\r
+       @param moduleName    The module who use this PCD token\r
+       @param datum         The PCD's datum\r
+       @param datumType     The PCD's datum type\r
+       @param maxDatumSize  The max size for PCD's Datum.\r
+\r
+       @return String       exception strings.\r
 \r
-       @return String\r
     **/\r
     public abstract String                  verifyDatum(String            cName,\r
                                                         String            moduleName,\r
@@ -112,23 +117,25 @@ public abstract class PlatformPcdPreprocessAction {
     public abstract DynamicPcdBuildDefinitions.PcdBuildData\r
                                             getDynamicInfoFromFpd(Token     token,\r
                                                                   String    moduleName)\r
-                                            throws EntityException;\r
+                                            throws PlatformPcdPreprocessException;\r
 \r
     /**\r
        Abstract function: Get all dynamic PCD information from FPD file.\r
 \r
-       @return List<DynamicPcdBuildDefinitions.PcdBuildData>\r
+       @return List<DynamicPcdBuildDefinitions.PcdBuildData>    All DYNAMIC PCD list in <DynamicPcdBuildDefinitions> in FPD file.\r
+       @throws PlatformPcdPreprocessBuildException              Failure to get dynamic information list.\r
+\r
     **/\r
     public abstract List<DynamicPcdBuildDefinitions.PcdBuildData>\r
                                             getAllDynamicPcdInfoFromFpd()\r
-                                            throws EntityException;\r
+                                            throws PlatformPcdPreprocessException;\r
 \r
     /**\r
       Collect all PCD information from FPD file into PCD memory database.\r
 \r
     **/\r
     public void initPcdMemoryDbWithPlatformInfo()\r
-        throws EntityException {\r
+        throws PlatformPcdPreprocessException {\r
         int                                 index             = 0;\r
         int                                 pcdIndex          = 0;\r
         List<PcdBuildDefinition.PcdData>    pcdBuildDataArray = new ArrayList<PcdBuildDefinition.PcdData>();\r
@@ -154,7 +161,8 @@ public abstract class PlatformPcdPreprocessAction {
         modules = getComponentsFromFpd();\r
 \r
         if (modules == null) {\r
-            throw new EntityException("[FPD file error] No modules in FPD file, Please check whether there are elements in <FrameworkModules> in FPD file!");\r
+            throw new PlatformPcdPreprocessException(\r
+                "No modules in FPD file, Please check whether there are elements in <FrameworkModules> in FPD file!");\r
         }\r
 \r
         //\r
@@ -185,7 +193,9 @@ public abstract class PlatformPcdPreprocessAction {
                 tokenSpaceStrRet = getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());\r
 \r
                 if (tokenSpaceStrRet == null) {\r
-                    throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName());\r
+                    throw new PlatformPcdPreprocessException(\r
+                        "Fail to get Token space guid for token" + pcdBuildData.getCName() +\r
+                        " from all SPD files. You must have an <GuidDeclaration> for this token space Guid");\r
                 }\r
 \r
                 primaryKey   = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
@@ -201,11 +211,11 @@ public abstract class PlatformPcdPreprocessAction {
 \r
                 if ((pcdType    == Token.PCD_TYPE.FEATURE_FLAG) &&\r
                     (datumType  != Token.DATUM_TYPE.BOOLEAN)){\r
-                    exceptionString = String.format("[FPD file error] For PCD %s in module %s, the PCD type is FEATRUE_FLAG but "+\r
+                    exceptionString = String.format("In FPD file, for PCD %s in module %s, the PCD type is FEATRUE_FLAG but "+\r
                                                     "datum type of this PCD entry is not BOOLEAN!",\r
                                                     pcdBuildData.getCName(),\r
                                                     moduleName);\r
-                    throw new EntityException(exceptionString);\r
+                    throw new PlatformPcdPreprocessException(exceptionString);\r
                 }\r
 \r
                 //\r
@@ -218,10 +228,10 @@ public abstract class PlatformPcdPreprocessAction {
                      // Value is required.\r
                      //\r
                      if (datum == null) {\r
-                         exceptionString = String.format("[FPD file error] There is no value for PCD entry %s in module %s!",\r
+                         exceptionString = String.format("In FPD file, there is no value for PCD entry %s in module %s!",\r
                                                          pcdBuildData.getCName(),\r
                                                          moduleName);\r
-                         throw new EntityException(exceptionString);\r
+                         throw new PlatformPcdPreprocessException(exceptionString);\r
                      }\r
 \r
                      //\r
@@ -232,7 +242,7 @@ public abstract class PlatformPcdPreprocessAction {
                                                         datum,\r
                                                         datumType,\r
                                                         maxDatumSize)) != null) {\r
-                         throw new EntityException(exceptionString);\r
+                         throw new PlatformPcdPreprocessException(exceptionString);\r
                      }\r
                 }\r
 \r
@@ -253,32 +263,32 @@ public abstract class PlatformPcdPreprocessAction {
                     // modules.\r
                     //\r
                     if (token.datumType != datumType) {\r
-                        exceptionString = String.format("[FPD file error] The datum type of PCD entry %s is %s, which is different with  %s defined in before!",\r
+                        exceptionString = String.format("In FPD file, the datum type of PCD entry %s is %s, which is different with  %s defined in before!",\r
                                                         pcdBuildData.getCName(),\r
                                                         pcdBuildData.getDatumType().toString(),\r
                                                         Token.getStringOfdatumType(token.datumType));\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
 \r
                     //\r
                     // Check token number is valid\r
                     //\r
                     if (tokenNumber != token.tokenNumber) {\r
-                        exceptionString = String.format("[FPD file error] The token number of PCD entry %s in module %s is different with same PCD entry in other modules!",\r
+                        exceptionString = String.format("In FPD file, the token number of PCD entry %s in module %s is different with same PCD entry in other modules!",\r
                                                         pcdBuildData.getCName(),\r
                                                         moduleName);\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
 \r
                     //\r
                     // For same PCD used in different modules, the PCD type should all be dynamic or non-dynamic.\r
                     //\r
                     if (token.isDynamicPCD != Token.isDynamic(pcdType)) {\r
-                        exceptionString = String.format("[FPD file error] For PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+\r
-                                                        "is different with others module's",\r
+                        exceptionString = String.format("In FPD file, for PCD entry %s in module %s, you define dynamic or non-dynamic PCD type which"+\r
+                                                        " is different with others module's",\r
                                                         token.cName,\r
                                                         moduleName);\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
 \r
                     if (token.isDynamicPCD) {\r
@@ -291,24 +301,24 @@ public abstract class PlatformPcdPreprocessAction {
                             (token.getDefaultSku().type == DynamicTokenValue.VALUE_TYPE.DEFAULT_TYPE) &&\r
                             (datum != null)) {\r
                             if (!datum.equalsIgnoreCase(token.getDefaultSku().value)) {\r
-                                exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the datum in <ModuleSA> is "+\r
+                                exceptionString = String.format("In FPD file, for dynamic PCD %s in module %s, the datum in <ModuleSA> is "+\r
                                                                 "not equal to the datum in <DynamicPcdBuildDefinitions>, it is "+\r
                                                                 "illega! You could no set <Value> in <ModuleSA> for a dynamic PCD!",\r
                                                                 token.cName,\r
                                                                 moduleName);\r
-                                throw new EntityException(exceptionString);\r
+                                throw new PlatformPcdPreprocessException(exceptionString);\r
                             }\r
                         }\r
 \r
                         if ((maxDatumSize != 0) &&\r
                             (maxDatumSize != token.datumSize)){\r
-                            exceptionString = String.format("[FPD file error] For dynamic PCD %s in module %s, the max datum size is %d which "+\r
+                            exceptionString = String.format("In FPD file, for dynamic PCD %s in module %s, the max datum size is %d which "+\r
                                                             "is different with <MaxDatumSize> %d defined in <DynamicPcdBuildDefinitions>!",\r
                                                             token.cName,\r
                                                             moduleName,\r
                                                             maxDatumSize,\r
                                                             token.datumSize);\r
-                            throw new EntityException(exceptionString);\r
+                            throw new PlatformPcdPreprocessException(exceptionString);\r
                         }\r
                     }\r
 \r
@@ -320,7 +330,10 @@ public abstract class PlatformPcdPreprocessAction {
                     tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());\r
 \r
                     if (tokenSpaceStrRet == null) {\r
-                        throw new EntityException("Fail to get token space guid for token " + token.cName);\r
+                        throw new PlatformPcdPreprocessException(\r
+                            "Fail to get Token space guid for token" + token.cName +\r
+                            " from all SPD files. You must have an <GuidDeclaration> for this token space Guid");\r
+\r
                     }\r
 \r
                     token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
@@ -361,7 +374,14 @@ public abstract class PlatformPcdPreprocessAction {
                                                   pcdType,\r
                                                   datum,\r
                                                   maxDatumSize);\r
-                token.addUsageInstance(usageInstance);\r
+                if (!token.addUsageInstance(usageInstance)) {\r
+                    throw new PlatformPcdPreprocessException(\r
+                        String.format("PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
+                                      "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",\r
+                                      token.cName,\r
+                                      moduleName,\r
+                                      moduleName));\r
+                }\r
             }\r
         }\r
 \r
@@ -396,7 +416,7 @@ public abstract class PlatformPcdPreprocessAction {
                                            Token    token,\r
                                            String   datum,\r
                                            int      maxDatumSize)\r
-        throws EntityException {\r
+        throws PlatformPcdPreprocessException {\r
         int                 index           = 0;\r
         int                 offset;\r
         String              exceptionString = null;\r
@@ -412,12 +432,12 @@ public abstract class PlatformPcdPreprocessAction {
 \r
         dynamicInfo = getDynamicInfoFromFpd(token, moduleName);\r
         if (dynamicInfo == null) {\r
-            exceptionString = String.format("[FPD file error] For Dynamic PCD %s used by module %s, "+\r
+            exceptionString = String.format("In FPD file, for Dynamic PCD %s used by module %s, "+\r
                                             "there is no dynamic information in <DynamicPcdBuildDefinitions> "+\r
                                             "in FPD file, but it is required!",\r
                                             token.cName,\r
                                             moduleName);\r
-            throw new EntityException(exceptionString);\r
+            throw new PlatformPcdPreprocessException(exceptionString);\r
         }\r
 \r
         token.datumSize = dynamicInfo.getMaxDatumSize();\r
@@ -428,28 +448,28 @@ public abstract class PlatformPcdPreprocessAction {
                                       token.datumType,\r
                                       token.datumSize);\r
         if (exceptionString != null) {\r
-            throw new EntityException(exceptionString);\r
+            throw new PlatformPcdPreprocessException(exceptionString);\r
         }\r
 \r
         if ((maxDatumSize != 0) &&\r
             (maxDatumSize != token.datumSize)) {\r
-            exceptionString = String.format("FPD file error] For dynamic PCD %s, the datum size in module %s is %d, but "+\r
+            exceptionString = String.format("In FPD file, for dynamic PCD %s, the datum size in module %s is %d, but "+\r
                                             "the datum size in <DynamicPcdBuildDefinitions> is %d, they are not match!",\r
                                             token.cName,\r
                                             moduleName,\r
                                             maxDatumSize,\r
                                             dynamicInfo.getMaxDatumSize());\r
-            throw new EntityException(exceptionString);\r
+            throw new PlatformPcdPreprocessException(exceptionString);\r
         }\r
         tokenNumber = Long.decode(dynamicInfo.getToken().toString());\r
         if (tokenNumber != token.tokenNumber) {\r
-            exceptionString = String.format("[FPD file error] For dynamic PCD %s, the token number in module %s is 0x%x, but"+\r
+            exceptionString = String.format("In FPD file, for dynamic PCD %s, the token number in module %s is 0x%x, but"+\r
                                             "in <DynamicPcdBuildDefinictions>, the token number is 0x%x, they are not match!",\r
                                             token.cName,\r
                                             moduleName,\r
                                             token.tokenNumber,\r
                                             tokenNumber);\r
-            throw new EntityException(exceptionString);\r
+            throw new PlatformPcdPreprocessException(exceptionString);\r
         }\r
 \r
         token.dynamicExTokenNumber = tokenNumber;\r
@@ -479,7 +499,7 @@ public abstract class PlatformPcdPreprocessAction {
                                                    skuInfoList.get(index).getValue().toString(),\r
                                                    token.datumType,\r
                                                    token.datumSize)) != null) {\r
-                    throw new EntityException(exceptionString);\r
+                    throw new PlatformPcdPreprocessException(exceptionString);\r
                 }\r
 \r
                 token.skuData.add(skuInstance);\r
@@ -491,10 +511,10 @@ public abstract class PlatformPcdPreprocessAction {
                 if (datum != null) {\r
                     if ((skuInstance.id == 0)                                   &&\r
                         !datum.toString().equalsIgnoreCase(skuInfoList.get(index).getValue().toString())) {\r
-                        exceptionString = "[FPD file error] For dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+\r
+                        exceptionString = "In FPD file, for dynamic PCD " + token.cName + ", the value in module " + moduleName + " is " + datum.toString() + " but the "+\r
                                           "value of sku 0 data in <DynamicPcdBuildDefinition> is " + skuInstance.value.value + ". They are must be same!"+\r
                                           " or you could not define value for a dynamic PCD in every <ModuleSA>!";\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
                 }\r
                 continue;\r
@@ -506,32 +526,32 @@ public abstract class PlatformPcdPreprocessAction {
             if (skuInfoList.get(index).getVariableName() != null) {\r
                 exceptionString = null;\r
                 if (skuInfoList.get(index).getVariableGuid() == null) {\r
-                    exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                    exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                     "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
                     if (exceptionString != null) {\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
                 }\r
 \r
                 if (skuInfoList.get(index).getVariableOffset() == null) {\r
-                    exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                    exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                     "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
                     if (exceptionString != null) {\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
                 }\r
 \r
                 if (skuInfoList.get(index).getHiiDefaultValue() == null) {\r
-                    exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                    exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                     "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",\r
                                                     token.cName,\r
                                                     index);\r
                     if (exceptionString != null) {\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
                 }\r
 \r
@@ -546,15 +566,16 @@ public abstract class PlatformPcdPreprocessAction {
                                                    hiiDefaultValue,\r
                                                    token.datumType,\r
                                                    token.datumSize)) != null) {\r
-                    throw new EntityException(exceptionString);\r
+                    throw new PlatformPcdPreprocessException(exceptionString);\r
                 }\r
 \r
                 offset = Integer.decode(skuInfoList.get(index).getVariableOffset());\r
                 if (offset > 0xFFFF) {\r
-                    throw new EntityException(String.format("[FPD file error] For dynamic PCD %s ,  the variable offset defined in sku %d data "+\r
-                                                            "exceed 64K, it is not allowed!",\r
-                                                            token.cName,\r
-                                                            index));\r
+                    throw new PlatformPcdPreprocessException(\r
+                        String.format("In FPD file, for dynamic PCD %s ,  the variable offset defined in sku %d data "+\r
+                                      "exceed 64K, it is not allowed!",\r
+                                      token.cName,\r
+                                      index));\r
                 }\r
 \r
                 //\r
@@ -562,17 +583,18 @@ public abstract class PlatformPcdPreprocessAction {
                 //\r
                 variableGuidString = getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString());\r
                 if (variableGuidString == null) {\r
-                    throw new EntityException(String.format("[GUID Error] For dynamic PCD %s,  the variable guid %s can be found in all SPD file!",\r
-                                                            token.cName,\r
-                                                            skuInfoList.get(index).getVariableGuid().toString()));\r
+                    throw new PlatformPcdPreprocessException(\r
+                        String.format("In FPD file, for dynamic PCD %s,  the variable guid %s can be found in all SPD file!",\r
+                                      token.cName,\r
+                                      skuInfoList.get(index).getVariableGuid().toString()));\r
                 }\r
                 String variableStr = skuInfoList.get(index).getVariableName();\r
                 Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}");\r
                 Matcher matcher = pattern.matcher(variableStr);\r
                 List<String> varNameList = new ArrayList<String>();\r
                 while (matcher.find()){\r
-                        String str = variableStr.substring(matcher.start(),matcher.end());\r
-                        varNameList.add(str);\r
+                    String str = variableStr.substring(matcher.start(),matcher.end());\r
+                    varNameList.add(str);\r
                 }\r
 \r
                 skuInstance.value.setHiiData(varNameList,\r
@@ -589,29 +611,29 @@ public abstract class PlatformPcdPreprocessAction {
                 continue;\r
             }\r
 \r
-            exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+\r
+            exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+\r
                                             "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",\r
                                             token.cName);\r
-            throw new EntityException(exceptionString);\r
+            throw new PlatformPcdPreprocessException(exceptionString);\r
         }\r
 \r
         if (!hasSkuId0) {\r
-            exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
+            exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
                                             "no sku id = 0 data, which is required for every dynamic PCD",\r
                                             token.cName);\r
-            throw new EntityException(exceptionString);\r
+            throw new PlatformPcdPreprocessException(exceptionString);\r
         }\r
 \r
         return token;\r
     }\r
 \r
     /**\r
-       Get all dynamic PCD defined in <DynamicPcdBuildDefinitions> which unreferenced by \r
+       Get all dynamic PCD defined in <DynamicPcdBuildDefinitions> which unreferenced by\r
        any <ModuleSA> in FPD file.\r
-         \r
-       @return List<Token>  Return PCD token \r
+\r
+       @return List<Token>  Return PCD token\r
     **/\r
-    private List<Token> getUnreferencedDynamicPcd () throws EntityException {\r
+    private List<Token> getUnreferencedDynamicPcd () throws PlatformPcdPreprocessException {\r
         List<Token>                                   tokenArray                 = new ArrayList<Token>();\r
         Token                                         token                      = null;\r
         List<DynamicPcdBuildDefinitions.PcdBuildData> dynamicPcdBuildDataArray   = null;\r
@@ -638,7 +660,7 @@ public abstract class PlatformPcdPreprocessAction {
             tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());\r
 \r
             if (tokenSpaceStrRet == null) {\r
-                throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName());\r
+                throw new PlatformPcdPreprocessException("Fail to get Token space guid for token" + pcdBuildData.getCName());\r
             }\r
 \r
             primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),\r
@@ -650,8 +672,9 @@ public abstract class PlatformPcdPreprocessAction {
 \r
             pcdType = Token.getPcdTypeFromString(pcdBuildData.getItemType().toString());\r
             if (pcdType != Token.PCD_TYPE.DYNAMIC_EX) {\r
-                throw new EntityException (String.format("[FPD file error] It not allowed for DYNAMIC PCD %s who is no used by any module",\r
-                                                         pcdBuildData.getCName()));\r
+                throw new PlatformPcdPreprocessException(\r
+                    String.format("In FPD file, it not allowed for DYNAMIC PCD %s who is no used by any module",\r
+                                   pcdBuildData.getCName()));\r
             }\r
 \r
             //\r
@@ -673,7 +696,7 @@ public abstract class PlatformPcdPreprocessAction {
                                           token.datumType,\r
                                           token.datumSize);\r
             if (exceptionString != null) {\r
-                throw new EntityException(exceptionString);\r
+                throw new PlatformPcdPreprocessException(exceptionString);\r
             }\r
 \r
             skuInfoList = pcdBuildData.getSkuInfoList();\r
@@ -701,7 +724,7 @@ public abstract class PlatformPcdPreprocessAction {
                                                        skuInfoList.get(index).getValue().toString(),\r
                                                        token.datumType,\r
                                                        token.datumSize)) != null) {\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
 \r
                     token.skuData.add(skuInstance);\r
@@ -715,32 +738,32 @@ public abstract class PlatformPcdPreprocessAction {
                 if (skuInfoList.get(index).getVariableName() != null) {\r
                     exceptionString = null;\r
                     if (skuInfoList.get(index).getVariableGuid() == null) {\r
-                        exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                        exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                         "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",\r
                                                         token.cName,\r
                                                         index);\r
                         if (exceptionString != null) {\r
-                            throw new EntityException(exceptionString);\r
+                            throw new PlatformPcdPreprocessException(exceptionString);\r
                         }\r
                     }\r
 \r
                     if (skuInfoList.get(index).getVariableOffset() == null) {\r
-                        exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                        exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                         "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",\r
                                                         token.cName,\r
                                                         index);\r
                         if (exceptionString != null) {\r
-                            throw new EntityException(exceptionString);\r
+                            throw new PlatformPcdPreprocessException(exceptionString);\r
                         }\r
                     }\r
 \r
                     if (skuInfoList.get(index).getHiiDefaultValue() == null) {\r
-                        exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                        exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
                                                         "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",\r
                                                         token.cName,\r
                                                         index);\r
                         if (exceptionString != null) {\r
-                            throw new EntityException(exceptionString);\r
+                            throw new PlatformPcdPreprocessException(exceptionString);\r
                         }\r
                     }\r
 \r
@@ -755,15 +778,16 @@ public abstract class PlatformPcdPreprocessAction {
                                                        hiiDefaultValue,\r
                                                        token.datumType,\r
                                                        token.datumSize)) != null) {\r
-                        throw new EntityException(exceptionString);\r
+                        throw new PlatformPcdPreprocessException(exceptionString);\r
                     }\r
 \r
                     offset = Integer.decode(skuInfoList.get(index).getVariableOffset());\r
                     if (offset > 0xFFFF) {\r
-                        throw new EntityException(String.format("[FPD file error] For dynamic PCD %s ,  the variable offset defined in sku %d data "+\r
-                                                                "exceed 64K, it is not allowed!",\r
-                                                                token.cName,\r
-                                                                index));\r
+                        throw new PlatformPcdPreprocessException(\r
+                            String.format("In FPD file, for dynamic PCD %s ,  the variable offset defined in sku %d data "+\r
+                                          "exceed 64K, it is not allowed!",\r
+                                          token.cName,\r
+                                          index));\r
                     }\r
 \r
                     //\r
@@ -771,17 +795,18 @@ public abstract class PlatformPcdPreprocessAction {
                     //\r
                     variableGuidString = this.getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString());\r
                     if (variableGuidString == null) {\r
-                        throw new EntityException(String.format("[GUID Error] For dynamic PCD %s,  the variable guid %s can be found in all SPD file!",\r
-                                                                token.cName,\r
-                                                                skuInfoList.get(index).getVariableGuid().toString()));\r
+                        throw new PlatformPcdPreprocessException(\r
+                            String.format("In FPD file, for dynamic PCD %s,  the variable guid %s can be found in all SPD file!",\r
+                                           token.cName,\r
+                                           skuInfoList.get(index).getVariableGuid().toString()));\r
                     }\r
                     String variableStr = skuInfoList.get(index).getVariableName();\r
                     Pattern pattern = Pattern.compile("0x([a-fA-F0-9]){4}");\r
                     Matcher matcher = pattern.matcher(variableStr);\r
                     List<String> varNameList = new ArrayList<String>();\r
                     while (matcher.find()){\r
-                            String str = variableStr.substring(matcher.start(),matcher.end());\r
-                            varNameList.add(str);\r
+                        String str = variableStr.substring(matcher.start(),matcher.end());\r
+                        varNameList.add(str);\r
                     }\r
 \r
                     skuInstance.value.setHiiData(varNameList,\r
@@ -798,17 +823,17 @@ public abstract class PlatformPcdPreprocessAction {
                     continue;\r
                 }\r
 \r
-                exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+\r
+                exceptionString = String.format("In FPD file, for dynamic PCD %s, the dynamic info must "+\r
                                                 "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",\r
                                                 token.cName);\r
-                throw new EntityException(exceptionString);\r
+                throw new PlatformPcdPreprocessException(exceptionString);\r
             }\r
 \r
             if (!hasSkuId0) {\r
-                exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
+                exceptionString = String.format("In FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
                                                 "no sku id = 0 data, which is required for every dynamic PCD",\r
                                                 token.cName);\r
-                throw new EntityException(exceptionString);\r
+                throw new PlatformPcdPreprocessException(exceptionString);\r
             }\r
 \r
             tokenArray.add(token);\r
@@ -834,7 +859,7 @@ public abstract class PlatformPcdPreprocessAction {
        @return UUID         UUID instance\r
     **/\r
     private UUID translateSchemaStringToUUID(String uuidString)\r
-        throws EntityException {\r
+        throws PlatformPcdPreprocessException {\r
         String      temp;\r
         String[]    splitStringArray;\r
         int         index;\r
@@ -864,7 +889,7 @@ public abstract class PlatformPcdPreprocessAction {
         if ((uuidString.charAt(0) == '0') && ((uuidString.charAt(1) == 'x') || (uuidString.charAt(1) == 'X'))) {\r
             splitStringArray = uuidString.split("," );\r
             if (splitStringArray.length != 11) {\r
-                throw new EntityException ("[FPD file error] Wrong format for UUID string: " + uuidString);\r
+                throw new PlatformPcdPreprocessException ("Wrong format for UUID string: " + uuidString);\r
             }\r
 \r
             //\r
index 2de993d5111d9242ff12b2f85163b813cea77546..0ed76b3ebe82925ae61957d39a1b461774e14244 100644 (file)
@@ -20,7 +20,7 @@ import java.util.UUID;
 \r
 import org.tianocore.pcd.exception.EntityException;\r
 \r
-/** \r
+/**\r
    This class is to descript a value type of dynamic PCD.\r
    For a dynamic or dynamicEx type PCD data, the value type can be:\r
        1) Hii type: the value of dynamic or dynamicEx is stored into a variable.\r
@@ -33,19 +33,19 @@ public class DynamicTokenValue {
     ///\r
     /// Enumeration macro defintion for value type.\r
     ///\r
-    public enum        VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r
+    public static enum        VALUE_TYPE {HII_TYPE, VPD_TYPE, DEFAULT_TYPE}\r
 \r
     ///\r
     /// The value type maybe:\r
     /// HII_TYPE: the value stored into variable area.\r
     /// VPD_TYPE: the value stored into OEM specific area.\r
     /// DEFAULT_TYPE: the value stored into PCD runtime database.\r
-    /// \r
+    ///\r
     public VALUE_TYPE  type;\r
 \r
     ///\r
     /// ---------------------------------------------------------------------\r
-    /// Following member is for HII case. The value of HII case will be put \r
+    /// Following member is for HII case. The value of HII case will be put\r
     /// into variable area in flash.\r
     /// ---------------------------------------------------------------------\r
     ///\r
@@ -87,12 +87,12 @@ public class DynamicTokenValue {
 \r
     ///\r
     /// The default value of this PCD in default case.\r
-    /// \r
+    ///\r
     public String      value;\r
 \r
     /**\r
        Constructor function for DynamicTokenValue class.\r
-         \r
+\r
     **/\r
     public DynamicTokenValue() {\r
         type               = VALUE_TYPE.DEFAULT_TYPE;\r
@@ -107,7 +107,7 @@ public class DynamicTokenValue {
     /**\r
        Set the HII case data.\r
 \r
-       @param variableName      The variable name \r
+       @param variableName      The variable name\r
        @param variableGuid      The variable guid\r
        @param variableOffset    The offset of value in this variable\r
        @param hiiDefaultValue   Default value for this PCD\r
@@ -130,7 +130,7 @@ public class DynamicTokenValue {
        BUGBUG: In fact, it is not correctly, variable name should be\r
                treated as unicode UINT16 array.\r
 \r
-       @return String \r
+       @return String\r
     **/\r
     public String getStringOfVariableName()\r
         throws EntityException {\r
index d1867fba5bc76df5514f45f4ad33e72f644a0345..1038cb021c13dfc474a4422edd482ce54a4056d7 100644 (file)
@@ -21,9 +21,6 @@ import java.util.HashMap;
 import java.util.List;\r
 import java.util.Map;\r
 \r
-import org.tianocore.pcd.entity.UsageIdentification;\r
-import org.tianocore.pcd.exception.EntityException;\r
-\r
 /**\r
    This class is to descript a PCD token object. The information of a token mainly\r
    comes from MSA, SPD and setting produced by platform developer.\r
@@ -32,7 +29,7 @@ public class Token {
     ///\r
     /// Enumeration macro defintion for PCD type.\r
     ///\r
-    public enum             PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC,\r
+    public static enum      PCD_TYPE {FEATURE_FLAG, FIXED_AT_BUILD, PATCHABLE_IN_MODULE, DYNAMIC,\r
                                       DYNAMIC_EX, UNKNOWN}\r
 \r
     ///\r
@@ -40,12 +37,12 @@ public class Token {
     /// Wizard maybe expand this type as "int, unsigned int, short, unsigned short etc" in\r
     /// prompt dialog.\r
     ///\r
-    public enum             DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}\r
+    public static enum      DATUM_TYPE {UINT8, UINT16, UINT32, UINT64, BOOLEAN, POINTER, UNKNOWN}\r
 \r
     ///\r
     /// Enumeration macor defintion for usage of PCD\r
     ///\r
-    public enum             PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED,\r
+    public static enum      PCD_USAGE {ALWAYS_PRODUCED, ALWAYS_CONSUMED, SOMETIMES_PRODUCED,\r
                                        SOMETIMES_CONSUMED, UNKNOWN}\r
 \r
     ///\r
@@ -169,7 +166,7 @@ public class Token {
 \r
     /**\r
        The pcd type is DynamicEx?\r
-         \r
+\r
        @retval true     Is DynamicEx type\r
        @retval false    not DynamicEx type\r
     **/\r
@@ -285,16 +282,9 @@ public class Token {
       @retval TRUE  - Success to add usage instance.\r
       @retval FALSE - Fail to add usage instance\r
     **/\r
-    public boolean addUsageInstance(UsageInstance usageInstance) throws EntityException {\r
-        String exceptionStr;\r
-\r
+    public boolean addUsageInstance(UsageInstance usageInstance) {\r
         if (isUsageInstanceExist(usageInstance.usageId)) {\r
-            exceptionStr = String.format("[PCD Collection Tool Exception] PCD %s for module %s has already exist in database, Please check all PCD build entries "+\r
-                                         "in modules %s in <ModuleSA> to make sure no duplicated definitions in FPD file!",\r
-                                         usageInstance.parentToken.cName,\r
-                                         usageInstance.usageId.moduleName,\r
-                                         usageInstance.usageId.moduleName);\r
-            throw new EntityException(exceptionStr);\r
+            return false;\r
         }\r
 \r
         //\r
@@ -631,7 +621,7 @@ public class Token {
     }\r
 \r
     /**\r
-        Judge whether a DYNAMIC PCD has default value. \r
+        Judge whether a DYNAMIC PCD has default value.\r
 \r
         @return whether a DYNAMIC PCD has default value.\r
     **/\r
@@ -832,7 +822,7 @@ public class Token {
 \r
     /**\r
        Get string value for ANSIC string type\r
-         \r
+\r
        @return String the string value\r
     **/\r
     public String getStringTypeString () {\r
index ca258108550b08b98b876755e54e8b024dab13a7..77d4518a554e6a3ab92e1e4345f1f876614da5db 100644 (file)
@@ -26,6 +26,6 @@ public class EntityException extends Exception {
       @param expStr exception message string.\r
     **/\r
     public EntityException(String expStr) {\r
-        super("[PCD EntityException]:" + expStr);\r
+        super("[PCD tools Internal Errors]:" + expStr);\r
     }\r
 }\r
diff --git a/Tools/Source/PcdTools/org/tianocore/pcd/exception/PlatformPcdPreprocessException.java b/Tools/Source/PcdTools/org/tianocore/pcd/exception/PlatformPcdPreprocessException.java
new file mode 100644 (file)
index 0000000..69b50c8
--- /dev/null
@@ -0,0 +1,36 @@
+/** @file\r
+  PlatformPcdPreprocessException class.\r
+\r
+  The class handle the exception throwed by PlatformPcdPreprocessAction class.\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution.  The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+package org.tianocore.pcd.exception;\r
+\r
+public class PlatformPcdPreprocessException extends Exception {\r
+    /**\r
+         serial version ID\r
+       **/\r
+       private static final long serialVersionUID = 2858398552845888282L;\r
+\r
+       /**\r
+      Constructure function\r
+\r
+      @param expStr exception message string.\r
+    **/\r
+    public PlatformPcdPreprocessException(String expStr) {\r
+        super("\r\n[PlatformPcdPreprocess Failure] #############################\r\n" + expStr);\r
+    }\r
+\r
+    public PlatformPcdPreprocessException() {\r
+        super();\r
+    }\r
+}\r