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

@ -59,6 +59,18 @@ public class EdkLog {
logger.putMessage(null, EDK_INFO, message);
}
}
public static void log(Object o, int level, String message) {
if (level <= logLevel) {
logger.putMessage(o, level, message);
}
}
public static void log(Object o, String message) {
if (EDK_INFO <= logLevel) {
logger.putMessage(o, EDK_INFO, message);
}
}
public static void flushLogToFile(File file) {
logger.flushToFile(file);

View File

@ -63,12 +63,7 @@ public class CreateMtFileTask extends Task implements EfiDefine {
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "createmtfile");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
@ -109,20 +104,20 @@ public class CreateMtFileTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.outputFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.outputFile)).getName());
revl = runner.execute();
if (EFI_SUCCESS == revl) {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "CreateMtFile succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "CreateMtFile succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("CreateMtFile failed!");
}
} catch (Exception e) {

View File

@ -59,12 +59,7 @@ public class EfiCompressTask extends Task implements EfiDefine {
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "eficompress");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
@ -105,8 +100,8 @@ public class EfiCompressTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
revl = runner.execute();
@ -114,12 +109,12 @@ public class EfiCompressTask extends Task implements EfiDefine {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "EfiCompress succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "EfiCompress succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("EfiCompress failed!");
}

View File

@ -112,12 +112,7 @@ public class EfiRomTask extends Task implements EfiDefine {
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "efirom");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
@ -163,8 +158,8 @@ public class EfiRomTask extends Task implements EfiDefine {
}
}
EdkLog.log(EdkLog.EDK_VERBOSE, argList.toString().replaceAll(",",""));
EdkLog.log(EdkLog.EDK_INFO, " ");
EdkLog.log(this, EdkLog.EDK_VERBOSE, argList.toString().replaceAll(",",""));
EdkLog.log(this, EdkLog.EDK_INFO, " ");
//
// lauch the program

View File

