Adjust some code format and clear some unused codes.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1273 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
wuyizhong 2006-08-15 08:36:45 +00:00
parent 5a6cd58892
commit 8251688793
8 changed files with 124 additions and 211 deletions

View File

@ -21,14 +21,12 @@ import javax.xml.namespace.QName;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.xmlbeans.XmlCursor; import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.BuildOptionsDocument; import org.tianocore.BuildOptionsDocument;
import org.tianocore.build.global.GlobalData; import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.SurfaceAreaQuery; import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.FpdModuleIdentification; import org.tianocore.build.id.FpdModuleIdentification;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.w3c.dom.Node;
/** /**
<p><code>FfsProcess</code> is a class to find the corresponding FFS layout. </p> <p><code>FfsProcess</code> is a class to find the corresponding FFS layout. </p>
@ -54,11 +52,6 @@ import org.w3c.dom.Node;
**/ **/
public class FfsProcess { public class FfsProcess {
///
/// Xml Document Node for corresponding FFS layout
///
private Node ffs;
private BuildOptionsDocument.BuildOptions.Ffs ffsXmlObject; private BuildOptionsDocument.BuildOptions.Ffs ffsXmlObject;
/// ///
@ -133,18 +126,7 @@ public class FfsProcess {
**/ **/
public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException { public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException {
// //
// Firstly, try to find in ModuleSA // Try to find Ffs layout from FPD file
//
// BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getModuleFfs();
// for (int i = 0; i < ffsArray.length; i++) {
// if (isMatch(ffsArray[i].getFfsKey(), buildType)) {
// ffsXmlObject = ffsArray[i];
// return true;
// }
// }
//
// secondly, try to sections defined in PLATFORM level
// //
SurfaceAreaQuery.push(GlobalData.getFpdBuildOptions()); SurfaceAreaQuery.push(GlobalData.getFpdBuildOptions());
BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getFpdFfs(); BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getFpdFfs();
@ -162,16 +144,11 @@ public class FfsProcess {
// //
if (buildType == null) { if (buildType == null) {
System.out.println("Warning: this module doesn't specify a FfsFormatKey. "); System.out.println("Warning: this module doesn't specify a FfsFormatKey. ");
} } else {
else {
throw new BuildException("Can't find the FfsFormatKey [" + buildType + "] attribute in the FPD file!"); throw new BuildException("Can't find the FfsFormatKey [" + buildType + "] attribute in the FPD file!");
} }
if (ffs == null) { return false;
return false;
} else {
return true;
}
} }
/** /**
@ -185,43 +162,36 @@ public class FfsProcess {
**/ **/
public String[] getGenSectionElements(Document document, String basename, String guid, String targetFilename) { public String[] getGenSectionElements(Document document, String basename, String guid, String targetFilename) {
this.basename = basename; this.basename = basename;
if (ffs == null && ffsXmlObject == null) { if (ffsXmlObject == null) {
return new String[0]; return new String[0];
} }
Vector<String> sectionList = new Vector<String>(); Vector<String> sectionList = new Vector<String>();
XmlCursor cursor = null; XmlCursor cursor = null;
try { try {
if (ffsXmlObject == null) { cursor = ffsXmlObject.newCursor();
cursor = XmlObject.Factory.parse(ffs).newCursor();
}
else {
cursor = ffsXmlObject.newCursor();
}
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
int mode = MODE_NONE; int mode = MODE_NONE;
Element root = document.createElement("genffsfile"); Element genffsfileEle = document.createElement("genffsfile");
root.setAttribute("outputDir", "${BIN_DIR}"); genffsfileEle.setAttribute("outputDir", "${BIN_DIR}");
root.setAttribute("moduleType", "${MODULE_TYPE}"); genffsfileEle.setAttribute("moduleType", "${MODULE_TYPE}");
root.setAttribute("BaseName", basename); genffsfileEle.setAttribute("BaseName", basename);
root.setAttribute("fileGuid", guid); genffsfileEle.setAttribute("fileGuid", guid);
if (ffsXmlObject == null) {
cursor.toFirstChild();
}
if (cursor.toFirstChild()) { if (cursor.toFirstChild()) {
do { do {
if (cursor.getName().getLocalPart().equalsIgnoreCase("Attribute")) { if (cursor.getName().getLocalPart().equalsIgnoreCase("Attribute")) {
String name = cursor.getAttributeText(new QName("Name")); String name = cursor.getAttributeText(new QName("Name"));
String value = cursor.getAttributeText(new QName("Value")); String value = cursor.getAttributeText(new QName("Value"));
root.setAttribute(changeAttributeName(name), value); genffsfileEle.setAttribute(changeAttributeName(name), value);
} else if (cursor.getName().getLocalPart().equalsIgnoreCase("Section")) { } else if (cursor.getName().getLocalPart().equalsIgnoreCase("Section")) {
cursor.push(); cursor.push();
dealSection(mode, document, root, cursor, sectionList); dealSection(mode, document, genffsfileEle, cursor, sectionList);
cursor.pop(); cursor.pop();
} else if (cursor.getName().getLocalPart().equalsIgnoreCase("Sections")) { } else if (cursor.getName().getLocalPart().equalsIgnoreCase("Sections")) {
cursor.push(); cursor.push();
dealSections(mode, document, root, cursor, sectionList); dealSections(mode, document, genffsfileEle, cursor, sectionList);
cursor.pop(); cursor.pop();
} }
} while (cursor.toNextSibling()); } while (cursor.toNextSibling());
@ -246,7 +216,7 @@ public class FfsProcess {
targetEle.appendChild(fileEle); targetEle.appendChild(fileEle);
outofdateEle.appendChild(targetEle); outofdateEle.appendChild(targetEle);
Element sequentialEle = document.createElement("sequential"); Element sequentialEle = document.createElement("sequential");
sequentialEle.appendChild(root); sequentialEle.appendChild(genffsfileEle);
outofdateEle.appendChild(sequentialEle); outofdateEle.appendChild(sequentialEle);
ffsNode = outofdateEle; ffsNode = outofdateEle;
return result; return result;

View File

@ -156,18 +156,12 @@ public class FileProcess {
@param root Root node @param root Root node
**/ **/
public synchronized void parseFile(String filename, Node root) throws BuildException { public synchronized void parseFile(String filename, Node root) throws BuildException {
boolean flag = false;
for (int i = 0; i < fileTypes.length; i++) { for (int i = 0; i < fileTypes.length; i++) {
if (filename.endsWith(fileTypes[i][0])) { if (filename.endsWith(fileTypes[i][0])) {
flag = true;
parseFile(filename, fileTypes[i][2], root); parseFile(filename, fileTypes[i][2], root);
return ;
} }
} }
/*
if (!flag) {
throw new BuildException("File [" + filename + "] is not known from its suffix.");
}
*/
} }
/** /**

View File

@ -113,23 +113,18 @@ public class FrameworkBuildTask extends Task{
File buildFile = null; File buildFile = null;
if (msaFiles.size() > 1) { if (msaFiles.size() > 1) {
throw new BuildException("Having more than one MSA file in a directory is not allowed!"); throw new BuildException("Having more than one MSA file in a directory is not allowed!");
} } else if (msaFiles.size() == 1 && activePlatform == null) {
else if (msaFiles.size() == 1 && activePlatform == null) {
throw new BuildException("If trying to build a single module, please set ACTIVE_PLATFORM in file [Tool/Conf/target.txt]. "); throw new BuildException("If trying to build a single module, please set ACTIVE_PLATFORM in file [Tool/Conf/target.txt]. ");
} } else if (msaFiles.size() == 1 && activePlatform != null) {
else if (msaFiles.size() == 1 && activePlatform != null) {
// //
// Build the single module // Build the single module
// //
buildFile = msaFiles.toArray(new File[1])[0]; buildFile = msaFiles.toArray(new File[1])[0];
} } else if (activePlatform != null) {
else if (activePlatform != null) {
buildFile = new File(GlobalData.getWorkspacePath() + File.separatorChar + activePlatform); buildFile = new File(GlobalData.getWorkspacePath() + File.separatorChar + activePlatform);
} } else if (fpdFiles.size() == 1) {
else if (fpdFiles.size() == 1) {
buildFile = fpdFiles.toArray(new File[1])[0]; buildFile = fpdFiles.toArray(new File[1])[0];
} } else if (fpdFiles.size() > 1) {
else if (fpdFiles.size() > 1) {
buildFile = intercommuniteWithUser(); buildFile = intercommuniteWithUser();
} }
// //
@ -191,20 +186,16 @@ public class FrameworkBuildTask extends Task{
private File intercommuniteWithUser(){ private File intercommuniteWithUser(){
File file = null; File file = null;
if (fpdFiles.size() + msaFiles.size() > 1) { if (fpdFiles.size() > 1) {
File[] allFiles = new File[fpdFiles.size() + msaFiles.size()]; File[] allFiles = new File[fpdFiles.size()];
int index = 0; int index = 0;
Iterator<File> iter = fpdFiles.iterator(); Iterator<File> iter = fpdFiles.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
allFiles[index] = iter.next(); allFiles[index] = iter.next();
index++; index++;
} }
iter = msaFiles.iterator();
while (iter.hasNext()) { System.out.println("Finding " + allFiles.length + " FPD files: ");
allFiles[index] = iter.next();
index++;
}
System.out.println("Finding " + allFiles.length + " FPD and MSA files: ");
for (int i = 0; i < allFiles.length; i++) { for (int i = 0; i < allFiles.length; i++) {
System.out.println("[" + (i + 1) + "]: " + allFiles[i].getName()); System.out.println("[" + (i + 1) + "]: " + allFiles[i].getName());
} }
@ -234,13 +225,9 @@ public class FrameworkBuildTask extends Task{
flag = true; flag = true;
} }
} while (flag); } while (flag);
} } else if (fpdFiles.size() == 1) {
else if (fpdFiles.size() == 1) {
file = fpdFiles.toArray(new File[1])[0]; file = fpdFiles.toArray(new File[1])[0];
} }
else if (msaFiles.size() == 1) {
file = msaFiles.toArray(new File[1])[0];
}
return file; return file;
} }
@ -248,8 +235,7 @@ public class FrameworkBuildTask extends Task{
public void setType(String type) { public void setType(String type) {
if (type.equalsIgnoreCase("clean") || type.equalsIgnoreCase("cleanall")) { if (type.equalsIgnoreCase("clean") || type.equalsIgnoreCase("cleanall")) {
this.type = type.toLowerCase(); this.type = type.toLowerCase();
} } else {
else {
this.type = "all"; this.type = "all";
} }
} }
@ -265,22 +251,19 @@ public class FrameworkBuildTask extends Task{
String str = getValue("TARGET", targetFileInfo); String str = getValue("TARGET", targetFileInfo);
if (str == null || str.trim().equals("")) { if (str == null || str.trim().equals("")) {
envToolChainInfo.addTargets("*"); envToolChainInfo.addTargets("*");
} } else {
else {
envToolChainInfo.addTargets(str); envToolChainInfo.addTargets(str);
} }
str = getValue("TOOL_CHAIN_TAG", targetFileInfo); str = getValue("TOOL_CHAIN_TAG", targetFileInfo);
if (str == null || str.trim().equals("")) { if (str == null || str.trim().equals("")) {
envToolChainInfo.addTagnames("*"); envToolChainInfo.addTagnames("*");
} } else {
else {
envToolChainInfo.addTagnames(str); envToolChainInfo.addTagnames(str);
} }
str = getValue("TARGET_ARCH", targetFileInfo); str = getValue("TARGET_ARCH", targetFileInfo);
if (str == null || str.trim().equals("")) { if (str == null || str.trim().equals("")) {
envToolChainInfo.addArchs("*"); envToolChainInfo.addArchs("*");
} } else {
else {
envToolChainInfo.addArchs(str); envToolChainInfo.addArchs(str);
} }
GlobalData.setToolChainEnvInfo(envToolChainInfo); GlobalData.setToolChainEnvInfo(envToolChainInfo);

View File

@ -89,11 +89,8 @@ public class GenBuildTask extends Ant {
/// ///
File msaFile; File msaFile;
/// private String type = "all";
///
///
private String type = "all"; // = "build";
/// ///
/// Module's Identification. /// Module's Identification.
/// ///
@ -123,8 +120,7 @@ public class GenBuildTask extends Ant {
GenBuildLogger logger = new GenBuildLogger(getProject()); GenBuildLogger logger = new GenBuildLogger(getProject());
EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL")); EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger); EdkLog.setLogger(logger);
// remove !!
try {
pushProperties(); pushProperties();
// //
// Enable all specified properties // Enable all specified properties
@ -152,8 +148,7 @@ public class GenBuildTask extends Ant {
Map<String, XmlObject> doc = GlobalData.getNativeMsa(moduleId); Map<String, XmlObject> doc = GlobalData.getNativeMsa(moduleId);
SurfaceAreaQuery.setDoc(doc); SurfaceAreaQuery.setDoc(doc);
moduleId = SurfaceAreaQuery.getMsaHeader(); moduleId = SurfaceAreaQuery.getMsaHeader();
} } else {
else {
Map<String, XmlObject> doc = GlobalData.getNativeMsa(msaFile); Map<String, XmlObject> doc = GlobalData.getNativeMsa(msaFile);
SurfaceAreaQuery.setDoc(doc); SurfaceAreaQuery.setDoc(doc);
moduleId = SurfaceAreaQuery.getMsaHeader(); moduleId = SurfaceAreaQuery.getMsaHeader();
@ -161,8 +156,7 @@ public class GenBuildTask extends Ant {
String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED",null); String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED",null);
if (producedLibraryClasses.length == 0) { if (producedLibraryClasses.length == 0) {
moduleId.setLibrary(false); moduleId.setLibrary(false);
} } else {
else {
moduleId.setLibrary(true); moduleId.setLibrary(true);
} }
@ -174,8 +168,7 @@ public class GenBuildTask extends Ant {
// Single Module build // Single Module build
// //
prepareSingleModuleBuild(); prepareSingleModuleBuild();
} } else {
else {
// //
// Platform build. Restore the platform related info // Platform build. Restore the platform related info
// //
@ -191,8 +184,8 @@ public class GenBuildTask extends Ant {
} }
// //
// If single module : intersection MSA supported ARCHs and tools def!! // If single module : get arch from pass down, otherwise intersection MSA
// else, get arch from pass down // supported ARCHs and tools def
// //
Set<String> archListSupByToolChain = new LinkedHashSet<String>(); Set<String> archListSupByToolChain = new LinkedHashSet<String>();
String[] archs = GlobalData.getToolChainInfo().getArchs(); String[] archs = GlobalData.getToolChainInfo().getArchs();
@ -211,9 +204,8 @@ public class GenBuildTask extends Ant {
archSet.add(fpdArchList[i]); archSet.add(fpdArchList[i]);
} }
} }
} } else {
else { archSet = archListSupByToolChain;
archSet = archListSupByToolChain;
} }
String[] archList = archSet.toArray(new String[archSet.size()]); String[] archList = archSet.toArray(new String[archSet.size()]);
@ -296,20 +288,16 @@ public class GenBuildTask extends Ant {
if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) { if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) {
applyBuild(targetList[i], toolchainList[j], fpdModuleId); applyBuild(targetList[i], toolchainList[j], fpdModuleId);
} } else if (type.equalsIgnoreCase("clean")) {
else if (type.equalsIgnoreCase("clean")) {
applyClean(fpdModuleId); applyClean(fpdModuleId);
} } else if (type.equalsIgnoreCase("cleanall")) {
else if (type.equalsIgnoreCase("cleanall")) {
applyCleanall(fpdModuleId); applyCleanall(fpdModuleId);
} }
} }
} }
} }
popProperties(); popProperties();
}catch (Exception e){
throw new BuildException(e.getMessage());
}
} }
/** /**
@ -331,7 +319,7 @@ public class GenBuildTask extends Ant {
moduleId.setPackage(packageId); moduleId.setPackage(packageId);
// //
// Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method) // Read ACTIVE_PLATFORM's FPD file
// //
String filename = getProject().getProperty("PLATFORM_FILE"); String filename = getProject().getProperty("PLATFORM_FILE");
@ -342,7 +330,7 @@ public class GenBuildTask extends Ant {
PlatformIdentification platformId = GlobalData.getPlatform(filename); PlatformIdentification platformId = GlobalData.getPlatform(filename);
// //
// Read FPD file // Read FPD file (Call FpdParserTask's method)
// //
FpdParserTask fpdParser = new FpdParserTask(); FpdParserTask fpdParser = new FpdParserTask();
fpdParser.setProject(getProject()); fpdParser.setProject(getProject());
@ -360,6 +348,8 @@ public class GenBuildTask extends Ant {
/** /**
Set Module-Related information to properties. Set Module-Related information to properties.
@param arch current build ARCH
**/ **/
private void setModuleCommonProperties(String arch) { private void setModuleCommonProperties(String arch) {
// //
@ -381,8 +371,7 @@ public class GenBuildTask extends Ant {
String baseName = SurfaceAreaQuery.getModuleOutputFileBasename(); String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();
if (baseName == null) { if (baseName == null) {
getProject().setProperty("BASE_NAME", moduleId.getName()); getProject().setProperty("BASE_NAME", moduleId.getName());
} } else {
else {
getProject().setProperty("BASE_NAME", baseName); getProject().setProperty("BASE_NAME", baseName);
} }
getProject().setProperty("GUID", moduleId.getGuid()); getProject().setProperty("GUID", moduleId.getGuid());
@ -423,8 +412,7 @@ public class GenBuildTask extends Ant {
// //
if (arch.equalsIgnoreCase("EBC")) { if (arch.equalsIgnoreCase("EBC")) {
getProject().setProperty("ENTRYPOINT", "EfiStart"); getProject().setProperty("ENTRYPOINT", "EfiStart");
} } else {
else {
getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint"); getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
} }
@ -462,8 +450,7 @@ public class GenBuildTask extends Ant {
String extName = GlobalData.getCommandSetting(key, fpdModuleId); String extName = GlobalData.getCommandSetting(key, fpdModuleId);
if ( extName != null && ! extName.equalsIgnoreCase("")) { if ( extName != null && ! extName.equalsIgnoreCase("")) {
getProject().setProperty(cmd[m] + "_EXT", extName); getProject().setProperty(cmd[m] + "_EXT", extName);
} } else {
else {
getProject().setProperty(cmd[m] + "_EXT", ""); getProject().setProperty(cmd[m] + "_EXT", "");
} }
@ -483,8 +470,7 @@ public class GenBuildTask extends Ant {
String spath = GlobalData.getCommandSetting(key, fpdModuleId); String spath = GlobalData.getCommandSetting(key, fpdModuleId);
if (spath != null) { if (spath != null) {
getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/")); getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
} } else {
else {
getProject().setProperty(cmd[m] + "_SPATH", ""); getProject().setProperty(cmd[m] + "_SPATH", "");
} }
@ -495,8 +481,7 @@ public class GenBuildTask extends Ant {
String dpath = GlobalData.getCommandSetting(key, fpdModuleId); String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
if (dpath != null) { if (dpath != null) {
getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/")); getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
} } else {
else {
getProject().setProperty(cmd[m] + "_DPATH", ""); getProject().setProperty(cmd[m] + "_DPATH", "");
} }
} }
@ -543,7 +528,7 @@ public class GenBuildTask extends Ant {
this.type = type; this.type = type;
} }
private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws EdkException{ private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws BuildException{
// //
// AutoGen // AutoGen
// //
@ -555,8 +540,13 @@ public class GenBuildTask extends Ant {
// //
// Get compiler flags // Get compiler flags
// //
getCompilerFlags(buildTarget, buildTagname, fpdModuleId); try {
getCompilerFlags(buildTarget, buildTagname, fpdModuleId);
}
catch (EdkException ee) {
throw new BuildException(ee.getMessage());
}
// //
// Prepare LIBS // Prepare LIBS
// //
@ -573,12 +563,10 @@ public class GenBuildTask extends Ant {
// //
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml"); GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
Ant ant = new Ant();
ant.setProject(getProject()); String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"); antCall(antFilename, null);
ant.setInheritAll(true);
ant.init();
ant.execute();
return ; return ;
} }
@ -594,12 +582,8 @@ public class GenBuildTask extends Ant {
// //
// Ant call ${BASE_NAME}_build.xml // Ant call ${BASE_NAME}_build.xml
// //
Ant ant = new Ant(); String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
ant.setProject(getProject()); antCall(antFilename, null);
ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
ant.setInheritAll(true);
ant.init();
ant.execute();
} }
private void applyClean(FpdModuleIdentification fpdModuleId){ private void applyClean(FpdModuleIdentification fpdModuleId){
@ -609,27 +593,15 @@ public class GenBuildTask extends Ant {
// //
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml"); GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml");
Ant ant = new Ant();
ant.setProject(getProject()); String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"); antCall(antFilename, "clean");
ant.setTarget("clean");
ant.setInheritAll(true);
ant.init();
ant.execute();
return ; return ;
} }
Ant ant = new Ant(); String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
ant.setProject(getProject()); antCall(antFilename, "clean");
ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
ant.setTarget("clean");
ant.setInheritAll(true);
ant.init();
ant.execute();
//
// Delete current module's DEST_DIR_OUTPUT
// TBD
} }
private void applyCleanall(FpdModuleIdentification fpdModuleId){ private void applyCleanall(FpdModuleIdentification fpdModuleId){
@ -639,32 +611,30 @@ public class GenBuildTask extends Ant {
// //
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) { if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml"); GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml");
Ant ant = new Ant();
ant.setProject(getProject()); String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml"); antCall(antFilename, "cleanall");
ant.setTarget("cleanall");
ant.setInheritAll(true);
ant.init();
ant.execute();
return ; return ;
} }
String antFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
antCall(antFilename, "cleanall");
}
private void antCall(String antFilename, String target) {
Ant ant = new Ant(); Ant ant = new Ant();
ant.setProject(getProject()); ant.setProject(getProject());
ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml"); ant.setAntfile(antFilename);
ant.setTarget("cleanall"); if (target != null) {
ant.setTarget(target);
}
ant.setInheritAll(true); ant.setInheritAll(true);
ant.init(); ant.init();
ant.execute(); ant.execute();
//
// Delete current module's DEST_DIR_OUTPUT
// TBD
} }
/** /**
Separate the string and instore in set. Separate the string and instore in set.

View File

@ -82,9 +82,6 @@ public class FpdParserTask extends Task {
private PlatformIdentification platformId; private PlatformIdentification platformId;
///
///
///
private String type; private String type;
/// ///
@ -127,7 +124,10 @@ public class FpdParserTask extends Task {
Surface area is not valid. Surface area is not valid.
**/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
// Remove !! //
// If fpdFile is not specified,
// then try to get FPD file by platformName
//
if ( fpdFile == null) { if ( fpdFile == null) {
if (platformName == null) { if (platformName == null) {
throw new BuildException("FpdParserTask parameter error. Please specify either the platform name or FPD file!"); throw new BuildException("FpdParserTask parameter error. Please specify either the platform name or FPD file!");
@ -150,9 +150,9 @@ public class FpdParserTask extends Task {
// For every Target and ToolChain // For every Target and ToolChain
// //
String[] targetList = GlobalData.getToolChainInfo().getTargets(); String[] targetList = GlobalData.getToolChainInfo().getTargets();
for (int i = 0; i < targetList.length; i++){ for (int i = 0; i < targetList.length; i++) {
String[] toolchainList = GlobalData.getToolChainInfo().getTagnames(); String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
for(int j = 0; j < toolchainList.length; j++){ for(int j = 0; j < toolchainList.length; j++) {
// //
// Prepare FV_DIR // Prepare FV_DIR
// //
@ -187,8 +187,6 @@ public class FpdParserTask extends Task {
ant.setInheritAll(true); ant.setInheritAll(true);
ant.init(); ant.init();
ant.execute(); ant.execute();
// GlobalData.log.info("Fpd build end. ");
} }
/** /**
@ -409,7 +407,6 @@ public class FpdParserTask extends Task {
// //
SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId)); SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));
String fvBinding = SurfaceAreaQuery.getModuleFvBindingKeyword(); String fvBinding = SurfaceAreaQuery.getModuleFvBindingKeyword();
SurfaceAreaQuery.pop();
fpdModuleId.setFvBinding(fvBinding); fpdModuleId.setFvBinding(fvBinding);
updateFvs(fvBinding, fpdModuleId); updateFvs(fvBinding, fpdModuleId);
@ -418,9 +415,9 @@ public class FpdParserTask extends Task {
// Prepare for out put file name // Prepare for out put file name
// //
ModuleIdentification moduleId = fpdModuleId.getModule(); ModuleIdentification moduleId = fpdModuleId.getModule();
SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));
String baseName = SurfaceAreaQuery.getModuleOutputFileBasename(); String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();
SurfaceAreaQuery.pop();
if (baseName == null) { if (baseName == null) {
baseName = moduleId.getName(); baseName = moduleId.getName();
} }
@ -431,7 +428,6 @@ public class FpdParserTask extends Task {
// //
// parse module build options, if any // parse module build options, if any
// //
SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));
GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false)); GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));
GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true)); GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));
SurfaceAreaQuery.pop(); SurfaceAreaQuery.pop();
@ -496,8 +492,7 @@ public class FpdParserTask extends Task {
if (fvs.containsKey(fvNameArray[i])) { if (fvs.containsKey(fvNameArray[i])) {
Set<FpdModuleIdentification> set = fvs.get(fvNameArray[i]); Set<FpdModuleIdentification> set = fvs.get(fvNameArray[i]);
set.add(fpdModuleId); set.add(fpdModuleId);
} } else {
else {
Set<FpdModuleIdentification> set = new LinkedHashSet<FpdModuleIdentification>(); Set<FpdModuleIdentification> set = new LinkedHashSet<FpdModuleIdentification>();
set.add(fpdModuleId); set.add(fpdModuleId);
fvs.put(fvNameArray[i], set); fvs.put(fvNameArray[i], set);
@ -573,6 +568,4 @@ public class FpdParserTask extends Task {
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
} }

View File

@ -39,6 +39,11 @@ import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
/**
class PlatformBuildFileGenerator is used to generate ${PLATFORM}_build.xml file.
@since GenBuild 1.0
**/
public class PlatformBuildFileGenerator { public class PlatformBuildFileGenerator {
private String platformName; private String platformName;

View File

@ -175,7 +175,7 @@ public class GlobalData {
// //
// validate FrameworkDatabaseFile // validate FrameworkDatabaseFile
// //
if (! db.validate()) { if (!db.validate()) {
throw new BuildException("Framework Database file [" + dbFile.getPath() + "] format is invalid!"); throw new BuildException("Framework Database file [" + dbFile.getPath() + "] format is invalid!");
} }
// //
@ -201,14 +201,14 @@ public class GlobalData {
while (iter.hasNext()) { while (iter.hasNext()) {
String fileName = iter.next().getStringValue(); String fileName = iter.next().getStringValue();
File fpdFile = new File(workspaceDir + File.separatorChar + fileName); File fpdFile = new File(workspaceDir + File.separatorChar + fileName);
if ( ! fpdFile.exists() ) { if ( !fpdFile.exists() ) {
throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. "); throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. ");
} }
XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile); XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile);
// //
// Verify FPD file, if is invalid, throw Exception // Verify FPD file, if is invalid, throw Exception
// //
if (! fpdDoc.validate()) { if (!fpdDoc.validate()) {
throw new BuildException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!"); throw new BuildException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");
} }
// //
@ -259,8 +259,7 @@ public class GlobalData {
} }
if (msaFile == null){ if (msaFile == null){
throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!"); throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");
} } else {
else {
return msaFile; return msaFile;
} }
} }
@ -285,8 +284,7 @@ public class GlobalData {
} }
if (packageId == null){ if (packageId == null){
throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!"); throw new BuildException("Can't find Module [" + moduleId.getName() + "] in any SPD package!");
} } else {
else {
return packageId; return packageId;
} }
} }
@ -320,16 +318,14 @@ public class GlobalData {
} }
/** /**
Query overrided module surface area information. If current is Package Query module surface area information.
or Platform build, also include the information from FPD file.
<p>Note that surface area parsing is incremental. That means the method will <p>Note that surface area parsing is incremental. That means the method will
only parse the MSA and MBD files if necessary. </p> only parse the MSA files if necessary. </p>
@param moduleName the base name of the module @param fpdModuleId Module ID with arch
@return the overrided module surface area information @return ModuleSA info and MSA info for fpdModuleId
@throws BuildException @throws BuildException Can't find MSA
MSA or MBD is not valid
**/ **/
public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws BuildException { public synchronized static Map<String, XmlObject> getDoc(FpdModuleIdentification fpdModuleId) throws BuildException {
if (parsedModules.containsKey(fpdModuleId)) { if (parsedModules.containsKey(fpdModuleId)) {
@ -387,7 +383,7 @@ public class GlobalData {
} }
public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws BuildException { public synchronized static Map<String, XmlObject> getNativeMsa(File msaFile) throws BuildException {
if (! msaFile.exists()) { if (!msaFile.exists()) {
throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!"); throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] can't be found!");
} }
try { try {
@ -395,7 +391,7 @@ public class GlobalData {
// //
// Validate File if they accord with XML Schema // Validate File if they accord with XML Schema
// //
if ( ! doc.validate()){ if ( !doc.validate()){
throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] format is invalid!"); throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] format is invalid!");
} }
// //
@ -438,16 +434,12 @@ public class GlobalData {
GlobalData.fpdDynamicPcds = fpdDynamicPcds; GlobalData.fpdDynamicPcds = fpdDynamicPcds;
} }
//////////////////////////////////////////////
//////////////////////////////////////////////
public static Set<ModuleIdentification> getModules(PackageIdentification packageId){ public static Set<ModuleIdentification> getModules(PackageIdentification packageId){
Spd spd = spdTable.get(packageId); Spd spd = spdTable.get(packageId);
if (spd == null ) { if (spd == null ) {
Set<ModuleIdentification> dummy = new HashSet<ModuleIdentification>(); Set<ModuleIdentification> dummy = new HashSet<ModuleIdentification>();
return dummy; return dummy;
} } else {
else {
return spd.getModules(); return spd.getModules();
} }
} }
@ -611,10 +603,7 @@ public class GlobalData {
} }
public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws BuildException { public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws BuildException {
// System.out.println("1");
// System.out.println("##" + moduleId.getGuid());
PackageIdentification packageId = getPackageForModule(moduleId); PackageIdentification packageId = getPackageForModule(moduleId);
// System.out.println("" + packageId.getGuid());
moduleId.setPackage(packageId); moduleId.setPackage(packageId);
Spd spd = spdTable.get(packageId); Spd spd = spdTable.get(packageId);
if (spd == null) { if (spd == null) {
@ -637,7 +626,16 @@ public class GlobalData {
public synchronized static Set<PackageIdentification> getPackageList(){ public synchronized static Set<PackageIdentification> getPackageList(){
return packageList; return packageList;
} }
///// remove!!
/**
BUGBUG: It is a walk around method. If do not clone, can't query info with
XPath correctly.
@param object XmlObject
@param deep flag for deep clone
@return XmlObject after clone
@throws BuildException parse original XmlObject error.
**/
private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws BuildException { private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws BuildException {
if ( object == null) { if ( object == null) {
return null; return null;

View File

@ -86,7 +86,6 @@ public class OutputManager {
@param type the module build type (MODULE or UNIFIED) @param type the module build type (MODULE or UNIFIED)
**/ **/
public void update(Project project) { public void update(Project project) {
// GlobalData.log.info("" + userdir + ":" + type);
// //
// Default mode is UNIFIED. // Default mode is UNIFIED.
// //
@ -183,6 +182,7 @@ public class OutputManager {
buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir; buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir;
} }
} }
// //
// Set to property // Set to property
// //