]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/PcdTools/org/tianocore/pcd/action/PlatformPcdPreprocessAction.java
Fix track EDKT179.
[mirror_edk2.git] / Tools / Source / PcdTools / org / tianocore / pcd / action / PlatformPcdPreprocessAction.java
index 90c9ca0f31d774acf3259697f86f37cb190c8530..9343c1689d09365a4ab0205d48ecae4b17d056ee 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
@@ -42,6 +42,24 @@ public abstract class PlatformPcdPreprocessAction {
     ///\r
     private MemoryDatabaseManager pcdDbManager;\r
 \r
+    ///\r
+    /// Errors string when perform preprocess \r
+    /// \r
+    private String                errorString;\r
+\r
+    ///\r
+    /// the count of errors when perform preprocess\r
+    /// \r
+    private int                   errorCount;\r
+\r
+    /**\r
+       Default contructor function  \r
+    **/\r
+    public PlatformPcdPreprocessAction() {\r
+        pcdDbManager = null;\r
+        errorString  = null;\r
+    }\r
+\r
     /**\r
        Set parameter pcdDbManager\r
 \r
@@ -53,7 +71,7 @@ public abstract class PlatformPcdPreprocessAction {
 \r
     /**\r
        Get parameter pcdDbManager\r
-         \r
+\r
        @return MemoryDatabaseManager\r
     **/\r
     public MemoryDatabaseManager getPcdDbManager() {\r
@@ -64,10 +82,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 +96,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
+    public abstract String                  getGuidInfoFromSpd(String guidCName)\r
+                                            throws PlatformPcdPreprocessException;\r
 \r
     /**\r
        Abstract function: Verification the PCD data.\r
@@ -87,13 +109,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 +135,44 @@ 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
+       Return the error string after preprocess \r
+\r
+       @return String error string\r
+    **/\r
+    public String getErrorString() {\r
+        return errorString;\r
+    }\r
+\r
+    public void putError(String error) {\r
+        if (errorString == null) {\r
+            errorString = "### ERROR[" + errorCount + "] ###\r\n" + error + "\r\n";\r
+        } else {\r
+            errorString += "### ERROR[" + errorCount + "] ###\r\n" + error + "\r\n";\r
+        }\r
+\r
+        errorCount++;\r
+    }\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
@@ -144,7 +188,7 @@ public abstract class PlatformPcdPreprocessAction {
         String                              moduleName        = null;\r
         String                              datum             = null;\r
         int                                 maxDatumSize      = 0;\r
-        String[]                            tokenSpaceStrRet  = null;\r
+        String                              tokenSpaceStrRet  = null;\r
 \r
         //\r
         // ----------------------------------------------\r
@@ -154,7 +198,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 found in the FPD file.\nPlease check whether there are elements in <FrameworkModules> in the FPD file!");\r
         }\r
 \r
         //\r
@@ -185,10 +230,16 @@ 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
+                    putError("Failed to get Token Space Guid for token " + pcdBuildData.getCName() +\r
+                             " from any SPD file. You must have an <GuidDeclaration> for this Token Space Guid!");\r
+                    //\r
+                    // Do not break preprocess, continues to analysis.\r
+                    // All errors will be summary to be shown.\r
+                    // \r
+                    continue;\r
                 }\r
 \r
-                primaryKey   = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
+                primaryKey   = Token.getPrimaryKeyString(pcdBuildData.getCName(), tokenSpaceStrRet);\r
                 pcdType      = Token.getPcdTypeFromString(pcdBuildData.getItemType().toString());\r
                 datumType    = Token.getdatumTypeFromString(pcdBuildData.getDatumType().toString());\r
                 tokenNumber  = Long.decode(pcdBuildData.getToken().toString());\r
@@ -201,11 +252,16 @@ 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
-                                                    "datum type of this PCD entry is not BOOLEAN!",\r
+                    exceptionString = String.format("In FPD file, for PCD %s in module %s, the PCD type is FEATURE_FLAG but "+\r
+                                                    "datum type for this PCD entry is not BOOLEAN!",\r
                                                     pcdBuildData.getCName(),\r
                                                     moduleName);\r
-                    throw new EntityException(exceptionString);\r
+                    putError(exceptionString);\r
+                    //\r
+                    // Do not break preprocess, continues to analysis.\r
+                    // All errors will be summary to be shown.\r
+                    // \r
+                    continue;\r
                 }\r
 \r
                 //\r
@@ -218,10 +274,15 @@ 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 the FPD file, there is no value for PCD entry %s in module %s!",\r
                                                          pcdBuildData.getCName(),\r
                                                          moduleName);\r
