]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/pcd/action/PlatformPcdPreprocessActionForBuilding.java
Refine the code for PCD tools.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / PlatformPcdPreprocessActionForBuilding.java
index e9d13720509491ff5440de763d6dfb4b55387f63..4d2335dfd2525975e791e01d124b1bce262b858e 100644 (file)
@@ -19,7 +19,6 @@ package org.tianocore.build.pcd.action;
 \r
 import java.io.File;\r
 import java.io.IOException;\r
-import java.math.BigInteger;\r
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
 import java.util.List;\r
@@ -50,7 +49,7 @@ import org.tianocore.pcd.exception.PlatformPcdPreprocessException;
 **/\r
 public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreprocessAction {\r
     ///\r
-    /// FPD file is the root file.\r
+    /// FPD file path.\r
     ///\r
     private String                      fpdFilePath;\r
 \r
@@ -88,7 +87,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     /**\r
       Common function interface for outer.\r
 \r
-      @param fpdFilePath    The fpd file path of current build or analysis.\r
+      @param fpdFilePath    The fpd file path of current build or processing.\r
       @param messageLevel   The message level for this Action.\r
 \r
       @throws  PlatformPreprocessBuildException \r
@@ -98,7 +97,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
     **/\r
     public void perform(String fpdFilePath, int messageLevel) \r
         throws PlatformPcdPreprocessBuildException {\r
-        setFPDFilePath(fpdFilePath);\r
+        this.fpdFilePath = fpdFilePath;\r
         setActionMessageLevel(messageLevel);\r
         checkParameter();\r
         execute();\r
@@ -121,7 +120,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
 \r
     **/\r
     public void execute() throws PlatformPcdPreprocessBuildException {\r
-        String errorMessageHeader   = "Fail to initialize Pcd memory database for building. Because:";\r
+        String errorMessageHeader   = "Failed to initialize the Pcd memory database because: ";\r
         String errorsForPreprocess  = null;\r
 \r
         //\r
@@ -152,7 +151,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
         try {\r
             genPcdDatabaseSourceCode ();\r
         } catch (EntityException exp) {\r
-            throw new PlatformPcdPreprocessBuildException(errorMessageHeader + exp.getMessage());\r
+            throw new PlatformPcdPreprocessBuildException(errorMessageHeader + "\r\n" + exp.getMessage());\r
         }\r
     }\r
 \r
@@ -170,7 +169,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
         try {\r
             tokenSpaceStrRet = GlobalData.getGuidInfoFromCname(guidCName);\r
         } catch ( Exception e ) {\r
-            throw new PlatformPcdPreprocessException ("Failed get Guid CName " + guidCName + "from SPD file!");\r
+            throw new PlatformPcdPreprocessException ("Failed to get Guid CName " + guidCName + " from the SPD file!");\r
         }\r
         return tokenSpaceStrRet;\r
     }\r
@@ -303,8 +302,8 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
 \r
         dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions();\r
         if (dynamicPcdBuildDefinitions == null) {\r
-            exceptionString = String.format("[FPD file error] There are no <PcdDynamicBuildDescriptions> in FPD file but contains Dynamic type "+\r
-                                            "PCD entry %s in module %s!",\r
+            exceptionString = String.format("[FPD file error] There are no <PcdDynamicBuildDescriptions> elements in FPD file but there are Dynamic type "+\r
+                                            "PCD entries %s in module %s!",\r
                                             token.cName,\r
                                             moduleName);\r
             putError(exceptionString);\r
@@ -323,7 +322,7 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
 \r
             dynamicPrimaryKey = Token.getPrimaryKeyString(dynamicPcdBuildDataArray.get(index).getCName(),\r
                                                           tokenSpaceStrRet);\r
-            if (dynamicPrimaryKey.equalsIgnoreCase(token.getPrimaryKeyString())) {\r
+            if (dynamicPrimaryKey.equals(token.getPrimaryKeyString())) {\r
                 return dynamicPcdBuildDataArray.get(index);\r
             }\r
         }\r
@@ -359,7 +358,6 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
 \r
         dynamicPcdBuildDefinitions = fpdDocInstance.getPlatformSurfaceArea().getDynamicPcdBuildDefinitions();\r
         if (dynamicPcdBuildDefinitions == null) {\r
-            putError("There is no <DynamicPcdBuildDefinitions> in FPD file!");\r
             return null;\r
         }\r
 \r
@@ -375,11 +373,11 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
         File file = null;\r
 \r
         if (fpdFilePath == null) {\r
-            throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
+            throw new PlatformPcdPreprocessBuildException("FPDFileName should be empty for CollectPCDAtion!");\r
         }\r
 \r
         if (fpdFilePath.length() == 0) {\r
-            throw new PlatformPcdPreprocessBuildException("WorkspacePath and FPDFileName should be blank for CollectPCDAtion!");\r
+            throw new PlatformPcdPreprocessBuildException("FPDFileName should be empty for CollectPCDAtion!");\r
         }\r
 \r
         file = new File(fpdFilePath);\r
@@ -388,23 +386,4 @@ public class PlatformPcdPreprocessActionForBuilding extends PlatformPcdPreproces
             throw new PlatformPcdPreprocessBuildException("FPD File " + fpdFilePath + " does not exist!");\r
         }\r
     }\r
-\r
-    /**\r
-      Test case function\r
-\r
-      @param argv  parameter from command line\r
-    **/\r
-    public static void main(String argv[]) throws PlatformPcdPreprocessBuildException {\r
-        PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
-        String projectDir = "x:/edk2";\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
-                            projectDir,\r
-                            "tools_def.txt");\r
-        System.out.println("After initInfo!");\r
-        FpdParserTask fpt = new FpdParserTask();\r
-        fpt.parseFpdFile(new File(projectDir + "/EdkNt32Pkg/Nt32.fpd"));\r
-        ca.execute();\r
-    }\r
 }\r