mirror of https://github.com/acidanthera/audk.git
Unify the logger and exception in AutoGen.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1493 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
607ef9948b
commit
61528a1be3
|
@ -208,13 +208,18 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Failed to creat AutoGen.c & AutoGen.h.
|
||||
**/
|
||||
public void genAutogen() throws BuildException {
|
||||
public void genAutogen() throws EdkException {
|
||||
try {
|
||||
//
|
||||
// If outputPath do not exist, create it.
|
||||
//
|
||||
File path = new File(outputPath);
|
||||
path.mkdirs();
|
||||
} catch (Exception e) {
|
||||
throw new AutoGenException(
|
||||
"Failed to create "
|
||||
+ outputPath + " directory");
|
||||
}
|
||||
|
||||
//
|
||||
// Check current is library or not, then call the corresponding
|
||||
|
@ -225,12 +230,6 @@ public class AutoGen {
|
|||
} else {
|
||||
moduleGenAutogen();
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new BuildException(
|
||||
"Failed to create AutoGen.c & AutoGen.h!\n"
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -241,17 +240,10 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Faile to create module AutoGen.c & AutoGen.h.
|
||||
**/
|
||||
void moduleGenAutogen() throws BuildException {
|
||||
|
||||
try {
|
||||
void moduleGenAutogen() throws EdkException {
|
||||
collectLibInstanceInfo();
|
||||
moduleGenAutogenC();
|
||||
moduleGenAutogenH();
|
||||
} catch (Exception e) {
|
||||
throw new BuildException(
|
||||
"Faile to create module AutoGen.c & AutoGen.h!\n"
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -262,15 +254,9 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Faile to create library AutoGen.c & AutoGen.h
|
||||
**/
|
||||
void libGenAutogen() throws BuildException {
|
||||
try {
|
||||
void libGenAutogen() throws EdkException {
|
||||
libGenAutogenC();
|
||||
libGenAutogenH();
|
||||
} catch (Exception e) {
|
||||
throw new BuildException(
|
||||
"Failed to create library AutoGen.c & AutoGen.h!\n"
|
||||
+ e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,7 +267,7 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Failed to generate AutoGen.h.
|
||||
**/
|
||||
void moduleGenAutogenH() throws EdkException, AutoGenException {
|
||||
void moduleGenAutogenH() throws EdkException {
|
||||
|
||||
Set<String> libClassIncludeH;
|
||||
String moduleType;
|
||||
|
@ -395,7 +381,7 @@ public class AutoGen {
|
|||
// Save string buffer content in AutoGen.h.
|
||||
//
|
||||
if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
|
||||
throw new BuildException("Failed to generate AutoGen.h !!!");
|
||||
throw new AutoGenException("Failed to generate AutoGen.h !!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -407,7 +393,7 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Failed to generate AutoGen.c.
|
||||
**/
|
||||
void moduleGenAutogenC() throws EdkException, AutoGenException {
|
||||
void moduleGenAutogenC() throws EdkException {
|
||||
|
||||
StringBuffer fileBuffer = new StringBuffer(8192);
|
||||
//
|
||||
|
@ -511,19 +497,15 @@ public class AutoGen {
|
|||
false,
|
||||
null,
|
||||
pcdDriverType);
|
||||
try {
|
||||
this.myPcdAutogen.execute();
|
||||
} catch (Exception exp) {
|
||||
throw new PcdAutogenException (exp.getMessage());
|
||||
}
|
||||
|
||||
this.myPcdAutogen.execute();
|
||||
if (this.myPcdAutogen != null) {
|
||||
fileBuffer.append("\r\n");
|
||||
fileBuffer.append(this.myPcdAutogen.getCAutoGenString());
|
||||
}
|
||||
|
||||
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
|
||||
throw new BuildException("Failed to generate AutoGen.c !!!");
|
||||
throw new AutoGenException("Failed to generate AutoGen.c !!!");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -536,7 +518,7 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Failed to generate AutoGen.c.
|
||||
**/
|
||||
void libGenAutogenH() throws EdkException, AutoGenException {
|
||||
void libGenAutogenH() throws EdkException {
|
||||
|
||||
Set<String> libClassIncludeH;
|
||||
String moduleType;
|
||||
|
@ -641,7 +623,7 @@ public class AutoGen {
|
|||
// Save content of string buffer to AutoGen.h file.
|
||||
//
|
||||
if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {
|
||||
throw new BuildException("Failed to generate AutoGen.h !!!");
|
||||
throw new AutoGenException("Failed to generate AutoGen.h !!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -653,7 +635,7 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Failed to generate AutoGen.c.
|
||||
**/
|
||||
void libGenAutogenC() throws BuildException, PcdAutogenException {
|
||||
void libGenAutogenC() throws EdkException {
|
||||
StringBuffer fileBuffer = new StringBuffer(10240);
|
||||
|
||||
//
|
||||
|
@ -672,19 +654,14 @@ public class AutoGen {
|
|||
true,
|
||||
saq.getModulePcdEntryNameArray(),
|
||||
pcdDriverType);
|
||||
try {
|
||||
this.myPcdAutogen.execute();
|
||||
} catch (Exception e) {
|
||||
throw new PcdAutogenException(e.getMessage());
|
||||
}
|
||||
|
||||
if (this.myPcdAutogen != null) {
|
||||
fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);
|
||||
fileBuffer.append(this.myPcdAutogen.getCAutoGenString());
|
||||
}
|
||||
|
||||
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
|
||||
throw new BuildException("Failed to generate AutoGen.c !!!");
|
||||
throw new AutoGenException("Failed to generate AutoGen.c !!!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -700,7 +677,7 @@ public class AutoGen {
|
|||
@return includeStrList List of *.h file.
|
||||
**/
|
||||
Set<String> LibraryClassToAutogenH(String[] libClassList)
|
||||
throws EdkException, AutoGenException {
|
||||
throws EdkException {
|
||||
Set<String> includeStrList = new LinkedHashSet<String>();
|
||||
String includeName[];
|
||||
String str = "";
|
||||
|
@ -781,7 +758,7 @@ public class AutoGen {
|
|||
@throws Exception
|
||||
**/
|
||||
void EntryPointToAutoGen(String[] entryPointList, String[] unloadImageList, StringBuffer fileBuffer)
|
||||
throws BuildException {
|
||||
throws EdkException {
|
||||
|
||||
String typeStr = saq.getModuleType();
|
||||
int unloadImageCount = 0;
|
||||
|
@ -795,7 +772,7 @@ public class AutoGen {
|
|||
|
||||
case CommonDefinition.ModuleTypePeiCore:
|
||||
if (entryPointList == null ||entryPointList.length != 1 ) {
|
||||
throw new BuildException(
|
||||
throw new AutoGenException(
|
||||
"Module type = 'PEI_CORE', can have only one module entry point!");
|
||||
} else {
|
||||
fileBuffer.append("EFI_STATUS\r\n");
|
||||
|
@ -827,7 +804,7 @@ public class AutoGen {
|
|||
case CommonDefinition.ModuleTypeDxeCore:
|
||||
fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");
|
||||
if (entryPointList == null || entryPointList.length != 1) {
|
||||
throw new BuildException(
|
||||
throw new AutoGenException(
|
||||
"Module type = 'DXE_CORE', can have only one module entry point!");
|
||||
} else {
|
||||
|
||||
|
@ -1294,7 +1271,7 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
Protocol name must set.
|
||||
**/
|
||||
void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {
|
||||
void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws EdkException {
|
||||
String[] cNameGuid = null;
|
||||
|
||||
String[] protocolList = saq.getProtocolArray(this.arch);
|
||||
|
@ -1334,7 +1311,7 @@ public class AutoGen {
|
|||
//
|
||||
// If can't find protocol GUID declaration in every package
|
||||
//
|
||||
throw new BuildException("Can not find protocol Guid ["
|
||||
throw new AutoGenException("Can not find protocol Guid ["
|
||||
+ protocolKeyWord + "] declaration in any SPD package!");
|
||||
}
|
||||
}
|
||||
|
@ -1395,8 +1372,7 @@ public class AutoGen {
|
|||
String buffer for AutoGen.c
|
||||
@throws BuildException
|
||||
**/
|
||||
void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException {
|
||||
try {
|
||||
void LibInstanceToAutogenC(StringBuffer fileBuffer) throws EdkException {
|
||||
String moduleType = this.moduleId.getModuleType();
|
||||
//
|
||||
// Add library constructor to AutoGen.c
|
||||
|
@ -1407,9 +1383,6 @@ public class AutoGen {
|
|||
// Add library destructor to AutoGen.c
|
||||
//
|
||||
LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);
|
||||
} catch (Exception e) {
|
||||
throw new BuildException(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1427,7 +1400,7 @@ public class AutoGen {
|
|||
@throws Exception
|
||||
**/
|
||||
void LibConstructorToAutogenC(List<String> libInstanceList,
|
||||
String moduleType, StringBuffer fileBuffer) throws Exception {
|
||||
String moduleType, StringBuffer fileBuffer) throws EdkException {
|
||||
boolean isFirst = true;
|
||||
|
||||
//
|
||||
|
@ -1568,7 +1541,7 @@ public class AutoGen {
|
|||
@throws Exception
|
||||
**/
|
||||
void LibDestructorToAutogenC(List<String> libInstanceList,
|
||||
String moduleType, StringBuffer fileBuffer) throws Exception {
|
||||
String moduleType, StringBuffer fileBuffer) throws EdkException {
|
||||
boolean isFirst = true;
|
||||
for (int i = 0; i < libInstanceList.size(); i++) {
|
||||
switch (CommonDefinition.getModuleType(moduleType)) {
|
||||
|
@ -1663,7 +1636,7 @@ public class AutoGen {
|
|||
String buffer for AutoGen.c
|
||||
**/
|
||||
void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)
|
||||
throws BuildException {
|
||||
throws EdkException {
|
||||
|
||||
//
|
||||
// Check what <extern> contains. And the number of following elements
|
||||
|
@ -1702,7 +1675,7 @@ public class AutoGen {
|
|||
//
|
||||
if (compNamList != null && compNamList.length != 0) {
|
||||
if (drvBindList.length != compNamList.length) {
|
||||
throw new BuildException(
|
||||
throw new AutoGenException(
|
||||
"Different number of Driver Binding and Component Name protocols!");
|
||||
}
|
||||
|
||||
|
@ -1719,7 +1692,7 @@ public class AutoGen {
|
|||
//
|
||||
if (compConfList != null && compConfList.length != 0) {
|
||||
if (drvBindList.length != compConfList.length) {
|
||||
throw new BuildException(
|
||||
throw new AutoGenException(
|
||||
"Different number of Driver Binding and Driver Configuration protocols!");
|
||||
}
|
||||
|
||||
|
@ -1736,7 +1709,7 @@ public class AutoGen {
|
|||
//
|
||||
if (compDiagList != null && compDiagList.length != 0) {
|
||||
if (drvBindList.length != compDiagList.length) {
|
||||
throw new BuildException(
|
||||
throw new AutoGenException(
|
||||
"Different number of Driver Binding and Driver Diagnosis protocols!");
|
||||
}
|
||||
|
||||
|
@ -1818,7 +1791,7 @@ public class AutoGen {
|
|||
@throws BuildException
|
||||
**/
|
||||
void ExternCallBackToAutoGenC(StringBuffer fileBuffer)
|
||||
throws BuildException {
|
||||
throws EdkException {
|
||||
//
|
||||
// Collect module's <SetVirtualAddressMapCallBack> and
|
||||
// <ExitBootServiceCallBack> and add to setVirtualAddList
|
||||
|
@ -1879,20 +1852,21 @@ public class AutoGen {
|
|||
// do nothing.
|
||||
//
|
||||
if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {
|
||||
try {
|
||||
if (inFile.exists()) {
|
||||
try{
|
||||
FileInputStream fis = new FileInputStream (inFile);
|
||||
fis.read(buffer);
|
||||
FileOutputStream fos = new FileOutputStream(outFile);
|
||||
fos.write(buffer);
|
||||
fis.close();
|
||||
fos.close();
|
||||
} catch (IOException e){
|
||||
throw new AutoGenException("The file, flashMap.h can't be open!");
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new AutoGenException("The file, flashMap.h doesn't exist!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new AutoGenException(e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1914,7 +1888,7 @@ public class AutoGen {
|
|||
String[] exitBoots = null;
|
||||
|
||||
ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);
|
||||
try {
|
||||
|
||||
if (libraryIdList != null) {
|
||||
//
|
||||
// Reorder library instance sequence.
|
||||
|
@ -2022,11 +1996,6 @@ public class AutoGen {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
System.out.println("Collect library instance failed!");
|
||||
}
|
||||
}
|
||||
private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){
|
||||
//
|
||||
|
|
|
@ -22,9 +22,11 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.xmlbeans.XmlObject;
|
||||
import org.tianocore.build.exception.AutoGenException;
|
||||
import org.tianocore.build.global.GlobalData;
|
||||
import org.tianocore.build.global.SurfaceAreaQuery;
|
||||
import org.tianocore.build.id.ModuleIdentification;
|
||||
import org.tianocore.common.exception.EdkException;
|
||||
|
||||
/**
|
||||
This class This class is to reorder library instance sequence according to
|
||||
|
@ -55,7 +57,7 @@ public class AutogenLibOrder {
|
|||
@param libraryList List of the library instance.
|
||||
@throws Exception
|
||||
**/
|
||||
AutogenLibOrder(ModuleIdentification[] libraryList, String arch) throws Exception {
|
||||
AutogenLibOrder(ModuleIdentification[] libraryList, String arch) throws EdkException {
|
||||
LibraryInstanceNode libInstanceNode;
|
||||
String[] libClassDeclList = null;
|
||||
String[] libClassConsmList = null;
|
||||
|
@ -80,9 +82,9 @@ public class AutogenLibOrder {
|
|||
classStr[k] = libClassConsmList[k];
|
||||
}
|
||||
if (this.libInstanceMap.containsKey(libraryList[i])) {
|
||||
throw new Exception(
|
||||
throw new AutoGenException(
|
||||
libraryList[i].getName()
|
||||
+ "this library instance already exists, please check the library instance list!");
|
||||
+ "-- this library instance already exists, please check the library instance list!");
|
||||
} else {
|
||||
this.libInstanceMap.put(libraryList[i], classStr);
|
||||
}
|
||||
|
@ -98,7 +100,7 @@ public class AutogenLibOrder {
|
|||
System.out.println(libClassDeclList[j]
|
||||
+ " class is already implement by "
|
||||
+ this.libClassMap.get(libClassDeclList[j]));
|
||||
throw new Exception("Library Class: " + libClassDeclList
|
||||
throw new AutoGenException("Library Class: " + libClassDeclList
|
||||
+ " already has a library instance!");
|
||||
} else {
|
||||
this.libClassMap.put(libClassDeclList[j], libraryList[i]);
|
||||
|
|
|
@ -28,7 +28,7 @@ public class GenBuildException extends EdkException {
|
|||
@param expStr exception message string.
|
||||
**/
|
||||
public GenBuildException(String expStr) {
|
||||
super("[GenBuildException]:" + expStr);
|
||||
super(expStr);
|
||||
}
|
||||
|
||||
public GenBuildException() {
|
||||
|
|
|
@ -26,7 +26,7 @@ public class PcdAutogenException extends AutoGenException {
|
|||
@param expStr exception message string.
|
||||
**/
|
||||
public PcdAutogenException(String expStr) {
|
||||
super("\r\n[PcdAutogenException] #############################\r\n" + expStr);
|
||||
super(expStr);
|
||||
}
|
||||
|
||||
public PcdAutogenException() {
|
||||
|
|
|
@ -27,7 +27,7 @@ public class PlatformPcdPreprocessBuildException extends GenBuildException {
|
|||
@param expStr exception message string.
|
||||
**/
|
||||
public PlatformPcdPreprocessBuildException(String expStr) {
|
||||
super("\r\n[PlatformPcdPreprocess Failure] #############################\r\n" + expStr);
|
||||
super(expStr);
|
||||
}
|
||||
|
||||
public PlatformPcdPreprocessBuildException() {
|
||||
|
|
|
@ -28,7 +28,7 @@ public class TianoToolsException extends EdkException {
|
|||
@param expStr exception message string.
|
||||
**/
|
||||
public TianoToolsException(String expStr) {
|
||||
super("[TianoToolsException]:" + expStr);
|
||||
super(expStr);
|
||||
}
|
||||
|
||||
public TianoToolsException() {
|
||||
|
|
|
@ -26,7 +26,7 @@ public class XmlParseException extends GenBuildException {
|
|||
@param expStr exception message string.
|
||||
**/
|
||||
public XmlParseException(String expStr) {
|
||||
super("[XmlParseException]:" + expStr);
|
||||
super(expStr);
|
||||
}
|
||||
|
||||
public XmlParseException() {
|
||||
|
|
Loading…
Reference in New Issue