-                         throw new EntityException(exceptionString);\r
+                         putError(exceptionString);\r
+                         //\r
+                         // Do not break preprocess, continues to analysis.\r
+                         // All errors will be summary to be shown.\r
+                         // \r
+                         continue;\r
                      }\r
 \r
                      //\r
@@ -232,7 +293,12 @@ public abstract class PlatformPcdPreprocessAction {
                                                         datum,\r
                                                         datumType,\r
                                                         maxDatumSize)) != null) {\r
-                         throw new EntityException(exceptionString);\r
+                         putError(exceptionString);\r
+                         //\r
+                         // Do not break preprocess, continues to analysis.\r
+                         // All errors will be summary to be shown.\r
+                         // \r
+                         continue;\r
                      }\r
                 }\r
 \r
@@ -253,62 +319,64 @@ 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 the FPD file, the datum type of the PCD entry %s is %s, which is different from %s which was previously defined!",\r
                                                         pcdBuildData.getCName(),\r
                                                         pcdBuildData.getDatumType().toString(),\r
                                                         Token.getStringOfdatumType(token.datumType));\r
-                        throw new EntityException(exceptionString);\r
+                        putError(exceptionString);\r
+                        //\r
+                        // Do not break preprocess, continues to analysis.\r
+                        // All errors will be summary to be shown.\r
+                        // \r
+                        continue;\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 the FPD file, the token number of PCD entry %s in module %s is different from the same PCD entry in other modules!",\r
                                                         pcdBuildData.getCName(),\r
                                                         moduleName);\r
-                        throw new EntityException(exceptionString);\r
+                        putError(exceptionString);\r
+                        //\r
+                        // Do not break preprocess, continues to analysis.\r
+                        // All errors will be summary to be shown.\r
+                        // \r
+                        continue;\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 the FPD file, for PCD entry %s in module %s, you defined dynamic or non-dynamic PCD type which"+\r
+                                                        " is different from other module's definition.",\r
                                                         token.cName,\r
                                                         moduleName);\r
-                        throw new EntityException(exceptionString);\r
+                        putError(exceptionString);\r
+                        //\r
+                        // Do not break preprocess, continues to analysis.\r
+                        // All errors will be summary to be shown.\r
+                        // \r
+                        continue;\r
                     }\r
 \r
                     if (token.isDynamicPCD) {\r
-                        //\r
-                        // Check datum is equal the datum in dynamic information.\r
-                        // For dynamic PCD, you can do not write <Value> in sperated every <PcdBuildDefinition> in different <ModuleSA>,\r
-                        // But if you write, the <Value> must be same as the value in <DynamicPcdBuildDefinitions>.\r
-                        //\r
-                        if (!token.isSkuEnable() &&\r
-                            (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
-                                                                "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
-                            }\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
-                                                            "is different with <MaxDatumSize> %d defined in <DynamicPcdBuildDefinitions>!",\r
+                            exceptionString = String.format("In the FPD file, for dynamic PCD %s in module %s, the max datum size is %d which "+\r
+                                                            "is different than <MaxDatumSize> %d defined in <DynamicPcdBuildDefinitions>!",\r
                                                             token.cName,\r
                                                             moduleName,\r
                                                             maxDatumSize,\r
                                                             token.datumSize);\r
-                            throw new EntityException(exceptionString);\r
+                            putError(exceptionString);\r
+                            //\r
+                            // Do not break preprocess, continues to analysis.\r
+                            // All errors will be summary to be shown.\r
+                            // \r
+                            continue;\r
                         }\r
                     }\r
 \r
@@ -317,13 +385,19 @@ public abstract class PlatformPcdPreprocessAction {
                     // If the token is not in database, create a new token instance and add\r
                     // a usage instance into this token in database.\r
                     //\r
-                    tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());\r
+                    tokenSpaceStrRet = getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());\r
 \r
                     if (tokenSpaceStrRet == null) {\r
-                        throw new EntityException("Fail to get token space guid for token " + token.cName);\r
+                        putError("Failed to get the Token Space Guid for token" + token.cName +\r
+                                 " from any SPD file. You must have a <GuidDeclaration> for this Token Space Guid!");\r
+                        //\r
+                        // Do not break preprocess, continues to analysis.\r
+                        // All errors will be summary to be shown.\r
+                        // \r
+                        continue;\r
                     }\r
 \r
-                    token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
+                    token = new Token(pcdBuildData.getCName(), tokenSpaceStrRet);\r
 \r
                     token.datumType     = datumType;\r
                     token.tokenNumber   = tokenNumber;\r
