There is a rule here:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Jul 2006 16:44:52 +0000 (16:44 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 28 Jul 2006 16:44:52 +0000 (16:44 +0000)
If a module link a library instance, all pcds defined by library instance should be instanted in module's <ModuleSA> in FPD file.

I add more checking code follows above rules.

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

Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java

index 7f955ff..ad4ebe7 100644 (file)
@@ -382,7 +382,9 @@ private UUID translateSchemaStringToUUID(String uuidString)
         String                guidStringCName = null;\r
         String                guidString      = null;\r
         UsageInstance         usageInstance   = null;\r
+        boolean               found           = false;\r
 \r
+        usageInstanceArray = null;\r
         if (!isBuildUsedLibrary) {\r
             usageInstanceArray  = dbManager.getUsageInstanceArrayByModuleName(moduleName,\r
                                                                               moduleGuid,\r
@@ -392,10 +394,10 @@ private UUID translateSchemaStringToUUID(String uuidString)
                                                                               version);\r
             dbManager.UsageInstanceContext = usageInstanceArray;\r
             dbManager.CurrentModuleName    = moduleName; \r
-        } else {\r
+        } else if ((pcdNameArray != null) && (pcdNameArray.length > 0)) {\r
             usageContext = dbManager.UsageInstanceContext;\r
             //\r
-            // For building MDE package, although all module are library, but PCD entries of \r
+            // For building library package, although all module are library, but PCD entries of \r
             // these library should be used to autogen.\r
             // \r
             if (usageContext == null) {\r
@@ -407,24 +409,43 @@ private UUID translateSchemaStringToUUID(String uuidString)
                                                                                   version);\r
             } else {\r
                 usageInstanceArray = new ArrayList<UsageInstance>();\r
+\r
                 //\r
-                // Remove PCD entries which are not belong to this library.\r
+                // Try to find all PCD defined in library's PCD in all <PcdEntry> in module's \r
+                // <ModuleSA> in FPD file.\r
                 // \r
-                for (index = 0; index < usageContext.size(); index++) {\r
-                    if ((pcdNameArray == null) || (pcdNameArray.length == 0)){\r
-                        break;\r
-                    }\r
-\r
-                    for (index2 = 0; index2 < pcdNameArray.length; index2 ++) {\r
-                        if (pcdNameArray[index2].equalsIgnoreCase(usageContext.get(index).parentToken.cName)) {\r
-                            usageInstanceArray.add(usageContext.get(index));\r
+                for (index = 0; index < pcdNameArray.length; index++) {\r
+                    found = false;\r
+                    for (index2 = 0; index2 < usageContext.size(); index2 ++) {\r
+                        if (pcdNameArray[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {\r
+                            usageInstanceArray.add(usageContext.get(index2));\r
+                            found = true;\r
                             break;\r
                         }\r
                     }\r
+\r
+                    if (!found) {\r
+                        //\r
+                        // 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
+                                                                      "is required by this library instance, but can not find " +\r
+                                                                      "it in the %s's <ModuleSA> in FPD file!",\r
+                                                                      dbManager.CurrentModuleName,\r
+                                                                      moduleName,\r
+                                                                      pcdNameArray[index],\r
+                                                                      dbManager.CurrentModuleName\r
+                                                                      ));\r
+                    }\r
                 }\r
             }\r
         }\r
 \r
+        if (usageInstanceArray == null) {\r
+            return;\r
+        }\r
+\r
         //\r
         // Generate all PCD entry for a module.\r
         // \r