mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
1ee3e26b94
commit
a236f1a127
|
@ -14,7 +14,6 @@
|
||||||
|
|
||||||
**/
|
**/
|
||||||
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;
|
||||||
|
@ -23,6 +22,16 @@ 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 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
|
GenFvImageTask
|
||||||
|
|
||||||
|
@ -30,11 +39,23 @@ import org.apache.tools.ant.types.Commandline;
|
||||||
|
|
||||||
**/
|
**/
|
||||||
public class GenFvImageTask extends Task implements EfiDefine{
|
public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
|
///
|
||||||
|
/// tool name
|
||||||
|
///
|
||||||
|
static final private String toolName = "GenFvImage";
|
||||||
///
|
///
|
||||||
/// The name of input inf file
|
/// The name of input inf file
|
||||||
///
|
///
|
||||||
private String infFile="";
|
private String infFile="";
|
||||||
|
///
|
||||||
|
/// Output directory
|
||||||
|
///
|
||||||
|
private String outputDir = ".";
|
||||||
|
///
|
||||||
|
/// argument list
|
||||||
|
///
|
||||||
|
LinkedList<String> argList = new LinkedList<String>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
execute
|
execute
|
||||||
|
|
||||||
|
@ -44,57 +65,39 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
Project project = this.getOwningTarget().getProject();
|
Project project = this.getOwningTarget().getProject();
|
||||||
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||||
String command = "";
|
|
||||||
|
|
||||||
if (path == null){
|
|
||||||
path = "";
|
|
||||||
}else {
|
|
||||||
path = path + File.separatorChar;
|
|
||||||
}
|
|
||||||
|
|
||||||
command = path + "GenFvImage";
|
|
||||||
|
|
||||||
String argument = infFile;
|
if (path == null) {
|
||||||
|
path = "";
|
||||||
|
} else {
|
||||||
|
path += File.separatorChar;
|
||||||
|
}
|
||||||
|
argList.addFirst(path + toolName);
|
||||||
|
|
||||||
|
/// lauch the program
|
||||||
|
///
|
||||||
|
ProcessBuilder pb = new ProcessBuilder(argList);
|
||||||
|
pb.directory(new File(outputDir));
|
||||||
|
int exitCode = 0;
|
||||||
try {
|
try {
|
||||||
|
Process cmdProc = pb.start();
|
||||||
Commandline commandLine = new Commandline();
|
InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream());
|
||||||
commandLine.setExecutable(command);
|
char[] buf = new char[1024];
|
||||||
commandLine.createArgument().setLine(argument);
|
|
||||||
|
exitCode = cmdProc.waitFor();
|
||||||
LogStreamHandler streamHandler = new LogStreamHandler(this,
|
if (exitCode != 0) {
|
||||||
Project.MSG_INFO,
|
int len = cmdOut.read(buf, 0, 1024);
|
||||||
Project.MSG_WARN);
|
log(new String(buf, 0, len), Project.MSG_ERR);
|
||||||
//
|
|
||||||
// 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 {
|
} else {
|
||||||
|
log("GenFvImage - DONE!", Project.MSG_VERBOSE);
|
||||||
//
|
|
||||||
// execute command line failed!
|
|
||||||
//
|
|
||||||
throw new BuildException("GenFvImage failed !(error =" +
|
|
||||||
Integer.toHexString(revl) + ")");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} 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
|
getInfFile
|
||||||
|
@ -114,7 +117,30 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
||||||
@param infFile name of infFile
|
@param infFile name of infFile
|
||||||
**/
|
**/
|
||||||
public void setInfFile(String 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue