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 File outPutFile;\r
- private String createIfrBinFile = "";\r
- private String processerArg ="";\r
- private String vfrFile = "";\r
- private String vfrFileName = "";\r
+ private static String toolName = "VfrCompile";\r
\r
- private List<IncludePath> includepathList = new ArrayList<IncludePath>();\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
\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
- if (outPutDir != null) {\r
- outPutFile = new File(outPutDir);\r
- }\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.vfrFileName = (new File(vfrFile)).getName();\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
/**\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
- String incPath = ""; \r
\r
- int count = includepathList.size(); \r
- for (int i = 0; i < count; i++) {\r
- incPath += includepathList.get(i).toString();\r
- }\r
-\r
- String argument = this.createIfrBinFile +\r
- this.processerArg + \r
- incPath +\r
- this.outPutDir + \r
- this.createListFile +\r
- this.vfrFile ;\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
- \r
+ runner.setAntRun(project); \r
runner.setCommandline(commandLine.getCommandline());\r
+ runner.setWorkingDirectory(new File(outPutDir.getValue())); \r
\r
- if (outPutFile != null && outPutFile.exists()) {\r
- runner.setWorkingDirectory(outPutFile); \r
- }\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));\r
+ EdkLog.log(this, vfrFile.toFileList());\r
\r
- log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);\r
- log(vfrFileName);\r
int returnVal = runner.execute();\r
if (EFI_SUCCESS == returnVal) {\r
- log("VfrCompile succeeded!", Project.MSG_VERBOSE);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "VfrCompile succeeded!");\r
} else {\r
- log("ERROR = " + Integer.toHexString(returnVal));\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));\r
throw new BuildException("VfrCompile failed!");\r
}\r
} catch (IOException e) {\r