package org.tianocore.build.global;\r
\r
import java.io.File;\r
+import java.io.IOException;\r
import java.util.HashMap;\r
import java.util.Iterator;\r
import java.util.Map;\r
import java.util.Set;\r
\r
-import org.apache.tools.ant.BuildException;\r
+import org.apache.xmlbeans.XmlException;\r
import org.apache.xmlbeans.XmlObject;\r
import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.id.PackageIdentification;\r
+import org.tianocore.common.exception.EdkException;\r
\r
/**\r
\r
This class is to generate a global table for the content of spd file.\r
\r
- **/\r
+**/\r
public class Spd {\r
///\r
///\r
\r
This function mainly initialize some member variables. \r
**/\r
- Spd(File packageFile) throws BuildException {\r
+ Spd(File packageFile) throws EdkException {\r
//\r
// If specified package file not exists\r
//\r
if ( ! packageFile.exists()) {\r
- throw new BuildException("Package file [" + packageFile.getPath() + "] does not exist!");\r
+ throw new EdkException("Package file [" + packageFile.getPath() + "] does not exist!");\r
}\r
try {\r
XmlObject spdDoc = XmlObject.Factory.parse(packageFile);\r
// Verify SPD file, if is invalid, throw Exception\r
//\r
if (! spdDoc.validate()) {\r
- throw new BuildException("Package Surface Area file [" + packageFile.getPath() + "] format is invalid!");\r
+ throw new EdkException("Package Surface Area file [" + packageFile.getPath() + "] format is invalid!");\r
}\r
+ //\r
// We can change Map to XmlObject\r
+ //\r
Map<String, XmlObject> spdDocMap = new HashMap<String, XmlObject>();\r
spdDocMap.put("PackageSurfaceArea", spdDoc);\r
SurfaceAreaQuery saq = new SurfaceAreaQuery(spdDocMap);\r
- //\r
- //\r
- //\r
+\r
packageId = saq.getSpdHeader();\r
packageId.setSpdFile(packageFile);\r
\r
moduleId.setPackage(packageId);\r
moduleId.setMsaFile(msaFile);\r
if (msaInfo.containsKey(moduleId)) {\r
- throw new BuildException("Found two modules with the same GUID and Version in package " + packageId + ".\nThey are module [" + msaInfo.get(moduleId) + "] and MSA file [" + msaFile + "]!");\r
+ throw new EdkException("Found two modules with the same GUID and Version in package " + packageId + ".\nThey are module [" + msaInfo.get(moduleId) + "] and MSA file [" + msaFile + "]!");\r
}\r
msaInfo.put(moduleId, msaFile);\r
}\r
}\r
libClassHeaderList.put(libraryClassName, headerFiles);\r
}\r
- }\r
- catch (Exception e) {\r
- throw new BuildException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n"\r
- + e.getMessage());\r
+ } catch (IOException ex) {\r
+ EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());\r
+ edkException.setStackTrace(ex.getStackTrace());\r
+ throw edkException;\r
+ } catch (XmlException ex) {\r
+ EdkException edkException = new EdkException("Parse of the package description file [" + packageFile.getPath() + "] failed!\n" + ex.getMessage());\r
+ edkException.setStackTrace(ex.getStackTrace());\r
+ throw edkException;\r
}\r
}\r
\r