@@ -335,10 +409,12 @@ public abstract class PlatformPcdPreprocessAction {
                         // For Dynamic and Dynamic Ex type, need find the dynamic information\r
                         // in <DynamicPcdBuildDefinition> section in FPD file.\r
                         //\r
-                        updateDynamicInformation(moduleName,\r
-                                                 token,\r
-                                                 datum,\r
-                                                 maxDatumSize);\r
+                        if (null == updateDynamicInformation(moduleName,\r
+                                                             token,\r
+                                                             datum,\r
+                                                             maxDatumSize)) {\r
+                            continue;\r
+                        }\r
                     }\r
 \r
                     pcdDbManager.addTokenToDatabase(primaryKey, token);\r
@@ -361,7 +437,15 @@ public abstract class PlatformPcdPreprocessAction {
                                                   pcdType,\r
                                                   datum,\r
                                                   maxDatumSize);\r
-                token.addUsageInstance(usageInstance);\r
+                if (!token.addUsageInstance(usageInstance)) {\r
+                    putError(String.format("PCD %s for module %s(%s) already exists in the database.\nPlease check all PCD build entries "+\r
+                                           "in the %s module's <ModuleSA> section to make sure there are no duplicated definitions in the FPD file!",\r
+                                           token.cName,\r
+                                           modules.get(index).usageId.moduleGuid,\r
+                                           moduleName,\r
+                                           moduleName));\r
+                    continue;\r
+                }\r
             }\r
         }\r
 \r
@@ -396,7 +480,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
@@ -405,19 +489,20 @@ public abstract class PlatformPcdPreprocessAction {
         boolean             hasSkuId0       = false;\r
         long                tokenNumber     = 0;\r
         String              hiiDefaultValue = null;\r
-        String[]            variableGuidString = null;\r
+        String              variableGuidString = null;\r
 \r
         List<DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo>   skuInfoList = null;\r
         DynamicPcdBuildDefinitions.PcdBuildData                 dynamicInfo = null;\r
 \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
-                                            "there is no dynamic information in <DynamicPcdBuildDefinitions> "+\r
-                                            "in FPD file, but it is required!",\r
+            exceptionString = String.format("In the FPD file, the Dynamic PCD %s is used by module %s.\n" +\r
+                                            "However, there is no dynamic information in the <DynamicPcdBuildDefinitions> " +\r
+                                            "section of the FPD file.  This section is required!",\r
                                             token.cName,\r
                                             moduleName);\r
-            throw new EntityException(exceptionString);\r
+            putError(exceptionString);\r
+            return null;\r
         }\r
 \r
         token.datumSize = dynamicInfo.getMaxDatumSize();\r
@@ -428,28 +513,30 @@ 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
-                                            "the datum size in <DynamicPcdBuildDefinitions> is %d, they are not match!",\r
+            exceptionString = String.format("In the FPD file, for dynamic PCD %s, the datum size in module %s is %d, but "+\r
+                                            "the datum size in <DynamicPcdBuildDefinitions> is %d, they do not match!",\r
                                             token.cName,\r
                                             moduleName,\r
                                             maxDatumSize,\r
                                             dynamicInfo.getMaxDatumSize());\r
-            throw new EntityException(exceptionString);\r
+            putError(exceptionString);\r
+            return null;\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
-                                            "in <DynamicPcdBuildDefinictions>, the token number is 0x%x, they are not match!",\r
+            exceptionString = String.format("In the FPD file, for dynamic PCD %s, the token number in module %s is 0x%x, but "+\r
+                                            "in the <DynamicPcdBuildDefinictions> section, the token number is 0x%x, they do not match!",\r
                                             token.cName,\r
                                             moduleName,\r
                                             token.tokenNumber,\r
                                             tokenNumber);\r
-            throw new EntityException(exceptionString);\r
+            putError(exceptionString);\r
+            return null;\r
         }\r
 \r
         token.dynamicExTokenNumber = tokenNumber;\r
@@ -479,24 +566,12 @@ public abstract class PlatformPcdPreprocessAction {
                                                    skuInfoList.get(index).getValue().toString(),\r
                                                    token.datumType,\r
                                                    token.datumSize)) != null) {\r
-                    throw new EntityException(exceptionString);\r
+                    putError(exceptionString);\r
+                    return null;\r
                 }\r
 \r
                 token.skuData.add(skuInstance);\r
 \r
-                //\r
-                // Judege wether is same of datum between module's information\r
-                // and dynamic information.\r
-                //\r
-                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
-                                          "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
-                    }\r
-                }\r
                 continue;\r
             }\r
 \r
