Remove FrameworkLogger in FrameworkTasks and EdkException in GenBuild. Update EdkLog to accept one more parameter. Remove all System.out in GenBuild.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1474 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
wuyizhong
2006-09-06 05:58:31 +00:00
parent 7ab9a5e580
commit 91f7d58229
26 changed files with 205 additions and 322 deletions

View File

@@ -26,6 +26,7 @@ import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.common.definitions.EdkDefinitions;
import org.tianocore.common.logger.EdkLog;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -129,7 +130,7 @@ public class FfsProcess {
// Otherwise report warning message
//
if (buildType == null) {
System.out.println("Warning: this module doesn't specify a FfsFormatKey. ");
EdkLog.log(EdkLog.EDK_WARNING, "Warning: this module doesn't specify a FfsFormatKey. ");
} else {
throw new BuildException("Can't find the FfsFormatKey [" + buildType + "] attribute in the FPD file!");
}

View File

@@ -15,6 +15,7 @@ package org.tianocore.build;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Hashtable;
import java.util.Iterator;
@@ -24,6 +25,10 @@ import java.util.Set;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.tianocore.build.exception.AutoGenException;
import org.tianocore.build.exception.GenBuildException;
import org.tianocore.build.exception.PcdAutogenException;
import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;
import org.tianocore.build.fpd.FpdParserForThread;
import org.tianocore.build.fpd.FpdParserTask;
import org.tianocore.build.global.GenBuildLogger;
@@ -31,6 +36,7 @@ import org.tianocore.build.global.GlobalData;
import org.tianocore.build.toolchain.ConfigReader;
import org.tianocore.build.toolchain.ToolChainInfo;
import org.tianocore.common.definitions.ToolDefinitions;
import org.tianocore.common.exception.EdkException;
import org.tianocore.common.logger.EdkLog;
/**
@@ -105,6 +111,37 @@ public class FrameworkBuildTask extends Task{
private String type = "all";
public void execute() throws BuildException {
try {
processFrameworkBuild();
} catch (PcdAutogenException e) {
//
// Add more logic process here
//
throw new BuildException(e.getMessage());
} catch (AutoGenException e) {
//
// Add more logic process here
//
throw new BuildException(e.getMessage());
} catch (PlatformPcdPreprocessBuildException e) {
//
// Add more logic process here
//
throw new BuildException(e.getMessage());
} catch (GenBuildException e) {
//
// Add more logic process here
//
throw new BuildException(e.getMessage());
} catch (EdkException e) {
//
// Add more logic process here
//
throw new BuildException(e.getMessage());
}
}
private void processFrameworkBuild() throws EdkException, GenBuildException, AutoGenException, PcdAutogenException, PlatformPcdPreprocessBuildException {
//
// set Logger
//
@@ -143,7 +180,7 @@ public class FrameworkBuildTask extends Task{
}
}
}
} catch (Exception e) {
} catch (IOException e) {
throw new BuildException(e.getMessage());
}
@@ -199,12 +236,12 @@ public class FrameworkBuildTask extends Task{
// Build every FPD files (PLATFORM build)
//
if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {
System.out.println("Processing the FPD file [" + buildFile.getPath() + "] ..>> ");
EdkLog.log(this, "Processing the FPD file [" + buildFile.getPath() + "] ..>> ");
//
// Iff for platform build will enable the multi-thread if set in target.txt
//
if (multithread && type.equalsIgnoreCase("all")) {
System.out.println("Multi-thread build is enabled. ");
EdkLog.log(this, "Multi-thread build is enabled. ");
FpdParserForThread fpdParserForThread = new FpdParserForThread();
fpdParserForThread.setType(type);
fpdParserForThread.setProject(getProject());
@@ -237,8 +274,8 @@ public class FrameworkBuildTask extends Task{
//
else if (buildFile.getName().endsWith(ToolDefinitions.MSA_EXTENSION)) {
File tmpFile = new File(GlobalData.getWorkspacePath() + File.separatorChar + activePlatform);
System.out.println("Using the FPD file [" + tmpFile.getPath() + "] for the active platform. ");
System.out.println("Processing the MSA file [" + buildFile.getPath() + "] ..>> ");
EdkLog.log(this, "Using the FPD file [" + tmpFile.getPath() + "] for the active platform. ");
EdkLog.log(this, "Processing the MSA file [" + buildFile.getPath() + "] ..>> ");
GenBuildTask genBuildTask = new GenBuildTask();
genBuildTask.setSingleModuleBuild(true);
genBuildTask.setType(type);
@@ -290,13 +327,13 @@ public class FrameworkBuildTask extends Task{
index++;
}
System.out.println("Finding " + allFiles.length + " FPD files: ");
EdkLog.log(this, "Finding " + allFiles.length + " FPD files: ");
for (int i = 0; i < allFiles.length; i++) {
System.out.println("[" + (i + 1) + "]: " + allFiles[i].getName());
}
boolean flag = true;
System.out.print("Please select one of the following FPD files to build:[1] ");
EdkLog.log(this, "Please select one of the following FPD files to build:[1] ");
do{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
@@ -308,7 +345,7 @@ public class FrameworkBuildTask extends Task{
}
int indexSelect = Integer.parseInt(str);
if (indexSelect <=0 || indexSelect > allFiles.length) {
System.out.print("Please enter a number between [1.." + allFiles.length + "]:[1] ");
EdkLog.log(this, "Please enter a number between [1.." + allFiles.length + "]:[1] ");
continue ;
} else {
file = allFiles[indexSelect - 1];
@@ -316,7 +353,7 @@ public class FrameworkBuildTask extends Task{
continue ;
}
} catch (Exception e) {
System.out.print("Please enter a valid number:[1] ");
EdkLog.log(this, "Please enter a valid number:[1] ");
flag = true;
}
} while (flag);
@@ -335,68 +372,62 @@ public class FrameworkBuildTask extends Task{
}
}
private void readTargetFile(){
try {
String targetFile = getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + targetFilename;
String[][] targetFileInfo = ConfigReader.parse(targetFile);
//
// Get ToolChain Info from target.txt
//
ToolChainInfo envToolChainInfo = new ToolChainInfo();
String str = getValue(ToolDefinitions.TARGET_KEY_TARGET, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addTargets("*");
} else {
envToolChainInfo.addTargets(str);
}
str = getValue(ToolDefinitions.TARGET_KEY_TOOLCHAIN, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addTagnames("*");
} else {
envToolChainInfo.addTagnames(str);
}
str = getValue(ToolDefinitions.TARGET_KEY_ARCH, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addArchs("*");
} else {
envToolChainInfo.addArchs(str);
}
GlobalData.setToolChainEnvInfo(envToolChainInfo);
str = getValue(ToolDefinitions.TARGET_KEY_TOOLS_DEF, targetFileInfo);
if (str != null && str.trim().length() > 0) {
toolsDefFilename = str;
}
str = getValue(ToolDefinitions.TARGET_KEY_ACTIVE_PLATFORM, targetFileInfo);
if (str != null && ! str.trim().equals("")) {
if ( ! str.endsWith(".fpd")) {
throw new BuildException("FPD file's extension must be \"" + ToolDefinitions.FPD_EXTENSION + "\"!");
}
activePlatform = str;
}
str = getValue(ToolDefinitions.TARGET_KEY_MULTIPLE_THREAD, targetFileInfo);
if (str != null && str.trim().equalsIgnoreCase("Enable")) {
multithread = true;
}
str = getValue(ToolDefinitions.TARGET_KEY_MAX_CONCURRENT_THREAD_NUMBER, targetFileInfo);
if (str != null ) {
try {
int threadNum = Integer.parseInt(str);
if (threadNum > 0) {
MAX_CONCURRENT_THREAD_NUMBER = threadNum;
}
} catch (Exception enuma) {
}
}
private void readTargetFile() throws EdkException{
String targetFile = getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + targetFilename;
String[][] targetFileInfo = ConfigReader.parse(targetFile);
//
// Get ToolChain Info from target.txt
//
ToolChainInfo envToolChainInfo = new ToolChainInfo();
String str = getValue(ToolDefinitions.TARGET_KEY_TARGET, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addTargets("*");
} else {
envToolChainInfo.addTargets(str);
}
catch (Exception ex) {
throw new BuildException(ex.getMessage());
str = getValue(ToolDefinitions.TARGET_KEY_TOOLCHAIN, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addTagnames("*");
} else {
envToolChainInfo.addTagnames(str);
}
str = getValue(ToolDefinitions.TARGET_KEY_ARCH, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addArchs("*");
} else {
envToolChainInfo.addArchs(str);
}
GlobalData.setToolChainEnvInfo(envToolChainInfo);
str = getValue(ToolDefinitions.TARGET_KEY_TOOLS_DEF, targetFileInfo);
if (str != null && str.trim().length() > 0) {
toolsDefFilename = str;
}
str = getValue(ToolDefinitions.TARGET_KEY_ACTIVE_PLATFORM, targetFileInfo);
if (str != null && ! str.trim().equals("")) {
if ( ! str.endsWith(".fpd")) {
throw new BuildException("FPD file's extension must be \"" + ToolDefinitions.FPD_EXTENSION + "\"!");
}
activePlatform = str;
}
str = getValue(ToolDefinitions.TARGET_KEY_MULTIPLE_THREAD, targetFileInfo);
if (str != null && str.trim().equalsIgnoreCase("Enable")) {
multithread = true;
}
str = getValue(ToolDefinitions.TARGET_KEY_MAX_CONCURRENT_THREAD_NUMBER, targetFileInfo);
if (str != null ) {
try {
int threadNum = Integer.parseInt(str);
if (threadNum > 0) {
MAX_CONCURRENT_THREAD_NUMBER = threadNum;
}
} catch (Exception enuma) {
}
}
}

View File

@@ -35,6 +35,7 @@ import org.apache.xmlbeans.XmlObject;
import org.tianocore.common.definitions.ToolDefinitions;
import org.tianocore.common.exception.EdkException;
import org.tianocore.common.logger.EdkLog;
import org.tianocore.build.autogen.AutoGen;
import org.tianocore.build.fpd.FpdParserTask;
import org.tianocore.build.global.GlobalData;
@@ -231,7 +232,7 @@ public class GenBuildTask extends Ant {
// Whether the module is built before
//
if (moduleId.isLibrary() == false && GlobalData.hasFpdModuleSA(fpdModuleId) == false) {
System.out.println("\nWARNING: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n");
EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: " + moduleId + " for " + archList[k] + " was not found in current platform FPD file!\n");
continue;
} else if (GlobalData.isModuleBuilt(fpdModuleId)) {
break;
@@ -256,7 +257,7 @@ public class GenBuildTask extends Ant {
// don't do anything if no tools found
//
if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) {
System.out.println("Warning: No build issued. No tools were found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
EdkLog.log(this, EdkLog.EDK_WARNING, "Warning: No build issued. No tools were found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
continue;
}
@@ -266,8 +267,8 @@ public class GenBuildTask extends Ant {
//
getProject().setProperty("TOOLCHAIN", toolchainList[j]);
System.out.println("Build " + moduleId + " start >>>");
System.out.println("Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]);
EdkLog.log(this, "Build " + moduleId + " start >>>");
EdkLog.log(this, "Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]);
saq.push(GlobalData.getDoc(fpdModuleId));
//
@@ -576,7 +577,7 @@ public class GenBuildTask extends Ant {
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
System.out.println("Call user-defined " + moduleId.getName() + "_build.xml");
EdkLog.log(this, "Call user-defined " + moduleId.getName() + "_build.xml");
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
antCall(antFilename, null);
@@ -606,7 +607,7 @@ public class GenBuildTask extends Ant {
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");
EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
antCall(antFilename, "clean");
@@ -624,7 +625,7 @@ public class GenBuildTask extends Ant {
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");
EdkLog.log(this, "Calling user-defined " + moduleId.getName() + "_build.xml");
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
antCall(antFilename, "cleanall");

View File

@@ -1,36 +0,0 @@
/** @file
EntityException class.
The class handle the exception throwed by entity class.
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.exception;
/**
The class handle the exception throwed by entity class.
**/
public class EdkException extends Exception {
static final long serialVersionUID = -8034897190740066938L;
/**
Constructure function
@param expStr exception message string.
**/
public EdkException(String expStr) {
super("[EdkException]:" + expStr);
}
public EdkException() {
super();
}
}

View File

@@ -613,7 +613,7 @@ public class PlatformBuildFileGenerator {
root.appendChild(recursiveNode(childItem, document));
}
else if (childItem.getNodeType() == Node.TEXT_NODE){
if ( ! childItem.getNodeValue().trim().equalsIgnoreCase("")) {
if (!childItem.getNodeValue().trim().equalsIgnoreCase("")) {
root.setTextContent(childItem.getNodeValue());
}
}

View File

@@ -23,6 +23,7 @@ import java.util.List;
import java.util.Vector;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.tianocore.common.logger.EdkLog;
import org.tianocore.common.logger.LogMethod;
@@ -72,40 +73,40 @@ public class GenBuildLogger implements LogMethod {
//
switch (msgLevel) {
case EdkLog.EDK_ALWAYS:
this.project.log(msg, Project.MSG_INFO);
log(msgSource, msg, Project.MSG_INFO);
break;
case EdkLog.EDK_ERROR:
if (flag) {
this.project.log(msg, Project.MSG_ERR);
log(msgSource, msg, Project.MSG_ERR);
} else {
this.project.log(msg, Project.MSG_ERR);
log(msgSource, msg, Project.MSG_ERR);
v.add(msg);
}
break;
case EdkLog.EDK_WARNING:
if (flag) {
this.project.log(msg, Project.MSG_WARN);
log(msgSource, msg, Project.MSG_WARN);
} else {
v.add(msg);
}
break;
case EdkLog.EDK_INFO:
if (flag) {
this.project.log(msg, Project.MSG_INFO);
log(msgSource, msg, Project.MSG_INFO);
} else {
v.add(msg);
}
break;
case EdkLog.EDK_VERBOSE:
if (flag) {
this.project.log(msg, Project.MSG_VERBOSE);
log(msgSource, msg, Project.MSG_VERBOSE);
} else {
v.add(msg);
}
break;
case EdkLog.EDK_DEBUG:
if (flag) {
this.project.log(msg, Project.MSG_DEBUG);
log(msgSource, msg, Project.MSG_DEBUG);
} else {
v.add(msg);
}
@@ -119,4 +120,12 @@ public class GenBuildLogger implements LogMethod {
//
}
private void log(Object msgSource, String msg, int level) {
if (msgSource instanceof Task) {
this.project.log((Task)msgSource, msg, level);
} else {
this.project.log(msg, level);
}
}
}

View File

@@ -161,7 +161,7 @@ public class GlobalData {
// CONF dir + tools definition file name
//
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);
System.out.println("Using tool definiton file [" + toolsDefFile.getPath() + "].");
EdkLog.log("Using tool definiton file [" + toolsDefFile.getPath() + "].");
try {
toolsDef = new ToolChainConfig(toolsDefFile);
} catch (Exception e) {
@@ -661,8 +661,8 @@ public class GlobalData {
}
toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());
toolChainInfo.normalize();
System.out.println("Current build tool chain information summary: ");
System.out.println(toolChainInfo + "");
EdkLog.log("Current build tool chain information summary: ");
EdkLog.log(toolChainInfo + "");
}
return toolChainInfo;
}