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
///\r
private String[] pcdNameArrayInMsa;\r
\r
+ private UsageIdentification parentId = null;\r
/**\r
Set parameter moduleId\r
\r
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
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
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