diff options
Diffstat (limited to 'Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java')
-rw-r--r-- | Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java | 140 |
1 files changed, 59 insertions, 81 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java index 6f3cd7bd7b..1f5e4ecf6d 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java @@ -14,6 +14,7 @@ **/
package org.tianocore.framework.tasks;
+import java.io.File;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
@@ -22,16 +23,6 @@ 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
@@ -40,10 +31,6 @@ import java.util.Map; **/
public class GenFvImageTask extends Task implements EfiDefine{
///
- /// tool name
- ///
- static final private String toolName = "GenFvImage";
- ///
/// The name of input inf file
///
private String infFile="";
@@ -51,15 +38,7 @@ public class GenFvImageTask extends Task implements EfiDefine{ /// The target architecture.
///
private String arch="";
- ///
- /// Output directory
- ///
- private String outputDir = ".";
- ///
- /// argument list
- ///
- LinkedList<String> argList = new LinkedList<String>();
-
+
/**
execute
@@ -68,45 +47,68 @@ 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");
- if (path == null) {
+ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
+ String command = "";
+
+ if (path == null){
path = "";
- } else {
- path += File.separatorChar;
+ }else {
+ path = path + File.separatorChar;
}
-
- if (arch != null && arch.length() > 0) {
- argList.addFirst(path + toolName + "_" + arch);
- } else {
- argList.addFirst(path + toolName);
+
+ if (arch.equalsIgnoreCase("")){
+ command = path + "GenFvImage";
}
-
- ///
- /// lauch the program
- ///
- ProcessBuilder pb = new ProcessBuilder(argList);
- pb.directory(new File(outputDir));
- int exitCode = 0;
+ if (arch.equalsIgnoreCase("ia32")){
+ command = path + "GenFvImage_IA32";
+ }
+ if (arch.equalsIgnoreCase("x64")){
+ command = path + "GenFvImage_X64";
+ }
+ if (arch.equalsIgnoreCase("ipf")){
+ command = path + "GenFvImage_IPF";
+ }
+ String argument = infFile;
+
try {
- 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);
+
+ 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!");
} else {
- log("GenFvImage - DONE!", Project.MSG_VERBOSE);
+
+ //
+ // execute command line failed!
+ //
+ throw new BuildException("GenFvImage failed !(error =" +
+ Integer.toHexString(revl) + ")");
}
+
} catch (Exception e) {
- throw new BuildException(e.getMessage());
- } finally {
- if (exitCode != 0) {
- throw new BuildException("GenFvImage: failed to generate FV file!");
- }
- }
-
+ System.out.println(e.getMessage());
+ }
}
/**
getInfFile
@@ -126,9 +128,7 @@ public class GenFvImageTask extends Task implements EfiDefine{ @param infFile name of infFile
**/
public void setInfFile(String infFile) {
- this.infFile = infFile;
- argList.add("-I");
- argList.add(infFile);
+ this.infFile = "-I " + infFile;
}
/**
@@ -150,27 +150,5 @@ public class GenFvImageTask extends Task implements EfiDefine{ **/
public void setArch(String arch) {
this.arch = arch;
- }
-
- /**
- 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;
- }
+ }
}
\ No newline at end of file |