**/\r
package org.tianocore.framework.tasks;\r
\r
+import java.io.File;\r
import java.io.IOException;\r
import java.util.ArrayList;\r
import java.util.List;\r
import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
import org.apache.tools.ant.types.Commandline;\r
\r
+import org.tianocore.common.logger.EdkLog;\r
+\r
/**\r
VfrcompilerTask Task Class\r
class member \r
-includepathList : add IncPath to the search path for VFR included files\r
**/\r
public class VfrCompilerTask extends Task implements EfiDefine {\r
- private String createListFile = "";\r
- private String outPutDir = "";\r
- private String createIfrBinFile = "";\r
- private String processerArg ="";\r
- private String vfrFile;\r
+ private static String toolName = "VfrCompile";\r
\r
- private List<Object> includepathList = new ArrayList<Object>();\r
+ private ToolArg createListFile = new ToolArg();\r
+ private ToolArg createIfrBinFile = new ToolArg();\r
+ private ToolArg processerArg = new ToolArg();\r
+ private FileArg vfrFile = new FileArg();\r
+ private IncludePath includepathList = new IncludePath();\r
+ private FileArg outPutDir = new FileArg(" -od ", ".");\r
+ private String dllPath = "";\r
\r
/**\r
get class member of createList file\r
\r
@returns file name of createList\r
**/\r
- public String getCreateListFile() {\r
- return createListFile;\r
+ public boolean getCreateListFile() {\r
+ return this.createListFile.getValue().length() > 0;\r
}\r
\r
/**\r
\r
@param createListFile if createList string equal "on" set '-l' flag\r
**/\r
- public void setCreateListFile(String createListFile) {\r
- if (createListFile.equals("ON")||createListFile.equals("on"))\r
- this.createListFile = " -l";\r
+ public void setCreateListFile(boolean createListFile) {\r
+ if (createListFile) {\r
+ this.createListFile.setArg(" -", "l");\r
+ }\r
}\r
\r
/**\r
@returns name of output dir\r
**/\r
public String getOutPutDir() {\r
- return outPutDir;\r
+ return this.outPutDir.getValue();\r
}\r
\r
/**\r
@param outPutDir The directory name for ouput file\r
**/\r
public void setOutPutDir(String outPutDir) {\r
- this.outPutDir = " -od " + outPutDir;\r
+ this.outPutDir.setArg(" -od ", outPutDir);\r
}\r
\r
\r
\r
@return file name of ifrBinFile\r
**/\r
- public String getCreateIfrBinFile() {\r
- return createIfrBinFile;\r
+ public boolean getCreateIfrBinFile() {\r
+ return this.createIfrBinFile.getValue().length() > 0;\r
}\r
\r
/**\r
@param createIfrBinFile The flag to specify if the IFR binary file should\r
be generated or not\r
*/\r
- public void setCreateIfrBinFile(String createIfrBinFile) {\r
- if (createIfrBinFile.equals("ON") || createIfrBinFile.equals("on"));\r
- this.createIfrBinFile = " -ibin";\r
+ public void setCreateIfrBinFile(boolean createIfrBinFile) {\r
+ if (createIfrBinFile) {\r
+ this.createIfrBinFile.setArg(" -", "ibin");\r
+ }\r
}\r
\r
/**\r
@returns name of vfrFile\r
**/\r
public String getVfrFile() {\r
- return vfrFile;\r
+ return this.vfrFile.getValue();\r
}\r
\r
/**\r
@param vfrFile The name of VFR file\r
**/\r
public void setVfrFile(String vfrFile) {\r
- this.vfrFile = " " + vfrFile;\r
+ this.vfrFile.setArg(" ", vfrFile);\r
}\r
\r
/**\r
\r
@param includepath The IncludePath object which represents include path\r
**/\r
- public void addIncludepath(IncludePath includepath){\r
- includepathList.add(includepath);\r
+ public void addConfiguredIncludepath(IncludePath includepath){\r
+ this.includepathList.insert(includepath);\r
}\r
\r
-\r
/**\r
get class member of processerArg\r
\r
@returns processer argument\r
**/\r
public String getProcesserArg() {\r
- return processerArg;\r
+ return this.processerArg.getValue();\r
}\r
\r
\r
@param processerArg The processor argument\r
*/\r
public void setProcesserArg(String processerArg) {\r
- this.processerArg = " -ppflag " + processerArg;\r
+ this.processerArg.setArg(" -ppflag ", processerArg);\r
+ }\r
+\r
+ public void setDllPath(String dllPath) {\r
+ this.dllPath = dllPath;\r
}\r
\r
/**\r
**/\r
public void execute() throws BuildException {\r
Project project = this.getProject();\r
- String toolPath= project.getProperty("env.Framework_Tools_Path");\r
+ String toolPath= project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (toolPath == null) {\r
- command = "VfrCompile";\r
+ command = toolName;\r
} else {\r
- command = toolPath + "/" + "VfrCompile";\r
+ command = toolPath + File.separator + toolName;\r
}\r
- List<Object> includePath = new ArrayList<Object>(); \r
- String incPath = ""; \r
-\r
- int count = includepathList.size(); \r
- IncludePath path;\r
- for (int i = 0; i < count; i++) {\r
- path = (IncludePath) includepathList.get(i);\r
- if (path.getFile() != null) {\r
- FileParser.loadFile( project,includePath,path.getFile(), "-I"); \r
- }\r
- }\r
- for (int i = 0; i < count; i++) {\r
- incPath = incPath + " " + includepathList.get(i);\r
- }\r
- count = includePath.size();\r
- for (int i = 0; i < count; i++) {\r
- incPath = incPath + " " + includePath.get(i);\r
- }\r
- String argument = this.createIfrBinFile +\r
- this.processerArg + \r
- incPath +\r
- this.outPutDir + \r
- this.createListFile +\r
- this.vfrFile ;\r
+\r
+ String argument = "" + createIfrBinFile\r
+ + processerArg \r
+ + includepathList\r
+ + outPutDir\r
+ + createListFile\r
+ + vfrFile;\r
try {\r
///\r
/// constructs the command-line\r
Project.MSG_WARN);\r
\r
Execute runner = new Execute(streamHandler,null);\r
- runner.setAntRun(project);\r
+ runner.setAntRun(project); \r
runner.setCommandline(commandLine.getCommandline());\r
+ runner.setWorkingDirectory(new File(outPutDir.getValue())); \r
+ runner.setEnvironment(new String[]{"PATH", dllPath});\r
+ \r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));\r
+ EdkLog.log(this, vfrFile.toFileList());\r
\r
- System.out.println(Commandline.toString(commandLine.getCommandline())); \r
int returnVal = runner.execute();\r
if (EFI_SUCCESS == returnVal) {\r
- System.out.println("VfrCompiler execution succeeded!");\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "VfrCompile succeeded!");\r
} else {\r
- System.out.println("VfrCompiler failed. (error=" + \r
- Integer.toHexString(returnVal) + ")"); \r
- throw new BuildException("VfrCompiler failed. (error=" + \r
- Integer.toHexString(returnVal) + ")");\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));\r
+ throw new BuildException("VfrCompile failed!");\r
}\r
-\r
} catch (IOException e) {\r
throw new BuildException(e.getMessage());\r
}\r
}\r
-}
\ No newline at end of file
+}\r