@throws BuildException\r
Failed to creat AutoGen.c & AutoGen.h.\r
**/\r
- public void genAutogen() throws BuildException {\r
+ public void genAutogen() throws EdkException {\r
try {\r
//\r
// If outputPath do not exist, create it.\r
//\r
File path = new File(outputPath);\r
path.mkdirs();\r
-\r
- //\r
- // Check current is library or not, then call the corresponding\r
- // function.\r
- //\r
- if (this.moduleId.isLibrary()) {\r
- libGenAutogen();\r
- } else {\r
- moduleGenAutogen();\r
- }\r
-\r
- } catch (Exception e) {\r
- throw new BuildException(\r
- "Failed to create AutoGen.c & AutoGen.h!\n"\r
- + e.getMessage());\r
+ } catch (Exception e) {\r
+ throw new AutoGenException(\r
+ "Failed to create "\r
+ + outputPath + " directory");\r
}\r
+ \r
+ //\r
+ // Check current is library or not, then call the corresponding\r
+ // function.\r
+ //\r
+ if (this.moduleId.isLibrary()) {\r
+ libGenAutogen();\r
+ } else {\r
+ moduleGenAutogen();\r
+ }\r
}\r
\r
/**\r
@throws BuildException\r
Faile to create module AutoGen.c & AutoGen.h.\r
**/\r
- void moduleGenAutogen() throws BuildException {\r
-\r
- try {\r
- collectLibInstanceInfo();\r
- moduleGenAutogenC();\r
- moduleGenAutogenH();\r
- } catch (Exception e) {\r
- throw new BuildException(\r
- "Faile to create module AutoGen.c & AutoGen.h!\n"\r
- + e.getMessage());\r
- }\r
+ void moduleGenAutogen() throws EdkException {\r
+ collectLibInstanceInfo();\r
+ moduleGenAutogenC();\r
+ moduleGenAutogenH();\r
}\r
\r
/**\r
@throws BuildException\r
Faile to create library AutoGen.c & AutoGen.h\r
**/\r
- void libGenAutogen() throws BuildException {\r
- try {\r
- libGenAutogenC();\r
- libGenAutogenH();\r
- } catch (Exception e) {\r
- throw new BuildException(\r
- "Failed to create library AutoGen.c & AutoGen.h!\n"\r
- + e.getMessage());\r
- }\r
+ void libGenAutogen() throws EdkException {\r
+ libGenAutogenC();\r
+ libGenAutogenH();\r
}\r
\r
/**\r
@throws BuildException\r
Failed to generate AutoGen.h.\r
**/\r
- void moduleGenAutogenH() throws EdkException, AutoGenException {\r
+ void moduleGenAutogenH() throws EdkException {\r
\r
Set<String> libClassIncludeH;\r
String moduleType;\r
// Save string buffer content in AutoGen.h.\r
//\r
if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
- throw new BuildException("Failed to generate AutoGen.h !!!");\r
+ throw new AutoGenException("Failed to generate AutoGen.h !!!");\r
}\r
}\r
\r
@throws BuildException\r
Failed to generate AutoGen.c.\r
**/\r
- void moduleGenAutogenC() throws EdkException, AutoGenException {\r
+ void moduleGenAutogenC() throws EdkException {\r
\r
StringBuffer fileBuffer = new StringBuffer(8192);\r
//\r
false, \r
null,\r
pcdDriverType);\r
- try {\r
- this.myPcdAutogen.execute();\r
- } catch (Exception exp) {\r
- throw new PcdAutogenException (exp.getMessage());\r
- }\r
-\r
+ \r
+ this.myPcdAutogen.execute();\r
if (this.myPcdAutogen != null) {\r
fileBuffer.append("\r\n");\r
fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
}\r
\r
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
- throw new BuildException("Failed to generate AutoGen.c !!!");\r
+ throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
}\r
\r
}\r
@throws BuildException\r
Failed to generate AutoGen.c.\r
**/\r
- void libGenAutogenH() throws EdkException, AutoGenException {\r
+ void libGenAutogenH() throws EdkException {\r
\r
Set<String> libClassIncludeH;\r
String moduleType;\r
// Save content of string buffer to AutoGen.h file.\r
//\r
if (!saveFile(outputPath + File.separatorChar + "AutoGen.h", fileBuffer)) {\r
- throw new BuildException("Failed to generate AutoGen.h !!!");\r
+ throw new AutoGenException("Failed to generate AutoGen.h !!!");\r
}\r
}\r
\r
@throws BuildException\r
Failed to generate AutoGen.c.\r
**/\r
- void libGenAutogenC() throws BuildException, PcdAutogenException {\r
+ void libGenAutogenC() throws EdkException {\r
StringBuffer fileBuffer = new StringBuffer(10240);\r
\r
//\r
true,\r
saq.getModulePcdEntryNameArray(),\r
pcdDriverType);\r
- try {\r
- this.myPcdAutogen.execute();\r
- } catch (Exception e) {\r
- throw new PcdAutogenException(e.getMessage());\r
- }\r
-\r
+ this.myPcdAutogen.execute();\r
if (this.myPcdAutogen != null) {\r
fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);\r
fileBuffer.append(this.myPcdAutogen.getCAutoGenString());\r
}\r
\r
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {\r
- throw new BuildException("Failed to generate AutoGen.c !!!");\r
+ throw new AutoGenException("Failed to generate AutoGen.c !!!");\r
}\r
}\r
\r
@return includeStrList List of *.h file.\r
**/\r
Set<String> LibraryClassToAutogenH(String[] libClassList)\r
- throws EdkException, AutoGenException {\r
+ throws EdkException {\r
Set<String> includeStrList = new LinkedHashSet<String>();\r
String includeName[];\r
String str = "";\r
@throws Exception\r
**/\r
void EntryPointToAutoGen(String[] entryPointList, String[] unloadImageList, StringBuffer fileBuffer)\r
- throws BuildException {\r
+ throws EdkException {\r
\r
String typeStr = saq.getModuleType();\r
int unloadImageCount = 0;\r
\r
case CommonDefinition.ModuleTypePeiCore:\r
if (entryPointList == null ||entryPointList.length != 1 ) {\r
- throw new BuildException(\r
+ throw new AutoGenException(\r
"Module type = 'PEI_CORE', can have only one module entry point!");\r
} else {\r
fileBuffer.append("EFI_STATUS\r\n");\r
case CommonDefinition.ModuleTypeDxeCore:\r
fileBuffer.append("const UINT32 _gUefiDriverRevision = 0;\r\n");\r
if (entryPointList == null || entryPointList.length != 1) {\r
- throw new BuildException(\r
+ throw new AutoGenException(\r
"Module type = 'DXE_CORE', can have only one module entry point!");\r
} else {\r
\r
@throws BuildException\r
Protocol name must set.\r
**/\r
- void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {\r
+ void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws EdkException {\r
String[] cNameGuid = null;\r
\r
String[] protocolList = saq.getProtocolArray(this.arch);\r
//\r
// If can't find protocol GUID declaration in every package\r
//\r
- throw new BuildException("Can not find protocol Guid ["\r
+ throw new AutoGenException("Can not find protocol Guid ["\r
+ protocolKeyWord + "] declaration in any SPD package!");\r
}\r
}\r
String buffer for AutoGen.c\r
@throws BuildException\r
**/\r
- void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException {\r
- try {\r
- String moduleType = this.moduleId.getModuleType();\r
- //\r
- // Add library constructor to AutoGen.c\r
- //\r
- LibConstructorToAutogenC(libConstructList, moduleType,\r
- fileBuffer/* autogenC */);\r
- //\r
- // Add library destructor to AutoGen.c\r
- //\r
- LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
- } catch (Exception e) {\r
- throw new BuildException(e.getMessage());\r
- }\r
+ void LibInstanceToAutogenC(StringBuffer fileBuffer) throws EdkException {\r
+ String moduleType = this.moduleId.getModuleType();\r
+ //\r
+ // Add library constructor to AutoGen.c\r
+ //\r
+ LibConstructorToAutogenC(libConstructList, moduleType,\r
+ fileBuffer/* autogenC */);\r
+ //\r
+ // Add library destructor to AutoGen.c\r
+ //\r
+ LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);\r
}\r
\r
/**\r
@throws Exception\r
**/\r
void LibConstructorToAutogenC(List<String> libInstanceList,\r
- String moduleType, StringBuffer fileBuffer) throws Exception {\r
+ String moduleType, StringBuffer fileBuffer) throws EdkException {\r
boolean isFirst = true;\r
\r
//\r
@throws Exception\r
**/\r
void LibDestructorToAutogenC(List<String> libInstanceList,\r
- String moduleType, StringBuffer fileBuffer) throws Exception {\r
+ String moduleType, StringBuffer fileBuffer) throws EdkException {\r
boolean isFirst = true;\r
for (int i = 0; i < libInstanceList.size(); i++) {\r
switch (CommonDefinition.getModuleType(moduleType)) {\r
String buffer for AutoGen.c\r
**/\r
void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)\r
- throws BuildException {\r
+ throws EdkException {\r
\r
//\r
// Check what <extern> contains. And the number of following elements\r
//\r
if (compNamList != null && compNamList.length != 0) {\r
if (drvBindList.length != compNamList.length) {\r
- throw new BuildException(\r
+ throw new AutoGenException(\r
"Different number of Driver Binding and Component Name protocols!");\r
}\r
\r
//\r
if (compConfList != null && compConfList.length != 0) {\r
if (drvBindList.length != compConfList.length) {\r
- throw new BuildException(\r
+ throw new AutoGenException(\r
"Different number of Driver Binding and Driver Configuration protocols!");\r
}\r
\r
//\r
if (compDiagList != null && compDiagList.length != 0) {\r
if (drvBindList.length != compDiagList.length) {\r
- throw new BuildException(\r
+ throw new AutoGenException(\r
"Different number of Driver Binding and Driver Diagnosis protocols!");\r
}\r
\r
@throws BuildException\r
**/\r
void ExternCallBackToAutoGenC(StringBuffer fileBuffer)\r
- throws BuildException {\r
+ throws EdkException {\r
//\r
// Collect module's <SetVirtualAddressMapCallBack> and\r
// <ExitBootServiceCallBack> and add to setVirtualAddList\r
// do nothing.\r
//\r
if ((!outFile.exists()) ||(inFile.lastModified() - outFile.lastModified()) >= 0) {\r
- try {\r
- if (inFile.exists()) {\r
- FileInputStream fis = new FileInputStream (inFile);\r
- fis.read(buffer);\r
- FileOutputStream fos = new FileOutputStream(outFile);\r
- fos.write(buffer);\r
- fis.close();\r
- fos.close();\r
- } else {\r
- throw new AutoGenException("The file, flashMap.h doesn't exist!");\r
- }\r
- } catch (Exception e) {\r
- throw new AutoGenException(e.getMessage());\r
- }\r
+ if (inFile.exists()) {\r
+ try{\r
+ FileInputStream fis = new FileInputStream (inFile);\r
+ fis.read(buffer);\r
+ FileOutputStream fos = new FileOutputStream(outFile);\r
+ fos.write(buffer);\r
+ fis.close();\r
+ fos.close();\r
+ } catch (IOException e){\r
+ throw new AutoGenException("The file, flashMap.h can't be open!");\r
+ }\r
+ \r
+ } else {\r
+ throw new AutoGenException("The file, flashMap.h doesn't exist!");\r
+ }\r
}\r
}\r
\r
String[] exitBoots = null;\r
\r
ModuleIdentification[] libraryIdList = saq.getLibraryInstance(this.arch);\r
- try {\r
- if (libraryIdList != null) {\r
- //\r
- // Reorder library instance sequence.\r
- //\r
- AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,\r
- this.arch);\r
- List<ModuleIdentification> orderList = libOrder\r
- .orderLibInstance();\r
-\r
- if (orderList != null) {\r
- //\r
- // Process library instance one by one.\r
- //\r
- for (int i = 0; i < orderList.size(); i++) {\r
-\r
- //\r
- // Get library instance basename.\r
- //\r
- ModuleIdentification libInstanceId = orderList.get(i);\r
-\r
- //\r
- // Get override map\r
- //\r
-\r
- Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
- saq.push(libDoc);\r
- //\r
- // Get <PPis>, <Protocols>, <Guids> list of this library\r
- // instance.\r
- //\r
- String[] ppiList = saq.getPpiArray(this.arch);\r
- String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
- String[] protocolList = saq.getProtocolArray(this.arch);\r
- String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
- String[] guidList = saq.getGuidEntryArray(this.arch);\r
- PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
-\r
- //\r
- // Add those ppi, protocol, guid in global ppi,\r
- // protocol, guid\r
- // list.\r
- //\r
- for (index = 0; index < ppiList.length; index++) {\r
- this.mPpiList.add(ppiList[index]);\r
- }\r
-\r
- for (index = 0; index < ppiNotifyList.length; index++) {\r
- this.mPpiList.add(ppiNotifyList[index]);\r
- }\r
-\r
- for (index = 0; index < protocolList.length; index++) {\r
- this.mProtocolList.add(protocolList[index]);\r
- }\r
-\r
- for (index = 0; index < protocolNotifyList.length; index++) {\r
- this.mProtocolList.add(protocolNotifyList[index]);\r
- }\r
\r
- for (index = 0; index < guidList.length; index++) {\r
- this.mGuidList.add(guidList[index]);\r
- }\r
- for (index = 0; index < pkgList.length; index++) {\r
- if (!this.mDepPkgList.contains(pkgList[index])) {\r
- this.mDepPkgList.add(pkgList[index]);\r
- }\r
- }\r
-\r
- //\r
- // If not yet parse this library instance's constructor\r
- // element,parse it.\r
- //\r
- libConstructName = saq.getLibConstructorName();\r
- libDestructName = saq.getLibDestructorName();\r
-\r
- //\r
- // Collect SetVirtualAddressMapCallBack and\r
- // ExitBootServiceCallBack.\r
- //\r
- setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
- exitBoots = saq.getExitBootServicesCallBackArray();\r
- if (setVirtuals != null) {\r
- for (int j = 0; j < setVirtuals.length; j++) {\r
- this.setVirtalAddList.add(setVirtuals[j]);\r
- }\r
- }\r
- if (exitBoots != null) {\r
- for (int k = 0; k < exitBoots.length; k++) {\r
- this.exitBootServiceList.add(exitBoots[k]);\r
- }\r
- }\r
- saq.pop();\r
- //\r
- // Add dependent library instance constructor function.\r
- //\r
- if (libConstructName != null) {\r
- this.libConstructList.add(libConstructName);\r
- }\r
- //\r
- // Add dependent library instance destructor fuction.\r
- //\r
- if (libDestructName != null) {\r
- this.libDestructList.add(libDestructName);\r
- }\r
- }\r
- }\r
-\r
- }\r
+ if (libraryIdList != null) {\r
+ //\r
+ // Reorder library instance sequence.\r
+ //\r
+ AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList,\r
+ this.arch);\r
+ List<ModuleIdentification> orderList = libOrder\r
+ .orderLibInstance();\r
+\r
+ if (orderList != null) {\r
+ //\r
+ // Process library instance one by one.\r
+ //\r
+ for (int i = 0; i < orderList.size(); i++) {\r
+\r
+ //\r
+ // Get library instance basename.\r
+ //\r
+ ModuleIdentification libInstanceId = orderList.get(i);\r
+\r
+ //\r
+ // Get override map\r
+ //\r
+\r
+ Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstanceId, this.arch);\r
+ saq.push(libDoc);\r
+ //\r
+ // Get <PPis>, <Protocols>, <Guids> list of this library\r
+ // instance.\r
+ //\r
+ String[] ppiList = saq.getPpiArray(this.arch);\r
+ String[] ppiNotifyList = saq.getPpiNotifyArray(this.arch);\r
+ String[] protocolList = saq.getProtocolArray(this.arch);\r
+ String[] protocolNotifyList = saq.getProtocolNotifyArray(this.arch);\r
+ String[] guidList = saq.getGuidEntryArray(this.arch);\r
+ PackageIdentification[] pkgList = saq.getDependencePkg(this.arch);\r
+\r
+ //\r
+ // Add those ppi, protocol, guid in global ppi,\r
+ // protocol, guid\r
+ // list.\r
+ //\r
+ for (index = 0; index < ppiList.length; index++) {\r
+ this.mPpiList.add(ppiList[index]);\r
+ }\r
+\r
+ for (index = 0; index < ppiNotifyList.length; index++) {\r
+ this.mPpiList.add(ppiNotifyList[index]);\r
+ }\r
+\r
+ for (index = 0; index < protocolList.length; index++) {\r
+ this.mProtocolList.add(protocolList[index]);\r
+ }\r
+\r
+ for (index = 0; index < protocolNotifyList.length; index++) {\r
+ this.mProtocolList.add(protocolNotifyList[index]);\r
+ }\r
+\r
+ for (index = 0; index < guidList.length; index++) {\r
+ this.mGuidList.add(guidList[index]);\r
+ }\r
+ for (index = 0; index < pkgList.length; index++) {\r
+ if (!this.mDepPkgList.contains(pkgList[index])) {\r
+ this.mDepPkgList.add(pkgList[index]);\r
+ }\r
+ }\r
+\r
+ //\r
+ // If not yet parse this library instance's constructor\r
+ // element,parse it.\r
+ //\r
+ libConstructName = saq.getLibConstructorName();\r
+ libDestructName = saq.getLibDestructorName();\r
+\r
+ //\r
+ // Collect SetVirtualAddressMapCallBack and\r
+ // ExitBootServiceCallBack.\r
+ //\r
+ setVirtuals = saq.getSetVirtualAddressMapCallBackArray();\r
+ exitBoots = saq.getExitBootServicesCallBackArray();\r
+ if (setVirtuals != null) {\r
+ for (int j = 0; j < setVirtuals.length; j++) {\r
+ this.setVirtalAddList.add(setVirtuals[j]);\r
+ }\r
+ }\r
+ if (exitBoots != null) {\r
+ for (int k = 0; k < exitBoots.length; k++) {\r
+ this.exitBootServiceList.add(exitBoots[k]);\r
+ }\r
+ }\r
+ saq.pop();\r
+ //\r
+ // Add dependent library instance constructor function.\r
+ //\r
+ if (libConstructName != null) {\r
+ this.libConstructList.add(libConstructName);\r
+ }\r
+ //\r
+ // Add dependent library instance destructor fuction.\r
+ //\r
+ if (libDestructName != null) {\r
+ this.libDestructList.add(libDestructName);\r
+ }\r
+ }\r
+ }\r
\r
- } catch (Exception e) {\r
- System.out.println(e.getMessage());\r
- System.out.println("Collect library instance failed!");\r
- }\r
+ }\r
}\r
private void setVirtualAddressToAutogenC(StringBuffer fileBuffer){\r
//\r