private String type = "all";\r
\r
public void execute() throws BuildException {\r
+ //\r
+ // set Logger\r
+ //\r
+ GenBuildLogger logger = new GenBuildLogger(getProject());\r
+ EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));\r
+ EdkLog.setLogger(logger);\r
+ \r
try {\r
processFrameworkBuild();\r
} catch (PcdAutogenException e) {\r
}\r
\r
private void processFrameworkBuild() throws EdkException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r
- //\r
- // set Logger\r
- //\r
- GenBuildLogger logger = new GenBuildLogger(getProject());\r
- EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));\r
- EdkLog.setLogger(logger);\r
-\r
//\r
// Seach build.xml -> .FPD -> .MSA file\r
//\r
}\r
}\r
}\r
- } catch (IOException e) {\r
- throw new BuildException(e.getMessage());\r
+ } catch (IOException ex) {\r
+ BuildException buildException = new BuildException("Scanning current directory error. \n" + ex.getMessage());\r
+ buildException.setStackTrace(ex.getStackTrace());\r
+ throw buildException;\r
}\r
\r
//\r
if (threadNum > 0) {\r
MAX_CONCURRENT_THREAD_NUMBER = threadNum;\r
}\r
- } catch (Exception enuma) {\r
+ } catch (Exception ex) {\r
}\r
}\r
}\r
import org.tianocore.common.exception.EdkException;\r
import org.tianocore.common.logger.EdkLog;\r
import org.tianocore.build.autogen.AutoGen;\r
+import org.tianocore.build.exception.AutoGenException;\r
+import org.tianocore.build.exception.GenBuildException;\r
+import org.tianocore.build.exception.PcdAutogenException;\r
+import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;\r
import org.tianocore.build.fpd.FpdParserTask;\r
import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.global.OutputManager;\r
From module build, exception from module surface area invalid.\r
**/\r
public void execute() throws BuildException {\r
+ try {\r
+ processGenBuild();\r
+ } catch (PcdAutogenException e) {\r
+ //\r
+ // Add more logic process here\r
+ //\r
+ throw new BuildException(e.getMessage());\r
+ } catch (AutoGenException e) {\r
+ //\r
+ // Add more logic process here\r
+ //\r
+ throw new BuildException(e.getMessage());\r
+ } catch (PlatformPcdPreprocessBuildException e) {\r
+ //\r
+ // Add more logic process here\r
+ //\r
+ throw new BuildException(e.getMessage());\r
+ } catch (GenBuildException e) {\r
+ //\r
+ // Add more logic process here\r
+ //\r
+ throw new BuildException(e.getMessage());\r
+ } catch (EdkException e) {\r
+ //\r
+ // Add more logic process here\r
+ //\r
+ throw new BuildException(e.getMessage());\r
+ }\r
+ }\r
+\r
+ private void processGenBuild() throws EdkException, BuildException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {\r
if (!FrameworkBuildTask.multithread) {\r
cleanupProperties();\r
}\r
String moduleVersion = getProject().getProperty("MODULE_VERSION");\r
String packageGuid = getProject().getProperty("PACKAGE_GUID");\r
String packageVersion = getProject().getProperty("PACKAGE_VERSION");\r
+ //\r
+ // If one of module Guid or package Guid is not specified, report error\r
+ //\r
if (moduleGuid == null || packageGuid == null) {\r
throw new BuildException("GenBuild parameter error.");\r
}\r
+ \r
PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);\r
+ GlobalData.refreshPackageIdentification(packageId);\r
moduleId = new ModuleIdentification(moduleGuid, moduleVersion);\r
moduleId.setPackage(packageId);\r
+ GlobalData.refreshModuleIdentification(moduleId);\r
Map<String, XmlObject> doc = GlobalData.getNativeMsa(moduleId);\r
saq = new SurfaceAreaQuery(doc);\r
- moduleId = saq.getMsaHeader();\r
} else {\r
Map<String, XmlObject> doc = GlobalData.getNativeMsa(msaFile);\r
saq = new SurfaceAreaQuery(doc);\r
moduleId = saq.getMsaHeader();\r
}\r
+ \r
String[] producedLibraryClasses = saq.getLibraryClasses("ALWAYS_PRODUCED",null);\r
if (producedLibraryClasses.length == 0) {\r
moduleId.setLibrary(false);\r
// Single Module build\r
//\r
prepareSingleModuleBuild();\r
- } else {\r
- String packageGuid = getProject().getProperty("PACKAGE_GUID");\r
- String packageVersion = getProject().getProperty("PACKAGE_VERSION");\r
- PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);\r
- moduleId.setPackage(packageId);\r
}\r
\r
//\r
Database must be unique. </p>\r
\r
**/\r
- private void prepareSingleModuleBuild(){\r
+ private void prepareSingleModuleBuild() throws EdkException {\r
//\r
// Find out the package which the module belongs to\r
// TBD: Enhance it!!!!\r
//\r
PackageIdentification packageId = GlobalData.getPackageForModule(moduleId);\r
-\r
+ GlobalData.refreshPackageIdentification(packageId);\r
moduleId.setPackage(packageId);\r
+ GlobalData.refreshModuleIdentification(moduleId);\r
\r
//\r
// Read ACTIVE_PLATFORM's FPD file \r
this.type = type;\r
}\r
\r
- private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws BuildException{\r
+ private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws EdkException {\r
//\r
// Call AutoGen to generate AutoGen.c and AutoGen.h\r
//\r
this.isSingleModuleBuild = isSingleModuleBuild;\r
}\r
\r
- private String[] prepareIncludePaths(FpdModuleIdentification fpdModuleId) {\r
+ private String[] prepareIncludePaths(FpdModuleIdentification fpdModuleId) throws EdkException{\r
//\r
// Prepare the includes: PackageDependencies and Output debug direactory\r
//\r
public void setStatus(int status) {\r
this.status = status;\r
}\r
- \r
}\r
import org.tianocore.build.id.FpdModuleIdentification;\r
import org.tianocore.build.id.ModuleIdentification;\r
import org.tianocore.build.id.PackageIdentification;\r
+import org.tianocore.common.exception.EdkException;\r
import org.w3c.dom.Comment;\r
import org.w3c.dom.Document;\r
import org.w3c.dom.Element;\r
@param document current BaseName_build.xml XML document\r
@param root Root element for current\r
**/\r
- private void applyLibraryInstance(Document document, Node root) {\r
+ private void applyLibraryInstance(Document document, Node root) throws EdkException {\r
ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch());\r
for (int i = 0; i < libinstances.length; i++) {\r
//\r
import org.tianocore.build.pcd.action.PCDAutoGenAction;\r
import org.tianocore.common.logger.EdkLog;\r
import org.tianocore.common.definitions.ToolDefinitions;\r
+import org.tianocore.common.exception.EdkException;\r
\r
/**\r
This class is to generate Autogen.h and Autogen.c according to module surface\r
@throws BuildException\r
Failed to generate AutoGen.h.\r
**/\r
- void moduleGenAutogenH() throws AutoGenException {\r
+ void moduleGenAutogenH() throws EdkException, AutoGenException {\r
\r
Set<String> libClassIncludeH;\r
String moduleType;\r
@throws BuildException\r
Failed to generate AutoGen.c.\r
**/\r
- void moduleGenAutogenC() throws AutoGenException {\r
+ void moduleGenAutogenC() throws EdkException, AutoGenException {\r
\r
StringBuffer fileBuffer = new StringBuffer(8192);\r
//\r
@throws BuildException\r
Failed to generate AutoGen.c.\r
**/\r
- void libGenAutogenH() throws AutoGenException {\r
+ void libGenAutogenH() throws EdkException, AutoGenException {\r
\r
Set<String> libClassIncludeH;\r
String moduleType;\r
@return includeStrList List of *.h file.\r
**/\r
Set<String> LibraryClassToAutogenH(String[] libClassList)\r
- throws AutoGenException {\r
+ throws EdkException, AutoGenException {\r
Set<String> includeStrList = new LinkedHashSet<String>();\r
String includeName[];\r
String str = "";\r
@param\r
@return \r
**/\r
- private void collectLibInstanceInfo(){\r
+ private void collectLibInstanceInfo() throws EdkException{\r
int index;\r
\r
String libConstructName = null;\r
\r
<p>The method parseFpdFile is also prepared for single module build. </p>\r
\r
- <p>The usage is (take NT32 Platform for example):</p>\r
-\r
- <pre>\r
- <FPDParser platformName="Nt32" />\r
- </pre>\r
-\r
@since GenBuild 1.0\r
**/\r
public class FpdParserTask extends Task {\r
\r
- private String platformName;\r
-\r
private File fpdFile = null;\r
\r
PlatformIdentification platformId;\r
Surface area is not valid.\r
**/\r
public void execute() throws BuildException {\r
- //\r
- // If fpdFile is not specified, \r
- // then try to get FPD file by platformName\r
- //\r
- if ( fpdFile == null) {\r
- if (platformName == null) {\r
- throw new BuildException("FpdParserTask parameter error. Please specify either the platform name or FPD file!");\r
- }\r
- platformId = GlobalData.getPlatformByName(platformName);\r
- fpdFile = platformId.getFpdFile();\r
- }\r
-\r
//\r
// Parse FPD file\r
//\r
//\r
// Ant call ${PLATFORM}_build.xml\r
//\r
-\r
Ant ant = new Ant();\r
ant.setProject(getProject());\r
ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
properties.addElement(p);\r
}\r
\r
- public void setPlatformName(String platformName) {\r
- this.platformName = platformName;\r
- }\r
-\r
public void setFpdFile(File fpdFile) {\r
this.fpdFile = fpdFile;\r
}\r
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.HashSet;\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
\r
import org.tianocore.common.exception.EdkException;\r
@throws BuildException\r
Framework Dababase or SPD or MSA file is not valid\r
**/\r
- public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws BuildException {\r
+ public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename ) throws EdkException {\r
//\r
// ensure this method will be revoked only once\r
//\r
// CONF dir + tools definition file name\r
//\r
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);\r
- EdkLog.log("Init", "Using tool definiton file [" + toolsDefFile.getPath() + "].");\r
- try {\r
- toolsDef = new ToolChainConfig(toolsDefFile);\r
- } catch (Exception e) {\r
- throw new BuildException(e.getMessage());\r
- }\r
+ EdkLog.log("Init", "Using tool definition file [" + toolsDefFile.getPath() + "].");\r
+ toolsDef = new ToolChainConfig(toolsDefFile);\r
+\r
\r
//\r
// Parse Framework Database\r
// validate FrameworkDatabaseFile\r
//\r
if (!db.validate()) {\r
- throw new BuildException("Framework Database file [" + dbFile.getPath() + "] format is invalid!");\r
+ throw new EdkException("Framework Database file [" + dbFile.getPath() + "] format is invalid!");\r
}\r
//\r
// Get package list\r
String fileName = iter.next().getStringValue().trim();\r
Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));\r
packageList.add(spd.getPackageId());\r
+ //\r
+ // Report warning if existing two packages with same GUID and Version\r
+ //\r
+ if (spdTable.containsKey(spd.getPackageId())) {\r
+ //\r
+ // BUGBUG\r
+ //\r
+ EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two packages with same GUID and Version. They are ... " + spd.getPackageId().getSpdFile().getPath());\r
+ }\r
spdTable.put(spd.getPackageId(), spd);\r
}\r
}\r
String fileName = iter.next().getStringValue().trim();\r
File fpdFile = new File(workspaceDir + File.separatorChar + fileName);\r
if ( !fpdFile.exists() ) {\r
- throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. ");\r
+ throw new EdkException("Platform file [" + fpdFile.getPath() + "] not exists. ");\r
}\r
XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile);\r
//\r
// Verify FPD file, if is invalid, throw Exception\r
//\r
if (!fpdDoc.validate()) {\r
- throw new BuildException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");\r
+ throw new EdkException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");\r
}\r
//\r
// We can change Map to XmlObject\r
//\r
- //\r
- // TBD check SPD or FPD is existed in FS\r
- //\r
Map<String, XmlObject> fpdDocMap = new HashMap<String, XmlObject>();\r
fpdDocMap.put("PlatformSurfaceArea", fpdDoc);\r
SurfaceAreaQuery saq = new SurfaceAreaQuery(fpdDocMap);\r
PlatformIdentification platformId = saq.getFpdHeader();\r
platformId.setFpdFile(fpdFile);\r
+ //\r
+ // Report warning if existing two platfrom with same GUID and Version\r
+ //\r
+ if (platformList.contains(platformId)) {\r
+ //\r
+ // BUGBUG\r
+ //\r
+ EdkLog.log("Init", EdkLog.EDK_WARNING, "Warning: Existing two platforms with same GUID and Version. They are ... " + fpdFile.getPath());\r
+ }\r
platformList.add(platformId);\r
}\r
}\r
- } catch (Exception e) {\r
- throw new BuildException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + e.getMessage());\r
+ } catch(IOException ex) {\r
+ EdkException edkException = new EdkException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + ex.getMessage());\r
+ edkException.setStackTrace(ex.getStackTrace());\r
+ throw edkException;\r
+ } catch(XmlException ex) {\r
+ EdkException edkException = new EdkException("Parse WORKSPACE Database file [" + dbFile.getPath() + "] Error.\n" + ex.getMessage());\r
+ edkException.setStackTrace(ex.getStackTrace());\r
+ throw edkException;\r
}\r
}\r
\r
/**\r
Get the MSA file name with absolute path\r
*/\r
- public synchronized static File getMsaFile(ModuleIdentification moduleId) throws BuildException {\r
+ public synchronized static File getMsaFile(ModuleIdentification moduleId) throws EdkException {\r
File msaFile = null;\r
//\r
// TBD. Do only when package is null.\r
}\r
}\r
if (msaFile == null){\r
- throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
+ throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
} else {\r
return msaFile;\r
}\r
}\r
\r
- public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) {\r
+ public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) throws EdkException {\r
//\r
// If package already defined in module\r
//\r
}\r
}\r
if (packageId == null){\r
- throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
+ throw new EdkException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");\r
} else {\r
return packageId;\r
}\r
}\r
\r
\r
- public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) {\r
+ public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map<String, XmlObject> doc) throws EdkException{\r
Map<String, XmlObject> result = new HashMap<String, XmlObject>();\r
Set keySet = doc.keySet();\r
Iterator iter = keySet.iterator();\r
@return ModuleSA info and MSA info for fpdModuleId\r
@throws BuildException Can't find MSA\r
**/\r
- public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws BuildException {\r
+ public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws EdkException{\r
if (parsedModules.containsKey(fpdModuleId)) {\r
return parsedModules.get(fpdModuleId);\r
}\r
return doc;\r
}\r
\r
- public synchronized static Map<String, XmlObject> getDoc(ModuleIdentification moduleId, String arch) throws BuildException {\r
+ public synchronized static Map<String, XmlObject> getDoc(ModuleIdentification moduleId, String arch) throws EdkException{\r
FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);\r
return getDoc(fpdModuleId);\r
}\r
+ \r
/**\r
Query the native MSA information with module base name.\r
\r
@throws BuildException\r
MSA file is not valid\r
**/\r
- public synchronized static Map<String, XmlObject> getNativeMsa(ModuleIdentification moduleId) throws BuildException {\r
+ public synchronized static Map<String, XmlObject> getNativeMsa(ModuleIdentification moduleId) throws EdkException {\r
if (nativeMsa.containsKey(moduleId)) {\r
return nativeMsa.get(moduleId);\r
}\r
return msaMap;\r
}\r
\r
- public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws BuildException {\r
+ public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws EdkException {\r
if (!msaFile.exists()) {\r
- throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");\r
+ throw new EdkException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");\r
}\r
try {\r
ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)XmlObject.Factory.parse(msaFile);\r
// Validate File if they accord with XML Schema\r
//\r
if ( !doc.validate()){\r
- throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] format is invalid!");\r
+ throw new EdkException("Module Surface Area file [" + msaFile.getPath() + "] format is invalid!");\r
}\r
//\r
// parse MSA file\r
msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));\r
msaMap.put("PcdCoded", cloneXmlObject(msa.getPcdCoded(), true));\r
return msaMap;\r
- }\r
- catch (Exception ex){\r
- throw new BuildException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage() );\r
+ } catch(IOException ex) {\r
+ EdkException edkException = new EdkException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage());\r
+ edkException.setStackTrace(ex.getStackTrace());\r
+ throw edkException;\r
+ } catch(XmlException ex) {\r
+ EdkException edkException = new EdkException("Parsing MSA file [" + msaFile.getPath() + "] error. \n" + ex.getMessage());\r
+ edkException.setStackTrace(ex.getStackTrace());\r
+ throw edkException;\r
}\r
}\r
\r
return fpdBuildOptionsMap;\r
}\r
\r
- public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {\r
+ public static void setFpdBuildOptions(XmlObject fpdBuildOptions) throws EdkException {\r
GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);\r
fpdBuildOptionsMap.put("BuildOptions", GlobalData.fpdBuildOptions);\r
}\r
* The header file path is relative to workspace dir\r
*/\r
public static String[] getLibraryClassHeaderFiles(\r
- PackageIdentification[] packages, String name)\r
- throws BuildException {\r
+ PackageIdentification[] packages, String name) throws EdkException{\r
if (packages == null) {\r
// throw Exception or not????\r
return new String[0];\r
//\r
// If can't find library class declaration in every package\r
//\r
- throw new BuildException("Can not find library class [" + name\r
+ throw new EdkException("Can not find library class [" + name\r
+ "] declaration in any SPD package!");\r
}\r
\r
* The header file path is relative to workspace dir\r
*/\r
public static String getPackageHeaderFiles(PackageIdentification packages,\r
- String moduleType) throws BuildException {\r
+ String moduleType) {\r
if (packages == null) {\r
return new String("");\r
}\r
/**\r
* return two values: {cName, GuidValue}\r
*/\r
- public static String[] getGuid(List<PackageIdentification> packages, String name)\r
- throws BuildException {\r
+ public static String[] getGuid(List<PackageIdentification> packages, String name) {\r
if (packages == null) {\r
// throw Exception or not????\r
return new String[0];\r
* return two values: {cName, GuidValue}\r
*/\r
public static String[] getPpiGuid(List<PackageIdentification> packages,\r
- String name) throws BuildException {\r
+ String name) {\r
if (packages == null) {\r
return new String[0];\r
}\r
* return two values: {cName, GuidValue}\r
*/\r
public static String[] getProtocolGuid(List<PackageIdentification> packages,\r
- String name) throws BuildException {\r
+ String name) {\r
if (packages == null) {\r
return new String[0];\r
}\r
\r
}\r
\r
- public synchronized static PlatformIdentification getPlatformByName(String name) throws BuildException {\r
+ public synchronized static PlatformIdentification getPlatformByName(String name) throws EdkException {\r
Iterator iter = platformList.iterator();\r
while(iter.hasNext()){\r
PlatformIdentification platformId = (PlatformIdentification)iter.next();\r
return platformId;\r
}\r
}\r
- throw new BuildException("Can't find platform [" + name + "] in the current WORKSPACE database!");\r
+ throw new EdkException("Can't find platform [" + name + "] in the current WORKSPACE database!");\r
}\r
\r
- public synchronized static PlatformIdentification getPlatform(String filename) throws BuildException {\r
+ public synchronized static PlatformIdentification getPlatform(String filename) throws EdkException {\r
File file = new File(workspaceDir + File.separatorChar + filename);\r
Iterator iter = platformList.iterator();\r
while(iter.hasNext()){\r
return platformId;\r
}\r
}\r
- throw new BuildException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");\r
+ throw new EdkException("Can't find platform file [" + filename + "] in the current WORKSPACE database!");\r
}\r
\r
- public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException {\r
+ public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws EdkException {\r
Iterator iter = packageList.iterator();\r
while(iter.hasNext()){\r
PackageIdentification packageItem = (PackageIdentification)iter.next();\r
return packageId;\r
}\r
}\r
- throw new BuildException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
+ throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
}\r
\r
- public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws BuildException {\r
+ public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws EdkException {\r
PackageIdentification packageId = getPackageForModule(moduleId);\r
moduleId.setPackage(packageId);\r
Spd spd = spdTable.get(packageId);\r
if (spd == null) {\r
- throw new BuildException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
+ throw new EdkException("Can't find package GUID value " + packageId.toGuidString() + " in the current workspace!");\r
}\r
Set<ModuleIdentification> modules = spd.getModules();\r
Iterator<ModuleIdentification> iter = modules.iterator();\r
return moduleId;\r
}\r
}\r
- throw new BuildException("Can't find module GUID value " + moduleId.toGuidString() + " in " + packageId + " under the current workspace!");\r
+ throw new EdkException("Can't find module GUID value " + moduleId.toGuidString() + " in " + packageId + " under the current workspace!");\r
}\r
\r
public synchronized static Set<PackageIdentification> getPackageList(){\r
@return XmlObject after clone\r
@throws BuildException parse original XmlObject error. \r
**/\r
- private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws BuildException {\r
+ private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws EdkException {\r
if ( object == null) {\r
return null;\r
}\r
try {\r
result = XmlObject.Factory.parse(object.getDomNode()\r
.cloneNode(deep));\r
- } catch (Exception ex) {\r
- throw new BuildException(ex.getMessage());\r
+ } catch (XmlException ex) {\r
+ EdkException edkException = new EdkException(ex.getMessage());\r
+ edkException.setStackTrace(ex.getStackTrace());\r
+ throw edkException;\r
}\r
return result;\r
}\r
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
import org.tianocore.ProtocolsDocument.Protocols.ProtocolNotify;\r
import org.tianocore.PcdDriverTypes;\r
\r
+import org.tianocore.common.exception.EdkException;\r
import org.tianocore.common.logger.EdkLog;\r
import org.tianocore.build.id.FpdModuleIdentification;\r
import org.tianocore.build.id.ModuleIdentification;\r
* @returns package name list if elements are found at the known xpath\r
* @returns null if nothing is there\r
*/\r
- public PackageIdentification[] getDependencePkg(String arch) {\r
+ public PackageIdentification[] getDependencePkg(String arch) throws EdkException {\r
String[] xPath;\r
String packageGuid = null;\r
String packageVersion = null;\r
if (arch == null || archList == null || contains(archList, arch)) {\r
packageGuid = item.getPackageGuid();\r
packageVersion = item.getPackageVersion();\r
- packageIdList.add(new PackageIdentification(null, packageGuid,\r
- packageVersion));\r
+ PackageIdentification pkgId = new PackageIdentification(null, packageGuid, packageVersion);\r
+ GlobalData.refreshPackageIdentification(pkgId);\r
+ packageIdList.add(pkgId);\r
}\r
}\r
\r
- //\r
- // transfer packageIdentification list to array.\r
- //\r
- PackageIdentification[] packageIdArray = new PackageIdentification[packageIdList.size()];\r
- for (int i = 0; i < packageIdList.size(); i++) {\r
- packageIdArray[i] = new PackageIdentification(null, packageIdList.get(i).getGuid(),packageIdList.get(i).getVersion());\r
- }\r
- return packageIdArray;\r
+ return packageIdList.toArray(new PackageIdentification[packageIdList.size()]);\r
}\r
\r
/**\r
* xpath\r
* @returns null if nothing is there\r
*/\r
- public ModuleIdentification[] getLibraryInstance(String arch) {\r
+ public ModuleIdentification[] getLibraryInstance(String arch) throws EdkException {\r
String[] xPath;\r
String saGuid = null;\r
String saVersion = null;\r
saVersion);\r
PackageIdentification pkgId = new PackageIdentification(null,\r
pkgGuid, pkgVersion);\r
+ GlobalData.refreshPackageIdentification(pkgId);\r
saId.setPackage(pkgId);\r
+ GlobalData.refreshModuleIdentification(saId);\r
\r
saIdList[i] = saId;\r
\r
* @returns ModuleSA objects list if elements are found at the known xpath\r
* @returns Empty ModuleSA list if nothing is there\r
*/\r
- public Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() {\r
+ public Map<FpdModuleIdentification, Map<String, XmlObject>> getFpdModules() throws EdkException {\r
String[] xPath = new String[] { "/FrameworkModules/ModuleSA" };\r
Object[] result = get("PlatformSurfaceArea", xPath);\r
String arch = null;\r
// identification.\r
//\r
PackageIdentification pkgId = new PackageIdentification(null, pkgGuid, pkgVersion);\r
+ GlobalData.refreshPackageIdentification(pkgId);\r
ModuleIdentification saId = new ModuleIdentification(null, saGuid, saVersion);\r
-\r
+ GlobalData.refreshModuleIdentification(saId);\r
+ \r
saId.setPackage(pkgId);\r
\r
//\r
\r
import java.io.File;\r
\r
-import org.tianocore.build.global.GlobalData;\r
/**\r
This class is used to identify a module with Module Guid, Module Version, \r
Package Guid, Package Version. \r
@return MSA File\r
**/\r
public File getMsaFile() {\r
- prepareMsaFile();\r
return msaFile;\r
}\r
\r
@return Module relative path to package\r
**/\r
public String getModuleRelativePath() {\r
- prepareMsaFile();\r
if (msaFile.getParent().length() == packageId.getPackageDir().length()) {\r
return ".";\r
}\r
return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);\r
}\r
\r
- private void prepareMsaFile(){\r
- if (msaFile == null) {\r
- GlobalData.refreshModuleIdentification(this);\r
- }\r
- }\r
-\r
/**\r
@param msaFile Set Msa File\r
**/\r
}\r
}\r
\r
- public String toString(){\r
- if (name == null) {\r
- GlobalData.refreshModuleIdentification(this);\r
- }\r
+ public String toString() {\r
if (version == null || version.trim().equalsIgnoreCase("")) {\r
return "Module [" + name + "] in " + packageId;\r
}\r
@return get module type\r
**/\r
public String getModuleType() {\r
- if (moduleType == null) {\r
- GlobalData.refreshModuleIdentification(this);\r
- }\r
return moduleType;\r
}\r
\r
}\r
\r
public String getName() {\r
- if (name == null) {\r
- GlobalData.refreshModuleIdentification(this);\r
- }\r
return name;\r
}\r
}\r
}\r
\r
public String toString(){\r
- if (name == null) {\r
- GlobalData.refreshPackageIdentification(this);\r
- }\r
if (version == null || version.trim().equalsIgnoreCase("")) {\r
return "package [" + name + "]";\r
}\r
@return Package Directory\r
**/\r
public String getPackageDir(){\r
- prepareSpdFile();\r
return spdFile.getParent();\r
}\r
\r
@return package relative directory\r
**/\r
public String getPackageRelativeDir(){\r
- prepareSpdFile();\r
String relativeDir =spdFile.getParent().substring(GlobalData.getWorkspacePath().length());\r
if(relativeDir.startsWith("\\") || relativeDir.startsWith("/")) {\r
relativeDir = relativeDir.substring(1);\r
return relativeDir;\r
}\r
\r
- private void prepareSpdFile(){\r
- if (spdFile == null) {\r
- GlobalData.refreshPackageIdentification(this);\r
- }\r
- }\r
- \r
public String getName() {\r
- if (name == null) {\r
- GlobalData.refreshPackageIdentification(this);\r
- }\r
return name;\r
}\r
}\r