@@ -506,33 +581,30 @@ 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
-                                                    "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",\r
+                    exceptionString = String.format("In the FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                                                    "file, use of HII was defined, 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
-                    }\r
+                    putError(exceptionString);\r
+                    return null;\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
-                                                    "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",\r
+                    exceptionString = String.format("In the FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                                                    "file, use of HII was defined, 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
-                    }\r
+                    putError(exceptionString);\r
+                    return null;\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
-                                                    "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",\r
+                    exceptionString = String.format("In the FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions> section in FPD "+\r
+                                                    "file, use of HII was defined, 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
-                    }\r
+                    putError(exceptionString);\r
+                    return null;\r
                 }\r
 \r
                 if (skuInfoList.get(index).getHiiDefaultValue() != null) {\r
@@ -546,15 +618,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
+                    putError(String.format("In the FPD file, for dynamic PCD %s, the variable offset defined in SKU %d data "+\r
+                                           "exceeds 64K, which is not allowed!",\r
+                                           token.cName,\r
+                                           index));\r
+                    return null;\r
                 }\r
 \r
                 //\r
@@ -562,21 +635,22 @@ 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
+                    putError(String.format("In the FPD file, for dynamic PCD %s, the variable guid: %s cannot be found in any SPD file!",\r
+                                           token.cName,\r
+                                           skuInfoList.get(index).getVariableGuid().toString()));\r
+                    return null;\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
-                                             translateSchemaStringToUUID(variableGuidString[1]),\r
+                                             translateSchemaStringToUUID(variableGuidString),\r
                                              skuInfoList.get(index).getVariableOffset(),\r
                                              skuInfoList.get(index).getHiiDefaultValue().toString());\r
                 token.skuData.add(skuInstance);\r
@@ -589,29 +663,31 @@ public abstract class PlatformPcdPreprocessAction {
                 continue;\r
             }\r
 \r
