Fixed EDKT493. Added support to "SupModuleList" for checking if a library instance is supporting current module.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2282 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jwang36 2007-01-23 08:51:06 +00:00
parent 2b34c3fe63
commit 700279a971
4 changed files with 146 additions and 135 deletions

View File

@ -26,14 +26,11 @@ import java.util.Vector;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener; import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Location;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Ant; import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property; import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject; import org.apache.xmlbeans.XmlObject;
import org.tianocore.common.definitions.ToolDefinitions;
import org.tianocore.common.exception.EdkException;
import org.tianocore.common.logger.EdkLog;
import org.tianocore.build.autogen.AutoGen; import org.tianocore.build.autogen.AutoGen;
import org.tianocore.build.exception.AutoGenException; import org.tianocore.build.exception.AutoGenException;
import org.tianocore.build.exception.GenBuildException; import org.tianocore.build.exception.GenBuildException;
@ -48,6 +45,9 @@ import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification; import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification; import org.tianocore.build.id.PlatformIdentification;
import org.tianocore.build.tools.ModuleItem; import org.tianocore.build.tools.ModuleItem;
import org.tianocore.common.definitions.ToolDefinitions;
import org.tianocore.common.exception.EdkException;
import org.tianocore.common.logger.EdkLog;
/** /**
<p> <p>
@ -151,6 +151,10 @@ public class GenBuildTask extends Ant {
BuildException buildException = new BuildException(e.getMessage()); BuildException buildException = new BuildException(e.getMessage());
buildException.setStackTrace(e.getStackTrace()); buildException.setStackTrace(e.getStackTrace());
throw buildException; throw buildException;
} catch (Exception e) {
BuildException buildException = new BuildException(e.getMessage());
buildException.setStackTrace(e.getStackTrace());
throw buildException;
} }
} }
@ -197,7 +201,7 @@ public class GenBuildTask extends Ant {
moduleId.setMsaFile(msaFile); moduleId.setMsaFile(msaFile);
} }
String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED",null); String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED", null, null);
if (producedLibraryClasses.length == 0) { if (producedLibraryClasses.length == 0) {
moduleId.setLibrary(false); moduleId.setLibrary(false);
} else { } else {

View File

@ -347,8 +347,8 @@ public class AutoGen {
// //
// Write library class's related *.h file to autogen.h. // Write library class's related *.h file to autogen.h.
// //
String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED,this.arch); String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);
if (libClassList != null) { if (libClassList.length > 0) {
libClassIncludeH = LibraryClassToAutogenH(libClassList); libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator(); item = libClassIncludeH.iterator();
while (item.hasNext()) { while (item.hasNext()) {
@ -356,8 +356,8 @@ public class AutoGen {
} }
} }
libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);
if (libClassList != null) { if (libClassList.length > 0) {
libClassIncludeH = LibraryClassToAutogenH(libClassList); libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator(); item = libClassIncludeH.iterator();
while (item.hasNext()) { while (item.hasNext()) {
@ -584,7 +584,7 @@ public class AutoGen {
// //
// Write library class's related *.h file to autogen.h // Write library class's related *.h file to autogen.h
// //
String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch); String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);
if (libClassList != null) { if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList); libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator(); item = libClassIncludeH.iterator();
@ -593,7 +593,7 @@ public class AutoGen {
} }
} }
libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch); libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);
if (libClassList != null) { if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList); libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator(); item = libClassIncludeH.iterator();
@ -1354,12 +1354,11 @@ public class AutoGen {
// //
// Add library constructor to AutoGen.c // Add library constructor to AutoGen.c
// //
LibConstructorToAutogenC(libConstructList, moduleType, LibConstructorToAutogenC(libConstructList, moduleType, fileBuffer);
fileBuffer/* autogenC */);
// //
// Add library destructor to AutoGen.c // Add library destructor to AutoGen.c
// //
LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */); LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer);
} }
/** /**
@ -2106,6 +2105,7 @@ public class AutoGen {
private void collectLibInstanceInfo() throws EdkException{ private void collectLibInstanceInfo() throws EdkException{
int index; int index;
String moduleType = moduleId.getModuleType();
String libConstructName = null; String libConstructName = null;
String libDestructName = null; String libDestructName = null;
String libModuleType = null; String libModuleType = null;
@ -2113,112 +2113,118 @@ public class AutoGen {
String[] exitBoots = null; String[] exitBoots = null;
ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch); ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);
if (libraryIdList.length <= 0) {
if (libraryIdList != null) { return;
}
//
// Reorder library instance sequence.
//
AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, this.arch);
List<ModuleIdentification> orderList = libOrder.orderLibInstance();
//
// Process library instance one by one.
//
for (int i = 0; i < orderList.size(); i++) {
// //
// Reorder library instance sequence. // Get library instance basename.
// //
AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, ModuleIdentification libInstanceId = orderList.get(i);
this.arch);
List<ModuleIdentification> orderList = libOrder
.orderLibInstance();
if (orderList != null) { //
// // Get override map
// Process library instance one by one. //
//
for (int i = 0; i < orderList.size(); i++) {
//
// Get library instance basename.
//
ModuleIdentification libInstanceId = orderList.get(i);
// Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);
// Get override map saq.push(libDoc);
// //
// check if the library instance support current module
//
String[] libraryClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED,
this.arch,
moduleType
);
if (libraryClassList.length <= 0) {
throw new EdkException("Library instance " + libInstanceId.getName()
+ " doesn't support module type " + moduleType);
}
//
// Get <PPis>, <Protocols>, <Guids> list of this library
// instance.
//
String[] ppiList = saq.getPpiArray(this.arch);
String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);
String[] protocolList = saq.getProtocolArray(this.arch);
String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);
String[] guidList = saq.getGuidEntryArray(this.arch);
PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);
Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch); //
saq.push(libDoc); // Add those ppi, protocol, guid in global ppi,
// // protocol, guid
// Get <PPis>, <Protocols>, <Guids> list of this library // list.
// instance. //
// for (index = 0; index < ppiList.length; index++) {
String[] ppiList = saq.getPpiArray(this.arch); this.mPpiList.add(ppiList[index]);
String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch); }
String[] protocolList = saq.getProtocolArray(this.arch);
String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);
String[] guidList = saq.getGuidEntryArray(this.arch);
PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);
// for (index = 0; index < ppiNotifyList.length; index++) {
// Add those ppi, protocol, guid in global ppi, this.mPpiList.add(ppiNotifyList[index]);
// protocol, guid }
// list.
//
for (index = 0; index < ppiList.length; index++) {
this.mPpiList.add(ppiList[index]);
}
for (index = 0; index < ppiNotifyList.length; index++) { for (index = 0; index < protocolList.length; index++) {
this.mPpiList.add(ppiNotifyList[index]); this.mProtocolList.add(protocolList[index]);
} }
for (index = 0; index < protocolList.length; index++) { for (index = 0; index < protocolNotifyList.length; index++) {
this.mProtocolList.add(protocolList[index]); this.mProtocolList.add(protocolNotifyList[index]);
} }
for (index = 0; index < protocolNotifyList.length; index++) { for (index = 0; index < guidList.length; index++) {
this.mProtocolList.add(protocolNotifyList[index]); this.mGuidList.add(guidList[index]);
} }
for (index = 0; index < pkgList.length; index++) {
for (index = 0; index < guidList.length; index++) { if (!this.mDepPkgList.contains(pkgList[index])) {
this.mGuidList.add(guidList[index]); this.mDepPkgList.add(pkgList[index]);
}
for (index = 0; index < pkgList.length; index++) {
if (!this.mDepPkgList.contains(pkgList[index])) {
this.mDepPkgList.add(pkgList[index]);
}
}
//
// If not yet parse this library instance's constructor
// element,parse it.
//
libConstructName = saq.getLibConstructorName();
libDestructName = saq.getLibDestructorName();
libModuleType = saq.getModuleType();
//
// Collect SetVirtualAddressMapCallBack and
// ExitBootServiceCallBack.
//
setVirtuals = saq.getSetVirtualAddressMapCallBackArray();
exitBoots = saq.getExitBootServicesCallBackArray();
if (setVirtuals != null) {
for (int j = 0; j < setVirtuals.length; j++) {
this.setVirtalAddList.add(setVirtuals[j]);
}
}
if (exitBoots != null) {
for (int k = 0; k < exitBoots.length; k++) {
this.exitBootServiceList.add(exitBoots[k]);
}
}
saq.pop();
//
// Add dependent library instance constructor function.
//
if (libConstructName != null) {
this.libConstructList.add(new String[] {libConstructName, libModuleType});
}
//
// Add dependent library instance destructor fuction.
//
if (libDestructName != null) {
this.libDestructList.add(new String[] {libDestructName, libModuleType});
}
} }
} }
//
// If not yet parse this library instance's constructor
// element,parse it.
//
libConstructName = saq.getLibConstructorName();
libDestructName = saq.getLibDestructorName();
libModuleType = saq.getModuleType();
//
// Collect SetVirtualAddressMapCallBack and
// ExitBootServiceCallBack.
//
setVirtuals = saq.getSetVirtualAddressMapCallBackArray();
exitBoots = saq.getExitBootServicesCallBackArray();
if (setVirtuals != null) {
for (int j = 0; j < setVirtuals.length; j++) {
this.setVirtalAddList.add(setVirtuals[j]);
}
}
if (exitBoots != null) {
for (int k = 0; k < exitBoots.length; k++) {
this.exitBootServiceList.add(exitBoots[k]);
}
}
saq.pop();
//
// Add dependent library instance constructor function.
//
if (libConstructName != null) {
this.libConstructList.add(new String[] {libConstructName, libModuleType});
}
//
// Add dependent library instance destructor fuction.
//
if (libDestructName != null) {
this.libDestructList.add(new String[] {libDestructName, libModuleType});
}
} }
} }

View File

@ -90,8 +90,8 @@ public class AutogenLibOrder {
// //
// Create library class consume database. // Create library class consume database.
// //
libClassConsmList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, arch); libClassConsmList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, arch, null);
if (libClassConsmList != null) { if (libClassConsmList.length > 0) {
if (this.libInstanceConsumes.containsKey(libInstance)) { if (this.libInstanceConsumes.containsKey(libInstance)) {
throw new AutoGenException( throw new AutoGenException(
libraryList[i].getName() libraryList[i].getName()
@ -104,8 +104,8 @@ public class AutogenLibOrder {
// //
// Create library class implementer database // Create library class implementer database
// //
libClassDeclList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, arch); libClassDeclList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, arch, null);
if (libClassDeclList != null) { if (libClassDeclList.length > 0) {
this.libInstanceProduces.put(libInstance, libClassDeclList); this.libInstanceProduces.put(libInstance, libClassDeclList);
for (int j = 0; j < libClassDeclList.length; j++) { for (int j = 0; j < libClassDeclList.length; j++) {
if (this.libClassProducer.containsKey(libClassDeclList[j])) { if (this.libClassProducer.containsKey(libClassDeclList[j])) {
@ -132,6 +132,9 @@ public class AutogenLibOrder {
for (int k = 0; k < libraryList.length; ++k) { for (int k = 0; k < libraryList.length; ++k) {
ModuleIdentification consumer = libraryList[k]; ModuleIdentification consumer = libraryList[k];
String[] consumedClassList = libInstanceConsumes.get(consumer); String[] consumedClassList = libInstanceConsumes.get(consumer);
if (consumedClassList == null) {
continue;
}
for (int l = 0; l < consumedClassList.length; ++l) { for (int l = 0; l < consumedClassList.length; ++l) {
if (consumedClassList[l].equals(className)) { if (consumedClassList[l].equals(className)) {
@ -168,6 +171,9 @@ public class AutogenLibOrder {
orderList.addFirst(n); orderList.addFirst(n);
String[] consumedClassList = libInstanceConsumes.get(n); String[] consumedClassList = libInstanceConsumes.get(n);
if (consumedClassList == null) {
continue;
}
for (int i = 0; i < consumedClassList.length; ++i) { for (int i = 0; i < consumedClassList.length; ++i) {
ModuleIdentification m = libClassProducer.get(consumedClassList[i]); ModuleIdentification m = libClassProducer.get(consumedClassList[i]);
if (m == null) { if (m == null) {
@ -231,27 +237,26 @@ public class AutogenLibOrder {
// //
// Append the remaining library instance to the end of sorted list // Append the remaining library instance to the end of sorted list
// //
boolean HasError = false; boolean HasError = false;
for (int i = 0; i < libInstanceList.length; ++i) { for (int i = 0; i < libInstanceList.length; ++i) {
HashSet<ModuleIdentification> consumedBy = libInstanceConsumedBy.get(libInstanceList[i]); HashSet<ModuleIdentification> consumedBy = libInstanceConsumedBy.get(libInstanceList[i]);
if (consumedBy.size() > 0 && libInstanceList[i].hasConstructor()) { if (consumedBy.size() > 0 && libInstanceList[i].hasConstructor()) {
EdkLog.log(EdkLog.EDK_ERROR, libInstanceList[i].getName() EdkLog.log(EdkLog.EDK_ERROR, libInstanceList[i].getName()
+ " with constructor has a circular dependency!"); + " with constructor has a circular dependency!");
ModuleIdentification[] consumedByList = consumedBy.toArray(new ModuleIdentification[consumedBy.size()]); ModuleIdentification[] consumedByList = consumedBy.toArray(new ModuleIdentification[consumedBy.size()]);
for (int j = 0; j < consumedByList.length; ++j) { for (int j = 0; j < consumedByList.length; ++j) {
EdkLog.log(EdkLog.EDK_ERROR, EdkLog.log(EdkLog.EDK_ERROR, " consumed by " + consumedByList[j].getName());
" consumed by " + consumedByList[j].getName()); }
} HasError = true;
HasError = true;
} }
if (!orderList.contains(libInstanceList[i])) { if (!orderList.contains(libInstanceList[i])) {
orderList.add(libInstanceList[i]); orderList.add(libInstanceList[i]);
} }
} }
if (HasError) { if (HasError) {
throw new AutoGenException("Circular dependency in library instances is found!"); throw new AutoGenException("Circular dependency in library instances is found!");
} }
return orderList; return orderList;
} }

View File

@ -38,6 +38,7 @@ import org.tianocore.build.id.PackageIdentification;
import org.tianocore.build.id.PlatformIdentification; import org.tianocore.build.id.PlatformIdentification;
import org.tianocore.build.toolchain.ToolChainInfo; import org.tianocore.build.toolchain.ToolChainInfo;
import org.tianocore.common.exception.EdkException; import org.tianocore.common.exception.EdkException;
import org.tianocore.common.definitions.EdkDefinitions;
import org.w3c.dom.Node; import org.w3c.dom.Node;
/** /**
@ -593,7 +594,7 @@ public class SurfaceAreaQuery {
* xpath * xpath
* @returns null if nothing is there * @returns null if nothing is there
*/ */
public String[] getLibraryClasses(String usage, String arch) { public String[] getLibraryClasses(String usage, String arch, String moduleType) {
String[] xPath; String[] xPath;
if (usage == null || usage.equals("")) { if (usage == null || usage.equals("")) {
xPath = new String[] { "/LibraryClass" }; xPath = new String[] { "/LibraryClass" };
@ -610,8 +611,10 @@ public class SurfaceAreaQuery {
List<String> libraryClassName = new ArrayList<String>(); List<String> libraryClassName = new ArrayList<String>();
for (int i = 0; i < libraryClassList.length; i++) { for (int i = 0; i < libraryClassList.length; i++) {
List archList = libraryClassList[i].getSupArchList(); List archList = libraryClassList[i].getSupArchList();
List moduleTypeList = libraryClassList[i].getSupModuleList();
if (arch == null || contains(archList, arch)) { if ((arch == null || contains(archList, arch))
&& (moduleType == null || contains(moduleTypeList, moduleType)
|| contains(moduleTypeList, EdkDefinitions.MODULE_TYPE_BASE))) {
libraryClassName.add(libraryClassList[i].getKeyword()); libraryClassName.add(libraryClassList[i].getKeyword());
} }
} }
@ -2008,15 +2011,8 @@ public class SurfaceAreaQuery {
if (list == null || list.size()== 0) { if (list == null || list.size()== 0) {
return true; return true;
} }
Iterator it = list.iterator();
while (it.hasNext()) {
String s = (String)it.next();
if (s.equalsIgnoreCase(str)) {
return true;
}
}
return false; return list.contains(str);
} }
public boolean isHaveTianoR8FlashMap(){ public boolean isHaveTianoR8FlashMap(){