summaryrefslogtreecommitdiff
path: root/Tools/Source/FrameworkTasks
diff options
context:
space:
mode:
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-15 09:42:34 +0000
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2006-06-15 09:42:34 +0000
commita236f1a1276279d11bce7990e527e6abf48fa579 (patch)
tree48ece2a00b10aed143774a5729e453fb9b6c1728 /Tools/Source/FrameworkTasks
parent1ee3e26b9474444603a36fc740702c80927ca8d1 (diff)
downloadedk2-a236f1a1276279d11bce7990e527e6abf48fa579.zip
edk2-a236f1a1276279d11bce7990e527e6abf48fa579.tar.gz
edk2-a236f1a1276279d11bce7990e527e6abf48fa579.tar.bz2
rollback to rev.273, merged new updates as well
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@523 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Source/FrameworkTasks')
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java120
1 files changed, 73 insertions, 47 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
index ae47ec7..282e2d3 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java
@@ -14,7 +14,6 @@
**/
package org.tianocore.framework.tasks;
-import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -23,6 +22,16 @@ import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.ProcessBuilder;
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+
/**
GenFvImageTask
@@ -31,10 +40,22 @@ import org.apache.tools.ant.types.Commandline;
**/
public class GenFvImageTask extends Task implements EfiDefine{
///
+ /// tool name
+ ///
+ static final private String toolName = "GenFvImage";
+ ///
/// The name of input inf file
///
private String infFile="";
-
+ ///
+ /// Output directory
+ ///
+ private String outputDir = ".";
+ ///
+ /// argument list
+ ///
+ LinkedList<String> argList = new LinkedList<String>();
+
/**
execute
@@ -44,57 +65,39 @@ public class GenFvImageTask extends Task implements EfiDefine{
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
- String command = "";
-
- if (path == null){
+
+ if (path == null) {
path = "";
- }else {
- path = path + File.separatorChar;
+ } else {
+ path += File.separatorChar;
}
-
- command = path + "GenFvImage";
+ argList.addFirst(path + toolName);
- String argument = infFile;
-
+ /// lauch the program
+ ///
+ ProcessBuilder pb = new ProcessBuilder(argList);
+ pb.directory(new File(outputDir));
+ int exitCode = 0;
try {
-
- Commandline commandLine = new Commandline();
- commandLine.setExecutable(command);
- commandLine.createArgument().setLine(argument);
-
- LogStreamHandler streamHandler = new LogStreamHandler(this,
- Project.MSG_INFO,
- Project.MSG_WARN);
- //
- // create a execute object and set it's commandline
- //
- Execute runner = new Execute(streamHandler,null);
- runner.setAntRun(project);
- runner.setCommandline(commandLine.getCommandline());
- System.out.println(Commandline.toString(commandLine.getCommandline()));
-
- int revl = -1;
- //
- // user execute class call external programs - GenFvImage
- //
- revl = runner.execute();
- //
- // execute command line success!
- //
- if (EFI_SUCCESS == revl){
- System.out.println("GenFvImage succeeded!");
+ Process cmdProc = pb.start();
+ InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream());
+ char[] buf = new char[1024];
+
+ exitCode = cmdProc.waitFor();
+ if (exitCode != 0) {
+ int len = cmdOut.read(buf, 0, 1024);
+ log(new String(buf, 0, len), Project.MSG_ERR);
} else {
-
- //
- // execute command line failed!
- //
- throw new BuildException("GenFvImage failed !(error =" +
- Integer.toHexString(revl) + ")");
+ log("GenFvImage - DONE!", Project.MSG_VERBOSE);
}
-
} catch (Exception e) {
- System.out.println(e.getMessage());
- }
+ throw new BuildException(e.getMessage());
+ } finally {
+ if (exitCode != 0) {
+ throw new BuildException("GenFvImage: failed to generate FV file!");
+ }
+ }
+
}
/**
getInfFile
@@ -114,7 +117,30 @@ public class GenFvImageTask extends Task implements EfiDefine{
@param infFile name of infFile
**/
public void setInfFile(String infFile) {
- this.infFile = "-I " + infFile;
+ this.infFile = infFile;
+ argList.add("-I");
+ argList.add(infFile);
}
+ /**
+ getOutputDir
+
+ This function is to get output directory.
+
+ @return Path of output directory.
+ **/
+ public String getOutputDir() {
+ return outputDir;
+ }
+
+ /**
+ setOutputDir
+
+ This function is to set output directory.
+
+ @param outputDir The output direcotry.
+ **/
+ public void setOutputDir(String outputDir) {
+ this.outputDir = outputDir;
+ }
}