Fixed EDKT532 and EDKT533

- Support GUID CName in <Events>, <SystemTables>, <DataHubs>, <HiiPackages>, <Hobs> in msa file
- Support auto-insert related header file of DebugLib and UefiBootServicesTableLib according to module type


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@2440 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jwang36 2007-03-12 06:57:33 +00:00
parent d126eaecb0
commit 90a98f29c5
3 changed files with 331 additions and 204 deletions

View File

@ -82,22 +82,10 @@ public class AutoGen {
private CommonDefinition.PCD_DRIVER_TYPE pcdDriverType;
///
/// The protocl list which records in module or library surface area and
/// it's dependence on library instance surface area.
/// The Guid CName list which recoreded in module or library surface area
/// and it's dependence on library instance surface area.
///
private Set<String> mProtocolList = new HashSet<String>();
///
/// The Ppi list which recorded in module or library surface area and its
/// dependency on library instance surface area.
///
private Set<String> mPpiList = new HashSet<String>();
///
/// The Guid list which recoreded in module or library surface area and it's
/// dependence on library instance surface area.
///
private Set<String> mGuidList = new HashSet<String>();
private Set<String> mGuidCNameList = new HashSet<String>();
///
/// The dependence package list which recoreded in module or library surface
@ -348,23 +336,37 @@ public class AutoGen {
//
// Write library class's related *.h file to autogen.h.
//
List<String> libClasses = new ArrayList<String>(100);
String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);
if (libClassList.length > 0) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator();
while (item.hasNext()) {
fileBuffer.append(item.next().toString());
}
for (int i = 0; i < libClassList.length; ++i) {
libClasses.add(libClassList[i]);
}
libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);
if (libClassList.length > 0) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator();
while (item.hasNext()) {
fileBuffer.append(item.next().toString());
}
for (int i = 0; i < libClassList.length; ++i) {
libClasses.add(libClassList[i]);
}
//
// Add AutoGen used library class
//
int moduleTypeId = CommonDefinition.getModuleType(moduleType);
if (!libClasses.contains("DebugLib") && moduleTypeId != CommonDefinition.ModuleTypeUnknown
&& moduleTypeId != CommonDefinition.ModuleTypeBase) {
libClasses.add("DebugLib");
}
switch (moduleTypeId) {
case CommonDefinition.ModuleTypeDxeDriver:
case CommonDefinition.ModuleTypeDxeRuntimeDriver:
case CommonDefinition.ModuleTypeDxeSalDriver:
case CommonDefinition.ModuleTypeDxeSmmDriver:
case CommonDefinition.ModuleTypeUefiDriver:
case CommonDefinition.ModuleTypeUefiApplication:
if (!libClasses.contains("UefiBootServicesTableLib")) {
libClasses.add("UefiBootServicesTableLib");
}
break;
}
LibraryClassToAutogenH(fileBuffer, libClasses.toArray(new String[libClasses.size()]));
fileBuffer.append("\r\n");
//
@ -458,8 +460,10 @@ public class AutoGen {
//
String guid = CommonDefinition.formatGuidName(saq.getModuleGuid());
if (this.moduleId.getModuleType().equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_BASE)) {
globalDeclarations.append("extern GUID gEfiCallerIdGuid;\r\n");
fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED GUID gEfiCallerIdGuid = {");
} else {
} else if (!this.moduleId.getModuleType().equalsIgnoreCase(EdkDefinitions.MODULE_TYPE_USER_DEFINED)) {
globalDeclarations.append("extern EFI_GUID gEfiCallerIdGuid;\r\n");
fileBuffer.append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
}
@ -496,11 +500,9 @@ public class AutoGen {
}
//
// Write consumed ppi, guid, protocol to autogen.c
// Write consumed ppi, guid, protocol, etc to autogen.c
//
ProtocolGuidToAutogenC(fileBuffer);
PpiGuidToAutogenC(fileBuffer);
GuidGuidToAutogenC(fileBuffer);
CNameToAutogenC(fileBuffer);
//
// Call pcd autogen.
@ -586,23 +588,37 @@ public class AutoGen {
//
// Write library class's related *.h file to autogen.h
//
List<String> libClasses = new ArrayList<String>(100);
String[] libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSCONSUMED, this.arch, null);
if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator();
while (item.hasNext()) {
fileBuffer.append(item.next().toString());
}
for (int i = 0; i < libClassList.length; ++i) {
libClasses.add(libClassList[i]);
}
libClassList = saq.getLibraryClasses(CommonDefinition.ALWAYSPRODUCED, this.arch, null);
if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
item = libClassIncludeH.iterator();
while (item.hasNext()) {
fileBuffer.append(item.next().toString());
}
for (int i = 0; i < libClassList.length; ++i) {
libClasses.add(libClassList[i]);
}
//
// Add AutoGen used library class
//
int moduleTypeId = CommonDefinition.getModuleType(moduleType);
if (!libClasses.contains("DebugLib") && moduleTypeId != CommonDefinition.ModuleTypeUnknown
&& moduleTypeId != CommonDefinition.ModuleTypeBase) {
libClasses.add("DebugLib");
}
switch (moduleTypeId) {
case CommonDefinition.ModuleTypeDxeDriver:
case CommonDefinition.ModuleTypeDxeRuntimeDriver:
case CommonDefinition.ModuleTypeDxeSalDriver:
case CommonDefinition.ModuleTypeDxeSmmDriver:
case CommonDefinition.ModuleTypeUefiDriver:
case CommonDefinition.ModuleTypeUefiApplication:
if (!libClasses.contains("UefiBootServicesTableLib")) {
libClasses.add("UefiBootServicesTableLib");
}
break;
}
LibraryClassToAutogenH(fileBuffer, libClasses.toArray(new String[libClasses.size()]));
fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);
//
@ -688,9 +704,8 @@ public class AutoGen {
build module or library.
@return includeStrList List of *.h file.
**/
Set<String> LibraryClassToAutogenH(String[] libClassList)
void LibraryClassToAutogenH(StringBuffer fileBuffer, String[] libClassList)
throws EdkException {
Set<String> includeStrList = new LinkedHashSet<String>();
String includeName[];
String str = "";
@ -709,14 +724,14 @@ public class AutoGen {
for (int j = 0; j < includeName.length; j++) {
String includeNameStr = includeName[j];
if (includeNameStr != null) {
str = CommonDefinition.INCLUDE + " " + "<";
str = str + includeNameStr + ">\r\n";
includeStrList.add(str);
fileBuffer.append(CommonDefinition.INCLUDE);
fileBuffer.append(" <");
fileBuffer.append(includeNameStr);
fileBuffer.append(">\r\n");
includeNameStr = null;
}
}
}
return includeStrList;
}
/**
@ -1185,153 +1200,50 @@ public class AutoGen {
}
/**
PpiGuidToAutogenc
CNameToAutogenc
This function gets GUIDs from SPD file accrodeing to <PPIs> information
and write those GUIDs to AutoGen.c.
@param fileBuffer
String Buffer for Autogen.c file.
@throws BuildException
Guid must set value!
**/
void PpiGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
String[] cNameGuid = null;
//
// Get the all PPI adn PPI Notify from MSA file,
// then add those PPI ,and PPI Notify name to list.
//
String[] ppiList = saq.getPpiArray(this.arch);
for (int i = 0; i < ppiList.length; i++) {
this.mPpiList.add(ppiList[i]);
}
String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);
for (int i = 0; i < ppiNotifyList.length; i++) {
this.mPpiList.add(ppiNotifyList[i]);
}
//
// Find CNAME and GUID from dependence SPD file and write to Autogen.c
//
Iterator ppiIterator = this.mPpiList.iterator();
String ppiKeyWord = null;
while (ppiIterator.hasNext()) {
ppiKeyWord = ppiIterator.next().toString();
cNameGuid = GlobalData.getPpiGuid(this.mDepPkgList, ppiKeyWord);
if (cNameGuid != null) {
fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
fileBuffer.append(cNameGuid[0]);
fileBuffer.append(" = { ");
fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));
fileBuffer.append(" } ;");
} else {
//
// If can't find Ppi GUID declaration in every package
//
throw new AutoGenException("Can not find Ppi GUID ["
+ ppiKeyWord + "] declaration in any SPD package!");
}
}
}
/**
ProtocolGuidToAutogenc
This function gets GUIDs from SPD file accrodeing to <Protocol>
information and write those GUIDs to AutoGen.c.
@param fileBuffer
String Buffer for Autogen.c file.
@throws BuildException
Protocol name must set.
**/
void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws EdkException {
String[] cNameGuid = null;
String[] protocolList = saq.getProtocolArray(this.arch);
//
// Add result to Autogen global list.
//
for (int i = 0; i < protocolList.length; i++) {
this.mProtocolList.add(protocolList[i]);
}
String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);
for (int i = 0; i < protocolNotifyList.length; i++) {
this.mProtocolList.add(protocolNotifyList[i]);
}
//
// Get the NAME and GUID from dependence SPD and write to Autogen.c
//
Iterator protocolIterator = this.mProtocolList.iterator();
String protocolKeyWord = null;
while (protocolIterator.hasNext()) {
protocolKeyWord = protocolIterator.next().toString();
cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, protocolKeyWord);
if (cNameGuid != null) {
fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
fileBuffer.append(cNameGuid[0]);
fileBuffer.append(" = { ");
fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));
fileBuffer.append(" } ;");
} else {
//
// If can't find protocol GUID declaration in every package
//
throw new AutoGenException("Can not find protocol Guid ["
+ protocolKeyWord + "] declaration in any SPD package!");
}
}
}
/**
GuidGuidToAutogenc
This function gets GUIDs from SPD file accrodeing to <Guids> information
and write those GUIDs to AutoGen.c.
This function gets GUIDs from SPD file accrodeing to <Protocols> <Ppis>
<Guids> information and write those GUIDs to AutoGen.c.
@param fileBuffer
String Buffer for Autogen.c file.
**/
void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
void CNameToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
String[] cNameGuid = null;
String guidKeyWord = null;
String[] guidList = saq.getGuidEntryArray(this.arch);
for (int i = 0; i < guidList.length; i++) {
this.mGuidList.add(guidList[i]);
String[] cnameList = saq.getCNameArray(this.arch);
for (int i = 0; i < cnameList.length; i++) {
this.mGuidCNameList.add(cnameList[i]);
}
Iterator guidIterator = this.mGuidList.iterator();
Iterator guidIterator = this.mGuidCNameList.iterator();
while (guidIterator.hasNext()) {
guidKeyWord = guidIterator.next().toString();
cNameGuid = GlobalData.getGuid(this.mDepPkgList, guidKeyWord);
if (cNameGuid != null) {
fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
fileBuffer.append(cNameGuid[0]);
fileBuffer.append(" = { ");
fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));
fileBuffer.append("} ;");
} else {
//
// If can't find GUID declaration in every package
//
throw new AutoGenException("Can not find Guid [" + guidKeyWord
+ "] declaration in any SPD package. ");
if (cNameGuid == null) {
cNameGuid = GlobalData.getProtocolGuid(this.mDepPkgList, guidKeyWord);
if (cNameGuid == null) {
cNameGuid = GlobalData.getPpiGuid(this.mDepPkgList, guidKeyWord);
if (cNameGuid == null) {
//
// If can't find GUID declaration in every package, stop the build
//
EdkLog.log(EdkLog.EDK_INFO,"WARN: Can not find Guid [" + guidKeyWord + "] declaration in any SPD file.");
continue;
//throw new AutoGenException("Can not find Guid [" + guidKeyWord
// + "] declaration in any SPD package. ");
}
}
}
fileBuffer.append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
fileBuffer.append(cNameGuid[0]);
fileBuffer.append(" = { ");
fileBuffer.append(CommonDefinition.formatGuidName(cNameGuid[1]));
fileBuffer.append("} ;");
}
}
@ -2144,14 +2056,10 @@ public class AutoGen {
+ " doesn't support module type " + moduleType);
}
//
// Get <PPis>, <Protocols>, <Guids> list of this library
// Get CName list from <PPis>, <Protocols>, <Guids>, etc. 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);
String[] guidCNameList = saq.getCNameArray(this.arch);
PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);
//
@ -2159,25 +2067,10 @@ public class AutoGen {
// protocol, guid
// list.
//
for (index = 0; index < ppiList.length; index++) {
this.mPpiList.add(ppiList[index]);
for (index = 0; index < guidCNameList.length; index++) {
this.mGuidCNameList.add(guidCNameList[index]);
}
for (index = 0; index < ppiNotifyList.length; index++) {
this.mPpiList.add(ppiNotifyList[index]);
}
for (index = 0; index < protocolList.length; index++) {
this.mProtocolList.add(protocolList[index]);
}
for (index = 0; index < protocolNotifyList.length; index++) {
this.mProtocolList.add(protocolNotifyList[index]);
}
for (index = 0; index < guidList.length; index++) {
this.mGuidList.add(guidList[index]);
}
for (index = 0; index < pkgList.length; index++) {
if (!this.mDepPkgList.contains(pkgList[index])) {
this.mDepPkgList.add(pkgList[index]);

View File

@ -434,6 +434,12 @@ public class GlobalData {
msaMap.put("Protocols", cloneXmlObject(msa.getProtocols(), true));
msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true));
msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));
msaMap.put("Events", cloneXmlObject(msa.getEvents(), true));
msaMap.put("Hobs", cloneXmlObject(msa.getHobs(), true));
msaMap.put("Variables", cloneXmlObject(msa.getVariables(), true));
msaMap.put("SystemTables", cloneXmlObject(msa.getSystemTables(), true));
msaMap.put("DataHubs", cloneXmlObject(msa.getDataHubs(), true));
msaMap.put("HiiPackages", cloneXmlObject(msa.getHiiPackages(), true));
msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));
msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));
msaMap.put("ModuleBuildOptions", cloneXmlObject(msa.getModuleBuildOptions(), true));

