Fix a bug when generate default value for byte array for FIXED_AT_BUILD, PATCHABLE_IN...
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 17 Jun 2006 13:25:31 +0000 (13:25 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 17 Jun 2006 13:25:31 +0000 (13:25 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@551 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/pcd/action/CollectPCDAction.java
Tools/Source/GenBuild/org/tianocore/build/pcd/entity/UsageInstance.java

index d6b0c9c..1dbcb23 100644 (file)
@@ -1978,7 +1978,7 @@ public class CollectPCDAction {
                 strValueArray   = strValue.split(",");\r
                 for (index = 0; index < strValueArray.length; index ++) {\r
                     try{\r
-                        value = Integer.decode(strValueArray[index]);\r
+                        value = Integer.decode(strValueArray[index].trim());\r
                     } catch (NumberFormatException nfeEx) {\r
                         exceptionString = String.format("[FPD file error] The datum type of PCD %s in %s is VOID*, and "+\r
                                                          "it is byte array in fact. For every byte in array should be a valid"+\r
index 40dd3b9..9005a98 100644 (file)
@@ -203,6 +203,7 @@ public class UsageInstance {
     throws EntityException {\r
         String guidStringArray[] = null;\r
         String guidString        = null;\r
+        boolean isByteArray      = false;\r
 \r
         hAutogenStr = "";\r
         cAutogenStr = "";\r
@@ -217,6 +218,12 @@ public class UsageInstance {
                                          parentToken.cName, parentToken.tokenNumber);\r
         }\r
 \r
+        if (!isBuildUsedLibrary && !parentToken.isDynamicPCD) {\r
+            if (datum.trim().charAt(0) == '{') {\r
+                isByteArray = true;\r
+            }\r
+        }\r
+\r
         switch (modulePcdType) {\r
         case FEATURE_FLAG:\r
             if (isBuildUsedLibrary) {\r
@@ -254,17 +261,29 @@ public class UsageInstance {
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
                                              parentToken.cName, \r
                                              datum.toString());\r
-                hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
-                                             Token.getAutogendatumTypeString(parentToken.datumType),\r
-                                             parentToken.cName);\r
-                cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
-                                             Token.getAutogendatumTypeString(parentToken.datumType),\r
-                                             parentToken.cName,\r
-                                             parentToken.cName);\r
-                hAutogenStr += String.format("#define _PCD_MODE_%s_%s  _PCD_VALUE_%s\r\n",\r
-                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
-                                             parentToken.cName,\r
-                                             parentToken.cName);\r
+                if (isByteArray) {\r
+                    cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gPcd_FixedAtBuild_%s[] = _PCD_VALUE_%s;\r\n",\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("extern const UINT8 _gPcd_FixedAtBuild_%s[];\r\n",\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("#define _PCD_MODE_%s_%s  &_gPcd_FixedAtBuild_%s\r\n",\r
+                                                 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);\r
+                } else {\r
+                    cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED const %s _gPcd_FixedAtBuild_%s = _PCD_VALUE_%s;\r\n",\r
+                                                 Token.getAutogendatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("extern const %s _gPcd_FixedAtBuild_%s;\r\n",\r
+                                                 Token.getAutogendatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("#define _PCD_MODE_%s_%s  _PCD_VALUE_%s\r\n",\r
+                                                 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);\r
+                }\r
             }\r
             break;\r
         case PATCHABLE_IN_MODULE:\r
@@ -280,17 +299,29 @@ public class UsageInstance {
                 hAutogenStr += String.format("#define _PCD_VALUE_%s   %s\r\n", \r
                                              parentToken.cName, \r
                                              datum.toString());\r
-                hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
-                                             Token.getAutogendatumTypeString(parentToken.datumType),\r
-                                             parentToken.cName);\r
-                cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r
-                                             Token.getAutogendatumTypeString(parentToken.datumType),\r
-                                             parentToken.cName,\r
-                                             parentToken.cName);\r
-                hAutogenStr += String.format("#define _PCD_MODE_%s_%s  _gPcd_BinaryPatch_%s\r\n",\r
-                                             Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
-                                             parentToken.cName,\r
-                                             parentToken.cName);\r
+                if (isByteArray) {\r
+                    cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED UINT8 _gPcd_BinaryPatch_%s[] = _PCD_VALUE_%s;\r\n",\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("extern UINT8 _gPcd_BinaryPatch_%s[];\r\n",\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("#define _PCD_MODE_%s_%s  &_gPcd_BinaryPatch_%s\r\n",\r
+                                                 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);  \r
+                } else {\r
+                    cAutogenStr += String.format("GLOBAL_REMOVE_IF_UNREFERENCED %s _gPcd_BinaryPatch_%s = _PCD_VALUE_%s;\r\n",\r
+                                                 Token.getAutogendatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("extern %s _gPcd_BinaryPatch_%s;\r\n",\r
+                                                 Token.getAutogendatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName);\r
+                    hAutogenStr += String.format("#define _PCD_MODE_%s_%s  _gPcd_BinaryPatch_%s\r\n",\r
+                                                 Token.GetAutogenDefinedatumTypeString(parentToken.datumType),\r
+                                                 parentToken.cName,\r
+                                                 parentToken.cName);                \r
+                }\r
             }\r
 \r
             break;\r