1) Applied ToolArg and FileArg class to represent tool arguments

2) Unified the tool output message and exception handling
3) Cleaned the coding style
4) Removed used code

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1535 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
jwang36
2006-09-14 08:35:38 +00:00
parent 39e5e412f9
commit 0fdb42ac46
23 changed files with 1588 additions and 1712 deletions

View File

@@ -33,33 +33,33 @@ import org.tianocore.common.logger.EdkLog;
CreateMtFileTask is used to call CreateMtFile.exe to create MT file. CreateMtFileTask is used to call CreateMtFile.exe to create MT file.
**/ **/
public class CreateMtFileTask extends Task implements EfiDefine { public class CreateMtFileTask extends Task implements EfiDefine {
/// //
/// Tool name // Tool name
/// //
private String toolName="CreateMtFile"; private String toolName = "CreateMtFile";
/// //
/// file size // file size
/// //
private String fileSize = ""; private ToolArg fileSize = new ToolArg();
/// //
/// output file // output file
/// //
private String outputFile = ""; private FileArg outputFile = new FileArg();
/// //
/// output directory, this variable is added by jave wrap // output directory, this variable is added by jave wrap
/// //
private String outputDir = ""; private String outputDir = ".";
/** /**
* execute execute
*
* StripTask execute function is to assemble tool command line & execute StripTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -73,18 +73,12 @@ public class CreateMtFileTask extends Task implements EfiDefine {
if (path == null) { if (path == null) {
command = toolName; command = toolName;
} else { } else {
command = path + File.separatorChar + toolName; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(outputFile); argument = "" + outputFile + fileSize;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = outputDir + File.separatorChar + outputFile + " " + this.fileSize;
} else {
argument = outputFile + " " + this.fileSize;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -101,24 +95,26 @@ public class CreateMtFileTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.outputFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, this.outputFile.toFileList());
revl = runner.execute();
revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "CreateMtFile succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("CreateMtFile failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -126,70 +122,70 @@ public class CreateMtFileTask extends Task implements EfiDefine {
} }
/** /**
* getFileSize getFileSize
*
* This function is to get class member "fileSize". This function is to get class member "fileSize".
*
* @return fileSize string of file size. @return fileSize string of file size.
*/ **/
public String getFileSize() { public String getFileSize() {
return this.fileSize; return this.fileSize.getValue();
} }
/** /**
* setFileSize setFileSize
*
* This function is to set class member "fileSize". This function is to set class member "fileSize".
*
* @param fileSize @param fileSize
* string of file size value. string of file size value.
*/ **/
public void setFileSize(String fileSize) { public void setFileSize(String fileSize) {
this.fileSize = fileSize; this.fileSize.setArg(" ", fileSize);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile; this.outputFile.setArg(" ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -33,29 +33,33 @@ import org.tianocore.common.logger.EdkLog;
EfiCompressTask is used to call EfiCompress.exe to strip input file. EfiCompressTask is used to call EfiCompress.exe to strip input file.
**/ **/
public class EfiCompressTask extends Task implements EfiDefine { public class EfiCompressTask extends Task implements EfiDefine {
// / //
// / input file //
// / //
private String inputFile = ""; private final static String toolName = "EfiCompress";
//
// input file
//
private FileArg inputFile = new FileArg();
// / //
// / output file // output file
// / //
private String outputFile = ""; private FileArg outputFile = new FileArg();
// / //
// / output directory, this variable is added by jave wrap // output directory, this variable is added by jave wrap
// / //
private String outputDir = ""; private String outputDir = ".";
/** /**
* execute execute
*
* EfiCompressTask execute function is to assemble tool command line & execute EfiCompressTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -67,20 +71,14 @@ public class EfiCompressTask extends Task implements EfiDefine {
String command; String command;
String argument; String argument;
if (path == null) { if (path == null) {
command = "EfiCompress"; command = toolName;
} else { } else {
command = path + File.separatorChar + "EfiCompress"; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(outputFile); argument = "" + inputFile + outputFile;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = inputFile + " " + outputDir + File.separatorChar
+ outputFile;
} else {
argument = inputFile + " " + outputFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -97,25 +95,27 @@ public class EfiCompressTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, this.inputFile.toFileList() + " => "
+ this.outputFile.toFileList());
revl = runner.execute(); revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "EfiCompress succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("EfiCompress failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
@@ -124,70 +124,70 @@ public class EfiCompressTask extends Task implements EfiDefine {
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "inputFile". This function is to get class member "inputFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getInputFile() { public String getInputFile() {
return inputFile; return inputFile.getValue();
} }
/** /**
* setComponentType setComponentType
*
* This function is to set class member "inputFile". This function is to set class member "inputFile".
*
* @param inputFile @param inputFile
* string of input file name. string of input file name.
*/ **/
public void setInputFile(String inputFile) { public void setInputFile(String inputFile) {
this.inputFile = inputFile; this.inputFile.setArg(" ", inputFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile; this.outputFile.setArg(" ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -23,92 +23,95 @@ import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.tianocore.common.logger.EdkLog; import org.tianocore.common.logger.EdkLog;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
import com.sun.org.apache.bcel.internal.generic.NEW;
/** /**
* SecFixupTask class. SecFixupTask class.
*
* SecFixupTask is used to call SecFixup.exe to fix up sec image. SecFixupTask is used to call SecFixup.exe to fix up sec image.
*/ **/
public class EfiRomTask extends Task implements EfiDefine { public class EfiRomTask extends Task implements EfiDefine {
/// //
/// tool name // tool name
/// //
private final String toolName = "EfiRom"; private final static String toolName = "EfiRom";
/// //
/// Flash default file // Flash default file
/// //
private String verbose = ""; private ToolArg verbose = new ToolArg();
/// //
/// Flash device // Flash device
/// //
private String venderId = ""; private ToolArg venderId = new ToolArg();
/// //
/// Flash device Image // Flash device Image
/// //
private String deviceId = ""; private ToolArg deviceId = new ToolArg();
/// //
/// MCI file // output file
/// //
private String outputFile = ""; private FileArg outputFile = new FileArg();
/// //
/// MCO file // binary file
/// //
private List<Input> binaryFileList = new ArrayList<Input>(); private Input binaryFileList = new Input();
/// //
/// Efi PE32 image file // Efi PE32 image file
/// //
private List<Input> pe32FileList = new ArrayList<Input>(); private Input pe32FileList = new Input();
/// //
/// Compress efi PE32 image file // Compress efi PE32 image file
/// //
private List<Input> pe32ComprFileList = new ArrayList<Input>(); private Input pe32ComprFileList = new Input();
/// //
/// Hex class code in the PCI data strutor header // Hex class code in the PCI data strutor header
/// //
private String classCode = ""; private ToolArg classCode = new ToolArg();
/// //
/// Hex revision in the PCI data header. // Hex revision in the PCI data header.
/// //
private String revision = ""; private ToolArg revision = new ToolArg();
/// //
/// Dump the headers of an existing option rom image. // Dump the headers of an existing option rom image.
/// //
private String dump = ""; private ToolArg dump = new ToolArg();
//
/// // output directory
/// output directory //
///
private String outputDir = "."; private String outputDir = ".";
//
/// // command and argument list
/// command and argument list //
///
LinkedList<String> argList = new LinkedList<String>(); LinkedList<String> argList = new LinkedList<String>();
/** /**
* execute execute
*
* EfiRomTask execute function is to assemble tool command line & execute EfiRomTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -121,294 +124,259 @@ public class EfiRomTask extends Task implements EfiDefine {
if (path == null) { if (path == null) {
command = toolName; command = toolName;
} else { } else {
command = path + File.separatorChar + toolName; command = path + File.separator + toolName;
}
argList.addFirst(command);
//
// add microcode binary files
//
if (this.binaryFileList.size() > 0){
argList.add("-b");
Iterator binList = this.binaryFileList.iterator();
while (binList.hasNext()){
argList.addAll(((Input)binList.next()).getNameList());
}
} }
// String argument = "" + verbose + venderId + deviceId + dump + revision + classCode
// add pe32 file + binaryFileList.toStringWithSinglepPrefix(" -b ")
// + pe32FileList.toStringWithSinglepPrefix(" -e ")
if (this.pe32FileList.size() > 0){ + pe32ComprFileList.toStringWithSinglepPrefix(" -ec ")
argList.add("-e"); + outputFile;
Iterator pe32List = this.pe32FileList.iterator();
while (pe32List.hasNext()){
argList.addAll(((Input)pe32List.next()).getNameList());
}
}
//
// add compressed pe32 file
//
if (this.pe32ComprFileList.size() > 0){
argList.add("-ec");
Iterator pe32ComprList = this.pe32ComprFileList.iterator();
while (pe32ComprList.hasNext()){
argList.addAll(((Input)pe32ComprList.next()).getNameList());
}
}
EdkLog.log(this, EdkLog.EDK_VERBOSE, argList.toString().replaceAll(",",""));
EdkLog.log(this, EdkLog.EDK_INFO, " ");
//
// lauch the program
//
ProcessBuilder pb = new ProcessBuilder(argList);
pb.directory(new File(outputDir));
int exitCode = 0;
try { try {
Process cmdProc = pb.start(); Commandline cmdline = new Commandline();
InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream()); cmdline.setExecutable(command);
char[] buf = new char[1024]; cmdline.createArgument().setLine(argument);
exitCode = cmdProc.waitFor(); LogStreamHandler streamHandler = new LogStreamHandler(this,
Project.MSG_INFO, Project.MSG_WARN);
Execute runner = new Execute(streamHandler, null);
runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, binaryFileList.toFileList()
+ pe32FileList.toFileList() + pe32ComprFileList.toFileList()
+ " => " + outputFile.toFileList());
int exitCode = runner.execute();
if (exitCode != 0) { if (exitCode != 0) {
int len = cmdOut.read(buf, 0, 1024); //
EdkLog.log(EdkLog.EDK_INFO, new String(buf, 0, len)); // command execution fail
//
EdkLog.log(this, "ERROR = " + Integer.toHexString(exitCode));
throw new BuildException(toolName + " failed!");
} else { } else {
EdkLog.log(EdkLog.EDK_VERBOSE, "EfiRom succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
} finally {
if (exitCode != 0) {
throw new BuildException("EfiRom failed!");
}
} }
} }
/** /**
* getVerbose getVerbose
*
* This function is to get class member "verbose" This function is to get class member "verbose"
*
* @return verbose for verbose output. @return verbose for verbose output.
*/ **/
public String getVerbose() { public String getVerbose() {
return verbose; return verbose.getValue();
} }
/** /**
* setVerbose setVerbose
*
* This function is to set class member "verbose" This function is to set class member "verbose"
*
* @param verbose for verbose output. @param verbose for verbose output.
*/ **/
public void setVerbose(boolean verbose) { public void setVerbose(boolean verbose) {
if (verbose){ if (verbose){
this.verbose = "-p"; this.verbose.setArg(" -", "p");
argList.add(this.verbose);
} }
} }
/** /**
* getVenderId getVenderId
*
* This function is to get class member "venderId" This function is to get class member "venderId"
*
* @return venderId String of venderId. @return venderId String of venderId.
*/ **/
public String getVenderId() { public String getVenderId() {
return venderId; return venderId.getValue();
} }
/** /**
* setVenderId setVenderId
*
* This function is to set class member "venderId" This function is to set class member "venderId"
*
* @param venderId String of venderId. @param venderId String of venderId.
*/ **/
public void setVenderId(String VenderId) { public void setVenderId(String venderId) {
this.venderId = VenderId; this.venderId.setArg(" -v ", venderId);
argList.add("-v");
argList.add(this.venderId);
} }
/** /**
* getDeviceId getDeviceId
*
* This function is to get class member "deviceId" This function is to get class member "deviceId"
*
* @return deviceId String of device ID. @return deviceId String of device ID.
*/ **/
public String getDeviceId() { public String getDeviceId() {
return this.deviceId; return this.deviceId.getValue();
} }
/** /**
* setDeviceId setDeviceId
*
* This function is to set class member "deviceId" This function is to set class member "deviceId"
*
* @param deviceId String of device ID. @param deviceId String of device ID.
*/ **/
public void setDeviceId(String deviceId) { public void setDeviceId(String deviceId) {
this.deviceId = deviceId; this.deviceId.setArg(" -d ", deviceId);
argList.add("-d");
argList.add(this.deviceId);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile name of output directory. @return outputFile name of output directory.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "dscFile" This function is to set class member "dscFile"
*
* @param outputFile name of DSC file @param outputFile name of DSC file
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile; this.outputFile.setArg(" -o ", outputFile);
} }
/** /**
* getClassCode getClassCode
*
* This function is to get class member "classCode" This function is to get class member "classCode"
*
* @return fdImage name of class code file. @return fdImage name of class code file.
*/ **/
public String getClassCode() { public String getClassCode() {
return classCode; return classCode.getValue();
} }
/** /**
* setclassCode setclassCode
*
* This function is to set class member "classCode" This function is to set class member "classCode"
*
* @param fdImage name of class code file. @param fdImage name of class code file.
*/ **/
public void setclassCode(String classCode) { public void setclassCode(String classCode) {
this.classCode = classCode; this.classCode.setArg(" -cc ", classCode);
argList.add("-cc");
argList.add(this.classCode);
} }
/** /**
* getRevision getRevision
*
* This function is to get class member "revision". This function is to get class member "revision".
*
* @return revision hex revision in the PDI data header. @return revision hex revision in the PDI data header.
*/ **/
public String getRevision() { public String getRevision() {
return revision; return revision.getValue();
} }
/** /**
* setRevision setRevision
*
* This function is to set class member "revision" This function is to set class member "revision"
*
* @param revision hex revision in the PDI data header. @param revision hex revision in the PDI data header.
*/ **/
public void setRevision(String revision) { public void setRevision(String revision) {
this.revision = revision; this.revision.setArg(" -rev ", revision);
argList.add("-rev");
argList.add(this.revision);
} }
/** /**
* getFlashDeviceImage getFlashDeviceImage
*
* This function is to get class member "dump" This function is to get class member "dump"
*
* @return flashDeviceImage name of flash device image @return flashDeviceImage name of flash device image
*/ **/
public String getDump() { public String getDump() {
return dump; return dump.getValue();
} }
/** /**
* setFlashDeviceImage setFlashDeviceImage
*
* This function is to set class member "dump" This function is to set class member "dump"
*
* @param flashDeviceImage name of flash device image @param flashDeviceImage name of flash device image
*/ **/
public void setDump(boolean dump) { public void setDump(boolean dump) {
if (dump){ if (dump) {
this.dump = "-dump"; this.dump.setArg(" -", "dump");
argList.add(this.dump);
} }
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory @return outputDir string of output directory
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir string of output directory @param outputDir string of output directory
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }
/** /**
* addBinaryFile addBinaryFile
*
* This function is to add binary file to binaryFile list. This function is to add binary file to binaryFile list.
*
* @param binaryFile name of binary file. @param binaryFile name of binary file.
*/ **/
public void addBinaryFile(Input binaryFile){ public void addConfiguredBinaryFile(Input binaryFile){
this.binaryFileList.add(binaryFile); this.binaryFileList.insert(binaryFile);
} }
/** /**
* addPe32File addPe32File
*
* This function is to add pe32 file to pe32File list. This function is to add pe32 file to pe32File list.
*
* @param pe32File name of pe32 file. @param pe32File name of pe32 file.
*/ **/
public void addPe32File(Input pe32File){ public void addConfiguredPe32File(Input pe32File){
this.pe32FileList.add(pe32File); this.pe32FileList.insert(pe32File);
} }
/** /**
* addPe32ComprFile addPe32ComprFile
*
* This function os to add compressed pe32 file to pe32ComprFile list. This function os to add compressed pe32 file to pe32ComprFile list.
*
* @param pe32ComprFile name of compressed pe32 file. @param pe32ComprFile name of compressed pe32 file.
*/ **/
public void addPe32ComprFile(Input pe32ComprFile){ public void addConfiguredPe32ComprFile(Input pe32ComprFile){
this.pe32ComprFileList.add(pe32ComprFile); this.pe32ComprFileList.insert(pe32ComprFile);
} }
} }

View File

@@ -1,72 +0,0 @@
/** @file
FileParser class.
FileParser class is to parse file which contains the list of file name and
add those files to list.
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.framework.tasks;
import java.io.*;
import java.util.List;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
/**
FileParser class.
FileParser class is to parse file which contains the list of file name and
add those files to list.
**/
public class FileParser {
/**
loadFile
This function is to add files to array from input file which contains the
files list.
@param project The current project.
@param list File array.
@param file File which contains the file list.
@param tag Target of architecture.
@throws BuildException
**/
public static synchronized void loadFile(Project project, List<Object> list, File file, String tag) throws BuildException{
FileReader fileReader;
BufferedReader in;
String str;
if (!file.exists()) {
throw new BuildException("The file, " + file + " does not exist!");
}
try {
fileReader = new FileReader(file);
in = new BufferedReader(fileReader);
while((str=in.readLine())!= null){
if (str.trim()==""){
continue;
}
str = project.replaceProperties(str);
if (str.trim().substring(0,2).equalsIgnoreCase(tag)) {
list.add(str.trim());
} else {
list.add(tag + " " + str.trim());
}
}
} catch (Exception e){
System.out.println(e.getMessage());
}
}
}

View File

@@ -16,6 +16,8 @@
**/ **/
package org.tianocore.framework.tasks; package org.tianocore.framework.tasks;
import java.io.File;
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.tools.ant.Task; import org.apache.tools.ant.Task;
@@ -52,11 +54,6 @@ public class FwImageTask extends Task implements EfiDefine {
// //
private ToolArg componentType = new ToolArg(); private ToolArg componentType = new ToolArg();
/**
* assemble tool command line & execute tool command line
*
* @throws BuildException
*/
/** /**
execute execute
@@ -76,7 +73,7 @@ public class FwImageTask extends Task implements EfiDefine {
if (path == null) { if (path == null) {
command = toolName; command = toolName;
} else { } else {
command = path + "/" + toolName; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools

View File

@@ -33,29 +33,34 @@ import org.tianocore.common.logger.EdkLog;
GenAcpiTable is used to call GenAcpiTable.exe to generate ACPI Table image . GenAcpiTable is used to call GenAcpiTable.exe to generate ACPI Table image .
**/ **/
public class GenAcpiTableTask extends Task implements EfiDefine { public class GenAcpiTableTask extends Task implements EfiDefine {
// / //
// / input file // Tool name
// / //
private String inputFile = ""; private static String toolName = "GenAcpiTable";
// / //
// / output file // input file
// / //
private String outputFile = ""; private FileArg inputFile = new FileArg();
// / //
// / output directory, this variable is added by jave wrap // output file
// / //
private String outputDir = ""; private FileArg outputFile = new FileArg();
//
// output directory, this variable is added by jave wrap
//
private String outputDir = ".";
/** /**
* execute execute
*
* StripTask execute function is to assemble tool command line & execute StripTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -66,20 +71,15 @@ public class GenAcpiTableTask extends Task implements EfiDefine {
String command; String command;
String argument; String argument;
if (path == null) { if (path == null) {
command = "GenAcpiTable"; command = toolName;
} else { } else {
command = path + File.separatorChar + "GenAcpiTable"; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(outputFile); argument = "" + inputFile + outputFile;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = inputFile + " " + outputDir + File.separatorChar
+ outputFile;
} else {
argument = inputFile + " " + outputFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -96,24 +96,27 @@ public class GenAcpiTableTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, this.inputFile.toFileList() + " => "
revl = runner.execute(); + this.outputFile.toFileList());
revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenAcpiTable succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("GenAcpiTable failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -121,70 +124,70 @@ public class GenAcpiTableTask extends Task implements EfiDefine {
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "inputFile". This function is to get class member "inputFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getInputFile() { public String getInputFile() {
return inputFile; return inputFile.getValue();
} }
/** /**
* setComponentType setComponentType
*
* This function is to set class member "inputFile". This function is to set class member "inputFile".
*
* @param inputFile @param inputFile
* string of input file name. string of input file name.
*/ **/
public void setInputFile(String inputFile) { public void setInputFile(String inputFile) {
this.inputFile = inputFile; this.inputFile.setArg(" ", inputFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile; this.outputFile.setArg(" ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -16,14 +16,17 @@
package org.tianocore.framework.tasks; package org.tianocore.framework.tasks;
import java.util.*; import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.tianocore.common.logger.EdkLog;
/** /**
GenCRC32SectionTask GenCRC32SectionTask
@@ -31,18 +34,22 @@ import org.apache.tools.ant.types.Commandline;
**/ **/
public class GenCRC32SectionTask extends Task implements EfiDefine { public class GenCRC32SectionTask extends Task implements EfiDefine {
/// //
/// output file // Tool name
/// //
private String outputFile; private static String toolName = "GenCRC32Section";
/// //
/// inputFile list // output file
/// //
private List<NestElement> inputFileList = new ArrayList<NestElement>(); private FileArg outputFile = new FileArg();
//
// inputFile list
//
private InputFile inputFileList = new InputFile();
/// //
/// Project // Project
/// //
static private Project project; static private Project project;
/** /**
@@ -62,22 +69,14 @@ public class GenCRC32SectionTask extends Task implements EfiDefine {
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command; String command;
if (path == null) { if (path == null) {
command = "GenCRC32Section"; command = toolName;
} else { } else {
command = path + "/" + "GenCRC32Section" ; command = path + File.separator + toolName ;
} }
//
// string line of input files
//
String inputFiles = " -i ";
for (int i = 0; i < inputFileList.size(); ++i) {
inputFiles += inputFileList.get(i).toString(" ");
}
// //
// assemble argument // assemble argument
// //
String argument = inputFiles + outputFile; String argument = "" + inputFileList.toStringWithSinglepPrefix(" -i ") + outputFile;
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -93,21 +92,23 @@ public class GenCRC32SectionTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);
log(" "); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, inputFileList.toFileList() + " => " + outputFile.toFileList());
revl = runner.execute(); revl = runner.execute();
if (EFI_SUCCESS == revl){ if (EFI_SUCCESS == revl){
// //
// command execution success // command execution success
// //
log("GenCRC32Section succeeded!", Project.MSG_VERBOSE); EdkLog.log(this, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
log("ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));
// LAH Added This Line // LAH Added This Line
throw new BuildException("GenCRC32Section failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -120,22 +121,22 @@ public class GenCRC32SectionTask extends Task implements EfiDefine {
This function is to add a inputFile element into list This function is to add a inputFile element into list
@param inputFile : inputFile element @param inputFile : inputFile element
**/ **/
public void addInputfile(InputFile inputFile) { public void addConfiguredInputfile(InputFile inputFile) {
inputFileList.add(inputFile); inputFileList.insert(inputFile);
} }
/** /**
get class member "outputFile" get class member "outputFile"
* @return name of output file @return name of output file
*/ **/
public String getOutputFile() { public String getOutputFile() {
return this.outputFile; return this.outputFile.getValue();
} }
/** /**
* set class member "outputFile" set class member "outputFile"
* @param outputFile : outputFile parameter @param outputFile : outputFile parameter
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = " -o " + outputFile; this.outputFile.setArg(" -o ", outputFile);
} }
} }

View File

@@ -33,60 +33,60 @@ import org.tianocore.common.logger.EdkLog;
GenCapsuleHdrTask is used to call GenCapsuleHdr.exe to generate capsule. GenCapsuleHdrTask is used to call GenCapsuleHdr.exe to generate capsule.
**/ **/
public class GenCapsuleHdrTask extends Task implements EfiDefine { public class GenCapsuleHdrTask extends Task implements EfiDefine {
/// //
/// tool name // tool name
/// //
private String toolName = "GenCapsuleHdr"; private String toolName = "GenCapsuleHdr";
/// //
/// script file // script file
/// //
private String scriptFile = ""; private FileArg scriptFile = new FileArg();
/// //
/// output file // output file
/// //
private String outputFile = ""; private FileArg outputFile = new FileArg();
/// //
/// output directory, this variable is added by jave wrap // output directory, this variable is added by jave wrap
/// //
private String outputDir = ""; private String outputDir = ".";
/// //
/// Verbose flag // Verbose flag
/// //
private String verbose = ""; private ToolArg verbose = new ToolArg();
/// //
/// Dump flag // Dump flag
/// //
private String dump = ""; private ToolArg dump = new ToolArg();
/// //
/// Split size // Split size
/// //
private String size = ""; private ToolArg size = new ToolArg();
/// //
/// capsule into one image flag // capsule into one image flag
/// //
private String joinFlag = ""; private ToolArg joinFlag = new ToolArg();
/// //
/// capsule file // capsule file
/// //
private String capsuleFile = ""; private FileArg capsuleFile = new FileArg();
/** /**
* execute execute
*
* GenCapsuleHdrTask execute function is to assemble tool command line & execute GenCapsuleHdrTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -99,20 +99,14 @@ public class GenCapsuleHdrTask extends Task implements EfiDefine {
if (path == null) { if (path == null) {
command = toolName; command = toolName;
} else { } else {
command = path + File.separatorChar + toolName; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(outputFile); argument = "" + this.verbose + this.dump + this.outputFile
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) { + this.scriptFile + this.size + this.joinFlag + this.capsuleFile;
argument = this.verbose + this.dump + "-o " +this.outputDir
+ File.separatorChar + this.outputFile + " "
+ this.scriptFile + " " + this.size + " " + this.joinFlag + this.capsuleFile;
} else {
argument = this.verbose + this.dump + "-o " + this.outputFile
+ " " + this.scriptFile + " " + this.size + " " + this.joinFlag + this.capsuleFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -129,24 +123,27 @@ public class GenCapsuleHdrTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(scriptFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, scriptFile.toFileList() + " => " +
revl = runner.execute(); outputFile.toFileList() + capsuleFile.toFileList());
revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenCapsuleHdr succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_ERROR, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_ERROR, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("GenCapsuleHdr failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -154,192 +151,191 @@ public class GenCapsuleHdrTask extends Task implements EfiDefine {
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "scriptFile". This function is to get class member "scriptFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getScriptFile() { public String getScriptFile() {
return this.scriptFile; return this.scriptFile.getValue();
} }
/** /**
* setComponentType setComponentType
*
* This function is to set class member "inputFile". This function is to set class member "inputFile".
*
* @param inputFile @param inputFile
* string of input file name. string of input file name.
*/ **/
public void setScriptFile(String scriptFile) { public void setScriptFile(String scriptFile) {
this.scriptFile = "-script " + scriptFile; this.scriptFile.setArg(" -script ", scriptFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile + " "; this.outputFile.setArg(" -o ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }
/** /**
* getVerbose getVerbose
*
* This function is to get class member "verbose" This function is to get class member "verbose"
*
* @return verbose the flag of verbose. @return verbose the flag of verbose.
*/ **/
public String getVerbose() { public String getVerbose() {
return this.verbose; return this.verbose.getValue();
} }
/** /**
* setVerbose setVerbose
*
* This function is to set class member "verbose" This function is to set class member "verbose"
*
* @param verbose @param verbose
* True or False. True or False.
*/ **/
public void setVerbose(boolean verbose) { public void setVerbose(boolean verbose) {
if (verbose) { if (verbose) {
this.verbose = "-v "; this.verbose.setArg(" -", "v");
} }
} }
/** /**
* getDump getDump
*
* This function is to get class member "dump" This function is to get class member "dump"
*
* @return verbose the flag of dump. @return verbose the flag of dump.
*/ **/
public String getDump() { public String getDump() {
return dump; return dump.getValue();
} }
/** /**
* setDump setDump
*
* This function is to set class member "dump". This function is to set class member "dump".
*
* @param dump @param dump
* True or False. True or False.
*/ **/
public void setDump(boolean dump) { public void setDump(boolean dump) {
if (dump) { if (dump) {
this.dump = "-dump "; this.dump.setArg(" -", "dump");
} }
} }
/** /**
* getSize getSize
*
* This function is to set class member "size". This function is to set class member "size".
*
* @return size string of size value @return size string of size value
*/ **/
public String getSize() { public String getSize() {
return size; return size.getValue();
} }
/** /**
* setSize setSize
*
* This function is to set class member "size". This function is to set class member "size".
*
* @param size string of size value. @param size string of size value.
*/ **/
public void setSize(String size) { public void setSize(String size) {
this.size = "-split " + size; this.size.setArg(" -split ", size);
} }
/** /**
* getCapsuleFile getCapsuleFile
*
* This function is to get class member "capsuleFile" This function is to get class member "capsuleFile"
*
* @return capsuleFile capsule file name @return capsuleFile capsule file name
*/ **/
public String getCapsuleFile() { public String getCapsuleFile() {
return capsuleFile; return capsuleFile.getValue();
} }
/** /**
* setCapsuleFile setCapsuleFile
*
* This function is to set class member "capsuleFile" This function is to set class member "capsuleFile"
*
* @param capsuleFile capsule file name @param capsuleFile capsule file name
*/ **/
public void setCapsuleFile(String capsuleFile) { public void setCapsuleFile(String capsuleFile) {
this.capsuleFile = capsuleFile; this.capsuleFile.setArg(" ", capsuleFile);
} }
/** /**
* isJoinFlag isJoinFlag
*
* This function is to get class member "joinFlag" This function is to get class member "joinFlag"
*
* @return joinFlag flag of if need to join split capsule images into @return joinFlag flag of if need to join split capsule images into
* a single image. a single image.
*/ **/
public String getJoinFlag() { public String getJoinFlag() {
return joinFlag; return joinFlag.getValue();
} }
/** /**
* setJoinFlag setJoinFlag
*
* This function is to set class member "joinFlag" This function is to set class member "joinFlag"
*
* @param joinFlag flag of if need to join split capsule images into @param joinFlag flag of if need to join split capsule images into
* a single image. a single image.
*/ **/
public void setJoinFlag(boolean joinFlag) { public void setJoinFlag(boolean joinFlag) {
if (joinFlag){ if (joinFlag){
this.joinFlag = "-j "; this.joinFlag.setArg(" -", "j");
} }
} }
} }

View File

@@ -12,12 +12,14 @@
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
package org.tianocore.framework.tasks; package org.tianocore.framework.tasks;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream; import java.io.DataOutputStream;
import java.io.File;
import java.io.file;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@@ -30,8 +32,11 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.tianocore.common.logger.EdkLog; import org.tianocore.common.logger.EdkLog;
public class GenSectionTask extends Task implements EfiDefine, Section, public class GenSectionTask extends Task implements EfiDefine, Section, FfsTypes {
FfsTypes { //
// Tool name
//
private final static String toolName = "GenSection";
// //
// inputfile name // inputfile name
// //
@@ -68,13 +73,13 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
private boolean haveTool = false; private boolean haveTool = false;
/** /**
* execute execute
*
* GenSectionTaks execute is to assemble tool command line & execute tool GenSectionTaks execute is to assemble tool command line & execute tool
* command line. command line.
*
* @throws BuildException @throws BuildException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
String command; String command;
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -83,15 +88,14 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
// //
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
if (path == null) { if (path == null) {
command = "GenSection"; command = toolName;
} else { } else {
command = path + "/" + "GenSection"; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
String argument = "" + inputFile + outputFile + sectionType String argument = "" + inputFile + outputFile + sectionType + versionNum + interfaceString;
+ versionNum + interfaceString;
// //
// return value of gensection execution // return value of gensection execution
// //
@@ -109,21 +113,19 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
EdkLog.log(this, inputFile.toFileList() + " => " EdkLog.log(this, inputFile.toFileList() + versionNum.getValue()
+ outputFile.toFileList()); + interfaceString.getValue() + " => " + outputFile.toFileList());
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
.getCommandline()));
revl = runner.execute(); revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenSection succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
+ Integer.toHexString(revl)); throw new BuildException(toolName + " failed!");
throw new BuildException("GenSection failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -131,157 +133,144 @@ public class GenSectionTask extends Task implements EfiDefine, Section,
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "inputFile". This function is to get class member "inputFile".
*
* @return name of input file @return name of input file
*/ **/
public String getInputFile() { public String getInputFile() {
return this.inputFile.getValue(); return this.inputFile.getValue();
} }
/** /**
* setInputFile setInputFile
*
* This function is to set class member "inputFile". This function is to set class member "inputFile".
*
* @param inputFile @param inputFile name of input file
* name of input file **/
*/
public void setInputFile(String inputFile) { public void setInputFile(String inputFile) {
this.inputFile.setArg(" -i ", inputFile); this.inputFile.setArg(" -i ", inputFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile". This function is to get class member "outputFile".
*
* @return name of output file @return name of output file
*/ **/
public String getOutputFile() { public String getOutputFile() {
return this.outputFile.getValue(); return this.outputFile.getValue();
} }
/** /**
* setOutputfile setOutputfile
*
* This function is to set class member "outputFile". This function is to set class member "outputFile".
* @param outputFile name of output file
* @param outputFile **/
* name of output file
*/
public void setOutputfile(String outputFile) { public void setOutputfile(String outputFile) {
this.outputFile.setArg(" -o ", outputFile); this.outputFile.setArg(" -o ", outputFile);
} }
/** /**
* getSectionType getSectionType
*
* This function is to get class member "sectionType". This function is to get class member "sectionType".
*
* @return sectoin type @return sectoin type
*/ **/
public String getSectionType() { public String getSectionType() {
return this.sectionType.getValue(); return this.sectionType.getValue();
} }
/** /**
* setSectionType setSectionType
*
* This function is to set class member "sectionType". This function is to set class member "sectionType".
*
* @param sectionType @param sectionType section type
* section type **/
*/
public void setSectionType(String sectionType) { public void setSectionType(String sectionType) {
this.sectionType.setArg(" -s ", sectionType); this.sectionType.setArg(" -s ", sectionType);
} }
/** /**
* getVersionNum getVersionNum
*
* This function is to get class member "versionNum". This function is to get class member "versionNum".
* @return version number
* @return version number **/
*/
public String getVersionNum() { public String getVersionNum() {
return this.versionNum.getValue(); return this.versionNum.getValue();
} }
/** /**
* setVersionNume setVersionNume
*
* This function is to set class member "versionNum". This function is to set class member "versionNum".
* @param versionNum version number
* @param versionNum **/
* version number
*/
public void setVersionNum(String versionNum) { public void setVersionNum(String versionNum) {
this.versionNum.setArg(" -v ", versionNum); this.versionNum.setArg(" -v ", versionNum);
} }
/** /**
* getInterfaceString getInterfaceString
*
* This function is to get class member "interfaceString". This function is to get class member "interfaceString".
* @return interface string
* @return interface string **/
*/
public String getInterfaceString() { public String getInterfaceString() {
return this.interfaceString.getValue(); return this.interfaceString.getValue();
} }
/** /**
* setInterfaceString setInterfaceString
*
* This funcion is to set class member "interfaceString". This funcion is to set class member "interfaceString".
* @param interfaceString interface string
* @param interfaceString **/
* interface string
*/
public void setInterfaceString(String interfaceString) { public void setInterfaceString(String interfaceString) {
this.interfaceString.setArg(" -a ", "\"" + interfaceString + "\""); this.interfaceString.setArg(" -a ", "\"" + interfaceString + "\"");
} }
/** /**
* addSectFile addSectFile
*
* This function is to add sectFile to list. This function is to add sectFile to list.
*
* @param sectFile @param sectFile instance of sectFile.
* instance of sectFile. **/
*/ public void addSectFile(SectFile sectFile){
public void addSectFile(SectFile sectFile) {
this.sectFileList.add(sectFile); this.sectFileList.add(sectFile);
} }
/** /**
* setTool setTool
*
* This function is to set the class member "Tool"; This function is to set the class member "Tool";
*
* @param tool @param tool
*/ **/
public void addTool(Tool tool) { public void addTool(Tool tool) {
this.sectFileList.add(tool); this.sectFileList.add(tool);
this.haveTool = true; this.haveTool = true;
} }
/** /**
* addGenSection addGenSection
*
* This function is to add GenSectin element to list This function is to add GenSectin element to list
* @param task Instance of genSection
* @param task **/
* Instance of genSection public void addGenSection(GenSectionTask task){
*/
public void addGenSection(GenSectionTask task) {
this.sectFileList.add(task); this.sectFileList.add(task);
} }
public void toBuffer(DataOutputStream buffer) { public void toBuffer(DataOutputStream buffer){
// //
// Search SectionList find earch section and call it's // Search SectionList find earch section and call it's
// ToBuffer function. // ToBuffer function.

View File

@@ -33,48 +33,43 @@ import org.tianocore.common.logger.EdkLog;
* GenTeImageTask is used to call GenAcpiTable.exe to generate ACPI Table image . * GenTeImageTask is used to call GenAcpiTable.exe to generate ACPI Table image .
*/ */
public class GenTeImageTask extends Task implements EfiDefine { public class GenTeImageTask extends Task implements EfiDefine {
/// //
/// tool name // tool name
/// //
private String toolName = "GenTeImage"; private String toolName = "GenTeImage";
/// //
/// input file // input file
/// //
private String inputFile = ""; private FileArg inputFile = new FileArg();
/// //
/// output file // output file
/// //
private String outputFile = ""; private FileArg outputFile = new FileArg();
/// //
/// output directory, this variable is added by jave wrap // output directory, this variable is added by jave wrap
/// //
private String outputDir = ""; private String outputDir = "";
/// //
/// Verbose flag // Verbose flag
/// //
private String verbose = ""; private ToolArg verbose = new ToolArg();
/// //
/// Dump flag // Dump flag
/// //
private String dump = ""; private ToolArg dump = new ToolArg();
/** /**
* assemble tool command line & execute tool command line execute
*
* @throws BuildException GenTeImgaeTask execute function is to assemble tool command line & execute
*/ tool command line
/**
* execute @throws BuidException
* **/
* GenTeImgaeTask execute function is to assemble tool command line & execute
* tool command line
*
* @throws BuidException
*/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -87,20 +82,12 @@ public class GenTeImageTask extends Task implements EfiDefine {
if (path == null) { if (path == null) {
command = toolName; command = toolName;
} else { } else {
command = path + File.separatorChar + toolName; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(outputFile); argument = "" + this.verbose + this.dump + this.outputFile + this.inputFile;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = this.verbose + this.dump + "-o " +this.outputDir
+ File.separatorChar + this.outputFile + " "
+ this.inputFile;
} else {
argument = this.verbose + this.dump + "-o " + this.outputFile
+ " " + this.inputFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -117,11 +104,14 @@ public class GenTeImageTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, this.inputFile.toFileList()
+ " => " + this.outputFile.toFileList());
revl = runner.execute(); revl = runner.execute();
@@ -129,13 +119,13 @@ public class GenTeImageTask extends Task implements EfiDefine {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenTeImage succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));
throw new BuildException("GenTeImage failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -143,121 +133,121 @@ public class GenTeImageTask extends Task implements EfiDefine {
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "inputFile". This function is to get class member "inputFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getInputFile() { public String getInputFile() {
return inputFile; return inputFile.getValue();
} }
/** /**
* setComponentType setComponentType
*
* This function is to set class member "inputFile". This function is to set class member "inputFile".
*
* @param inputFile @param inputFile
* string of input file name. string of input file name.
*/ **/
public void setInputFile(String inputFile) { public void setInputFile(String inputFile) {
this.inputFile = inputFile; this.inputFile.setArg(" ", inputFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile + " "; this.outputFile.setArg(" -o ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }
/** /**
* getVerbose getVerbose
*
* This function is to get class member "verbose" This function is to get class member "verbose"
*
* @return verbose the flag of verbose. @return verbose the flag of verbose.
*/ **/
public String getVerbose() { public String getVerbose() {
return this.verbose; return this.verbose.getValue();
} }
/** /**
* setVerbose setVerbose
*
* This function is to set class member "verbose" This function is to set class member "verbose"
*
* @param verbose @param verbose
* True or False. True or False.
*/ **/
public void setVerbose(boolean verbose) { public void setVerbose(boolean verbose) {
if (verbose) { if (verbose) {
this.verbose = "-v "; this.verbose.setArg(" -", "v");
} }
} }
/** /**
* getDump getDump
*
* This function is to get class member "dump" This function is to get class member "dump"
*
* @return verbose the flag of dump. @return verbose the flag of dump.
*/ **/
public String getDump() { public String getDump() {
return dump; return dump.getValue();
} }
/** /**
* setDump setDump
*
* This function is to set class member "dump" This function is to set class member "dump"
*
* @param dump @param dump
* True or False. True or False.
*/ **/
public void setDump(boolean dump) { public void setDump(boolean dump) {
if (dump) { if (dump) {
this.dump = "-dump "; this.dump.setArg(" -", "dump");
} }
} }
} }

View File

@@ -23,6 +23,8 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.tianocore.common.logger.EdkLog;
/** /**
GuidChkTask GuidChkTask
@@ -46,49 +48,53 @@ public class GuidChkTask extends Task implements EfiDefine{
* -fos : out put redirect to this file * -fos : out put redirect to this file
* *
*/ */
/// //
/// Directory name of exclusion searching // Tool name
/// //
private String exDir = ""; private static String toolName = "GuidChk";
/// //
/// File name of exclusion searching. // Directory name of exclusion searching
/// //
private String exFile = ""; private FileArg exDir = new FileArg();
/// //
/// Extension name of exclusion searching. // File name of exclusion searching.
/// //
private String exExt = ""; private FileArg exFile = new FileArg();
/// //
/// Extesnion name of sub dir which excluded searching. // Extension name of exclusion searching.
/// //
private String exSubDir = ""; private FileArg exExt = new FileArg();
/// //
/// Out put file wrote internal GUID+basename list // Extesnion name of sub dir which excluded searching.
/// //
private String outFile = ""; private FileArg exSubDir = new FileArg();
/// //
/// Check for duplicate guids. // Out put file wrote internal GUID+basename list
/// //
private String chkGui = ""; private FileArg outFile = new FileArg();
/// //
/// Check for duplicate signatures // Check for duplicate guids.
/// //
private String chkSign = ""; private ToolArg chkGui = new ToolArg();
/// //
/// If set will print guid+defined symbol name // Check for duplicate signatures
/// //
private String printGuiDef = ""; private ToolArg chkSign = new ToolArg();
/// //
/// If set will print all GUIDS found // If set will print guid+defined symbol name
/// //
private String printAllGuid = ""; private ToolArg printGuiDef = new ToolArg();
/// //
/// redirection file name. // If set will print all GUIDS found
/// //
private ToolArg printAllGuid = new ToolArg();
//
// redirection file name.
//
private String outPut = ""; private String outPut = "";
/// //
/// out put redirect to this file. // out put redirect to this file.
/// //
protected PrintWriter fos = null; protected PrintWriter fos = null;
// //
@@ -99,25 +105,25 @@ public class GuidChkTask extends Task implements EfiDefine{
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command; String command;
if (path == null) { if (path == null) {
command = "GuidChk"; command = toolName;
} else { } else {
command = path + File.separatorChar + "GuidChk"; command = path + File.separatorChar + toolName;
} }
String argument = exDir + String argument = "" + exDir +
exFile + exFile +
exExt + exExt +
exSubDir + exSubDir +
outFile + outFile +
chkGui + chkGui +
chkSign + chkSign +
printGuiDef + printGuiDef +
printAllGuid; printAllGuid;
try { try {
log(command + " " + argument, Project.MSG_VERBOSE); EdkLog.log(this, EdkLog.EDK_VERBOSE, command + " " + argument);
// //
// execute command line // execute command line
// //
Process proc = Runtime.getRuntime().exec(command + "" + argument); Process proc = Runtime.getRuntime().exec(command + " " + argument);
// //
// if set output, redirect out put to output file, else print output to screen // if set output, redirect out put to output file, else print output to screen
// //
@@ -126,8 +132,8 @@ public class GuidChkTask extends Task implements EfiDefine{
BufferedReader bin = new BufferedReader(new InputStreamReader(proc.getInputStream())); BufferedReader bin = new BufferedReader(new InputStreamReader(proc.getInputStream()));
String line = bin.readLine(); String line = bin.readLine();
while (line != null ){ while (line != null ){
fos.println(line); fos.println(line);
line = bin.readLine(); line = bin.readLine();
} }
fos.close(); fos.close();
} }
@@ -138,9 +144,9 @@ public class GuidChkTask extends Task implements EfiDefine{
line = bin.readLine(); line = bin.readLine();
} }
} }
log("GuidChkTask Succeeded!", Project.MSG_VERBOSE); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " Succeeded!");
} catch (Exception e) { } catch (Exception e) {
throw new BuildException("GuidChkTask failed!"); throw new BuildException(toolName + " failed!");
} }
} }
/** /**
@@ -151,7 +157,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return string of flag of ChkGui @return string of flag of ChkGui
**/ **/
public String getChkGui() { public String getChkGui() {
return chkGui; return chkGui.getValue();
} }
/** /**
@@ -161,11 +167,10 @@ public class GuidChkTask extends Task implements EfiDefine{
@param chkGui set class member of chkGui @param chkGui set class member of chkGui
**/ **/
public void setChkGui(String chkGui) { public void setChkGui(boolean chkGui) {
if (chkGui.equals("on")||(chkGui.equals("ON"))){ if (chkGui) {
this.chkGui = " -g "; this.chkGui.setArg(" -", "g");
} }
} }
/** /**
@@ -176,7 +181,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return chkSign @return chkSign
**/ **/
public String getChkSign() { public String getChkSign() {
return chkSign; return chkSign.getValue();
} }
/** /**
@@ -185,9 +190,9 @@ public class GuidChkTask extends Task implements EfiDefine{
This function is to set class member of chkSign This function is to set class member of chkSign
* @param chkSign * @param chkSign
*/ */
public void setChkSign(String chkSign) { public void setChkSign(boolean chkSign) {
if (chkSign.equals("on")|| chkSign.equals("ON")){ if (chkSign){
this.chkSign = " -s "; this.chkSign.setArg(" -", "s");
} }
} }
/** /**
@@ -198,7 +203,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return exDir @return exDir
**/ **/
public String getExDir() { public String getExDir() {
return exDir; return exDir.getValue();
} }
/** /**
@@ -209,7 +214,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@param exDir @param exDir
**/ **/
public void setExDir(String exDir) { public void setExDir(String exDir) {
this.exDir = " -d " + exDir; this.exDir.setArg(" -d ", exDir);
} }
/** /**
@@ -220,7 +225,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return exExt @return exExt
**/ **/
public String getExExt() { public String getExExt() {
return exExt; return exExt.getValue();
} }
/** /**
@@ -230,7 +235,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@param exExt @param exExt
**/ **/
public void setExExt(String exExt) { public void setExExt(String exExt) {
this.exExt = " -e " + exExt; this.exExt.setArg(" -e ", exExt);
} }
/** /**
@@ -240,7 +245,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return exFile @return exFile
**/ **/
public String getExFile() { public String getExFile() {
return exFile; return exFile.getValue();
} }
/** /**
@@ -251,7 +256,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@param exFile @param exFile
**/ **/
public void setExFile(String exFile) { public void setExFile(String exFile) {
this.exFile = " -f " + exFile; this.exFile.setArg(" -f ", exFile);
} }
/** /**
@@ -262,7 +267,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return exSubDir @return exSubDir
**/ **/
public String getExSubDir() { public String getExSubDir() {
return exSubDir; return exSubDir.getValue();
} }
/** /**
@@ -272,7 +277,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@param exSubDir @param exSubDir
**/ **/
public void setExSubDir(String exSubDir) { public void setExSubDir(String exSubDir) {
this.exSubDir = " -u " + exSubDir; this.exSubDir.setArg(" -u ", exSubDir);
} }
/** /**
@@ -283,14 +288,14 @@ public class GuidChkTask extends Task implements EfiDefine{
@return outFile @return outFile
**/ **/
public String getOutFile() { public String getOutFile() {
return outFile; return outFile.getValue();
} }
/** /**
* set class member of outFile * set class member of outFile
* @param outFile * @param outFile
*/ */
public void setOutFile(String outFile) { public void setOutFile(String outFile) {
this.outFile = " -b " + outFile; this.outFile.setArg(" -b ", outFile);
} }
/** /**
getPrintGuidDef getPrintGuidDef
@@ -300,7 +305,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return flage of printing (guid+defined symbol name) @return flage of printing (guid+defined symbol name)
**/ **/
public String getPrintGuiDef() { public String getPrintGuiDef() {
return printGuiDef; return printGuiDef.getValue();
} }
@@ -310,9 +315,9 @@ public class GuidChkTask extends Task implements EfiDefine{
This function is to set class member of printGuiDef. This function is to set class member of printGuiDef.
@param printGuiDef @param printGuiDef
**/ **/
public void setPrintGuiDef(String printGuiDef) { public void setPrintGuiDef(boolean printGuiDef) {
if (printGuiDef.equals("on")|| printGuiDef.equals("ON")){ if (printGuiDef){
this.printGuiDef = " -x "; this.printGuiDef.setArg(" -", "x");
} }
} }
@@ -345,7 +350,7 @@ public class GuidChkTask extends Task implements EfiDefine{
@return printAllGuid @return printAllGuid
**/ **/
public String getPrintAllGuid() { public String getPrintAllGuid() {
return printAllGuid; return printAllGuid.getValue();
} }
/** /**
@@ -354,9 +359,9 @@ public class GuidChkTask extends Task implements EfiDefine{
This function is to set class member of printAllGuid. This function is to set class member of printAllGuid.
@param printAllGuid @param printAllGuid
**/ **/
public void setPrintAllGuid(String printAllGuid) { public void setPrintAllGuid(boolean printAllGuid) {
if (printAllGuid.equals("on")||printAllGuid.equals("ON")) { if (printAllGuid) {
this.printAllGuid = " -p "; this.printAllGuid.setArg(" -", "p");
} }
} }
} }

View File

@@ -40,14 +40,14 @@ public class MakeDeps extends Task {
// //
// private members, use set/get to access them // private members, use set/get to access them
// //
private static final String cmdName = "MakeDeps"; private static final String toolName = "MakeDeps";
private String depsFile = null; private FileArg depsFile = new FileArg();
private String subDir = null; private ToolArg subDir = new ToolArg();
private boolean quietMode = true; private ToolArg quietMode = new ToolArg(" -", "q");
private boolean ignoreError = true; private ToolArg ignoreError = new ToolArg(" -", "ignorenotfound");
private String extraDeps = ""; private IncludePath includePathList = new IncludePath();
private List<IncludePath> includePathList = new ArrayList<IncludePath>(); private Input inputFileList = new Input();
private List<Input> inputFileList = new ArrayList<Input>(); private ToolArg target = new FileArg(" -target ", "dummy");
public MakeDeps() { public MakeDeps() {
@@ -76,61 +76,27 @@ public class MakeDeps extends Task {
/// compose full tool path /// compose full tool path
/// ///
if (toolPath == null || toolPath.length() == 0) { if (toolPath == null || toolPath.length() == 0) {
toolPath = cmdName; toolPath = toolName;
} else { } else {
if (toolPath.endsWith("/") || toolPath.endsWith("\\")) { if (toolPath.endsWith("/") || toolPath.endsWith("\\")) {
toolPath = toolPath + cmdName; toolPath = toolPath + toolName;
} else { } else {
toolPath = toolPath + File.separator + cmdName; toolPath = toolPath + File.separator + toolName;
} }
} }
/// ///
/// compose tool arguments /// compose tool arguments
/// ///
StringBuffer args = new StringBuffer(4096); String argument = "" + inputFileList + includePathList + subDir
if (ignoreError) { + quietMode + ignoreError + target + depsFile;
args.append(" -ignorenotfound ");
}
if (quietMode) {
args.append(" -q ");
}
if (subDir != null && subDir.length() > 0) {
args.append(" -s ");
args.append(subDir);
}
///
/// if there's no source files, we can do nothing about dependency
///
if (inputFileList.size() == 0) {
throw new BuildException("No source files specified to scan");
}
///
/// compose source file arguments
///
for (int i = 0, listLength = inputFileList.size(); i < listLength; ++i) {
args.append(inputFileList.get(i).toString());
}
for (int i = 0, listLength = includePathList.size(); i < listLength; ++i) {
args.append(includePathList.get(i).toString());
}
///
/// We don't need a real target. So just a "dummy" is given
///
args.append(" -target dummy");
args.append(" -o ");
args.append(depsFile);
/// ///
/// prepare to execute the tool /// prepare to execute the tool
/// ///
Commandline cmd = new Commandline(); Commandline cmd = new Commandline();
cmd.setExecutable(toolPath); cmd.setExecutable(toolPath);
cmd.createArgument().setLine(args.toString()); cmd.createArgument().setLine(argument);
LogStreamHandler streamHandler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN); LogStreamHandler streamHandler = new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN);
Execute runner = new Execute(streamHandler, null); Execute runner = new Execute(streamHandler, null);
@@ -148,29 +114,20 @@ public class MakeDeps extends Task {
} }
if (result != 0) { if (result != 0) {
EdkLog.log(this, EdkLog.EDK_INFO, "MakeDeps failed!"); EdkLog.log(this, EdkLog.EDK_INFO, toolName + " failed!");
throw new BuildException("MakeDeps: failed to generate dependency file!"); throw new BuildException(toolName + ": failed to generate dependency file!");
} else {
EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} }
} }
///
/// Remove any duplicated path separator or inconsistent path separator
///
private String cleanupPathName(String path) {
String separator = "\\" + File.separator;
String duplicateSeparator = separator + "{2}";
path = Path.translateFile(path);
path = path.replaceAll(duplicateSeparator, separator);
return path;
}
/** /**
Set method for "DepsFile" attribute Set method for "DepsFile" attribute
@param name The name of dependency list file @param name The name of dependency list file
**/ **/
public void setDepsFile(String name) { public void setDepsFile(String name) {
depsFile = cleanupPathName(name); depsFile.setArg(" -o ", name);
} }
/** /**
@@ -179,7 +136,7 @@ public class MakeDeps extends Task {
@returns The name of dependency list file @returns The name of dependency list file
**/ **/
public String getDepsFile() { public String getDepsFile() {
return depsFile; return depsFile.getValue();
} }
/** /**
@@ -188,7 +145,9 @@ public class MakeDeps extends Task {
@param ignore flag to control error handling (true/false) @param ignore flag to control error handling (true/false)
**/ **/
public void setIgnoreError(boolean ignore) { public void setIgnoreError(boolean ignore) {
ignoreError = ignore; if (!ignore) {
ignoreError.setArg(" ", " ");
}
} }
/** /**
@@ -197,7 +156,7 @@ public class MakeDeps extends Task {
@returns The value of current IgnoreError flag @returns The value of current IgnoreError flag
**/ **/
public boolean getIgnoreError() { public boolean getIgnoreError() {
return ignoreError; return ignoreError.getValue().length() > 0;
} }
/** /**
@@ -206,7 +165,9 @@ public class MakeDeps extends Task {
@param quiet flag to control the output information (true/false) @param quiet flag to control the output information (true/false)
**/ **/
public void setQuietMode(boolean quiet) { public void setQuietMode(boolean quiet) {
quietMode = quiet; if (!quiet) {
quietMode.setArg(" ", " ");
}
} }
/** /**
@@ -215,7 +176,7 @@ public class MakeDeps extends Task {
@returns value of current QuietMode flag @returns value of current QuietMode flag
**/ **/
public boolean getQuietMode() { public boolean getQuietMode() {
return quietMode; return quietMode.getValue().length() > 0;
} }
/** /**
@@ -224,7 +185,7 @@ public class MakeDeps extends Task {
@param dir The name of sub-directory in which source files will be scanned @param dir The name of sub-directory in which source files will be scanned
**/ **/
public void setSubDir(String dir) { public void setSubDir(String dir) {
subDir = cleanupPathName(dir); subDir.setArg(" -s ", dir);
} }
/** /**
@@ -233,25 +194,7 @@ public class MakeDeps extends Task {
@returns The name of sub-directory @returns The name of sub-directory
**/ **/
public String getSubDir() { public String getSubDir() {
return subDir; return subDir.getValue();
}
/**
Set method for "ExtraDeps" attribute
@param deps The name of dependency file specified separately
**/
public void setExtraDeps(String deps) {
extraDeps = cleanupPathName(deps);
}
/**
Get method for "ExtraDeps" attribute
@returns The name of dependency file specified separately
**/
public String getExtraDeps () {
return extraDeps;
} }
/** /**
@@ -259,8 +202,8 @@ public class MakeDeps extends Task {
@param path The IncludePath object from nested IncludePath type of element @param path The IncludePath object from nested IncludePath type of element
**/ **/
public void addIncludepath(IncludePath path) { public void addConfiguredIncludepath(IncludePath path) {
includePathList.add(path); includePathList.insert(path);
} }
/** /**
@@ -268,8 +211,8 @@ public class MakeDeps extends Task {
@param input The Input object from nested Input type of element @param input The Input object from nested Input type of element
**/ **/
public void addInput(Input inputFile) { public void addConfiguredInput(Input inputFile) {
inputFileList.add(inputFile); inputFileList.insert(inputFile);
} }
/** /**
@@ -279,9 +222,10 @@ public class MakeDeps extends Task {
@returns false The dependency list file is outofdate. Re-generation is needed. @returns false The dependency list file is outofdate. Re-generation is needed.
**/ **/
private boolean isUptodate() { private boolean isUptodate() {
File df = new File(depsFile); String dfName = depsFile.getValue();
File df = new File(dfName);
if (!df.exists()) { if (!df.exists()) {
EdkLog.log(this, EdkLog.EDK_VERBOSE, depsFile + " doesn't exist!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, dfName + " doesn't exist!");
return false; return false;
} }
@@ -290,16 +234,12 @@ public class MakeDeps extends Task {
// re-generate the dependency list file // re-generate the dependency list file
// //
long depsFileTimeStamp = df.lastModified(); long depsFileTimeStamp = df.lastModified();
Iterator<Input> iterator = (Iterator<Input>)inputFileList.iterator(); List<String> fileList = inputFileList.getNameList();
while (iterator.hasNext()) { for (int i = 0, length = fileList.size(); i < length; ++i) {
Input inputFile = iterator.next(); File sf = new File(fileList.get(i));
List<String> fileList = inputFile.getNameList(); if (sf.lastModified() > depsFileTimeStamp) {
for (int i = 0, length = fileList.size(); i < length; ++i) { EdkLog.log(this, EdkLog.EDK_VERBOSE, sf.getPath() + " has been changed since last build!");
File sf = new File(fileList.get(i)); return false;
if (sf.lastModified() > depsFileTimeStamp) {
EdkLog.log(this, EdkLog.EDK_VERBOSE, sf.getPath() + " has been changed since last build!");
return false;
}
} }
} }
@@ -350,7 +290,7 @@ public class MakeDeps extends Task {
// check if the .dep file is empty // check if the .dep file is empty
// //
if (lines == 0) { if (lines == 0) {
EdkLog.log(this, EdkLog.EDK_VERBOSE, depsFile + " is empty!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, dfName + " is empty!");
ret = false; ret = false;
} }

View File

@@ -33,39 +33,39 @@ import org.tianocore.common.logger.EdkLog;
ModifyInfTask is used to call Modify.exe to generate inf file. ModifyInfTask is used to call Modify.exe to generate inf file.
**/ **/
public class ModifyInfTask extends Task implements EfiDefine { public class ModifyInfTask extends Task implements EfiDefine {
/// //
/// tool name // tool name
/// //
private String toolName = "ModifyInf"; private String toolName = "ModifyInf";
/// //
/// input FV inf file // input FV inf file
/// //
private String inputFVInfFile = ""; private FileArg inputFVInfFile = new FileArg();
/// //
/// output FV inf file // output FV inf file
/// //
private String outputFVInfFile = ""; private FileArg outputFVInfFile = new FileArg();
/// //
/// pattern string // pattern string
/// //
private String patternStr = ""; private ToolArg patternStr = new ToolArg();
/// //
/// Output dir // Output dir
/// //
private String outputDir = ""; private String outputDir = ".";
/** /**
* execute execute
*
* ModifyInfTask execute function is to assemble tool command line & execute ModifyInfTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -83,18 +83,7 @@ public class ModifyInfTask extends Task implements EfiDefine {
// //
// argument of tools // argument of tools
// //
File file = new File(outputFVInfFile); argument = "" + this.inputFVInfFile + this.outputFVInfFile + this.patternStr;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = this.inputFVInfFile +
this.outputDir +
File.separatorChar +
this.outputFVInfFile +
this.patternStr;
} else {
argument = this.inputFVInfFile +
this.outputFVInfFile +
this.patternStr;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -111,24 +100,27 @@ public class ModifyInfTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFVInfFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, this.inputFVInfFile.toFileList()
revl = runner.execute(); + " => " + this.inputFVInfFile.toFileList());
revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "ModifyInfTask succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("ModifyInfTask failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -136,93 +128,93 @@ public class ModifyInfTask extends Task implements EfiDefine {
} }
/** /**
* getinputFVInfFile getinputFVInfFile
*
* This function is to get class member "inputFVInfFile". This function is to get class member "inputFVInfFile".
*
* @return string of input inf file name. @return string of input inf file name.
*/ **/
public String getinputFVInfFile() { public String getinputFVInfFile() {
return this.inputFVInfFile; return this.inputFVInfFile.getValue();
} }
/** /**
* setinputFVInfFile setinputFVInfFile
*
* This function is to set class member "inputFVInfFile". This function is to set class member "inputFVInfFile".
*
* @param inputFile @param inputFile
* string of input inf file name. string of input inf file name.
*/ **/
public void setinputFVInfFile(String inputFVInfFileName) { public void setinputFVInfFile(String inputFVInfFileName) {
this.inputFVInfFile= inputFVInfFileName + " "; this.inputFVInfFile.setArg(" ", inputFVInfFileName);
} }
/** /**
* getoutputFVInfFile getoutputFVInfFile
*
* This function is to get class member "outputFVInfFile" This function is to get class member "outputFVInfFile"
*
* @return outputFVInfFile string of output inf file name. @return outputFVInfFile string of output inf file name.
*/ **/
public String getoutputFVInfFile() { public String getoutputFVInfFile() {
return this.outputFVInfFile; return this.outputFVInfFile.getValue();
} }
/** /**
* setoutputFVInfFile setoutputFVInfFile
*
* This function is to set class member "outputFVInfFile" This function is to set class member "outputFVInfFile"
*
* @param outputFVInfFile @param outputFVInfFile
* string of output inf file name. string of output inf file name.
*/ **/
public void setoutputFVInfFile(String outputFVInfFileName) { public void setoutputFVInfFile(String outputFVInfFileName) {
this.outputFVInfFile = outputFVInfFileName + " "; this.outputFVInfFile.setArg(" ", outputFVInfFileName);
} }
/** /**
* getpatternStr getpatternStr
*
* This function is to get class member "patternStr" This function is to get class member "patternStr"
*
* @return patternStr string of pattern. @return patternStr string of pattern.
*/ **/
public String getpatternStr() { public String getpatternStr() {
return this.patternStr; return this.patternStr.getValue();
} }
/** /**
* setpatternStr setpatternStr
*
* This function is to set class member "patternStr" This function is to set class member "patternStr"
*
* @param patternStr @param patternStr
* string of patternStr. string of patternStr.
*/ **/
public void setpatternStr(String patternStr) { public void setpatternStr(String patternStr) {
this.patternStr = patternStr; this.patternStr.setArg(" ", patternStr);
} }
/** /**
* getoutputDir getoutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getoutputDir() { public String getoutputDir() {
return this.outputDir; return this.outputDir;
} }
/** /**
* setoutputDir setoutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param patternStr @param patternStr
* string of output directory. string of output directory.
*/ **/
public void setoutputDir(String outputDir) { public void setoutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -35,34 +35,34 @@ import org.tianocore.common.logger.EdkLog;
Ap reset vector. Ap reset vector.
**/ **/
public class SecApResetVectorFixupTask extends Task implements EfiDefine { public class SecApResetVectorFixupTask extends Task implements EfiDefine {
/// //
/// tool name // tool name
/// //
private String toolName = "SecApResetVectorFixup"; private String toolName = "SecApResetVectorFixup";
// / //
// / input FV recovery file // input FV recovery file
// / //
private String fvInputFile = ""; private FileArg fvInputFile = new FileArg();
// / //
// / output file // output file
// / //
private String fvOutputFile = ""; private FileArg fvOutputFile = new FileArg();
// / //
// / output directory, this variable is added by jave wrap // output directory, this variable is added by jave wrap
// / //
private String outputDir = ""; private String outputDir = ".";
/** /**
* execute execute
*
* SecApResetVectorFixupTask execute function is to assemble tool command line & execute SecApResetVectorFixupTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -75,18 +75,12 @@ public class SecApResetVectorFixupTask extends Task implements EfiDefine {
if (path == null) { if (path == null) {
command = toolName; command = toolName;
} else { } else {
command = path + File.separatorChar + toolName; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(this.fvOutputFile); argument = "" + this.fvInputFile + this.fvOutputFile;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = this.fvInputFile + " " + outputDir + File.separatorChar
+ this.fvOutputFile;
} else {
argument = this.fvInputFile + " " + this.fvOutputFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -103,11 +97,14 @@ public class SecApResetVectorFixupTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.fvInputFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, this.fvInputFile.toFileList()
+ " => " + this.fvOutputFile.toFileList());
revl = runner.execute(); revl = runner.execute();
@@ -115,13 +112,13 @@ public class SecApResetVectorFixupTask extends Task implements EfiDefine {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "SecApResetVectorFixup succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("SecApResetVectorFixup failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -129,70 +126,70 @@ public class SecApResetVectorFixupTask extends Task implements EfiDefine {
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "fvInputFile". This function is to get class member "fvInputFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getfvInputFile() { public String getfvInputFile() {
return this.fvInputFile; return this.fvInputFile.getValue();
} }
/** /**
* setComponentType setComponentType
*
* This function is to set class member "fvInputFile". This function is to set class member "fvInputFile".
*
* @param inputFile @param inputFile
* string of input file name. string of input file name.
*/ **/
public void setFvInputFile(String inputFile) { public void setFvInputFile(String inputFile) {
this.fvInputFile = inputFile; this.fvInputFile.setArg(" ", inputFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "fvOutputFile" This function is to get class member "fvOutputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return this.fvOutputFile; return this.fvOutputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "fvOutputFile" This function is to set class member "fvOutputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setFvOutputFile(String outputFile) { public void setFvOutputFile(String outputFile) {
this.fvOutputFile = outputFile; this.fvOutputFile.setArg(" ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -33,39 +33,39 @@ import org.tianocore.common.logger.EdkLog;
* SecFixupTask is used to call SecFixup.exe to fix up sec image. * SecFixupTask is used to call SecFixup.exe to fix up sec image.
*/ */
public class SecFixupTask extends Task implements EfiDefine { public class SecFixupTask extends Task implements EfiDefine {
// / //
// / tool name // tool name
// / //
private String toolName = "SecFixup"; private String toolName = "SecFixup";
// / //
// / input file // input file
// / //
private String secExeFile = ""; private FileArg secExeFile = new FileArg();
// / //
// / output file // output file
// / //
private String resetVectorDataFile = ""; private FileArg resetVectorDataFile = new FileArg();
// / //
// / output directory, this variable is added by jave wrap // output file
// / //
private String outputFile = ""; private FileArg outputFile = new FileArg();
// / //
// / output directory // output directory, this variable is added by jave wrap
// / //
private String outputDir = ""; private String outputDir = ".";
/** /**
* execute execute
*
* SecFixupTask execute function is to assemble tool command line & execute SecFixupTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -84,13 +84,7 @@ public class SecFixupTask extends Task implements EfiDefine {
// //
// argument of tools // argument of tools
// //
if (!this.outputDir.equalsIgnoreCase("")) { argument = "" + secExeFile + resetVectorDataFile + outputFile;
argument = this.secExeFile + " " + this.resetVectorDataFile + " "
+ this.outputDir + File.separatorChar + this.outputFile;
} else {
argument = this.secExeFile + " " + this.resetVectorDataFile + " "
+ this.outputFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
@@ -108,10 +102,14 @@ public class SecFixupTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, secExeFile.toFileList()
+ resetVectorDataFile.toFileList() + " => " + outputFile.toFileList());
revl = runner.execute(); revl = runner.execute();
@@ -119,13 +117,13 @@ public class SecFixupTask extends Task implements EfiDefine {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "SecFixup succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = "+ Integer.toHexString(revl));
throw new BuildException("SecFixup failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -133,93 +131,93 @@ public class SecFixupTask extends Task implements EfiDefine {
} }
/** /**
* getSecExeFile getSecExeFile
*
* This function is to get class member "secExeFile". This function is to get class member "secExeFile".
*
* @return string of sectExe file name. @return string of sectExe file name.
*/ **/
public String getSecExeFile() { public String getSecExeFile() {
return this.secExeFile; return this.secExeFile.getValue();
} }
/** /**
* setSecExeFile setSecExeFile
*
* This function is to set class member "secExeFile". This function is to set class member "secExeFile".
*
* @param secExeFile @param secExeFile
* string of secExe file name. string of secExe file name.
*/ **/
public void setSecExeFile(String secExeFile) { public void setSecExeFile(String secExeFile) {
this.secExeFile = secExeFile; this.secExeFile.setArg(" ", secExeFile);
} }
/** /**
* getResetVectorDataFile getResetVectorDataFile
*
* This function is to get class member "resetVectorDataFile" This function is to get class member "resetVectorDataFile"
*
* @return resetVectorDataFile string of resetVectorData file name. @return resetVectorDataFile string of resetVectorData file name.
*/ **/
public String getResetVectorDataFile() { public String getResetVectorDataFile() {
return this.resetVectorDataFile; return this.resetVectorDataFile.getValue();
} }
/** /**
* setResetVectorDataFile setResetVectorDataFile
*
* This function is to set class member "resetVectorDataFile" This function is to set class member "resetVectorDataFile"
*
* @param resetVectorDataFile @param resetVectorDataFile
* string of resetVectorData file name. string of resetVectorData file name.
*/ **/
public void setResetVectorDataFile(String resetVectorDataFile) { public void setResetVectorDataFile(String resetVectorDataFile) {
this.resetVectorDataFile = resetVectorDataFile; this.resetVectorDataFile.setArg(" ", resetVectorDataFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return this.outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile; this.outputFile.setArg(" ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir name of output directory @return outputDir name of output directory
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* name of output directory name of output directory
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -22,6 +22,8 @@ import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.tianocore.common.logger.EdkLog;
/** /**
Class SetStampTask is a wrap class for setstamp.exe. Class SetStampTask is a wrap class for setstamp.exe.
**/ **/
@@ -32,10 +34,14 @@ public class SetStampTask extends Task implements EfiDefine {
-peFile : file of PE -peFile : file of PE
-timeFile: Txt file of time -timeFile: Txt file of time
**/ **/
private String peFile = "";
private String timeFile = ""; private static String toolName = "SetStamp";
private FileArg peFile = new FileArg();
private FileArg timeFile = new FileArg();
private String outputDir = ".";
/** /**
assemble tool command line & execute tool command line assemble tool command line & execute tool command line
@@ -51,14 +57,14 @@ public class SetStampTask extends Task implements EfiDefine {
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command; String command;
if (path == null) { if (path == null) {
command = "SetStamp"; command = toolName;
} else { } else {
command = path + "/" + "SetStamp"; command = path + File.separator + toolName;
} }
/// ///
/// argument of SetStamp tool /// argument of SetStamp tool
/// ///
String argument = peFile + timeFile; String argument = "" + peFile + timeFile;
/// ///
/// reture value of SetStamp execution /// reture value of SetStamp execution
/// ///
@@ -75,19 +81,20 @@ public class SetStampTask extends Task implements EfiDefine {
Execute runner = new Execute(streamHandler, null); Execute runner = new Execute(streamHandler, null);
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(commandLine.getCommandline()); runner.setCommandline(commandLine.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));
log((new File(this.peFile)).getName()); EdkLog.log(this, peFile.toFileList() + " < " + timeFile.toFileList());
returnVal = runner.execute(); returnVal = runner.execute();
if (EFI_SUCCESS == returnVal) { if (EFI_SUCCESS == returnVal) {
log("SetStamp succeeded!", Project.MSG_VERBOSE); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
/// ///
/// command execution fail /// command execution fail
/// ///
log("ERROR = " + Integer.toHexString(returnVal)); EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));
throw new BuildException("SetStamp failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -100,7 +107,7 @@ public class SetStampTask extends Task implements EfiDefine {
@param peFile name of PE File @param peFile name of PE File
**/ **/
public void setPeFile(String peFile) { public void setPeFile(String peFile) {
this.peFile = " " + peFile; this.peFile.setArg(" ", peFile);
} }
/** /**
@@ -109,7 +116,7 @@ public class SetStampTask extends Task implements EfiDefine {
@return peFile name of PE file @return peFile name of PE file
**/ **/
public String getPeFile() { public String getPeFile() {
return this.peFile; return this.peFile.getValue();
} }
/** /**
@@ -118,7 +125,7 @@ public class SetStampTask extends Task implements EfiDefine {
@param timeFile name of time file @param timeFile name of time file
**/ **/
public void setTimeFile(String timeFile) { public void setTimeFile(String timeFile) {
this.timeFile = " " + timeFile; this.timeFile.setArg(" ", timeFile);
} }
/** /**
@@ -127,7 +134,29 @@ public class SetStampTask extends Task implements EfiDefine {
@returns name of time file @returns name of time file
**/ **/
public String getTimeFile() { public String getTimeFile() {
return this.timeFile; return this.timeFile.getValue();
} }
/**
getOutputDir
This function is to get class member "outputDir"
@return outputDir string of output directory.
**/
public String getOutputDir() {
return outputDir;
}
/**
setOutputDir
This function is to set class member "outputDir"
@param outputDir
string of output directory.
**/
public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
}
} }

View File

@@ -35,25 +35,34 @@ import org.tianocore.common.logger.EdkLog;
file. file.
**/ **/
public class SplitfileTask extends Task implements EfiDefine { public class SplitfileTask extends Task implements EfiDefine {
/// //
/// input file // Tool name
/// //
private String inputFile = ""; private static String toolName = "SplitFile";
/// //
/// offset value // input file
/// //
private String offset = ""; private FileArg inputFile = new FileArg();
//
// offset value
//
private ToolArg offset = new ToolArg();
//
// Output directory
//
private String outputDir = ".";
/** /**
* execute execute
*
* SplitfleTask execute function is to assemble tool command line & execute SplitfleTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -65,15 +74,15 @@ public class SplitfileTask extends Task implements EfiDefine {
String command; String command;
String argument; String argument;
if (path == null) { if (path == null) {
command = "SplitFile"; command = toolName;
} else { } else {
command = path + File.separatorChar + "SplitFile"; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
argument = inputFile + " " + offset; argument = "" + inputFile + offset;
// //
// return value of fwimage execution // return value of fwimage execution
@@ -91,21 +100,24 @@ public class SplitfileTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName()); String fileName = inputFile.toFileList();
EdkLog.log(this, EdkLog.EDK_INFO, fileName + " => " + fileName + "1 " + fileName + "2");
revl = runner.execute(); revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "SplitFile succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("SplitFile failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -113,26 +125,26 @@ public class SplitfileTask extends Task implements EfiDefine {
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "inputFile". This function is to get class member "inputFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getInputFile() { public String getInputFile() {
return inputFile; return inputFile.getValue();
} }
/** /**
* setComponentType setComponentType
*
* This function is to set class member "inputFile". This function is to set class member "inputFile".
*
* @param inputFile @param inputFile
* string of input file name. string of input file name.
*/ **/
public void setInputFile(String inputFile) { public void setInputFile(String inputFile) {
this.inputFile = inputFile; this.inputFile.setArg(" ", inputFile);
} }
/** /**
@@ -143,7 +155,7 @@ public class SplitfileTask extends Task implements EfiDefine {
@return offset value of string. @return offset value of string.
**/ **/
public String getOffset() { public String getOffset() {
return offset; return offset.getValue();
} }
/** /**
@@ -155,7 +167,29 @@ public class SplitfileTask extends Task implements EfiDefine {
string of offset value. string of offset value.
**/ **/
public void setOffset(String offset) { public void setOffset(String offset) {
this.offset = offset; this.offset.setArg(" ", offset);
} }
/**
getOutputDir
This function is to get class member "outputDir"
@return outputDir string of output directory.
**/
public String getOutputDir() {
return outputDir;
}
/**
setOutputDir
This function is to set class member "outputDir"
@param outputDir
string of output directory.
**/
public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
}
} }

View File

@@ -44,16 +44,21 @@ import org.tianocore.common.logger.EdkLog;
-outputHpk : create an HII export pack of the strings -outputHpk : create an HII export pack of the strings
**/ **/
public class StrGatherTask extends Task implements EfiDefine { public class StrGatherTask extends Task implements EfiDefine {
/// //
/// common options // Tool name
/// //
private static String toolName = "StrGather";
//
// common options
//
private ToolArg commandType = new ToolArg(); private ToolArg commandType = new ToolArg();
private ToolArg baseName = new ToolArg(); private ToolArg baseName = new ToolArg();
/// //
/// "all/read/write" // "all/read/write"
/// //
private ToolArg verbose = new ToolArg(); private ToolArg verbose = new ToolArg();
private FileArg outputDatabase = new FileArg(); private FileArg outputDatabase = new FileArg();
@@ -62,25 +67,25 @@ public class StrGatherTask extends Task implements EfiDefine {
private InputFile inputFileList = new InputFile(); private InputFile inputFileList = new InputFile();
/// //
/// parse options newDatabase -- "ture/false" unquoteString -- "ture/false" // parse options newDatabase -- "ture/false" unquoteString -- "ture/false"
/// //
private ToolArg newDatabase = new ToolArg(); private ToolArg newDatabase = new ToolArg();
private ToolArg unquotedString = new ToolArg(); private ToolArg unquotedString = new ToolArg();
private IncludePath includePathList = new IncludePath(); private IncludePath includePathList = new IncludePath();
/// //
/// scan options ignoreNotFound -- "ture/false" // scan options ignoreNotFound -- "ture/false"
/// //
private ToolArg ignoreNotFound = new ToolArg(); private ToolArg ignoreNotFound = new ToolArg();
private SkipExt skipExtList = new SkipExt(); private SkipExt skipExtList = new SkipExt();
/// //
/// dump options // dump options
/// //
private ToolArg outputString = new ToolArg(); private ToolArg outputString = new ToolArg();
private ToolArg outputDefines = new ToolArg(); private ToolArg outputDefines = new ToolArg();
@@ -93,9 +98,9 @@ public class StrGatherTask extends Task implements EfiDefine {
private FileArg outputHpk = new FileArg(); private FileArg outputHpk = new FileArg();
/// //
/// global variable // global variable
/// //
static private Project project; static private Project project;
/** /**
@@ -112,9 +117,9 @@ public class StrGatherTask extends Task implements EfiDefine {
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command; String command;
if (path == null) { if (path == null) {
command = "StrGather"; command = toolName;
} else { } else {
command = path + File.separator + "StrGather"; command = path + File.separator + toolName;
} }
/// ///
@@ -157,13 +162,13 @@ public class StrGatherTask extends Task implements EfiDefine {
revl = runner.execute(); revl = runner.execute();
if (EFI_SUCCESS == revl) { if (EFI_SUCCESS == revl) {
EdkLog.log(this, EdkLog.EDK_VERBOSE, "StrGather succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
/// ///
/// command execution fail /// command execution fail
/// ///
EdkLog.log(this, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("StrGather failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());

View File

@@ -33,30 +33,34 @@ import org.tianocore.common.logger.EdkLog;
StripTask is used to call Strip.exe to strip input file. StripTask is used to call Strip.exe to strip input file.
*/ */
public class StripTask extends Task implements EfiDefine { public class StripTask extends Task implements EfiDefine {
// / //
// / input file //
// / //
private String inputFile = ""; private static String toolName = "Strip";
//
// input file
//
private FileArg inputFile = new FileArg();
// / //
// / output file // output file
// / //
private String outputFile = ""; private FileArg outputFile = new FileArg();
// / //
// / output directory, this variable is added by jave wrap // output directory, this variable is added by jave wrap
// / //
private String outputDir = ""; private String outputDir = ".";
/** /**
* execute execute
*
* StripTask execute function is to assemble tool command line & execute StripTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -67,21 +71,18 @@ public class StripTask extends Task implements EfiDefine {
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH"); String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command; String command;
String argument; String argument;
if (path == null) { if (path == null) {
command = "Strip"; command = toolName;
} else { } else {
command = path + File.separatorChar + "Strip"; command = path + File.separator + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(outputFile); argument = "" + inputFile + outputFile;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = inputFile + " " + outputDir + File.separatorChar
+ outputFile;
} else {
argument = inputFile + " " + outputFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -98,11 +99,13 @@ public class StripTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.inputFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, inputFile.toFileList() + " => " + outputFile.toFileList());
revl = runner.execute(); revl = runner.execute();
@@ -110,13 +113,13 @@ public class StripTask extends Task implements EfiDefine {
// //
// command execution success // command execution success
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, "Strip succeeded!"); EdkLog.log(this, EdkLog.EDK_VERBOSE, toolName + " succeeded!");
} else { } else {
// //
// command execution fail // command execution fail
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("Strip failed!"); throw new BuildException(toolName + " failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -124,70 +127,70 @@ public class StripTask extends Task implements EfiDefine {
} }
/** /**
* getInputFile getInputFile
*
* This function is to get class member "inputFile". This function is to get class member "inputFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getInputFile() { public String getInputFile() {
return inputFile; return inputFile.getValue();
} }
/** /**
* setComponentType setComponentType
*
* This function is to set class member "inputFile". This function is to set class member "inputFile".
*
* @param inputFile @param inputFile
* string of input file name. string of input file name.
*/ **/
public void setInputFile(String inputFile) { public void setInputFile(String inputFile) {
this.inputFile = inputFile; this.inputFile.setArg(" ", inputFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile; this.outputFile.setArg(" ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -49,7 +49,7 @@ public class Tool implements EfiDefine, Section {
try { try {
executeTool (); executeTool ();
} catch (Exception e) { } catch (Exception e) {
throw new BuildException("Call to executeTool failed!\n"); throw new BuildException("Call to executeTool failed!\n" + e.getMessage());
} }
/// ///
@@ -83,7 +83,7 @@ public class Tool implements EfiDefine, Section {
buffer.writeByte(0); buffer.writeByte(0);
} }
} catch (Exception e) { } catch (Exception e) {
System.out.print(e.getMessage()); EdkLog.log(e.getMessage());
throw new BuildException("Tool call, toBuffer failed!\n"); throw new BuildException("Tool call, toBuffer failed!\n");
} finally { } finally {
try { try {
@@ -94,7 +94,7 @@ public class Tool implements EfiDefine, Section {
fs.close(); fs.close();
} }
} catch (Exception e) { } catch (Exception e) {
System.out.println("WARNING: Cannot close " + outputFile.getPath()); EdkLog.log("WARNING: Cannot close " + outputFile.getPath());
} }
} }
} }
@@ -129,7 +129,7 @@ public class Tool implements EfiDefine, Section {
sect.toBuffer(Do); sect.toBuffer(Do);
} }
catch (BuildException e) { catch (BuildException e) {
System.out.print(e.getMessage()); EdkLog.log(e.getMessage());
throw new BuildException ("GenSection failed at Tool!"); throw new BuildException ("GenSection failed at Tool!");
} }
Do.close(); Do.close();
@@ -150,7 +150,7 @@ public class Tool implements EfiDefine, Section {
Process process = Runtime.getRuntime().exec(command + " " + argument); Process process = Runtime.getRuntime().exec(command + " " + argument);
process.waitFor(); process.waitFor();
} catch (Exception e) { } catch (Exception e) {
System.out.print (e.getMessage()); EdkLog.log(e.getMessage());
throw new BuildException("Execution of externalTool task failed!\n"); throw new BuildException("Execution of externalTool task failed!\n");
} }
} }

View File

@@ -33,30 +33,34 @@ import org.tianocore.common.logger.EdkLog;
ZeroDebugDataTask is used to call ZeroDebugData.exe to remove debug data. ZeroDebugDataTask is used to call ZeroDebugData.exe to remove debug data.
**/ **/
public class ZeroDebugDataTask extends Task implements EfiDefine { public class ZeroDebugDataTask extends Task implements EfiDefine {
// / //
// / input PE file // Tool name
// / //
private String peFile = ""; private static String toolName = "ZeroDebugData";
//
// input PE file
//
private FileArg peFile = new FileArg();
// / //
// / output file // output file
// / //
private String outputFile = "DebugData.dat"; private FileArg outputFile = new FileArg(" ", "DebugData.dat");
// / //
// / output directory, this variable is added by jave wrap // output directory, this variable is added by jave wrap
// / //
private String outputDir = ""; private String outputDir = ".";
/** /**
* execute execute
*
* ZeroDebugDataTask execute function is to assemble tool command line & execute ZeroDebugDataTask execute function is to assemble tool command line & execute
* tool command line tool command line
*
* @throws BuidException @throws BuidException
*/ **/
public void execute() throws BuildException { public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject(); Project project = this.getOwningTarget().getProject();
@@ -68,20 +72,16 @@ public class ZeroDebugDataTask extends Task implements EfiDefine {
String command; String command;
String argument; String argument;
if (path == null) { if (path == null) {
command = "ZeroDebugData"; command = toolName;
} else { } else {
command = path + File.separatorChar + "ZeroDebugData"; command = path + File.separatorChar + toolName;
} }
// //
// argument of tools // argument of tools
// //
File file = new File(outputFile); argument = "" + peFile + outputFile;
if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
argument = this.peFile + " " + outputDir + File.separatorChar
+ outputFile;
} else {
argument = this.peFile + " " + outputFile;
}
// //
// return value of fwimage execution // return value of fwimage execution
// //
@@ -98,11 +98,12 @@ public class ZeroDebugDataTask extends Task implements EfiDefine {
runner.setAntRun(project); runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline()); runner.setCommandline(cmdline.getCommandline());
runner.setWorkingDirectory(new File(outputDir));
// //
// Set debug log information. // Set debug log information.
// //
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline())); EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.peFile)).getName()); EdkLog.log(this, EdkLog.EDK_INFO, peFile.toFileList() + " => " + outputFile.toFileList());
revl = runner.execute(); revl = runner.execute();
@@ -117,7 +118,6 @@ public class ZeroDebugDataTask extends Task implements EfiDefine {
// //
EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl)); EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("ZeroDebugData failed!"); throw new BuildException("ZeroDebugData failed!");
} }
} catch (Exception e) { } catch (Exception e) {
throw new BuildException(e.getMessage()); throw new BuildException(e.getMessage());
@@ -125,70 +125,70 @@ public class ZeroDebugDataTask extends Task implements EfiDefine {
} }
/** /**
* getPeFile getPeFile
*
* This function is to get class member "inputFile". This function is to get class member "inputFile".
*
* @return string of input file name. @return string of input file name.
*/ **/
public String getPeFile() { public String getPeFile() {
return this.peFile; return this.peFile.getValue();
} }
/** /**
* setPeFile setPeFile
*
* This function is to set class member "peFile". This function is to set class member "peFile".
*
* @param peFile @param peFile
* string of input file name. string of input file name.
*/ **/
public void setPeFile(String peFile) { public void setPeFile(String peFile) {
this.peFile = peFile; this.peFile.setArg(" ", peFile);
} }
/** /**
* getOutputFile getOutputFile
*
* This function is to get class member "outputFile" This function is to get class member "outputFile"
*
* @return outputFile string of output file name. @return outputFile string of output file name.
*/ **/
public String getOutputFile() { public String getOutputFile() {
return outputFile; return this.outputFile.getValue();
} }
/** /**
* setOutputFile setOutputFile
*
* This function is to set class member "outputFile" This function is to set class member "outputFile"
*
* @param outputFile @param outputFile
* string of output file name. string of output file name.
*/ **/
public void setOutputFile(String outputFile) { public void setOutputFile(String outputFile) {
this.outputFile = outputFile; this.outputFile.setArg(" ", outputFile);
} }
/** /**
* getOutputDir getOutputDir
*
* This function is to get class member "outputDir" This function is to get class member "outputDir"
*
* @return outputDir string of output directory. @return outputDir string of output directory.
*/ **/
public String getOutputDir() { public String getOutputDir() {
return outputDir; return outputDir;
} }
/** /**
* setOutputDir setOutputDir
*
* This function is to set class member "outputDir" This function is to set class member "outputDir"
*
* @param outputDir @param outputDir
* string of output directory. string of output directory.
*/ **/
public void setOutputDir(String outputDir) { public void setOutputDir(String outputDir) {
this.outputDir = outputDir; this.outputDir = outputDir;
} }

View File

@@ -15,6 +15,7 @@ package org.tianocore.build.global;
import org.apache.tools.ant.types.DataType; import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.Path; import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.BuildException;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
@@ -77,7 +78,7 @@ public class DpFile extends DataType {
lineReader.close(); lineReader.close();
fileReader.close(); fileReader.close();
} catch (IOException e) { } catch (IOException e) {
System.out.println (e.getMessage()); throw new BuildException(e.getMessage());
} }
} }

View File

@@ -50,7 +50,7 @@ public class ConfigReader {
@return String[][] The variables defined in the config file @return String[][] The variables defined in the config file
@throws EdkException @throws GenBuildException
Config file's format is not valid Config file's format is not valid
**/ **/
public static synchronized String[][] parse(File configFile) throws GenBuildException { public static synchronized String[][] parse(File configFile) throws GenBuildException {
@@ -78,7 +78,8 @@ public class ConfigReader {
// //
int index; int index;
if ((index = str.indexOf('=')) <= 0) { if ((index = str.indexOf('=')) <= 0) {
throw new GenBuildException("ERROR Processing file [" + configFile.getAbsolutePath() throw new GenBuildException("ERROR Processing file ["
+ configFile.getAbsolutePath()
+ "] (line " + lines + ").\n"); + "] (line " + lines + ").\n");
} }
@@ -88,9 +89,12 @@ public class ConfigReader {
keyList.add(str.substring(0, index).trim()); keyList.add(str.substring(0, index).trim());
valueList.add(str.substring(index + 1).trim()); valueList.add(str.substring(index + 1).trim());
} }
} catch (Exception e) { } catch (Exception ex) {
throw new GenBuildException("ERROR Processing file [" + configFile.getAbsolutePath() GenBuildException e = new GenBuildException("ERROR Processing file ["
+ "] (line " + lines + ").\n" + e.getMessage()); + configFile.getAbsolutePath()
+ "] (line " + lines + ").\n" + ex.getMessage());
e.setStackTrace(ex.getStackTrace());
throw e;
} }
String[][] definitions = new String[2][keyList.size()]; String[][] definitions = new String[2][keyList.size()];