View File

@ -1088,7 +1088,7 @@ public class SurfaceAreaQuery {
usageXpath = "/GuidEntry[@Usage='" + arch + "']";
xPath = new String[] { archXpath, usageXpath };
} else {
return getProtocolNotifyArray(arch);
return getGuidEntryArray(arch);
}
}
@ -1105,6 +1105,234 @@ public class SurfaceAreaQuery {
return guidList;
}
public String[] getEventCNameArray(String arch) {
String[] xPath = null;
if (arch == null || arch.equals("")) {
xPath = new String[]{
"/CreateEvents/EventTypes[@EventGuidCName]",
"/SignalEvents/EventTypes[@EventGuidCName]",
};
} else {
xPath = new String[]{
"/CreateEvents/EventTypes[@EventGuidCName and not(@SupArchList)]",
"/SignalEvents/EventTypes[@EventGuidCName and not(@SupArchList)]",
"/CreateEvents/EventTypes[@EventGuidCName and contains(@SupArchList,'" + arch + "')]",
"/SignalEvents/EventTypes[@EventGuidCName and contains(@SupArchList,'" + arch + "')]",
};
}
Object[] returns = get("Events", xPath);
if (returns == null) {
return new String[0];
}
String[] cnameList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
if (returns[i] instanceof EventsDocument.Events.CreateEvents.EventTypes) {
cnameList[i] = ((EventsDocument.Events.CreateEvents.EventTypes) returns[i]).getEventGuidCName();
} else {
cnameList[i] = ((EventsDocument.Events.SignalEvents.EventTypes) returns[i]).getEventGuidCName();
}
}
return cnameList;
}
public String[] getHobCNameArray(String arch) {
String[] xPath = null;
if (arch == null || arch.equals("")) {
xPath = new String[]{"/HobTypes[@HobGuidCName]"};
} else {
xPath = new String[]{
"/HobTypes[@HobGuidCName and not(@SupArchList)]",
"/HobTypes[@HobGuidCName and contains(@SupArchList,'" + arch + "')]",
};
}
Object[] returns = get("Hobs", xPath);
if (returns == null) {
return new String[0];
}
String[] cnameList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
cnameList[i] = ((HobsDocument.Hobs.HobTypes) returns[i]).getHobGuidCName();
}
return cnameList;
}
public String[] getVariableCNameArray(String arch) {
String[] xPath = null;
if (arch == null || arch.equals("")) {
xPath = new String[]{"/Variable"};
} else {
xPath = new String[]{"/Variable[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"};
}
Object[] returns = get("Variables", xPath);
if (returns == null) {
return new String[0];
}
String[] cnameList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
cnameList[i] = ((VariablesDocument.Variables.Variable) returns[i]).getGuidCName();
}
return cnameList;
}
public String[] getSystemTableCNameArray(String arch) {
String[] xPath = null;
if (arch == null || arch.equals("")) {
xPath = new String[]{"/SystemTableCNames"};
} else {
xPath = new String[]{
"/SystemTableCNames[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"
};
}
Object[] returns = get("SystemTables", xPath);
if (returns == null) {
return new String[0];
}
String[] cnameList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
cnameList[i] = ((SystemTablesDocument.SystemTables.SystemTableCNames) returns[i]).getSystemTableCName();
}
return cnameList;
}
public String[] getDataHubCNameArray(String arch) {
String[] xPath = null;
if (arch == null || arch.equals("")) {
xPath = new String[]{"/DataHubRecord"};
} else {
xPath = new String[]{"/DataHubRecord[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"};
}
Object[] returns = get("DataHubs", xPath);
if (returns == null) {
return new String[0];
}
String[] cnameList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
cnameList[i] = ((DataHubsDocument.DataHubs.DataHubRecord) returns[i]).getDataHubCName();
}
return cnameList;
}
public String[] getHiiPackageCNameArray(String arch) {
String[] xPath = null;
if (arch == null || arch.equals("")) {
xPath = new String[]{"/HiiPackage"};
} else {
xPath = new String[]{"/HiiPackage[not(@SupArchList) or contains(@SupArchList,'" + arch + "')]"};
}
Object[] returns = get("HiiPackages", xPath);
if (returns == null) {
return new String[0];
}
String[] cnameList = new String[returns.length];
for (int i = 0; i < returns.length; i++) {
cnameList[i] = ((HiiPackagesDocument.HiiPackages.HiiPackage) returns[i]).getHiiCName();
}
return cnameList;
}
public String[] getCNameArray(String arch) {
List<String> cnameList = new ArrayList<String>(100);
String[] result = null;
//
// "/Guids/GuidCNames/GuidCName",
//
result = getGuidEntryArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/Protocols/Protocol/ProtocolCName",
//
result = getProtocolArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/Protocols/ProtocolNotify/ProtocolNotifyCName",
//
result = getProtocolNotifyArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/Events/CreateEvents/EventTypes[@EventGuidCName]",
// "/Events/SignalEvents/EventTypes[@EventGuidCName]",
//
result = getEventCNameArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/Hobs/HobTypes[@HobGuidCName]",
//
result = getHobCNameArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/PPIs/Ppi/PpiCName",
//
result = getPpiArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/PPIs/PpiNotify/PpiNotifyCName",
//
result = getPpiNotifyArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/Variables/Variable/GuidC_Name",
//
result = getVariableCNameArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/SystemTables/SystemTableCNames/SystemTableCName",
//
result = getSystemTableCNameArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/DataHubs/DataHubRecord/DataHubCName",
//
result = getDataHubCNameArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
//
// "/HiiPackages/HiiPackage/HiiCName",
//
result = getHiiPackageCNameArray(arch);
for (int i = 0; i < result.length; ++i) {
cnameList.add(result[i]);
}
return cnameList.toArray(new String[cnameList.size()]);
}
/**
* Retrieve Library instance information
*