-            exceptionString = String.format("[FPD file error] For dynamic PCD %s, the dynamic info must "+\r
-                                            "be one of 'DefaultGroup', 'HIIGroup', 'VpdGroup'.",\r
+            exceptionString = String.format("In the 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
+            putError(exceptionString);\r
+            return null;\r
         }\r
 \r
         if (!hasSkuId0) {\r
-            exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
-                                            "no sku id = 0 data, which is required for every dynamic PCD",\r
+            exceptionString = String.format("In the FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there is "+\r
+                                            "no SKU ID = 0 data, which is required for every dynamic PCD",\r
                                             token.cName);\r
-            throw new EntityException(exceptionString);\r
+            putError(exceptionString);\r
+            return null;\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
@@ -625,8 +701,8 @@ public abstract class PlatformPcdPreprocessAction {
         String  temp;\r
         String  exceptionString;\r
         String  hiiDefaultValue;\r
-        String  tokenSpaceStrRet[];\r
-        String  variableGuidString[];\r
+        String  tokenSpaceStrRet;\r
+        String  variableGuidString;\r
 \r
         dynamicPcdBuildDataArray = getAllDynamicPcdInfoFromFpd();\r
         if (dynamicPcdBuildDataArray == null) {\r
@@ -635,14 +711,15 @@ public abstract class PlatformPcdPreprocessAction {
 \r
         for (index2 = 0; index2 < dynamicPcdBuildDataArray.size(); index2++) {\r
             pcdBuildData = dynamicPcdBuildDataArray.get(index2);\r
-            tokenSpaceStrRet = this.getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());\r
+            tokenSpaceStrRet = getGuidInfoFromSpd(pcdBuildData.getTokenSpaceGuidCName());\r
 \r
             if (tokenSpaceStrRet == null) {\r
-                throw new EntityException ("Fail to get Token space guid for token" + pcdBuildData.getCName());\r
+                putError("Failed to get the Token Space Guid for token" + pcdBuildData.getCName());\r
+                continue;\r
             }\r
 \r
             primaryKey = Token.getPrimaryKeyString(pcdBuildData.getCName(),\r
-                                                   tokenSpaceStrRet[1]);\r
+                                                   tokenSpaceStrRet);\r
 \r
             if (pcdDbManager.isTokenInDatabase(primaryKey)) {\r
                 continue;\r
@@ -650,14 +727,15 @@ 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
+                putError(String.format("In the FPD file, it not allowed to define DYNAMIC PCD %s that is not used by any module",\r
+                                       pcdBuildData.getCName()));\r
+                continue;\r
             }\r
 \r
             //\r
             // Create new token for unreference dynamic PCD token\r
             //\r
-            token           = new Token(pcdBuildData.getCName(), tokenSpaceStrRet[1]);\r
+            token           = new Token(pcdBuildData.getCName(), tokenSpaceStrRet);\r
             token.datumSize = pcdBuildData.getMaxDatumSize();\r
 \r
 \r
@@ -673,7 +751,8 @@ public abstract class PlatformPcdPreprocessAction {
                                           token.datumType,\r
                                           token.datumSize);\r
             if (exceptionString != null) {\r
-                throw new EntityException(exceptionString);\r
+                putError(exceptionString);\r
+                continue;\r
             }\r
 \r
             skuInfoList = pcdBuildData.getSkuInfoList();\r
@@ -701,7 +780,8 @@ public abstract class PlatformPcdPreprocessAction {
                                                        skuInfoList.get(index).getValue().toString(),\r
                                                        token.datumType,\r
                                                        token.datumSize)) != null) {\r
-                        throw new EntityException(exceptionString);\r
+                        putError(exceptionString);\r
+                        continue;\r
                     }\r
 \r
                     token.skuData.add(skuInstance);\r
@@ -715,33 +795,30 @@ 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
-                                                        "file, who use HII, but there is no <VariableGuid> defined for Sku %d data!",\r
+                        exceptionString = String.format("In the FPD file, for dynamic PCD %s in the <DynamicPcdBuildDefinitions> section of the FPD "+\r
+                                                        "file, use of HII is defined, 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
-                        }\r
+                        putError(exceptionString);\r
+                        continue;\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
-                                                        "file, who use HII, but there is no <VariableOffset> defined for Sku %d data!",\r
+                        exceptionString = String.format("In the FPD file, for dynamic PCD %s in the <DynamicPcdBuildDefinitions> section of the FPD "+\r
+                                                        "file, use of HII is defined, 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
-                        }\r
+                        putError(exceptionString);\r
+                        continue;\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
-                                                        "file, who use HII, but there is no <HiiDefaultValue> defined for Sku %d data!",\r
+                        exceptionString = String.format("In the FPD file, for dynamic PCD %s in the <DynamicPcdBuildDefinitions> section of the FPD "+\r
+                                                        "file, use of HII is defined, 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
-                        }\r
+                        putError(exceptionString);\r
+                        continue;\r
                     }\r
 \r
                     if (skuInfoList.get(index).getHiiDefaultValue() != null) {\r
@@ -755,37 +832,42 @@ public abstract class PlatformPcdPreprocessAction {
                                                        hiiDefaultValue,\r
                                                        token.datumType,\r
                                                        token.datumSize)) != null) {\r
-                        throw new EntityException(exceptionString);\r
+                        putError(exceptionString);\r
+                        continue;\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
+                        exceptionString = String.format("In the FPD file, for dynamic PCD %s, the variable offset defined in SKU %d data "+\r
+                                          "exceeds 64K, which is not allowed!",\r
+                                          token.cName,\r
+                                          index);\r
+                        putError(exceptionString);\r
+                        continue;\r
                     }\r
 \r
                     //\r
                     // Get variable guid string according to the name of guid which will be mapped into a GUID in SPD file.\r
                     //\r
-                    variableGuidString = this.getGuidInfoFromSpd(skuInfoList.get(index).getVariableGuid().toString());\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
+                        exceptionString = String.format("In the FPD file, for dynamic PCD %s, the variable guid %s cannot be found in any SPD file!",\r
+                                                        token.cName,\r
+                                                        skuInfoList.get(index).getVariableGuid().toString());\r
+                        putError(exceptionString);\r
+                        continue;\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
-                                                 translateSchemaStringToUUID(variableGuidString[1]),\r
+                                                 translateSchemaStringToUUID(variableGuidString),\r
                                                  skuInfoList.get(index).getVariableOffset(),\r
                                                  skuInfoList.get(index).getHiiDefaultValue().toString());\r
                     token.skuData.add(skuInstance);\r
@@ -798,17 +880,18 @@ 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 the 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
+                putError(exceptionString);\r
             }\r
 \r
             if (!hasSkuId0) {\r
-                exceptionString = String.format("[FPD file error] For dynamic PCD %s in <DynamicPcdBuildDefinitions>, there are "+\r
-                                                "no sku id = 0 data, which is required for every dynamic PCD",\r
+                exceptionString = String.format("In the FPD file, for dynamic PCD %s in <DynamicPcdBuildDefinitions>, there is "+\r
+                                                "no SKU ID = 0 data, which is required for every dynamic PCD",\r
                                                 token.cName);\r
-                throw new EntityException(exceptionString);\r
+                putError(exceptionString);\r
+                continue;\r
             }\r
 \r
             tokenArray.add(token);\r
@@ -834,7 +917,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 +947,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 GUID string: " + uuidString);\r
             }\r
 \r
             //\r