]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/pcd/action/PCDAutoGenAction.java
Adding new Logger instead of Ant's.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / pcd / action / PCDAutoGenAction.java
index f3213c807927cb088d13719ae7d65c5f9dc77a7e..312e5e21369ee48405f8caf0d2498642a0897fb4 100644 (file)
@@ -21,6 +21,7 @@ import java.util.List;
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
 \r
+import org.tianocore.build.FrameworkBuildTask;\r
 import org.tianocore.build.autogen.CommonDefinition;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.id.ModuleIdentification;\r
@@ -72,6 +73,7 @@ public class PCDAutoGenAction extends BuildAction {
     ///\r
     private String[]              pcdNameArrayInMsa;\r
 \r
+    private UsageIdentification parentId = null;\r
     /**\r
       Set parameter moduleId\r
 \r
@@ -142,7 +144,8 @@ public class PCDAutoGenAction extends BuildAction {
                             String               arch,\r
                             boolean              isBuildUsedLibrary,\r
                             String[]             pcdNameArrayInMsa,\r
-                            CommonDefinition.PCD_DRIVER_TYPE pcdDriverType) {\r
+                            CommonDefinition.PCD_DRIVER_TYPE pcdDriverType,\r
+                            ModuleIdentification parentId) {\r
         dbManager       = null;\r
         hAutoGenString  = "";\r
         cAutoGenString  = "";\r
@@ -154,6 +157,15 @@ public class PCDAutoGenAction extends BuildAction {
                                            arch,\r
                                            moduleId.getVersion(),\r
                                            moduleId.getModuleType()));\r
+        if (parentId != null) {\r
+            this.parentId = new UsageIdentification(parentId.getName(),\r
+                        parentId.getGuid(),\r
+                        parentId.getPackage().getName(),\r
+                        parentId.getPackage().getGuid(),\r
+                        arch,\r
+                        parentId.getVersion(),\r
+                        parentId.getModuleType());\r
+        }\r
         setIsBuildUsedLibrary(isBuildUsedLibrary);\r
         setPcdNameArrayInMsa(pcdNameArrayInMsa);\r
         setPcdDriverType(pcdDriverType);\r
@@ -211,53 +223,100 @@ public class PCDAutoGenAction extends BuildAction {
         boolean               found           = false;\r
 \r
         usageInstanceArray = null;\r
-        if (!isBuildUsedLibrary) {\r
-            usageInstanceArray  = dbManager.getUsageInstanceArrayById(usageId);\r
-            MemoryDatabaseManager.UsageInstanceContext = usageInstanceArray;\r
-            MemoryDatabaseManager.CurrentModuleName    = moduleName;\r
-        } else if ((pcdNameArrayInMsa != null) && (pcdNameArrayInMsa.length > 0)) {\r
-            usageContext = MemoryDatabaseManager.UsageInstanceContext;\r
-            //\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
+        \r
+        if (FrameworkBuildTask.multithread) {\r
+            if (parentId == null) {\r
                 usageInstanceArray  = dbManager.getUsageInstanceArrayById(usageId);\r
-            } else {\r
-                usageInstanceArray = new ArrayList<UsageInstance>();\r
-\r
+            } else if ((pcdNameArrayInMsa != null) && (pcdNameArrayInMsa.length > 0)) {\r
+                usageContext = dbManager.getUsageInstanceArrayById(parentId);\r
                 //\r
-                // Try to find all PCD defined in library's PCD in all <PcdEntry> in module's\r
-                // <ModuleSA> in FPD file.\r
+                // For building library package, although all module are library, but PCD entries of\r
+                // these library should be used to autogen.\r
                 //\r
-                for (index = 0; index < pcdNameArrayInMsa.length; index++) {\r
-                    found = false;\r
-                    for (index2 = 0; index2 < usageContext.size(); index2 ++) {\r
-                        if (pcdNameArrayInMsa[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {\r
-                            usageInstanceArray.add(usageContext.get(index2));\r
-                            found = true;\r
-                            break;\r
+                if (usageContext == null) {\r
+                    usageInstanceArray  = dbManager.getUsageInstanceArrayById(usageId);\r
+                } else {\r
+                    usageInstanceArray = new ArrayList<UsageInstance>();\r
+\r
+                    //\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 < pcdNameArrayInMsa.length; index++) {\r
+                        found = false;\r
+                        for (index2 = 0; index2 < usageContext.size(); index2 ++) {\r
+                            if (pcdNameArrayInMsa[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {\r
+                                usageInstanceArray.add(usageContext.get(index2));\r
+                                found = true;\r
+                                break;\r
+                            }\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("Module %s using library instance %s; the PCD %s " +\r
-                                                                      "is required by this library instance, but can not be found " +\r
-                                                                      "in the %s's <ModuleSA> in the FPD file!",\r
-                                                                      MemoryDatabaseManager.CurrentModuleName,\r
-                                                                      moduleName,\r
-                                                                      pcdNameArrayInMsa[index],\r
-                                                                      MemoryDatabaseManager.CurrentModuleName\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("Module %s using library instance %s; the PCD %s " +\r
+                                                                          "is required by this library instance, but can not be found " +\r
+                                                                          "in the %s's <ModuleSA> in the FPD file!",\r
+                                                                          MemoryDatabaseManager.CurrentModuleName,\r
+                                                                          moduleName,\r
+                                                                          pcdNameArrayInMsa[index],\r
+                                                                          MemoryDatabaseManager.CurrentModuleName\r
+                                                                          ));\r
+                        }\r
+                    }\r
+                }\r
+            }\r
+        } else {\r
+            if (!isBuildUsedLibrary) {\r
+                usageInstanceArray  = dbManager.getUsageInstanceArrayById(usageId);\r
+                MemoryDatabaseManager.UsageInstanceContext = usageInstanceArray;\r
+                MemoryDatabaseManager.CurrentModuleName    = moduleName;\r
+            } else if ((pcdNameArrayInMsa != null) && (pcdNameArrayInMsa.length > 0)) {\r
+                usageContext = MemoryDatabaseManager.UsageInstanceContext;\r
+                //\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
+                    usageInstanceArray  = dbManager.getUsageInstanceArrayById(usageId);\r
+                } else {\r
+                    usageInstanceArray = new ArrayList<UsageInstance>();\r
+    \r
+                    //\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 < pcdNameArrayInMsa.length; index++) {\r
+                        found = false;\r
+                        for (index2 = 0; index2 < usageContext.size(); index2 ++) {\r
+                            if (pcdNameArrayInMsa[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("Module %s using library instance %s; the PCD %s " +\r
+                                                                          "is required by this library instance, but can not be found " +\r
+                                                                          "in the %s's <ModuleSA> in the FPD file!",\r
+                                                                          MemoryDatabaseManager.CurrentModuleName,\r
+                                                                          moduleName,\r
+                                                                          pcdNameArrayInMsa[index],\r
+                                                                          MemoryDatabaseManager.CurrentModuleName\r
+                                                                          ));\r
+                        }\r
                     }\r
                 }\r
             }\r
         }\r
-\r
         if (usageInstanceArray == null) {\r
             return;\r
         }\r