@ -142,12 +142,6 @@ public class FlashMapTask extends Task implements EfiDefine {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "flashmap");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
@ -198,13 +192,13 @@ public class FlashMapTask extends Task implements EfiDefine {
//
// log command line string.
//
EdkLog.log(EdkLog.EDK_VERBOSE, cmdProc.getOutputStream().toString());
EdkLog.log(EdkLog.EDK_INFO, (new File(this.flashDefFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, cmdProc.getOutputStream().toString());
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.flashDefFile)).getName());
if (exitCode != 0) {
int len = cmdOut.read(buf, 0, 1024);
EdkLog.log(EdkLog.EDK_INFO, new String(buf, 0, len));
EdkLog.log(this, EdkLog.EDK_INFO, new String(buf, 0, len));
} else {
EdkLog.log(EdkLog.EDK_VERBOSE, "FlashMap succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "FlashMap succeeded!");
}
} catch (Exception e) {
throw new BuildException(e.getMessage());

View File

@ -1,40 +0,0 @@
/*++
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.
Module Name:
FrameworkLogger.java
Abstract:
--*/
package org.tianocore.framework.tasks;
import org.apache.tools.ant.Project;
import java.io.File;
import org.tianocore.common.logger.LogMethod;
class FrameworkLogger implements LogMethod {
private Project project;
private String titleName;
public FrameworkLogger(Project project, String taskName) {
this.project = project;
this.titleName = taskName;
}
public void putMessage(Object msgSource, int msgLevel, String msg) {
String frameworkMsg = " [" + this.titleName + "] " + msg;
this.project.log(frameworkMsg, Project.MSG_INFO);
}
public void flushToFile(File file) {
}
}

View File

@ -60,12 +60,6 @@ public class GenAcpiTableTask extends Task implements EfiDefine {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "genacpitable");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
@ -105,20 +99,20 @@ public class GenAcpiTableTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
revl = runner.execute();
if (EFI_SUCCESS == revl) {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "GenAcpiTable succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenAcpiTable succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("GenAcpiTable failed!");
}
} catch (Exception e) {

View File

@ -91,12 +91,6 @@ public class GenCapsuleHdrTask extends Task implements EfiDefine {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "gencapsulehdr");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
@ -138,20 +132,20 @@ public class GenCapsuleHdrTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(scriptFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(scriptFile)).getName());
revl = runner.execute();
if (EFI_SUCCESS == revl) {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "GenCapsuleHdr succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenCapsuleHdr succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_ERROR, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_ERROR, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("GenCapsuleHdr failed!");
}
} catch (Exception e) {

View File

@ -124,13 +124,6 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
String ffsSuffix = "";
String outputPath = "";
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "genFfs");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// Get Fraemwork_Tools_Path
@ -751,7 +744,7 @@ public class GenFfsFileTask extends Task implements EfiDefine, FfsTypes {
FfsHeader ffsHeader = new FfsHeader();
FfsHeader orgFfsHeader = new FfsHeader();
EdkLog.log(EdkLog.EDK_INFO, ffsFile.getName());
EdkLog.log(this, EdkLog.EDK_INFO, ffsFile.getName());
try {
//

View File

@ -79,12 +79,6 @@ public class GenTeImageTask extends Task implements EfiDefine {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, toolName.toLowerCase());
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
@ -126,8 +120,8 @@ public class GenTeImageTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
revl = runner.execute();
@ -135,12 +129,12 @@ public class GenTeImageTask extends Task implements EfiDefine {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "GenTeImage succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenTeImage succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));
throw new BuildException("GenTeImage failed!");
}
} catch (Exception e) {

View File

@ -16,15 +16,11 @@ package org.tianocore.framework.tasks;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.StringTokenizer;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@ -75,9 +71,6 @@ public class MakeDeps extends Task {
Project prj = this.getOwningTarget().getProject();
String toolPath = prj.getProperty("env.FRAMEWORK_TOOLS_PATH");
FrameworkLogger logger = new FrameworkLogger(prj, "makedeps");
EdkLog.setLogLevel(prj.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
///
/// compose full tool path
@ -145,7 +138,7 @@ public class MakeDeps extends Task {
runner.setAntRun(prj);
runner.setCommandline(cmd.getCommandline());
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmd.getCommandline()));
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmd.getCommandline()));
int result = 0;
try {
@ -155,7 +148,7 @@ public class MakeDeps extends Task {
}
if (result != 0) {
EdkLog.log(EdkLog.EDK_INFO, "MakeDeps failed!");
EdkLog.log(this, EdkLog.EDK_INFO, "MakeDeps failed!");
throw new BuildException("MakeDeps: failed to generate dependency file!");
}
}

View File

@ -70,12 +70,6 @@ public class ModifyInfTask extends Task implements EfiDefine {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "modifyinftask");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
@ -120,20 +114,20 @@ public class ModifyInfTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFVInfFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFVInfFile)).getName());
revl = runner.execute();
if (EFI_SUCCESS == revl) {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "ModifyInfTask succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "ModifyInfTask succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("ModifyInfTask failed!");
}
} catch (Exception e) {

View File

@ -73,12 +73,6 @@ public class PeiReBaseTask extends Task implements EfiDefine {
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, toolName.toLowerCase());
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
@ -130,8 +124,8 @@ public class PeiReBaseTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, this.inputFileName);
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, this.inputFileName);
revl = runner.execute();
@ -139,12 +133,12 @@ public class PeiReBaseTask extends Task implements EfiDefine {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "PeiReBase succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "PeiReBase succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("PeiReBase failed!");
}
} catch (Exception e) {

View File

@ -67,12 +67,6 @@ public class SecApResetVectorFixupTask extends Task implements EfiDefine {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "secapresetvectorfixup");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
@ -112,8 +106,8 @@ public class SecApResetVectorFixupTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.fvInputFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.fvInputFile)).getName());
revl = runner.execute();
@ -121,12 +115,12 @@ public class SecApResetVectorFixupTask extends Task implements EfiDefine {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "SecApResetVectorFixup succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "SecApResetVectorFixup succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("SecApResetVectorFixup failed!");
}
} catch (Exception e) {

View File

@ -69,13 +69,7 @@ public class SecFixupTask extends Task implements EfiDefine {
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, toolName
.toLowerCase());
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
@ -117,7 +111,7 @@ public class SecFixupTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
revl = runner.execute();
@ -125,12 +119,12 @@ public class SecFixupTask extends Task implements EfiDefine {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "SecFixup succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "SecFixup succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));
throw new BuildException("SecFixup failed!");
}
} catch (Exception e) {

View File

@ -58,13 +58,6 @@ public class SplitfileTask extends Task implements EfiDefine {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "splitfile");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
@ -99,19 +92,19 @@ public class SplitfileTask extends Task implements EfiDefine {
runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline());
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
revl = runner.execute();
if (EFI_SUCCESS == revl) {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "SplitFile succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "SplitFile succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("SplitFile failed!");
}
} catch (Exception e) {

View File

@ -60,12 +60,7 @@ public class StripTask extends Task implements EfiDefine {
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "strip");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
@ -106,8 +101,8 @@ public class StripTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName());
revl = runner.execute();
@ -115,12 +110,12 @@ public class StripTask extends Task implements EfiDefine {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "Strip succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "Strip succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("Strip failed!");
}
} catch (Exception e) {

View File

@ -167,7 +167,6 @@ public class VfrCompilerTask extends Task implements EfiDefine {
} else {
command = toolPath + "/" + "VfrCompile";
}
List<Object> includePath = new ArrayList<Object>();
String incPath = "";
int count = includepathList.size();

View File

@ -60,12 +60,7 @@ public class ZeroDebugDataTask extends Task implements EfiDefine {
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
//
// set Logger
//
FrameworkLogger logger = new FrameworkLogger(project, "zerodebugdata");
EdkLog.setLogLevel(project.getProperty("env.LOGLEVEL"));
EdkLog.setLogger(logger);
//
// absolute path of efi tools
//
@ -106,8 +101,8 @@ public class ZeroDebugDataTask extends Task implements EfiDefine {
//
// Set debug log information.
//
EdkLog.log(EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(EdkLog.EDK_INFO, (new File(this.peFile)).getName());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.peFile)).getName());
revl = runner.execute();
@ -115,12 +110,12 @@ public class ZeroDebugDataTask extends Task implements EfiDefine {
//
// command execution success
//
EdkLog.log(EdkLog.EDK_VERBOSE, "ZeroDebugData succeeded!");
EdkLog.log(this, EdkLog.EDK_VERBOSE, "ZeroDebugData succeeded!");
} else {
//
// command execution fail
//
EdkLog.log(EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("ZeroDebugData failed!");
}

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;
}