CompressSection indicate that all section which in it should be compressed. \r
\r
**/\r
-public class CompressSection implements Section, FfsTypes{\r
+public class CompressSection implements Section, FfsTypes {\r
//\r
// The attribute of compressName.\r
//\r
--- /dev/null
+/** @file\r
+This file is used to nest elements which is meant for file path\r
+\r
+Copyright (c) 2006, Intel Corporation\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+package org.tianocore.framework.tasks;\r
+\r
+/**\r
+ FileArg class is defined to represent tool's argument which specifies file path.\r
+ **/\r
+public class FileArg extends ToolArg {\r
+ /**\r
+ Default constructor\r
+ **/\r
+ public FileArg() {\r
+ }\r
+\r
+ /**\r
+ Constructor which accepts argument prefix and its value as parameters\r
+\r
+ @param prefix The prefix of argument\r
+ @param value The value of argument\r
+ **/\r
+ public FileArg(String prefix, String value) {\r
+ super(prefix);\r
+ this.setValue(value);\r
+ }\r
+\r
+ /**\r
+ Set the prefix and value of an argument\r
+\r
+ @param prefix The prefix of argument\r
+ @param value The value of argument \r
+ **/\r
+ public void setArg(String prefix, String value) {\r
+ super.setPrefix(prefix);\r
+ this.setValue(value);\r
+ }\r
+\r
+ /**\r
+ Set the value of an argument\r
+\r
+ @param value The value of the argument\r
+ **/\r
+ public void setValue(String value) {\r
+ super.setFile(value);\r
+ }\r
+\r
+ /**\r
+ Add a value of an argument\r
+\r
+ @param value The value of the argument\r
+ **/\r
+ public void insValue(String value) {\r
+ super.insFile(value);\r
+ }\r
+}\r
import org.apache.tools.ant.Task;\r
import org.apache.tools.ant.Project;\r
import org.apache.tools.ant.BuildException;\r
+import org.apache.tools.ant.taskdefs.Execute;\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
* FlashMapTask is used to call FlashMap.exe to generate flash map defition files and fd files.\r
*/\r
public class FlashMapTask extends Task implements EfiDefine {\r
- // /\r
- // / tool name\r
- // /\r
+ //\r
+ // tool name\r
+ //\r
private final String toolName = "FlashMap";\r
\r
- // /\r
- // / Flash definition file\r
- // /\r
- private String flashDefFile = "";\r
-\r
- // /\r
- // / Flash device\r
- // /\r
- private String flashDevice = "";\r
-\r
- // /\r
- // / Flash device Image\r
- // /\r
- private String flashDeviceImage = "";\r
-\r
- // /\r
- // / MCI file\r
- // /\r
- private String mciFile = "";\r
-\r
- // /\r
- // / MCO file\r
- // /\r
- private String mcoFile = "";\r
-\r
- // /\r
- // / Discover FD image\r
- // /\r
- private String fdImage = "";\r
-\r
- // /\r
- // / Dsc file\r
- // /\r
- private String dscFile = "";\r
-\r
- // /\r
- // / Asm INC file\r
- // /\r
- private String asmIncFile = "";\r
-\r
- // /\r
- // / Image out file\r
- // /\r
- private String imageOutFile = "";\r
-\r
- // /\r
- // / Header file\r
- // /\r
- private String headerFile = "";\r
-\r
- // /\r
- // / Input string file\r
- // /\r
+ //\r
+ // Flash definition file\r
+ //\r
+ private FileArg flashDefFile = new FileArg();\r
+\r
+ //\r
+ // Flash device\r
+ //\r
+ private ToolArg flashDevice = new ToolArg();\r
+\r
+ //\r
+ // Flash device Image\r
+ //\r
+ private ToolArg flashDeviceImage = new ToolArg();\r
+\r
+ //\r
+ // MCI file\r
+ //\r
+ private FileArg mciFile = new FileArg();\r
+\r
+ //\r
+ // MCO file\r
+ //\r
+ private FileArg mcoFile = new FileArg();\r
+\r
+ //\r
+ // Discover FD image\r
+ //\r
+ private ToolArg fdImage = new ToolArg();\r
+\r
+ //\r
+ // Dsc file\r
+ //\r
+ private FileArg dscFile = new FileArg();\r
+\r
+ //\r
+ // Asm INC file\r
+ //\r
+ private FileArg asmIncFile = new FileArg();\r
+\r
+ //\r
+ // Image out file\r
+ //\r
+ private FileArg imageOutFile = new FileArg();\r
+\r
+ //\r
+ // Header file\r
+ //\r
+ private FileArg headerFile = new FileArg();\r
+\r
+ //\r
+ // Input string file\r
+ //\r
private String inStrFile = "";\r
\r
- // /\r
- // / Output string file\r
- // /\r
+ //\r
+ // Output string file\r
+ //\r
private String outStrFile = "";\r
\r
- // /\r
- // / Base address\r
- // /\r
- private String baseAddr = "";\r
-\r
- // /\r
- // / Aligment\r
- // /\r
- private String aligment = "";\r
-\r
- // /\r
- // / Padding value\r
- // /\r
- private String padValue = "";\r
-\r
- // /\r
- // / output directory\r
- // /\r
+ //\r
+ // \r
+ // \r
+ private FileArg strFile = new FileArg();\r
+ //\r
+ // Base address\r
+ //\r
+ private ToolArg baseAddr = new ToolArg();\r
+\r
+ //\r
+ // Aligment\r
+ //\r
+ private ToolArg aligment = new ToolArg();\r
+\r
+ //\r
+ // Padding value\r
+ //\r
+ private ToolArg padValue = new ToolArg();\r
+\r
+ //\r
+ // output directory\r
+ //\r
private String outputDir = ".";\r
\r
- // /\r
- // / MCI file array\r
- // /\r
- List<Input> mciFileArray = new ArrayList<Input>();\r
-\r
- // /\r
- // / command and argument list\r
- // /\r
- LinkedList<String> argList = new LinkedList<String>();\r
+ //\r
+ // MCI file array\r
+ //\r
+ FileArg mciFileArray = new FileArg();\r
\r
/**\r
- * execute\r
- *\r
- * FlashMapTask execute function is to assemble tool command line & execute\r
- * tool command line\r
- *\r
- * @throws BuidException\r
- */\r
+ execute\r
+ \r
+ FlashMapTask execute function is to assemble tool command line & execute\r
+ tool command line\r
+ \r
+ @throws BuidException\r
+ **/\r
public void execute() throws BuildException {\r
\r
Project project = this.getOwningTarget().getProject();\r
if (path == null) {\r
command = toolName;\r
} else {\r
- command = path + File.separatorChar + toolName;\r
+ command = path + File.separator + toolName;\r
}\r
- argList.addFirst(command);\r
\r
//\r
// add substituted input file and output file\r
//\r
if (this.inStrFile != null && this.outStrFile != null\r
- && !this.inStrFile.equalsIgnoreCase("")\r
- && !this.inStrFile.equalsIgnoreCase("")) {\r
- argList.add("-strsub");\r
- argList.add(this.inStrFile);\r
- argList.add(this.outStrFile);\r
+ && this.inStrFile.length() > 0 && this.outStrFile.length() > 0) {\r
+ strFile.setPrefix(" -strsub ");\r
+ strFile.insValue(this.inStrFile);\r
+ strFile.insValue(this.outStrFile);\r
}\r
\r
+ String argument = "" + flashDefFile + flashDevice + flashDeviceImage\r
+ + mciFile + mcoFile + fdImage + dscFile + asmIncFile\r
+ + imageOutFile + headerFile + strFile + baseAddr\r
+ + aligment + padValue + mciFileArray;\r
\r
- //\r
- // add microcode binary files\r
- //\r
- if (mciFileArray.size() > 0) {\r
- argList.add("-mcmerge");\r
- Iterator mciList = mciFileArray.iterator();\r
- while (mciList.hasNext()) {\r
- argList.addAll(((Input) mciList.next()).getNameList());\r
- }\r
- }\r
\r
//\r
// lauch the program\r
//\r
- ProcessBuilder pb = new ProcessBuilder(argList);\r
- pb.directory(new File(outputDir));\r
+ // ProcessBuilder pb = new ProcessBuilder(argList);\r
+ // pb.directory(new File(outputDir));\r
int exitCode = 0;\r
try {\r
- Process cmdProc = pb.start();\r
- InputStreamReader cmdOut = new InputStreamReader(cmdProc\r
- .getInputStream());\r
- char[] buf = new char[1024];\r
+ Commandline cmdline = new Commandline();\r
+ cmdline.setExecutable(command);\r
+ cmdline.createArgument().setLine(argument);\r
+\r
+ LogStreamHandler streamHandler = new LogStreamHandler(this,\r
+ Project.MSG_INFO, Project.MSG_WARN);\r
+ Execute runner = new Execute(streamHandler, null);\r
\r
- exitCode = cmdProc.waitFor();\r
+ runner.setAntRun(project);\r
+ runner.setCommandline(cmdline.getCommandline());\r
+\r
+ if (outputDir != null) {\r
+ runner.setWorkingDirectory(new File(outputDir)); \r
+ }\r
//\r
// log command line string.\r
//\r
- EdkLog.log(this, EdkLog.EDK_VERBOSE, cmdProc.getOutputStream().toString());\r
- EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.flashDefFile)).getName());\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+ EdkLog.log(this, flashDefFile.toFileList() \r
+ + mciFile.toFileList()\r
+ + mciFileArray.toFileList()\r
+ + fdImage.toFileList()\r
+ + inStrFile\r
+ + " => " \r
+ + headerFile.toFileList() \r
+ + imageOutFile.toFileList()\r
+ + mcoFile.toFileList()\r
+ + dscFile.toFileList()\r
+ + asmIncFile.toFileList()\r
+ + outStrFile);\r
+\r
+ exitCode = runner.execute();\r
if (exitCode != 0) {\r
- int len = cmdOut.read(buf, 0, 1024);\r
- EdkLog.log(this, EdkLog.EDK_INFO, new String(buf, 0, len));\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(exitCode));\r
} else {\r
EdkLog.log(this, EdkLog.EDK_VERBOSE, "FlashMap succeeded!");\r
}\r
}\r
\r
/**\r
- * getFlashDefFile\r
- *\r
- * This function is to get class member "flashDefFile"\r
- *\r
- * @return flashDeFile Name of flash definition file.\r
- */\r
+ getFlashDefFile\r
+ \r
+ This function is to get class member "flashDefFile"\r
+ \r
+ @return flashDeFile Name of flash definition file.\r
+ **/\r
public String getFlashDefFile() {\r
- return flashDefFile;\r
+ return this.flashDefFile.getValue();\r
}\r
\r
/**\r
- * setFlashDefFile\r
- *\r
- * This function is to set class member "flashDefFile"\r
- *\r
- * @param flashDefFile\r
- * Name of flash definition file.\r
- */\r
+ setFlashDefFile\r
+ \r
+ This function is to set class member "flashDefFile"\r
+ \r
+ @param flashDefFile\r
+ Name of flash definition file.\r
+ **/\r
public void setFlashDefFile(String flashDefFile) {\r
- this.flashDefFile = flashDefFile;\r
- argList.add("-fdf");\r
- argList.add(this.flashDefFile);\r
+ this.flashDefFile.setArg(" -fdf ", flashDefFile);\r
}\r
\r
/**\r
- * getAligment\r
- *\r
- * This function is to get class member "aligment"\r
- *\r
- * @return aligment String of aligment value.\r
- */\r
+ getAligment\r
+ \r
+ This function is to get class member "aligment"\r
+ \r
+ @return aligment String of aligment value.\r
+ **/\r
public String getAligment() {\r
- return aligment;\r
+ return this.aligment.getValue();\r
}\r
\r
/**\r
- * setAligment\r
- *\r
- * This function is to set class member "aligment"\r
- *\r
- * @param aligment\r
- * String of aligment value.\r
- */\r
+ setAligment\r
+ \r
+ This function is to set class member "aligment"\r
+ \r
+ @param aligment\r
+ String of aligment value.\r
+ **/\r
public void setAligment(String aligment) {\r
- this.aligment = aligment;\r
- argList.add("-align");\r
- argList.add(this.aligment);\r
+ this.aligment.setArg(" -align ", aligment);\r
}\r
\r
/**\r
- * getAsmIncFile\r
- *\r
- * This function is to get class member "asmIncFile"\r
- *\r
- * @return asmIncFile String of ASM include file.\r
- */\r
+ getAsmIncFile\r
+ \r
+ This function is to get class member "asmIncFile"\r
+ \r
+ @return asmIncFile String of ASM include file.\r
+ **/\r
public String getAsmIncFile() {\r
- return asmIncFile;\r
+ return this.asmIncFile.getValue();\r
}\r
\r
/**\r
- * setAsmIncFile\r
- *\r
- * This function is to set class member "asmIncFile"\r
- *\r
- * @param asmIncFile\r
- * String of ASM include file.\r
- */\r
+ setAsmIncFile\r
+ \r
+ This function is to set class member "asmIncFile"\r
+ \r
+ @param asmIncFile\r
+ String of ASM include file.\r
+ **/\r
public void setAsmIncFile(String asmIncFile) {\r
- this.asmIncFile = asmIncFile;\r
- argList.add("-asmincfile");\r
- argList.add(this.asmIncFile);\r
+ this.asmIncFile.setArg(" -asmincfile ", asmIncFile);\r
}\r
\r
/**\r
- * getBaseAddr\r
- *\r
- * This function is to get class member "baseAddr"\r
- *\r
- * @return baseAddr String of base address value.\r
- */\r
+ getBaseAddr\r
+ \r
+ This function is to get class member "baseAddr"\r
+ \r
+ @return baseAddr String of base address value.\r
+ **/\r
public String getBaseAddr() {\r
- return baseAddr;\r
+ return this.baseAddr.getValue();\r
}\r
\r
/**\r
- * setBaseAddr\r
- *\r
- * This function is to set class member "baseAddr"\r
- *\r
- * @param baseAddr\r
- * String of base address value.\r
- */\r
+ setBaseAddr\r
+ \r
+ This function is to set class member "baseAddr"\r
+ \r
+ @param baseAddr\r
+ String of base address value.\r
+ **/\r
public void setBaseAddr(String baseAddr) {\r
- this.baseAddr = baseAddr;\r
- argList.add("-baseaddr");\r
- argList.add(this.baseAddr);\r
+ this.baseAddr.setArg(" -baseaddr ", baseAddr);\r
}\r
\r
/**\r
- * getDscFile\r
- *\r
- * This function is to get class member "dscFile"\r
- *\r
- * @return dscFile name of DSC file\r
- */\r
+ getDscFile\r
+ \r
+ This function is to get class member "dscFile"\r
+ \r
+ @return dscFile name of DSC file\r
+ **/\r
public String getDscFile() {\r
- return dscFile;\r
+ return this.dscFile.getValue();\r
}\r
\r
/**\r
- * setDscFile\r
- *\r
- * This function is to set class member "dscFile"\r
- *\r
- * @param dscFile\r
- * name of DSC file\r
- */\r
+ setDscFile\r
+ \r
+ This function is to set class member "dscFile"\r
+ \r
+ @param dscFile\r
+ name of DSC file\r
+ **/\r
public void setDscFile(String dscFile) {\r
- this.dscFile = dscFile;\r
- argList.add("-dsc");\r
- argList.add(this.dscFile);\r
+ this.dscFile.setArg(" -dsc ", dscFile);\r
}\r
\r
/**\r
- * getFdImage\r
- *\r
- * This function is to get class member "fdImage"\r
- *\r
- * @return fdImage name of input FDI image file.\r
- */\r
+ getFdImage\r
+ \r
+ This function is to get class member "fdImage"\r
+ \r
+ @return fdImage name of input FDI image file.\r
+ **/\r
public String getFdImage() {\r
- return fdImage;\r
+ return this.fdImage.getValue();\r
}\r
\r
/**\r
- * setFdImage\r
- *\r
- * This function is to set class member "fdImage"\r
- *\r
- * @param fdImage\r
- * name of input FDI image file.\r
- */\r
+ setFdImage\r
+ \r
+ This function is to set class member "fdImage"\r
+ \r
+ @param fdImage\r
+ name of input FDI image file.\r
+ **/\r
public void setFdImage(String fdImage) {\r
- this.fdImage = fdImage;\r
- argList.add("-discover");\r
- argList.add(this.fdImage);\r
+ this.fdImage.setArg(" -discover ", fdImage);\r
}\r
\r
/**\r
- * getFlashDevice\r
- *\r
- * This function is to get class member "flashDevice".\r
- *\r
- * @return flashDevice name of flash device.\r
- */\r
+ getFlashDevice\r
+ \r
+ This function is to get class member "flashDevice".\r
+ \r
+ @return flashDevice name of flash device.\r
+ **/\r
public String getFlashDevice() {\r
- return flashDevice;\r
+ return this.flashDevice.getValue();\r
}\r
\r
/**\r
- * setFlashDevice\r
- *\r
- * This function is to set class member "flashDevice"\r
- *\r
- * @param flashDevice\r
- * name of flash device.\r
- */\r
+ setFlashDevice\r
+ \r
+ This function is to set class member "flashDevice"\r
+ \r
+ @param flashDevice\r
+ name of flash device.\r
+ **/\r
public void setFlashDevice(String flashDevice) {\r
- this.flashDevice = flashDevice;\r
- argList.add("-flashdevice");\r
- argList.add(this.flashDevice);\r
+ this.flashDevice.setArg(" -flashdevice ", flashDevice);\r
}\r
\r
/**\r
- * getFlashDeviceImage\r
- *\r
- * This function is to get class member "flashDeviceImage"\r
- *\r
- * @return flashDeviceImage name of flash device image\r
- */\r
+ getFlashDeviceImage\r
+ \r
+ This function is to get class member "flashDeviceImage"\r
+ \r
+ @return flashDeviceImage name of flash device image\r
+ **/\r
public String getFlashDeviceImage() {\r
- return flashDeviceImage;\r
+ return this.flashDeviceImage.getValue();\r
}\r
\r
/**\r
- * setFlashDeviceImage\r
- *\r
- * This function is to set class member "flashDeviceImage"\r
- *\r
- * @param flashDeviceImage\r
- * name of flash device image\r
- */\r
+ setFlashDeviceImage\r
+ \r
+ This function is to set class member "flashDeviceImage"\r
+ \r
+ @param flashDeviceImage\r
+ name of flash device image\r
+ **/\r
public void setFlashDeviceImage(String flashDeviceImage) {\r
- this.flashDeviceImage = flashDeviceImage;\r
- argList.add("-flashdeviceimage");\r
- argList.add(this.flashDeviceImage);\r
+ this.flashDeviceImage.setArg(" -flashdeviceimage ", flashDeviceImage);\r
\r
}\r
\r
/**\r
- * getHeaderFile\r
- *\r
- * This function is to get class member "headerFile"\r
- *\r
- * @return headerFile name of include file\r
- */\r
+ getHeaderFile\r
+ \r
+ This function is to get class member "headerFile"\r
+ \r
+ @return headerFile name of include file\r
+ **/\r
public String getHeaderFile() {\r
- return headerFile;\r
+ return this.headerFile.getValue();\r
}\r
\r
/**\r
- * setHeaderFile\r
- *\r
- * This function is to set class member "headerFile"\r
- *\r
- * @param headerFile\r
- * name of include file\r
- */\r
+ setHeaderFile\r
+ \r
+ This function is to set class member "headerFile"\r
+ \r
+ @param headerFile\r
+ name of include file\r
+ **/\r
public void setHeaderFile(String headerFile) {\r
- this.headerFile = headerFile;\r
- argList.add("-hfile");\r
- argList.add(this.headerFile);\r
+ this.headerFile.setArg(" -hfile ", headerFile);\r
}\r
\r
/**\r
- * getImageOutFile\r
- *\r
- * This function is to get class member "imageOutFile"\r
- *\r
- * @return imageOutFile name of output image file\r
- */\r
+ getImageOutFile\r
+ \r
+ This function is to get class member "imageOutFile"\r
+ \r
+ @return imageOutFile name of output image file\r
+ **/\r
public String getImageOutFile() {\r
- return imageOutFile;\r
+ return this.imageOutFile.getValue();\r
}\r
\r
/**\r
- * setImageOutFile\r
- *\r
- * This function is to set class member "ImageOutFile"\r
- *\r
- * @param imageOutFile\r
- * name of output image file\r
- */\r
+ setImageOutFile\r
+ \r
+ This function is to set class member "ImageOutFile"\r
+ \r
+ @param imageOutFile\r
+ name of output image file\r
+ **/\r
public void setImageOutFile(String imageOutFile) {\r
- this.imageOutFile = imageOutFile;\r
- argList.add("-imageout");\r
- argList.add(this.imageOutFile);\r
+ this.imageOutFile.setArg(" -imageout ", imageOutFile);\r
}\r
\r
/**\r
- * getInStrFile\r
- *\r
- * This function is to get class member "inStrFile"\r
- *\r
- * @return inStrFile name of input file which used to replace symbol names.\r
- */\r
+ getInStrFile\r
+ \r
+ This function is to get class member "inStrFile"\r
+ \r
+ @return inStrFile name of input file which used to replace symbol names.\r
+ **/\r
public String getInStrFile() {\r
- return inStrFile;\r
+ return this.inStrFile;\r
}\r
\r
/**\r
- * setInStrFile\r
- *\r
- * This function is to set class member "inStrFile"\r
- *\r
- * @param inStrFile\r
- * name of input file which used to replace symbol names.\r
- */\r
+ setInStrFile\r
+ \r
+ This function is to set class member "inStrFile"\r
+ \r
+ @param inStrFile\r
+ name of input file which used to replace symbol names.\r
+ **/\r
public void setInStrFile(String inStrFile) {\r
this.inStrFile = inStrFile;\r
}\r
\r
/**\r
- * getMciFile\r
- *\r
- * This function is to get class member "mciFile"\r
- *\r
- * @return mciFile name of input microcode file\r
- */\r
+ getMciFile\r
+ \r
+ This function is to get class member "mciFile"\r
+ \r
+ @return mciFile name of input microcode file\r
+ **/\r
public String getMciFile() {\r
- return mciFile;\r
+ return this.mciFile.getValue();\r
}\r
\r
/**\r
- * setMciFile\r
- *\r
- * This function is to set class member "mciFile"\r
- *\r
- * @param mciFile\r
- * name of input microcode file\r
- */\r
+ setMciFile\r
+ \r
+ This function is to set class member "mciFile"\r
+ \r
+ @param mciFile\r
+ name of input microcode file\r
+ **/\r
public void setMciFile(String mciFile) {\r
- this.mciFile = mciFile;\r
- argList.add("-mci");\r
- argList.add(this.mciFile);\r
+ this.mciFile.setArg(" -mci ", mciFile);\r
}\r
\r
/**\r
- * getMcoFile\r
- *\r
- * This function is to get class member "mcoFile"\r
- *\r
- * @return mcoFile name of output binary microcode image\r
- */\r
+ getMcoFile\r
+ \r
+ This function is to get class member "mcoFile"\r
+ \r
+ @return mcoFile name of output binary microcode image\r
+ **/\r
public String getMcoFile() {\r
- return mcoFile;\r
+ return this.mcoFile.getValue();\r
}\r
\r
/**\r
- * setMcoFile\r
- *\r
- * This function is to set class member "mcoFile"\r
- *\r
- * @param mcoFile\r
- * name of output binary microcode image\r
- */\r
+ setMcoFile\r
+ \r
+ This function is to set class member "mcoFile"\r
+ \r
+ @param mcoFile\r
+ name of output binary microcode image\r
+ **/\r
public void setMcoFile(String mcoFile) {\r
- this.mcoFile = mcoFile;\r
- argList.add("-mco");\r
- argList.add(this.mcoFile);\r
+ this.mcoFile.setArg(" -mco ", mcoFile);\r
}\r
\r
/**\r
- * getOutStrFile\r
- *\r
- * This function is to get class member "outStrFile"\r
- *\r
- * @return outStrFile name of output string substitution file\r
- */\r
+ getOutStrFile\r
+ \r
+ This function is to get class member "outStrFile"\r
+ \r
+ @return outStrFile name of output string substitution file\r
+ **/\r
public String getOutStrFile() {\r
- return outStrFile;\r
+ return this.outStrFile;\r
}\r
\r
/**\r
- * setOutStrFile\r
- *\r
- * This function is to set class member "outStrFile"\r
- *\r
- * @param outStrFile\r
- * name of output string substitution file\r
- */\r
+ setOutStrFile\r
+ \r
+ This function is to set class member "outStrFile"\r
+ \r
+ @param outStrFile\r
+ name of output string substitution file\r
+ **/\r
public void setOutStrFile(String outStrFile) {\r
this.outStrFile = outStrFile;\r
}\r
\r
/**\r
- * getPadValue\r
- *\r
- * This function is to get class member "padValue"\r
- *\r
- * @return padValue string of byte value to use as padding\r
- */\r
+ getPadValue\r
+ \r
+ This function is to get class member "padValue"\r
+ \r
+ @return padValue string of byte value to use as padding\r
+ **/\r
public String getPadValue() {\r
- return padValue;\r
+ return this.padValue.getValue();\r
}\r
\r
/**\r
- * setPadValue\r
- *\r
- * This function is to set class member "padValue"\r
- *\r
- * @param padValue\r
- * string of byte value to use as padding\r
- */\r
+ setPadValue\r
+ \r
+ This function is to set class member "padValue"\r
+ \r
+ @param padValue\r
+ string of byte value to use as padding\r
+ **/\r
public void setPadValue(String padValue) {\r
- this.padValue = padValue;\r
- argList.add("-padvalue");\r
- argList.add(this.padValue);\r
+ this.padValue.setArg(" -padvalue ", padValue);\r
}\r
\r
/**\r
- * addMciFile\r
- *\r
- * This function is to add Microcode binary file\r
- *\r
- * @param mciFile\r
- * instance of input class\r
- */\r
- public void addMciFile(Input mciFile) {\r
- this.mciFileArray.add(mciFile);\r
+ addMciFile\r
+ \r
+ This function is to add Microcode binary file\r
+ \r
+ @param mciFile\r
+ instance of input class\r
+ **/\r
+ public void addConfiguredMciFile(FileArg mciFile) {\r
+ this.mciFileArray.setPrefix(" -mcmerge ");\r
+ this.mciFileArray.insert(mciFile);\r
}\r
\r
/**\r
- * getOutputDir\r
- *\r
- * This function is to get class member "outputDir"\r
- *\r
- * @return outputDir string of output directory\r
- */\r
+ getOutputDir\r
+ \r
+ This function is to get class member "outputDir"\r
+ \r
+ @return outputDir string of output directory\r
+ **/\r
public String getOutputDir() {\r
return outputDir;\r
}\r
\r
/**\r
- * setOutputDir\r
- *\r
- * This function is to set class member "outputDir"\r
- *\r
- * @param outputDir\r
- * string of output directory\r
- */\r
+ setOutputDir\r
+ \r
+ This function is to set class member "outputDir"\r
+ \r
+ @param outputDir\r
+ string of output directory\r
+ **/\r
public void setOutputDir(String outputDir) {\r
this.outputDir = outputDir;\r
}\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
FwImageTask class.\r
\r
FwImageTask is used to call FwImage.ext to generate the FwImage.\r
**/\r
-public class FwImageTask extends Task implements EfiDefine{\r
- ///\r
- /// time&data\r
- ///\r
- private String time = "";\r
- ///\r
- /// input PE image\r
- ///\r
- private String peImage = "";\r
- private String peImageName = "";\r
- ///\r
- /// output EFI image\r
- ///\r
- private String outImage = "";\r
- ///\r
- /// component type\r
- ///\r
- private String componentType = "";\r
+public class FwImageTask extends Task implements EfiDefine {\r
+ //\r
+ // fwimage tool name\r
+ // \r
+ private static String toolName = "FwImage";\r
+ //\r
+ // time&data\r
+ //\r
+ private ToolArg time = new ToolArg();\r
+ //\r
+ // input PE image\r
+ //\r
+ private FileArg peImage = new FileArg();\r
+ //\r
+ // output EFI image\r
+ //\r
+ private FileArg outImage = new FileArg();\r
+ //\r
+ // component type\r
+ //\r
+ private ToolArg componentType = new ToolArg();\r
\r
/**\r
* assemble tool command line & execute tool command line\r
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (path == null) {\r
- command = "FwImage";\r
+ command = toolName;\r
} else {\r
- command = path + "/" + "FwImage";\r
+ command = path + "/" + toolName;\r
}\r
//\r
// argument of tools\r
//\r
- String argument = time + componentType + peImage + outImage;\r
+ String argument = "" + time + componentType + peImage + outImage;\r
//\r
// return value of fwimage execution\r
//\r
runner.setAntRun(project);\r
runner.setCommandline(cmdline.getCommandline());\r
\r
- log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);\r
- log(this.peImageName);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+ EdkLog.log(this, peImage.toFileList() + " => " + outImage.toFileList());\r
+\r
revl = runner.execute();\r
if (EFI_SUCCESS == revl) {\r
- log("FwImage succeeded!", Project.MSG_VERBOSE);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "FwImage succeeded!");\r
} else {\r
//\r
// command execution fail\r
//\r
- log("ERROR = " + Integer.toHexString(revl));\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));\r
throw new BuildException("FwImage failed!");\r
}\r
} catch (Exception e) {\r
@param time string of time\r
**/\r
public void setTime(String time) {\r
- this.time = " -t " + time;\r
+ this.time.setArg(" -t ", time);\r
}\r
\r
/**\r
@return time string of time\r
**/\r
public String getTime() {\r
- return this.time;\r
+ return this.time.getValue();\r
}\r
\r
/**\r
@return name of PE image\r
**/\r
public String getPeImage() {\r
- return this.peImage;\r
+ return this.peImage.getValue();\r
}\r
\r
/**\r
@param peImage name of PE image\r
**/\r
public void setPeImage(String peImage) {\r
- this.peImageName = (new File(peImage)).getName();\r
- this.peImage = " " + peImage;\r
+ this.peImage.setArg(" ", peImage);\r
}\r
\r
/**\r
@return name of output EFI image\r
**/\r
public String getOutImage() {\r
- return this.outImage;\r
+ return this.outImage.getValue();\r
}\r
\r
/**\r
@param outImage name of output EFI image\r
**/\r
public void setOutImage(String outImage) {\r
- this.outImage = " " + outImage;\r
+ this.outImage.setArg(" ", outImage);\r
}\r
\r
/**\r
@return string of componentType\r
**/\r
public String getComponentType() {\r
- return this.componentType;\r
+ return this.componentType.getValue();\r
}\r
\r
/**\r
@param componentType string of component type\r
**/\r
public void setComponentType(String componentType) {\r
- this.componentType = " " + componentType;\r
+ this.componentType.setArg(" ", componentType);\r
}\r
}\r
\r
**/\r
package org.tianocore.framework.tasks;\r
+\r
import java.io.File;\r
\r
import org.apache.tools.ant.BuildException;\r
import org.apache.tools.ant.taskdefs.Execute;\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
GenDepexTask\r
\r
\r
**/\r
public class GenDepexTask extends Task implements EfiDefine {\r
- ///\r
- /// output binary dependency files name\r
- ///\r
- private String outputFile = "";\r
- ///\r
- /// input pre-processed dependency text files name\r
- ///\r
- private String inputFile = "";\r
- private String inputFileName = "";\r
- ///\r
- /// padding integer value\r
- ///\r
- private String padding = "";\r
+ private static String toolName = "GenDepex";\r
+ //\r
+ // output binary dependency files name\r
+ //\r
+ private FileArg outputFile = new FileArg();\r
+ //\r
+ // input pre-processed dependency text files name\r
+ //\r
+ private FileArg inputFile = new FileArg();\r
+ //\r
+ // padding integer value\r
+ //\r
+ private ToolArg padding = new FileArg();\r
/**\r
execute\r
\r
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
String command;\r
if (path == null) {\r
- command = "GenDepex";\r
+ command = toolName;\r
} else {\r
- command = path + "/" + "GenDepex";\r
+ command = path + File.separator + toolName;\r
}\r
//\r
// argument of GenDepex tool\r
//\r
- String argument = inputFile + outputFile + padding;\r
+ String argument = "" + inputFile + outputFile + padding;\r
//\r
// reture value of GenDepex execution\r
//\r
runner.setAntRun(project);\r
runner.setCommandline(commandLine.getCommandline());\r
\r
- log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);\r
- log(inputFileName);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));\r
+ EdkLog.log(this, inputFile.toFileList() + " => " + outputFile.toFileList());\r
+\r
returnVal = runner.execute();\r
if (EFI_SUCCESS == returnVal) {\r
- log("GenDepex succeeded!", Project.MSG_VERBOSE);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenDepex succeeded!");\r
} else {\r
//\r
// command execution fail\r
//\r
- log("ERROR = " + Integer.toHexString(returnVal));\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));\r
throw new BuildException("GenDepex failed!");\r
}\r
} catch (Exception e) {\r
@param outputFileName name of output file\r
**/\r
public void setOutputFile(String outputFileName) {\r
- this.outputFile = " -O " + outputFileName;\r
+ this.outputFile.setArg(" -O ", outputFileName);\r
}\r
\r
/**\r
@return name of ouput file\r
**/\r
public String getOutputFile() {\r
- return this.outputFile;\r
+ return this.outputFile.getValue();\r
}\r
\r
/**\r
@param inputFileName name of inputFile\r
**/\r
public void setInputFile(String inputFileName) {\r
- this.inputFileName = (new File(inputFileName)).getName();\r
- this.inputFile = " -I " + inputFileName;\r
+ this.inputFile.setArg(" -I ", inputFileName);\r
}\r
\r
/**\r
@return name of input file\r
**/\r
public String getInputFile() {\r
- return this.inputFile;\r
+ return this.inputFile.getValue();\r
}\r
\r
/**\r
@param paddingNum padding value\r
**/\r
public void setPadding(String paddingNum) {\r
- this.padding = " -P " + paddingNum;\r
+ this.padding.setArg(" -P ", paddingNum);\r
}\r
\r
/**\r
@return value of padding\r
**/\r
public String getPadding() {\r
- return this.padding;\r
+ return this.padding.getValue();\r
}\r
}\r
import org.apache.tools.ant.BuildException;\r
import org.apache.tools.ant.Project;\r
import org.apache.tools.ant.Task;\r
+import org.apache.tools.ant.taskdefs.Execute;\r
+import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
+import org.apache.tools.ant.types.Commandline;\r
\r
import java.io.File;\r
import java.io.InputStreamReader;\r
import java.lang.ProcessBuilder;\r
import java.util.LinkedList;\r
\r
+import org.tianocore.common.logger.EdkLog;\r
+\r
/**\r
GenFvImageTask\r
\r
\r
**/\r
public class GenFvImageTask extends Task implements EfiDefine{\r
- ///\r
- /// tool name\r
- ///\r
+ //\r
+ // tool name\r
+ //\r
static final private String toolName = "GenFvImage";\r
- ///\r
- /// The name of input inf file\r
- ///\r
- private String infFile="";\r
- ///\r
- /// Output directory\r
- ///\r
+ //\r
+ // The name of input inf file\r
+ //\r
+ private FileArg infFile = new FileArg();\r
+ //\r
+ // Output directory\r
+ //\r
private String outputDir = ".";\r
- ///\r
- /// argument list\r
- ///\r
- LinkedList<String> argList = new LinkedList<String>();\r
\r
/**\r
execute\r
Project project = this.getOwningTarget().getProject();\r
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");\r
\r
+ String command;\r
if (path == null) {\r
- path = "";\r
+ command = toolName;\r
} else {\r
- path += File.separatorChar;\r
+ command = path + File.separator + toolName;\r
}\r
- argList.addFirst(path + toolName);\r
\r
- /// lauch the program\r
- ///\r
- ProcessBuilder pb = new ProcessBuilder(argList);\r
- pb.directory(new File(outputDir));\r
+ String argument = "" + infFile;\r
+ //\r
+ // lauch the program\r
+ //\r
int exitCode = 0;\r
- log((new File(this.infFile)).getName());\r
try {\r
- Process cmdProc = pb.start();\r
- InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream());\r
- char[] buf = new char[1024];\r
+ Commandline cmdline = new Commandline();\r
+ cmdline.setExecutable(command);\r
+ cmdline.createArgument().setLine(argument);\r
+\r
+ LogStreamHandler streamHandler = new LogStreamHandler(this,\r
+ Project.MSG_INFO, Project.MSG_WARN);\r
+ Execute runner = new Execute(streamHandler, null);\r
\r
- exitCode = cmdProc.waitFor();\r
+ runner.setAntRun(project);\r
+ runner.setCommandline(cmdline.getCommandline());\r
+ runner.setWorkingDirectory(new File(outputDir)); \r
+ //\r
+ // log command line string.\r
+ //\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+ EdkLog.log(this, infFile.toFileList());\r
+\r
+ exitCode = runner.execute();\r
if (exitCode != 0) {\r
- int len = cmdOut.read(buf, 0, 1024);\r
- log(new String(buf, 0, len));\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(exitCode));\r
} else {\r
- log("GenFvImage succeeded!", Project.MSG_VERBOSE);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenFvImage succeeded!");\r
}\r
} catch (Exception e) {\r
throw new BuildException(e.getMessage());\r
throw new BuildException("GenFvImage: failed to generate FV file!");\r
}\r
}\r
-\r
}\r
/**\r
getInfFile\r
@return String name of infFile\r
**/\r
public String getInfFile() {\r
- return infFile;\r
+ return infFile.getValue();\r
}\r
\r
/**\r
@param infFile name of infFile\r
**/\r
public void setInfFile(String infFile) {\r
- this.infFile = infFile;\r
- argList.add("-I");\r
- argList.add(infFile);\r
+ this.infFile.setArg(" -I ", infFile);\r
}\r
\r
/**\r
import org.apache.tools.ant.types.Commandline;\r
import org.tianocore.common.logger.EdkLog;\r
\r
-public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes {\r
- ///\r
- /// inputfile name\r
- ///\r
- private String inputFile = "";\r
- ///\r
- /// \r
- /// \r
- private String inputFileName = "";\r
- ///\r
- /// outputfile name\r
- ///\r
- private String outputFile = "";\r
- ///\r
- /// section type\r
- ///\r
- private String sectionType = "";\r
- ///\r
- /// version number\r
- ///\r
- private String versionNum = "";\r
- ///\r
- /// interface string\r
- ///\r
- private String interfaceString = "";\r
- ///\r
- /// Section file list\r
- ///\r
+public class GenSectionTask extends Task implements EfiDefine, Section, FfsTypes {\r
+ //\r
+ // inputfile name\r
+ //\r
+ private FileArg inputFile = new FileArg();\r
+ //\r
+ // outputfile name\r
+ //\r
+ private FileArg outputFile = new FileArg();\r
+ //\r
+ // section type\r
+ //\r
+ private ToolArg sectionType = new ToolArg();\r
+ //\r
+ // version number\r
+ //\r
+ private ToolArg versionNum = new ToolArg();\r
+ //\r
+ // interface string\r
+ //\r
+ private ToolArg interfaceString = new ToolArg();\r
+ //\r
+ // Section file list\r
+ //\r
private List<Section> sectFileList = new ArrayList<Section>();\r
\r
/**\r
//\r
// argument of tools\r
//\r
- String argument = inputFile + outputFile + " -s "+ sectionType + versionNum\r
- + interfaceString;\r
+ String argument = "" + inputFile + outputFile + sectionType + versionNum + interfaceString;\r
//\r
// return value of gensection execution\r
//\r
runner.setAntRun(project);\r
runner.setCommandline(cmdline.getCommandline());\r
\r
- EdkLog.log(this, EdkLog.EDK_INFO, inputFileName);\r
- EdkLog.log(this, EdkLog.EDK_DEBUG, Commandline.toString(cmdline.getCommandline()));\r
+ EdkLog.log(this, inputFile.toFileList() + " => " + outputFile.toFileList());\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+\r
revl = runner.execute();\r
if (EFI_SUCCESS == revl) {\r
- log("GenSection succeeded!", Project.MSG_VERBOSE);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenSection succeeded!");\r
} else {\r
//\r
// command execution fail\r
//\r
- log("ERROR = " + Integer.toHexString(revl));\r
+ EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));\r
throw new BuildException("GenSection failed!");\r
}\r
} catch (Exception e) {\r
@return name of input file\r
**/\r
public String getInputFile() {\r
- return this.inputFile;\r
+ return this.inputFile.getValue();\r
}\r
\r
/**\r
@param inputFile name of input file\r
**/\r
public void setInputFile(String inputFile) {\r
- this.inputFileName = (new File(inputFile)).getName();\r
- this.inputFile = " -i " + inputFile;\r
+ this.inputFile.setArg(" -i ", inputFile);\r
}\r
\r
/**\r
@return name of output file\r
**/\r
public String getOutputFile() {\r
- return this.outputFile;\r
+ return this.outputFile.getValue();\r
}\r
\r
/**\r
@param outputFile name of output file\r
**/\r
public void setOutputfile(String outputFile) {\r
- this.outputFile = " -o " + outputFile;\r
+ this.outputFile.setArg(" -o ", outputFile);\r
}\r
\r
/**\r
@return sectoin type\r
**/\r
public String getSectionType() {\r
- return this.sectionType;\r
+ return this.sectionType.getValue();\r
}\r
\r
/**\r
@param sectionType section type\r
**/\r
public void setSectionType(String sectionType) {\r
- this.sectionType = sectionType;\r
+ this.sectionType.setArg(" -s ", sectionType);\r
}\r
\r
/**\r
@return version number\r
**/\r
public String getVersionNum() {\r
- return this.versionNum;\r
+ return this.versionNum.getValue();\r
}\r
\r
/**\r
@param versionNum version number\r
**/\r
public void setVersionNum(String versionNum) {\r
- this.versionNum = " -v " + versionNum;\r
+ this.versionNum.setArg(" -v ", versionNum);\r
}\r
\r
/**\r
@return interface string\r
**/\r
public String getInterfaceString() {\r
- return this.interfaceString;\r
+ return this.interfaceString.getValue();\r
}\r
\r
/**\r
@param interfaceString interface string\r
**/\r
public void setInterfaceString(String interfaceString) {\r
- this.interfaceString = " -a " + "\"" + interfaceString + "\"";\r
+ this.interfaceString.setArg(" -a ", "\"" + interfaceString + "\"");\r
}\r
\r
/**\r
// Search SectionList find earch section and call it's \r
// ToBuffer function.\r
//\r
- if (this.sectionType.equalsIgnoreCase("EFI_SECTION_COMPRESSION")){\r
+ if (this.sectionType.getValue().equalsIgnoreCase("EFI_SECTION_COMPRESSION")){\r
Section sect;\r
\r
//\r
private boolean isUptodate() {\r
File df = new File(depsFile);\r
if (!df.exists()) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, depsFile + " doesn't exist!");\r
return false;\r
}\r
\r
for (int i = 0, length = fileList.size(); i < length; ++i) {\r
File sf = new File(fileList.get(i));\r
if (sf.lastModified() > depsFileTimeStamp) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, sf.getPath() + " has been changed since last build!");\r
return false;\r
}\r
}\r
//\r
LineNumberReader lineReader = null;\r
FileReader fileReader = null;\r
- boolean ret = true;\r
+ boolean ret = false;\r
try {\r
fileReader = new FileReader(df);\r
lineReader = new LineNumberReader(fileReader);\r
\r
String line = null;\r
+ int lines = 0;\r
while ((line = lineReader.readLine()) != null) {\r
- File sourceFile = new File(line);\r
+ //\r
+ // check file end flag "\t" to see if the .dep was generated correctly\r
+ // \r
+ if (line.equals("\t")) {\r
+ ret = true;\r
+ continue;\r
+ }\r
+ line = line.trim();\r
+ //\r
+ // skip empty line\r
+ // \r
+ if (line.length() == 0) {\r
+ continue;\r
+ }\r
+ ++lines;\r
+\r
//\r
// If a file cannot be found (moved or removed) or newer, regenerate the dep file\r
// \r
+ File sourceFile = new File(line);\r
if ((!sourceFile.exists()) || (sourceFile.lastModified() > depsFileTimeStamp)) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, sourceFile.getPath() + " has been (re)moved or changed since last build!");\r
ret = false;\r
break;\r
}\r
}\r
+\r
+ //\r
+ // check if the .dep file is empty\r
+ // \r
+ if (lines == 0) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, depsFile + " is empty!");\r
+ ret = false;\r
+ }\r
+\r
lineReader.close();\r
fileReader.close();\r
} catch (IOException e) {\r
- log (e.getMessage());\r
+ throw new BuildException(e.getMessage());\r
}\r
\r
return ret;\r
//\r
private List<String> nameList = new ArrayList<String>();\r
\r
+ /**\r
+ Insert content in the newElement into this NestElement\r
+\r
+ @param newElement The new NestElement\r
+ **/\r
+ public void insert(NestElement newElement) {\r
+ this.nameList.addAll(newElement.getNameList());\r
+ }\r
+\r
/**\r
Handle "name" attribute. No delimiter and special treatment are assumed.\r
\r
**/\r
public void setName(String name) {\r
if (name.length() > 0) {\r
- nameList.add(name);\r
+ this.nameList.clear();\r
+ this.nameList.add(name);\r
+ }\r
+ }\r
+\r
+ public void insName(String name) {\r
+ if (name.length() > 0) {\r
+ this.nameList.add(name);\r
}\r
}\r
\r
return;\r
}\r
\r
+ this.nameList.clear();\r
StringTokenizer tokens = new StringTokenizer(nameList, " \t,;", false);\r
while (tokens.hasMoreTokens()) {\r
String name = tokens.nextToken().trim();\r
//\r
// Read line by line\r
// \r
+ nameList.clear();\r
while((str = in.readLine()) != null){\r
str = str.trim();\r
if (str.length() == 0){\r
}\r
\r
//getProject().replaceProperties(str);\r
- nameList.add(str);\r
+ this.nameList.add(str);\r
}\r
} catch (Exception e){\r
throw new BuildException(e.getMessage()); \r
setPath(file);\r
}\r
\r
+ /**\r
+ Add a file or file list into the file list\r
+\r
+ @param file The path of a file\r
+ **/\r
+ public void insFile(String file) {\r
+ insPath(file);\r
+ }\r
+\r
/**\r
Handle "path" attribute. The value of "path" may contain compound path\r
separator (/ or \) which should be cleaned up. Because the "path" string\r
@param path String value of a file system path\r
**/\r
public void setPath(String path) {\r
+ this.nameList.clear();\r
+ insPath(path);\r
+ }\r
+\r
+ /**\r
+ Add a path or path list into the path list\r
+\r
+ @param path The path string\r
+ **/\r
+ public void insPath(String path) {\r
if (path.length() == 0) {\r
return;\r
}\r
//\r
// Read the file line by line, skipping empty ones\r
// \r
+ nameList.clear();\r
while((path = in.readLine()) != null){\r
path = path.trim();\r
if (path.length() == 0){\r
return string.toString();\r
}\r
\r
+ /**\r
+ Compose and return the name/path string concatenated by space and\r
+ with only one "prefix".\r
+\r
+ @param prefix The prefix at the beginning of the string\r
+ \r
+ @return String The string with one prefix at the beginning\r
+ **/\r
+ public String toStringWithSinglepPrefix(String prefix) {\r
+ return prefix + toString(" ");\r
+ }\r
+\r
+ /**\r
+ Compose a string list with file names only, separated by spcified string\r
+\r
+ @param separator The separator string\r
+ \r
+ @return String The file list\r
+ **/\r
+ public String toFileList(String separator) {\r
+ StringBuffer string = new StringBuffer(1024);\r
+ int length = nameList.size();\r
+\r
+ for (int i = 0; i < length; ++i) {\r
+ File file = new File(nameList.get(i));\r
+ string.append(file.getName());\r
+ string.append(separator);\r
+ }\r
+\r
+ return string.toString();\r
+ }\r
+\r
+ /**\r
+ Compose a string list with file names only, separated by space\r
+\r
+ @return String The list string\r
+ **/\r
+ public String toFileList() {\r
+ return toFileList(" ");\r
+ }\r
+\r
//\r
// Remove any duplicated path separator or inconsistent path separator\r
//\r
PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.\r
**/\r
public class PeiReBaseTask extends Task implements EfiDefine {\r
- ///\r
- /// tool name\r
- ///\r
+ //\r
+ // tool name\r
+ //\r
private String toolName = "PeiReBase";\r
- // /\r
- // / Input file\r
- // /\r
- private String inputFile = "";\r
- private String inputFileName = "";\r
- // /\r
- // / Output file\r
- // /\r
- private String outputFile = "";\r
-\r
- // /\r
- // / Output directory, this variable is added by jave wrap\r
- // /\r
- private String outputDir = "";\r
-\r
- ///\r
- /// Base address\r
- ///\r
- private String baseAddr = "";\r
-\r
- ///\r
- /// Architecture\r
- ///\r
- private String arch = "";\r
+ //\r
+ // Input file\r
+ //\r
+ private FileArg inputFile = new FileArg();\r
+ //\r
+ // Output file\r
+ //\r
+ private FileArg outputFile = new FileArg();\r
+ //\r
+ // Base address\r
+ //\r
+ private ToolArg baseAddr = new ToolArg();\r
+ //\r
+ // \r
+ // \r
+ private FileArg mapFile = new FileArg();\r
+ //\r
+ // Architecture\r
+ //\r
+ private String arch = "IA32";\r
\r
/**\r
- * execute\r
- *\r
- * PeiReBaseTask execute function is to assemble tool command line & execute\r
- * tool command line\r
- *\r
- * @throws BuidException\r
- */\r
+ execute\r
+ \r
+ PeiReBaseTask execute function is to assemble tool command line & execute\r
+ tool command line\r
+ \r
+ @throws BuidException\r
+ **/\r
public void execute() throws BuildException {\r
\r
Project project = this.getOwningTarget().getProject();\r
String argument;\r
if (this.arch.equalsIgnoreCase("IA32")){\r
command = toolName + "_IA32";\r
- }else if (this.arch.equalsIgnoreCase("X64")){\r
+ } else if (this.arch.equalsIgnoreCase("X64")){\r
command = toolName + "_X64";\r
- }else if (this.arch.equalsIgnoreCase("IPF")){\r
+ } else if (this.arch.equalsIgnoreCase("IPF")){\r
command = toolName + "_IPF";\r
- }else {\r
+ } else {\r
command = toolName + "_IA32";\r
}\r
if (path != null) {\r
- command = path + File.separatorChar + command;\r
+ command = path + File.separator + command;\r
}\r
\r
//\r
// argument of tools\r
//\r
- File file = new File(outputFile);\r
- if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {\r
- argument = inputFile + " " + "-O " + outputDir + File.separatorChar\r
- + outputFile + " " + this.baseAddr + " "\r
- + "-M " + outputDir + + File.separatorChar + outputFile + ".map";\r
- } else {\r
- argument = inputFile + " " + "-O " + outputFile + " " + this.baseAddr+ " " + "-M " + outputFile + ".map";\r
+ if (mapFile.getValue().length() == 0) {\r
+ mapFile.setArg(" -M ", outputFile.getValue() + ".map");\r
}\r
+ argument = "" + inputFile + outputFile + baseAddr + mapFile;\r
\r
//\r
// return value of fwimage execution\r
// Set debug log information.\r
//\r
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
- EdkLog.log(this, EdkLog.EDK_INFO, this.inputFileName);\r
+ EdkLog.log(this, EdkLog.EDK_INFO, inputFile.toFileList() + " => " \r
+ + outputFile.toFileList()\r
+ + mapFile.toFileList());\r
\r
revl = runner.execute();\r
\r
}\r
\r
/**\r
- * getInputFile\r
- *\r
- * This function is to get class member "inputFile".\r
- *\r
- * @return string of input file name.\r
- */\r
+ getInputFile\r
+ \r
+ This function is to get class member "inputFile".\r
+ \r
+ @return string of input file name.\r
+ **/\r
public String getInputFile() {\r
- return inputFile;\r
+ return inputFile.getValue();\r
}\r
\r
/**\r
- * setComponentType\r
- *\r
- * This function is to set class member "inputFile".\r
- *\r
- * @param inputFile\r
- * string of input file name.\r
- */\r
+ setComponentType\r
+ \r
+ This function is to set class member "inputFile".\r
+ \r
+ @param inputFile\r
+ string of input file name.\r
+ **/\r
public void setInputFile(String inputFile) {\r
- this.inputFileName = (new File(inputFile)).getName();\r
- this.inputFile = "-I " + inputFile;\r
+ this.inputFile.setArg(" -I ", inputFile);\r
}\r
\r
/**\r
- * getOutputFile\r
- *\r
- * This function is to get class member "outputFile"\r
- *\r
- * @return outputFile string of output file name.\r
- */\r
+ getOutputFile\r
+ \r
+ This function is to get class member "outputFile"\r
+ \r
+ @return outputFile string of output file name.\r
+ **/\r
public String getOutputFile() {\r
- return outputFile;\r
+ return outputFile.getValue();\r
}\r
\r
/**\r
- * setOutputFile\r
- *\r
- * This function is to set class member "outputFile"\r
- *\r
- * @param outputFile\r
- * string of output file name.\r
- */\r
+ setOutputFile\r
+ \r
+ This function is to set class member "outputFile"\r
+ \r
+ @param outputFile\r
+ string of output file name.\r
+ **/\r
public void setOutputFile(String outputFile) {\r
- this.outputFile = outputFile;\r
- }\r
-\r
- /**\r
- * getOutputDir\r
- *\r
- * This function is to get class member "outputDir"\r
- *\r
- * @return outputDir string of output directory.\r
- */\r
- public String getOutputDir() {\r
- return outputDir;\r
- }\r
-\r
- /**\r
- * setOutputDir\r
- *\r
- * This function is to set class member "outputDir"\r
- *\r
- * @param outputDir\r
- * string of output directory.\r
- */\r
- public void setOutputDir(String outputDir) {\r
- this.outputDir = outputDir;\r
+ this.outputFile.setArg(" -O ", outputFile);\r
}\r
\r
/**\r
- * getBaseAddr\r
- *\r
- * This function is to get class member "baseAddr"\r
- *\r
- * @return baseAddr string of base address.\r
- */\r
+ getBaseAddr\r
+ \r
+ This function is to get class member "baseAddr"\r
+ \r
+ @return baseAddr string of base address.\r
+ **/\r
public String getBaseAddr() {\r
- return baseAddr;\r
+ return baseAddr.getValue();\r
}\r
\r
/**\r
- * setBaseAddr\r
- *\r
- * This function is to set class member "baseAddr"\r
- *\r
- * @param baseAddr string of base address\r
- */\r
+ setBaseAddr\r
+ \r
+ This function is to set class member "baseAddr"\r
+ \r
+ @param baseAddr string of base address\r
+ **/\r
public void setBaseAddr(String baseAddr) {\r
- this.baseAddr = "-B " + baseAddr;\r
+ this.baseAddr.setArg(" -B ", baseAddr);\r
}\r
\r
/**\r
- * getArch\r
- *\r
- * This function is to get class member "arch".\r
- *\r
- * @return arch Architecture\r
- */\r
+ getArch\r
+ \r
+ This function is to get class member "arch".\r
+ \r
+ @return arch Architecture\r
+ **/\r
public String getArch() {\r
return arch;\r
}\r
\r
/**\r
- * setArch\r
- *\r
- * This function is to set class member "arch"\r
- *\r
- * @param arch Architecture\r
- */\r
+ setArch\r
+ \r
+ This function is to set class member "arch"\r
+ \r
+ @param arch Architecture\r
+ **/\r
public void setArch(String arch) {\r
this.arch = arch;\r
}\r
+\r
+ /**\r
+ Get the value of map file\r
+\r
+ @return String The map file path\r
+ **/\r
+ public String getMapFile() {\r
+ return mapFile.getValue();\r
+ }\r
+\r
+ /**\r
+ Set "-M MapFile" argument\r
+\r
+ @param mapFile The path of map file\r
+ **/\r
+ public void setMapFile(String mapFile) {\r
+ this.mapFile.setArg(" -M ", mapFile);\r
+ }\r
}\r
import org.apache.tools.ant.taskdefs.Execute;\r
import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
import org.apache.tools.ant.types.Commandline;\r
+import org.tianocore.common.logger.EdkLog;\r
\r
/**\r
StrGather Task Class\r
///\r
/// common options\r
///\r
- private String commandType = "";\r
+ private ToolArg commandType = new ToolArg();\r
\r
- private String baseName = "";\r
+ private ToolArg baseName = new ToolArg();\r
\r
///\r
/// "all/read/write"\r
///\r
- private String verbose = "";\r
+ private ToolArg verbose = new ToolArg();\r
\r
- private String outputDatabase = "";\r
+ private FileArg outputDatabase = new FileArg();\r
\r
- private List<Database> databaseList = new ArrayList<Database>();\r
+ private Database databaseList = new Database();\r
\r
- private List<InputFile> inputFileList = new ArrayList<InputFile>();\r
+ private InputFile inputFileList = new InputFile();\r
\r
///\r
/// parse options newDatabase -- "ture/false" unquoteString -- "ture/false"\r
///\r
- private String newDatabase = "";\r
+ private ToolArg newDatabase = new ToolArg();\r
\r
- private String unquotedString = "";\r
+ private ToolArg unquotedString = new ToolArg();\r
\r
- private List<IncludePath> includePathList = new ArrayList<IncludePath>();\r
+ private IncludePath includePathList = new IncludePath();\r
\r
///\r
/// scan options ignoreNotFound -- "ture/false"\r
///\r
- private String ignoreNotFound = "";\r
+ private ToolArg ignoreNotFound = new ToolArg();\r
\r
- private List<SkipExt> skipExtList = new ArrayList<SkipExt>();\r
+ private SkipExt skipExtList = new SkipExt();\r
\r
///\r
/// dump options\r
///\r
- private String outputString = "";\r
+ private ToolArg outputString = new ToolArg();\r
\r
- private String outputDefines = "";\r
+ private ToolArg outputDefines = new ToolArg();\r
\r
- private String outputUnicode = "";\r
+ private ToolArg outputUnicode = new ToolArg();\r
\r
- private String lang = "";\r
+ private ToolArg lang = new ToolArg();\r
\r
- private String indirectionFile = "";\r
+ private FileArg indirectionFile = new FileArg();\r
\r
- private String outputHpk = "";\r
+ private FileArg outputHpk = new FileArg();\r
\r
///\r
/// global variable\r
command = path + File.separator + "StrGather";\r
}\r
\r
- ///\r
- /// transfer nested elements into string\r
- ///\r
- String databases = list2Str(databaseList);\r
- String skipExts = list2Str(skipExtList);\r
- String includePaths = list2Str(includePathList);\r
- String inputFiles = list2Str(inputFileList);\r
-\r
///\r
/// assemble argument\r
///\r
- String argument = commandType + verbose + databases + baseName\r
- + outputDatabase + includePaths + newDatabase + unquotedString\r
- + skipExts + ignoreNotFound + outputString + outputDefines\r
+ String argument = "" + commandType + verbose + databaseList + baseName\r
+ + outputDatabase + includePathList + newDatabase + unquotedString\r
+ + skipExtList + ignoreNotFound + outputString + outputDefines\r
+ outputUnicode + lang + indirectionFile + outputHpk\r
- + inputFiles;\r
+ + inputFileList;\r
///\r
/// return value of fwimage execution\r
///\r
runner.setAntRun(project);\r
runner.setCommandline(cmdline.getCommandline());\r
\r
- log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);\r
- log(this.commandType.substring(2));\r
+ String cmdType = getCommandType();\r
+ if (cmdType.equalsIgnoreCase("parse")) {\r
+ EdkLog.log(this, "(parse) " + inputFileList.toFileList() + " => " \r
+ + databaseList.toFileList());\r
+ } else if (cmdType.equalsIgnoreCase("scan")) {\r
+ EdkLog.log(this, "(scan) " + databaseList.toFileList() + " => " \r
+ + outputDatabase.toFileList());\r
+ } else {\r
+ EdkLog.log(this, "(dump) " + databaseList.toFileList() + " => " \r
+ + outputDefines.toFileList() + outputString.toFileList() + outputHpk.toFileList());\r
+ }\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));\r
+\r
revl = runner.execute();\r
if (EFI_SUCCESS == revl) {\r
- log("StrGather succeeded!", Project.MSG_VERBOSE);\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "StrGather succeeded!");\r
} else {\r
///\r
/// command execution fail\r
///\r
- log("ERROR = " + Integer.toHexString(revl));\r
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));\r
throw new BuildException("StrGather failed!");\r
}\r
} catch (Exception e) {\r
@returns commandType parameter\r
**/\r
public String getCommandType() {\r
- return this.commandType;\r
+ return this.commandType.getValue();\r
}\r
\r
/**\r
@param commandType type of strgather command [parse/scan/dump]\r
**/\r
public void setCommandType(String commandType) {\r
- this.commandType = " -" + commandType;\r
+ this.commandType.setArg(" -", commandType);\r
}\r
\r
/**\r
@returns verbose parameter\r
**/\r
public String getVerbose() {\r
- return this.verbose;\r
+ return this.verbose.getValue();\r
}\r
\r
/**\r
///\r
/// for verbose output\r
///\r
- this.verbose = " -v ";\r
+ this.verbose.setArg(" -", "v");\r
} else if (verbose.equals("read")) {\r
///\r
/// for verbose output when reading database\r
///\r
- this.verbose = " -vdbr ";\r
+ this.verbose.setArg(" -", "vdbr");\r
} else if (verbose.equals("write")) {\r
///\r
/// for verbose output when writing database\r
///\r
- this.verbose = " -vdbw ";\r
+ this.verbose.setArg(" -", "vdbw");\r
}\r
}\r
\r
@returns baseName parameter\r
**/\r
public String getBaseName() {\r
- return this.baseName;\r
+ return this.baseName.getValue();\r
}\r
\r
/**\r
@param baseName name of the output files of .c and .h\r
**/\r
public void setBaseName(String baseName) {\r
- this.baseName = " -bn " + baseName;\r
+ this.baseName.setArg(" -bn ", baseName);\r
}\r
\r
/**\r
@returns outputDatabase parameter\r
**/\r
public String getOutputDatabase() {\r
- return this.outputDatabase;\r
+ return this.outputDatabase.getValue();\r
}\r
\r
/**\r
@param outputDatabase filename of output database file\r
**/\r
public void setOutputDatabase(String outputDatabase) {\r
- this.outputDatabase = " -od " + outputDatabase;\r
+ this.outputDatabase.setArg(" -od ", outputDatabase);\r
}\r
\r
/**\r
\r
@returns newDatabase parameter\r
**/\r
- public String getNewDatabse() {\r
- return this.newDatabase;\r
+ public boolean getNewDatabse() {\r
+ return this.newDatabase.getPrefix().length() > 0;\r
}\r
\r
/**\r
\r
@param newDatabase whether to not read in existing database file\r
**/\r
- public void setNewDatabase(String newDatabase) {\r
- if (newDatabase.equals("true")) {\r
- this.newDatabase = " -newdb ";\r
+ public void setNewDatabase(boolean newDatabase) {\r
+ if (newDatabase) {\r
+ this.newDatabase.setArg(" -", "newdb");\r
}\r
}\r
\r
\r
@returns unquotedString parameter\r
**/\r
- public String getUnquotedString() {\r
- return this.unquotedString;\r
+ public boolean getUnquotedString() {\r
+ return this.unquotedString.getValue().length() > 0;\r
}\r
\r
/**\r
@param unquotedString :\r
whether to indicate that unquoted strings are used\r
**/\r
- public void setUnquotedString(String unquotedString) {\r
- if (unquotedString.equals("true")) {\r
- this.unquotedString = " -uqs ";\r
+ public void setUnquotedString(boolean unquotedString) {\r
+ if (unquotedString) {\r
+ this.unquotedString.setArg(" -", "uqs");\r
}\r
}\r
\r
\r
@returns ignoreNotFound parameter\r
**/\r
- public String getIgnoreNotFound() {\r
- return this.ignoreNotFound;\r
+ public boolean getIgnoreNotFound() {\r
+ return this.ignoreNotFound.getValue().length() > 0;\r
}\r
\r
/**\r
@param ignoreNotFound whether to ignore if a given STRING_TOKEN(STR) \r
is not found in the database\r
**/\r
- public void setIgnoreNotFound(String ignoreNotFound) {\r
- if (ignoreNotFound.equals("true")) {\r
- this.ignoreNotFound = " -ignorenotfound ";\r
+ public void setIgnoreNotFound(boolean ignoreNotFound) {\r
+ if (ignoreNotFound) {\r
+ this.ignoreNotFound.setArg(" -", "ignorenotfound");\r
}\r
}\r
\r
@returns outputString parameter\r
**/\r
public String getOutputString() {\r
- return this.outputString;\r
+ return this.outputString.getValue();\r
}\r
\r
/**\r
@param outputString filename of string data file\r
**/\r
public void setOutputString(String outputString) {\r
- this.outputString = " -oc " + outputString;\r
+ this.outputString.setArg(" -oc ", outputString);\r
}\r
\r
/**\r
@returns outputDefines parameter\r
**/\r
public String getOutputDefines() {\r
- return this.outputDefines;\r
+ return this.outputDefines.getValue();\r
}\r
\r
/**\r
@param outputDefines filename of string defines file\r
**/\r
public void setOutputDefines(String outputDefines) {\r
- this.outputDefines = " -oh " + outputDefines;\r
+ this.outputDefines.setArg(" -oh ", outputDefines);\r
}\r
\r
/**\r
@returns outputUnicode parameter\r
**/\r
public String getOutputUnicode() {\r
- return this.outputUnicode;\r
+ return this.outputUnicode.getValue();\r
}\r
\r
/**\r
@param outputUnicode filename of unicode file to be dumped database\r
**/\r
public void setOutputUnicode(String outputUnicode) {\r
- this.outputUnicode = " -ou " + outputUnicode;\r
+ this.outputUnicode.setArg(" -ou ", outputUnicode);\r
}\r
\r
/**\r
@returns lang parameter\r
**/\r
public String getLang() {\r
- return this.lang;\r
+ return this.lang.getValue();\r
}\r
\r
/**\r
@param lang language of dump\r
**/\r
public void setLang(String lang) {\r
- this.lang = " -lang " + lang;\r
+ this.lang.setArg(" -lang ", lang);\r
}\r
\r
/**\r
@returns indirectionFile parameter\r
**/\r
public String getIndirectionFile() {\r
- return this.indirectionFile;\r
+ return this.indirectionFile.getValue();\r
}\r
\r
/**\r
@param indirectionFile filename of indirection file\r
**/\r
public void setIndirectionFile(String indirectionFile) {\r
- this.indirectionFile = " -if " + indirectionFile;\r
+ this.indirectionFile.setArg(" -if ", indirectionFile);\r
}\r
\r
/**\r
@returns outputHpk parameter\r
**/\r
public String getOutputHpk() {\r
- return this.outputHpk;\r
+ return this.outputHpk.getValue();\r
}\r
\r
/**\r
@param outputHpk filename of output HII export pack of the strings\r
**/\r
public void setOutputHpk(String outputHpk) {\r
- this.outputHpk = " -hpk " + outputHpk;\r
+ this.outputHpk.setArg(" -hpk ", outputHpk);\r
}\r
\r
/**\r
\r
@param skipExt skipExt element\r
**/\r
- public void addSkipext(SkipExt skipExt) {\r
- skipExtList.add(skipExt);\r
+ public void addConfiguredSkipext(SkipExt skipExt) {\r
+ this.skipExtList.insert(skipExt);\r
};\r
\r
/**\r
\r
@param includePath includePath element\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
@param inputFile inputFile element\r
**/\r
- public void addInputfile(InputFile inputFile) {\r
- inputFileList.add(inputFile);\r
+ public void addConfiguredInputfile(InputFile inputFile) {\r
+ this.inputFileList.insert(inputFile);\r
};\r
\r
/**\r
@param database :\r
database element\r
**/\r
- public void addDatabase(Database database) {\r
- databaseList.add(database);\r
- }\r
-\r
- /**\r
- Compose the content in each NestElement into a single string.\r
-\r
- @param list The NestElement list\r
- \r
- @return String\r
- **/\r
- private String list2Str(List list) {\r
- int listLength = list.size();\r
- String str = "";\r
- for (int i = 0; i < listLength; ++i) {\r
- NestElement e = (NestElement)list.get(i);\r
- str += e.toString();\r
- }\r
-\r
- return str;\r
+ public void addConfiguredDatabase(Database database) {\r
+ this.databaseList.insert(database);\r
}\r
}\r
**/\r
public class Tool implements EfiDefine, Section {\r
\r
- String toolName = "";\r
- List<Object> toolArgList = new ArrayList<Object>();\r
- String outputPath;\r
- File outputFile ;\r
- List<Input> inputFiles = new ArrayList<Input>();\r
- List<Section> gensectList = new ArrayList<Section>();\r
- String inputArg = "-i ";\r
+ private String toolName = "";\r
+ private ToolArg toolArgList = new ToolArg();\r
+ private Input inputFiles = new Input();\r
+ private String outputPath;\r
+ private File outputFile ;\r
+ private List<Section> gensectList = new ArrayList<Section>();\r
/**\r
Call extern tool\r
\r
String command = "";\r
String argument = "";\r
command = toolName;\r
- Iterator argIter = toolArgList.iterator();\r
- Iterator inputIter = inputFiles.iterator();\r
- ToolArg toolArg;\r
- Input file = null;\r
- \r
\r
//\r
// Get each section which under the compress {};\r
//\r
// Parse <genSection> element\r
//\r
- File outputFile = File.createTempFile("temp", "sec1",new File(outputPath));\r
+ File outputFile = File.createTempFile("temp", "sec1", new File(outputPath));\r
FileOutputStream bo = new FileOutputStream(outputFile);\r
DataOutputStream Do = new DataOutputStream (bo);\r
//\r
throw new BuildException ("GenSection failed at Tool!");\r
} \r
Do.close();\r
- this.inputArg += outputFile.getPath() + " "; \r
+ this.inputFiles.insFile(outputFile.getPath()); \r
} \r
} catch (IOException e){\r
throw new BuildException ("Gensection failed at tool!");\r
}\r
\r
- \r
- ///\r
- /// argument of tools\r
- ///\r
- while (argIter.hasNext()) {\r
- toolArg = (ToolArg)argIter.next();\r
- argument = argument + toolArg.getLine() + " ";\r
-\r
- }\r
-\r
- ///\r
- /// input files for tools\r
- ///\r
- while (inputIter.hasNext()) {\r
- file = (Input)inputIter.next();\r
- inputArg += file.toString(" ");\r
- }\r
try {\r
outputFile = File.createTempFile("temp", null, new File(outputPath));\r
- argument = argument + inputArg + " -o " + outputFile.getPath();\r
- EdkLog.log(EdkLog.EDK_INFO, argument);\r
+ argument = toolArgList + inputFiles.toStringWithSinglepPrefix(" -i ") \r
+ + " -o " + outputFile.getPath();\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, command + " " + argument);\r
///\r
/// execute command line\r
///\r
\r
@param toolArg The ToolArg object containing arguments for the tool\r
**/\r
- public void addToolArg (ToolArg toolArg) {\r
- toolArgList.add (toolArg);\r
+ public void addConfiguredToolArg (ToolArg toolArg) {\r
+ toolArgList.insert(toolArg);\r
}\r
\r
/**\r
\r
@param file The Input objec which represents a file\r
**/\r
- public void addInput(Input file) {\r
- inputFiles.add(file);\r
+ public void addConfiguredInput(Input file) {\r
+ inputFiles.insert(file);\r
}\r
\r
// /**\r
\r
public void addGenSection(GenSectionTask genSect){\r
this.gensectList.add(genSect);\r
- }\r
- \r
+ } \r
}\r
\r
\r
/** @file\r
-This file is to define nested element which is meant for specifying tool arguments\r
+This file is used to nest elements which is meant for tool's argument\r
\r
Copyright (c) 2006, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
package org.tianocore.framework.tasks;\r
\r
/**\r
- Class ToolArg is just used to specify arguments for genffsfile tool\r
+ ToolArg class is defined to represent the argument of a tool. The argument \r
+ includes the prefix (e.g. -I, -o) and the value.\r
**/\r
-public class ToolArg {\r
+public class ToolArg extends NestElement {\r
///\r
- /// keep the argument string\r
- ///\r
- private String line = "";\r
+ /// A constant which is used to represent an empty argument\r
+ /// \r
+ public final static ToolArg EMPTY_ARG = new ToolArg();\r
\r
- /**\r
- Get method of ANT task/datatype for attribute "line"\r
+ //\r
+ // Keep track the prefix of this argument\r
+ // \r
+ private String prefix = "";\r
\r
- @returns The argument string\r
+ /**\r
+ Default constructor\r
**/\r
- public String getLine() {\r
- return line;\r
+ public ToolArg() {\r
}\r
\r
/**\r
- Set method of ANT task/datatype for attribute "line"\r
+ Constructor which will initialize the prefix of this argument\r
\r
- @param line The argument string\r
- **/\r
+ @param prefix The string of prefix\r
+ */\r
+ public ToolArg(String prefix) {\r
+ this.prefix = prefix;\r
+ }\r
+\r
+ /**\r
+ Constructor which will initialize both the prefix and value of this argument\r
+ \r
+ @param prefix The prefix of this argument\r
+ @param value The value of this argument\r
+ */\r
+ public ToolArg(String prefix, String value) {\r
+ setArg(prefix, value);\r
+ }\r
+\r
+ /**\r
+ Set the prefix and value of this argument\r
+\r
+ @param prefix The prefix of this argument\r
+ @param value The value of this argument \r
+ */\r
+ public void setArg(String prefix, String value) {\r
+ this.prefix = prefix;\r
+ super.setName(value);\r
+ }\r
+\r
+ /**\r
+ Set the prefix of this argument\r
+\r
+ @param prefix The prefix of this argument\r
+ */\r
+ public void setPrefix(String prefix) {\r
+ this.prefix = prefix;\r
+ }\r
+\r
+ /**\r
+ Get the prefix of this argument\r
+\r
+ @return String The prefix of this argument\r
+ */\r
+ public String getPrefix() {\r
+ return this.prefix.trim();\r
+ }\r
+\r
+ /**\r
+ Set the value of this argument\r
+\r
+ @param value The value of this argument\r
+ */\r
+ public void setValue(String value) {\r
+ super.setName(value);\r
+ }\r
+\r
+ /**\r
+ Add a value for this argument\r
+\r
+ @param value The value of this argument\r
+ */\r
+ public void insValue(String value) {\r
+ super.insName(value);\r
+ }\r
+\r
+ /**\r
+ Get the value list of this argument, separated by space\r
+\r
+ @return String The value list\r
+ */\r
+ public String getValue() {\r
+ return super.toString(" ").trim();\r
+ }\r
+\r
+ /**\r
+ Set the argument as a whole\r
+\r
+ @param line The argument string line\r
+ */\r
public void setLine(String line) {\r
- this.line = line;\r
- } \r
-}
\ No newline at end of file
+ //\r
+ // Since the prefix is in the "line", we don't need another prefix.\r
+ // \r
+ this.prefix = " ";\r
+ super.setName(line);\r
+ }\r
+\r
+ /**\r
+ Get the argument line\r
+\r
+ @return String The argument string line\r
+ */\r
+ public String getLine() {\r
+ return this.toString();\r
+ }\r
+\r
+ /**\r
+ Compose a complete argument string.\r
+\r
+ @return String The complete argument\r
+ */\r
+ public String toString() {\r
+ return super.toString(prefix);\r
+ }\r
+}\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 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
import org.apache.tools.ant.BuildException;\r
import org.apache.tools.ant.Task;\r
import org.apache.tools.ant.taskdefs.Sequential;\r
+import org.tianocore.common.logger.EdkLog;\r
\r
/**\r
Class OnDepdendency is used to check the timestamp between source files and\r
/**\r
Standard execute method of ANT task\r
**/\r
- public void execute() {\r
+ public void execute() throws BuildException {\r
if (isOutOfDate() && task != null) {\r
task.perform();\r
}\r
/// if no source files specified, take it as a fresh start\r
///\r
if (sources.nameList.size() == 0) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "No source file spcified!");\r
return true;\r
}\r
\r
String dstFileName = (String)dstIt.next();\r
File dstFile = new File(dstFileName);\r
if (!dstFile.exists()) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Target file [" + dstFileName + "] doesn't exist!");\r
return true;\r
}\r
\r
}\r
\r
if (dstTimeStamp < srcTimeStamp) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Source file [" + srcFileName + "] has been changed since last build!");\r
return true;\r
}\r
}\r
// Close our output file\r
//\r
if ((mGlobals.OutFptr != stdout) && (mGlobals.OutFptr != NULL)) {\r
+ fprintf(mGlobals.OutFptr, "\t\n"); // file ending flag\r
fclose (mGlobals.OutFptr);\r
}\r
\r