diff options
16 files changed, 1092 insertions, 872 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java index d0cc2f50dd..5f35685fbe 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/CompressSection.java @@ -32,7 +32,7 @@ import org.apache.tools.ant.BuildException; CompressSection indicate that all section which in it should be compressed.
**/
-public class CompressSection implements Section, FfsTypes{
+public class CompressSection implements Section, FfsTypes {
//
// The attribute of compressName.
//
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FileArg.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FileArg.java new file mode 100644 index 0000000000..86adb07581 --- /dev/null +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FileArg.java @@ -0,0 +1,65 @@ +/** @file
+This file is used to nest elements which is meant for file path
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+package org.tianocore.framework.tasks;
+
+/**
+ FileArg class is defined to represent tool's argument which specifies file path.
+ **/
+public class FileArg extends ToolArg {
+ /**
+ Default constructor
+ **/
+ public FileArg() {
+ }
+
+ /**
+ Constructor which accepts argument prefix and its value as parameters
+
+ @param prefix The prefix of argument
+ @param value The value of argument
+ **/
+ public FileArg(String prefix, String value) {
+ super(prefix);
+ this.setValue(value);
+ }
+
+ /**
+ Set the prefix and value of an argument
+
+ @param prefix The prefix of argument
+ @param value The value of argument
+ **/
+ public void setArg(String prefix, String value) {
+ super.setPrefix(prefix);
+ this.setValue(value);
+ }
+
+ /**
+ Set the value of an argument
+
+ @param value The value of the argument
+ **/
+ public void setValue(String value) {
+ super.setFile(value);
+ }
+
+ /**
+ Add a value of an argument
+
+ @param value The value of the argument
+ **/
+ public void insValue(String value) {
+ super.insFile(value);
+ }
+}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java index 44c5b9c6be..847abebb32 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java @@ -26,6 +26,9 @@ import java.util.List; import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.LogStreamHandler;
+import org.apache.tools.ant.types.Commandline;
import org.tianocore.common.logger.EdkLog;
@@ -35,109 +38,108 @@ import org.tianocore.common.logger.EdkLog; * FlashMapTask is used to call FlashMap.exe to generate flash map defition files and fd files.
*/
public class FlashMapTask extends Task implements EfiDefine {
- // /
- // / tool name
- // /
+ //
+ // tool name
+ //
private final String toolName = "FlashMap";
- // /
- // / Flash definition file
- // /
- private String flashDefFile = "";
-
- // /
- // / Flash device
- // /
- private String flashDevice = "";
-
- // /
- // / Flash device Image
- // /
- private String flashDeviceImage = "";
-
- // /
- // / MCI file
- // /
- private String mciFile = "";
-
- // /
- // / MCO file
- // /
- private String mcoFile = "";
-
- // /
- // / Discover FD image
- // /
- private String fdImage = "";
-
- // /
- // / Dsc file
- // /
- private String dscFile = "";
-
- // /
- // / Asm INC file
- // /
- private String asmIncFile = "";
-
- // /
- // / Image out file
- // /
- private String imageOutFile = "";
-
- // /
- // / Header file
- // /
- private String headerFile = "";
-
- // /
- // / Input string file
- // /
+ //
+ // Flash definition file
+ //
+ private FileArg flashDefFile = new FileArg();
+
+ //
+ // Flash device
+ //
+ private ToolArg flashDevice = new ToolArg();
+
+ //
+ // Flash device Image
+ //
+ private ToolArg flashDeviceImage = new ToolArg();
+
+ //
+ // MCI file
+ //
+ private FileArg mciFile = new FileArg();
+
+ //
+ // MCO file
+ //
+ private FileArg mcoFile = new FileArg();
+
+ //
+ // Discover FD image
+ //
+ private ToolArg fdImage = new ToolArg();
+
+ //
+ // Dsc file
+ //
+ private FileArg dscFile = new FileArg();
+
+ //
+ // Asm INC file
+ //
+ private FileArg asmIncFile = new FileArg();
+
+ //
+ // Image out file
+ //
+ private FileArg imageOutFile = new FileArg();
+
+ //
+ // Header file
+ //
+ private FileArg headerFile = new FileArg();
+
+ //
+ // Input string file
+ //
private String inStrFile = "";
- // /
- // / Output string file
- // /
+ //
+ // Output string file
+ //
private String outStrFile = "";
- // /
- // / Base address
- // /
- private String baseAddr = "";
-
- // /
- // / Aligment
- // /
- private String aligment = "";
-
- // /
- // / Padding value
- // /
- private String padValue = "";
-
- // /
- // / output directory
- // /
+ //
+ //
+ //
+ private FileArg strFile = new FileArg();
+ //
+ // Base address
+ //
+ private ToolArg baseAddr = new ToolArg();
+
+ //
+ // Aligment
+ //
+ private ToolArg aligment = new ToolArg();
+
+ //
+ // Padding value
+ //
+ private ToolArg padValue = new ToolArg();
+
+ //
+ // output directory
+ //
private String outputDir = ".";
- // /
- // / MCI file array
- // /
- List<Input> mciFileArray = new ArrayList<Input>();
-
- // /
- // / command and argument list
- // /
- LinkedList<String> argList = new LinkedList<String>();
+ //
+ // MCI file array
+ //
+ FileArg mciFileArray = new FileArg();
/**
- * execute
- *
- * FlashMapTask execute function is to assemble tool command line & execute
- * tool command line
- *
- * @throws BuidException
- */
+ execute
+
+ FlashMapTask execute function is to assemble tool command line & execute
+ tool command line
+
+ @throws BuidException
+ **/
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
@@ -149,54 +151,66 @@ public class FlashMapTask extends Task implements EfiDefine { if (path == null) {
command = toolName;
} else {
- command = path + File.separatorChar + toolName;
+ command = path + File.separator + toolName;
}
- argList.addFirst(command);
//
// add substituted input file and output file
//
if (this.inStrFile != null && this.outStrFile != null
- && !this.inStrFile.equalsIgnoreCase("")
- && !this.inStrFile.equalsIgnoreCase("")) {
- argList.add("-strsub");
- argList.add(this.inStrFile);
- argList.add(this.outStrFile);
+ && this.inStrFile.length() > 0 && this.outStrFile.length() > 0) {
+ strFile.setPrefix(" -strsub ");
+ strFile.insValue(this.inStrFile);
+ strFile.insValue(this.outStrFile);
}
+ String argument = "" + flashDefFile + flashDevice + flashDeviceImage
+ + mciFile + mcoFile + fdImage + dscFile + asmIncFile
+ + imageOutFile + headerFile + strFile + baseAddr
+ + aligment + padValue + mciFileArray;
- //
- // add microcode binary files
- //
- if (mciFileArray.size() > 0) {
- argList.add("-mcmerge");
- Iterator mciList = mciFileArray.iterator();
- while (mciList.hasNext()) {
- argList.addAll(((Input) mciList.next()).getNameList());
- }
- }
//
// lauch the program
//
- ProcessBuilder pb = new ProcessBuilder(argList);
- pb.directory(new File(outputDir));
+ // ProcessBuilder pb = new ProcessBuilder(argList);
+ // pb.directory(new File(outputDir));
int exitCode = 0;
try {
- Process cmdProc = pb.start();
- InputStreamReader cmdOut = new InputStreamReader(cmdProc
- .getInputStream());
- char[] buf = new char[1024];
+ Commandline cmdline = new Commandline();
+ cmdline.setExecutable(command);
+ cmdline.createArgument().setLine(argument);
+
+ LogStreamHandler streamHandler = new LogStreamHandler(this,
+ Project.MSG_INFO, Project.MSG_WARN);
+ Execute runner = new Execute(streamHandler, null);
- exitCode = cmdProc.waitFor();
+ runner.setAntRun(project);
+ runner.setCommandline(cmdline.getCommandline());
+
+ if (outputDir != null) {
+ runner.setWorkingDirectory(new File(outputDir));
+ }
//
// log command line string.
//
- EdkLog.log(this, EdkLog.EDK_VERBOSE, cmdProc.getOutputStream().toString());
- EdkLog.log(this, EdkLog.EDK_INFO, (new File(this.flashDefFile)).getName());
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
+ EdkLog.log(this, flashDefFile.toFileList()
+ + mciFile.toFileList()
+ + mciFileArray.toFileList()
+ + fdImage.toFileList()
+ + inStrFile
+ + " => "
+ + headerFile.toFileList()
+ + imageOutFile.toFileList()
+ + mcoFile.toFileList()
+ + dscFile.toFileList()
+ + asmIncFile.toFileList()
+ + outStrFile);
+
+ exitCode = runner.execute();
if (exitCode != 0) {
- int len = cmdOut.read(buf, 0, 1024);
- EdkLog.log(this, EdkLog.EDK_INFO, new String(buf, 0, len));
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(exitCode));
} else {
EdkLog.log(this, EdkLog.EDK_VERBOSE, "FlashMap succeeded!");
}
@@ -210,408 +224,383 @@ public class FlashMapTask extends Task implements EfiDefine { }
/**
- * getFlashDefFile
- *
- * This function is to get class member "flashDefFile"
- *
- * @return flashDeFile Name of flash definition file.
- */
+ getFlashDefFile
+
+ This function is to get class member "flashDefFile"
+
+ @return flashDeFile Name of flash definition file.
+ **/
public String getFlashDefFile() {
- return flashDefFile;
+ return this.flashDefFile.getValue();
}
/**
- * setFlashDefFile
- *
- * This function is to set class member "flashDefFile"
- *
- * @param flashDefFile
- * Name of flash definition file.
- */
+ setFlashDefFile
+
+ This function is to set class member "flashDefFile"
+
+ @param flashDefFile
+ Name of flash definition file.
+ **/
public void setFlashDefFile(String flashDefFile) {
- this.flashDefFile = flashDefFile;
- argList.add("-fdf");
- argList.add(this.flashDefFile);
+ this.flashDefFile.setArg(" -fdf ", flashDefFile);
}
/**
- * getAligment
- *
- * This function is to get class member "aligment"
- *
- * @return aligment String of aligment value.
- */
+ getAligment
+
+ This function is to get class member "aligment"
+
+ @return aligment String of aligment value.
+ **/
public String getAligment() {
- return aligment;
+ return this.aligment.getValue();
}
/**
- * setAligment
- *
- * This function is to set class member "aligment"
- *
- * @param aligment
- * String of aligment value.
- */
+ setAligment
+
+ This function is to set class member "aligment"
+
+ @param aligment
+ String of aligment value.
+ **/
public void setAligment(String aligment) {
- this.aligment = aligment;
- argList.add("-align");
- argList.add(this.aligment);
+ this.aligment.setArg(" -align ", aligment);
}
/**
- * getAsmIncFile
- *
- * This function is to get class member "asmIncFile"
- *
- * @return asmIncFile String of ASM include file.
- */
+ getAsmIncFile
+
+ This function is to get class member "asmIncFile"
+
+ @return asmIncFile String of ASM include file.
+ **/
public String getAsmIncFile() {
- return asmIncFile;
+ return this.asmIncFile.getValue();
}
/**
- * setAsmIncFile
- *
- * This function is to set class member "asmIncFile"
- *
- * @param asmIncFile
- * String of ASM include file.
- */
+ setAsmIncFile
+
+ This function is to set class member "asmIncFile"
+
+ @param asmIncFile
+ String of ASM include file.
+ **/
public void setAsmIncFile(String asmIncFile) {
- this.asmIncFile = asmIncFile;
- argList.add("-asmincfile");
- argList.add(this.asmIncFile);
+ this.asmIncFile.setArg(" -asmincfile ", asmIncFile);
}
/**
- * getBaseAddr
- *
- * This function is to get class member "baseAddr"
- *
- * @return baseAddr String of base address value.
- */
+ getBaseAddr
+
+ This function is to get class member "baseAddr"
+
+ @return baseAddr String of base address value.
+ **/
public String getBaseAddr() {
- return baseAddr;
+ return this.baseAddr.getValue();
}
/**
- * setBaseAddr
- *
- * This function is to set class member "baseAddr"
- *
- * @param baseAddr
- * String of base address value.
- */
+ setBaseAddr
+
+ This function is to set class member "baseAddr"
+
+ @param baseAddr
+ String of base address value.
+ **/
public void setBaseAddr(String baseAddr) {
- this.baseAddr = baseAddr;
- argList.add("-baseaddr");
- argList.add(this.baseAddr);
+ this.baseAddr.setArg(" -baseaddr ", baseAddr);
}
/**
- * getDscFile
- *
- * This function is to get class member "dscFile"
- *
- * @return dscFile name of DSC file
- */
+ getDscFile
+
+ This function is to get class member "dscFile"
+
+ @return dscFile name of DSC file
+ **/
public String getDscFile() {
- return dscFile;
+ return this.dscFile.getValue();
}
/**
- * setDscFile
- *
- * This function is to set class member "dscFile"
- *
- * @param dscFile
- * name of DSC file
- */
+ setDscFile
+
+ This function is to set class member "dscFile"
+
+ @param dscFile
+ name of DSC file
+ **/
public void setDscFile(String dscFile) {
- this.dscFile = dscFile;
- argList.add("-dsc");
- argList.add(this.dscFile);
+ this.dscFile.setArg(" -dsc ", dscFile);
}
/**
- * getFdImage
- *
- * This function is to get class member "fdImage"
- *
- * @return fdImage name of input FDI image file.
- */
+ getFdImage
+
+ This function is to get class member "fdImage"
+
+ @return fdImage name of input FDI image file.
+ **/
public String getFdImage() {
- return fdImage;
+ return this.fdImage.getValue();
}
/**
- * setFdImage
- *
- * This function is to set class member "fdImage"
- *
- * @param fdImage
- * name of input FDI image file.
- */
+ setFdImage
+
+ This function is to set class member "fdImage"
+
+ @param fdImage
+ name of input FDI image file.
+ **/
public void setFdImage(String fdImage) {
- this.fdImage = fdImage;
- argList.add("-discover");
- argList.add(this.fdImage);
+ this.fdImage.setArg(" -discover ", fdImage);
}
/**
- * getFlashDevice
- *
- * This function is to get class member "flashDevice".
- *
- * @return flashDevice name of flash device.
- */
+ getFlashDevice
+
+ This function is to get class member "flashDevice".
+
+ @return flashDevice name of flash device.
+ **/
public String getFlashDevice() {
- return flashDevice;
+ return this.flashDevice.getValue();
}
/**
- * setFlashDevice
- *
- * This function is to set class member "flashDevice"
- *
- * @param flashDevice
- * name of flash device.
- */
+ setFlashDevice
+
+ This function is to set class member "flashDevice"
+
+ @param flashDevice
+ name of flash device.
+ **/
public void setFlashDevice(String flashDevice) {
- this.flashDevice = flashDevice;
- argList.add("-flashdevice");
- argList.add(this.flashDevice);
+ this.flashDevice.setArg(" -flashdevice ", flashDevice);
}
/**
- * getFlashDeviceImage
- *
- * This function is to get class member "flashDeviceImage"
- *
- * @return flashDeviceImage name of flash device image
- */
+ getFlashDeviceImage
+
+ This function is to get class member "flashDeviceImage"
+
+ @return flashDeviceImage name of flash device image
+ **/
public String getFlashDeviceImage() {
- return flashDeviceImage;
+ return this.flashDeviceImage.getValue();
}
/**
- * setFlashDeviceImage
- *
- * This function is to set class member "flashDeviceImage"
- *
- * @param flashDeviceImage
- * name of flash device image
- */
+ setFlashDeviceImage
+
+ This function is to set class member "flashDeviceImage"
+
+ @param flashDeviceImage
+ name of flash device image
+ **/
public void setFlashDeviceImage(String flashDeviceImage) {
- this.flashDeviceImage = flashDeviceImage;
- argList.add("-flashdeviceimage");
- argList.add(this.flashDeviceImage);
+ this.flashDeviceImage.setArg(" -flashdeviceimage ", flashDeviceImage);
}
/**
- * getHeaderFile
- *
- * This function is to get class member "headerFile"
- *
- * @return headerFile name of include file
- */
+ getHeaderFile
+
+ This function is to get class member "headerFile"
+
+ @return headerFile name of include file
+ **/
public String getHeaderFile() {
- return headerFile;
+ return this.headerFile.getValue();
}
/**
- * setHeaderFile
- *
- * This function is to set class member "headerFile"
- *
- * @param headerFile
- * name of include file
- */
+ setHeaderFile
+
+ This function is to set class member "headerFile"
+
+ @param headerFile
+ name of include file
+ **/
public void setHeaderFile(String headerFile) {
- this.headerFile = headerFile;
- argList.add("-hfile");
- argList.add(this.headerFile);
+ this.headerFile.setArg(" -hfile ", headerFile);
}
/**
- * getImageOutFile
- *
- * This function is to get class member "imageOutFile"
- *
- * @return imageOutFile name of output image file
- */
+ getImageOutFile
+
+ This function is to get class member "imageOutFile"
+
+ @return imageOutFile name of output image file
+ **/
public String getImageOutFile() {
- return imageOutFile;
+ return this.imageOutFile.getValue();
}
/**
- * setImageOutFile
- *
- * This function is to set class member "ImageOutFile"
- *
- * @param imageOutFile
- * name of output image file
- */
+ setImageOutFile
+
+ This function is to set class member "ImageOutFile"
+
+ @param imageOutFile
+ name of output image file
+ **/
public void setImageOutFile(String imageOutFile) {
- this.imageOutFile = imageOutFile;
- argList.add("-imageout");
- argList.add(this.imageOutFile);
+ this.imageOutFile.setArg(" -imageout ", imageOutFile);
}
/**
- * getInStrFile
- *
- * This function is to get class member "inStrFile"
- *
- * @return inStrFile name of input file which used to replace symbol names.
- */
+ getInStrFile
+
+ This function is to get class member "inStrFile"
+
+ @return inStrFile name of input file which used to replace symbol names.
+ **/
public String getInStrFile() {
- return inStrFile;
+ return this.inStrFile;
}
/**
- * setInStrFile
- *
- * This function is to set class member "inStrFile"
- *
- * @param inStrFile
- * name of input file which used to replace symbol names.
- */
+ setInStrFile
+
+ This function is to set class member "inStrFile"
+
+ @param inStrFile
+ name of input file which used to replace symbol names.
+ **/
public void setInStrFile(String inStrFile) {
this.inStrFile = inStrFile;
}
/**
- * getMciFile
- *
- * This function is to get class member "mciFile"
- *
- * @return mciFile name of input microcode file
- */
+ getMciFile
+
+ This function is to get class member "mciFile"
+
+ @return mciFile name of input microcode file
+ **/
public String getMciFile() {
- return mciFile;
+ return this.mciFile.getValue();
}
/**
- * setMciFile
- *
- * This function is to set class member "mciFile"
- *
- * @param mciFile
- * name of input microcode file
- */
+ setMciFile
+
+ This function is to set class member "mciFile"
+
+ @param mciFile
+ name of input microcode file
+ **/
public void setMciFile(String mciFile) {
- this.mciFile = mciFile;
- argList.add("-mci");
- argList.add(this.mciFile);
+ this.mciFile.setArg(" -mci ", mciFile);
}
/**
- * getMcoFile
- *
- * This function is to get class member "mcoFile"
- *
- * @return mcoFile name of output binary microcode image
- */
+ getMcoFile
+
+ This function is to get class member "mcoFile"
+
+ @return mcoFile name of output binary microcode image
+ **/
public String getMcoFile() {
- return mcoFile;
+ return this.mcoFile.getValue();
}
/**
- * setMcoFile
- *
- * This function is to set class member "mcoFile"
- *
- * @param mcoFile
- * name of output binary microcode image
- */
+ setMcoFile
+
+ This function is to set class member "mcoFile"
+
+ @param mcoFile
+ name of output binary microcode image
+ **/
public void setMcoFile(String mcoFile) {
- this.mcoFile = mcoFile;
- argList.add("-mco");
- argList.add(this.mcoFile);
+ this.mcoFile.setArg(" -mco ", mcoFile);
}
/**
- * getOutStrFile
- *
- * This function is to get class member "outStrFile"
- *
- * @return outStrFile name of output string substitution file
- */
+ getOutStrFile
+
+ This function is to get class member "outStrFile"
+
+ @return outStrFile name of output string substitution file
+ **/
public String getOutStrFile() {
- return outStrFile;
+ return this.outStrFile;
}
/**
- * setOutStrFile
- *
- * This function is to set class member "outStrFile"
- *
- * @param outStrFile
- * name of output string substitution file
- */
+ setOutStrFile
+
+ This function is to set class member "outStrFile"
+
+ @param outStrFile
+ name of output string substitution file
+ **/
public void setOutStrFile(String outStrFile) {
this.outStrFile = outStrFile;
}
/**
- * getPadValue
- *
- * This function is to get class member "padValue"
- *
- * @return padValue string of byte value to use as padding
- */
+ getPadValue
+
+ This function is to get class member "padValue"
+
+ @return padValue string of byte value to use as padding
+ **/
public String getPadValue() {
- return padValue;
+ return this.padValue.getValue();
}
/**
- * setPadValue
- *
- * This function is to set class member "padValue"
- *
- * @param padValue
- * string of byte value to use as padding
- */
+ setPadValue
+
+ This function is to set class member "padValue"
+
+ @param padValue
+ string of byte value to use as padding
+ **/
public void setPadValue(String padValue) {
- this.padValue = padValue;
- argList.add("-padvalue");
- argList.add(this.padValue);
+ this.padValue.setArg(" -padvalue ", padValue);
}
/**
- * addMciFile
- *
- * This function is to add Microcode binary file
- *
- * @param mciFile
- * instance of input class
- */
- public void addMciFile(Input mciFile) {
- this.mciFileArray.add(mciFile);
+ addMciFile
+
+ This function is to add Microcode binary file
+
+ @param mciFile
+ instance of input class
+ **/
+ public void addConfiguredMciFile(FileArg mciFile) {
+ this.mciFileArray.setPrefix(" -mcmerge ");
+ this.mciFileArray.insert(mciFile);
}
/**
- * getOutputDir
- *
- * This function is to get class member "outputDir"
- *
- * @return outputDir string of output directory
- */
+ getOutputDir
+
+ This function is to get class member "outputDir"
+
+ @return outputDir string of output directory
+ **/
public String getOutputDir() {
return outputDir;
}
/**
- * setOutputDir
- *
- * This function is to set class member "outputDir"
- *
- * @param outputDir
- * string of output directory
- */
+ setOutputDir
+
+ This function is to set class member "outputDir"
+
+ @param outputDir
+ string of output directory
+ **/
public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FwImageTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FwImageTask.java index 13df297fa6..b17e7fbf12 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FwImageTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FwImageTask.java @@ -25,29 +25,34 @@ import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
+import org.tianocore.common.logger.EdkLog;
+
/**
FwImageTask class.
FwImageTask is used to call FwImage.ext to generate the FwImage.
**/
-public class FwImageTask extends Task implements EfiDefine{
- ///
- /// time&data
- ///
- private String time = "";
- ///
- /// input PE image
- ///
- private String peImage = "";
- private String peImageName = "";
- ///
- /// output EFI image
- ///
- private String outImage = "";
- ///
- /// component type
- ///
- private String componentType = "";
+public class FwImageTask extends Task implements EfiDefine {
+ //
+ // fwimage tool name
+ //
+ private static String toolName = "FwImage";
+ //
+ // time&data
+ //
+ private ToolArg time = new ToolArg();
+ //
+ // input PE image
+ //
+ private FileArg peImage = new FileArg();
+ //
+ // output EFI image
+ //
+ private FileArg outImage = new FileArg();
+ //
+ // component type
+ //
+ private ToolArg componentType = new ToolArg();
/**
* assemble tool command line & execute tool command line
@@ -71,14 +76,14 @@ public class FwImageTask extends Task implements EfiDefine{ String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
- command = "FwImage";
+ command = toolName;
} else {
- command = path + "/" + "FwImage";
+ command = path + "/" + toolName;
}
//
// argument of tools
//
- String argument = time + componentType + peImage + outImage;
+ String argument = "" + time + componentType + peImage + outImage;
//
// return value of fwimage execution
//
@@ -96,16 +101,17 @@ public class FwImageTask extends Task implements EfiDefine{ runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline());
- log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);
- log(this.peImageName);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
+ EdkLog.log(this, peImage.toFileList() + " => " + outImage.toFileList());
+
revl = runner.execute();
if (EFI_SUCCESS == revl) {
- log("FwImage succeeded!", Project.MSG_VERBOSE);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "FwImage succeeded!");
} else {
//
// command execution fail
//
- log("ERROR = " + Integer.toHexString(revl));
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("FwImage failed!");
}
} catch (Exception e) {
@@ -121,7 +127,7 @@ public class FwImageTask extends Task implements EfiDefine{ @param time string of time
**/
public void setTime(String time) {
- this.time = " -t " + time;
+ this.time.setArg(" -t ", time);
}
/**
@@ -131,7 +137,7 @@ public class FwImageTask extends Task implements EfiDefine{ @return time string of time
**/
public String getTime() {
- return this.time;
+ return this.time.getValue();
}
/**
@@ -141,7 +147,7 @@ public class FwImageTask extends Task implements EfiDefine{ @return name of PE image
**/
public String getPeImage() {
- return this.peImage;
+ return this.peImage.getValue();
}
/**
@@ -151,8 +157,7 @@ public class FwImageTask extends Task implements EfiDefine{ @param peImage name of PE image
**/
public void setPeImage(String peImage) {
- this.peImageName = (new File(peImage)).getName();
- this.peImage = " " + peImage;
+ this.peImage.setArg(" ", peImage);
}
/**
@@ -162,7 +167,7 @@ public class FwImageTask extends Task implements EfiDefine{ @return name of output EFI image
**/
public String getOutImage() {
- return this.outImage;
+ return this.outImage.getValue();
}
/**
@@ -172,7 +177,7 @@ public class FwImageTask extends Task implements EfiDefine{ @param outImage name of output EFI image
**/
public void setOutImage(String outImage) {
- this.outImage = " " + outImage;
+ this.outImage.setArg(" ", outImage);
}
/**
@@ -183,7 +188,7 @@ public class FwImageTask extends Task implements EfiDefine{ @return string of componentType
**/
public String getComponentType() {
- return this.componentType;
+ return this.componentType.getValue();
}
/**
@@ -193,6 +198,6 @@ public class FwImageTask extends Task implements EfiDefine{ @param componentType string of component type
**/
public void setComponentType(String componentType) {
- this.componentType = " " + componentType;
+ this.componentType.setArg(" ", componentType);
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenDepexTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenDepexTask.java index 5a5e115a97..0e0ad9cc2f 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenDepexTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenDepexTask.java @@ -14,6 +14,7 @@ **/
package org.tianocore.framework.tasks;
+
import java.io.File;
import org.apache.tools.ant.BuildException;
@@ -22,6 +23,9 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
+
+import org.tianocore.common.logger.EdkLog;
+
/**
GenDepexTask
@@ -29,19 +33,19 @@ import org.apache.tools.ant.types.Commandline; **/
public class GenDepexTask extends Task implements EfiDefine {
- ///
- /// output binary dependency files name
- ///
- private String outputFile = "";
- ///
- /// input pre-processed dependency text files name
- ///
- private String inputFile = "";
- private String inputFileName = "";
- ///
- /// padding integer value
- ///
- private String padding = "";
+ private static String toolName = "GenDepex";
+ //
+ // output binary dependency files name
+ //
+ private FileArg outputFile = new FileArg();
+ //
+ // input pre-processed dependency text files name
+ //
+ private FileArg inputFile = new FileArg();
+ //
+ // padding integer value
+ //
+ private ToolArg padding = new FileArg();
/**
execute
@@ -57,14 +61,14 @@ public class GenDepexTask extends Task implements EfiDefine { String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (path == null) {
- command = "GenDepex";
+ command = toolName;
} else {
- command = path + "/" + "GenDepex";
+ command = path + File.separator + toolName;
}
//
// argument of GenDepex tool
//
- String argument = inputFile + outputFile + padding;
+ String argument = "" + inputFile + outputFile + padding;
//
// reture value of GenDepex execution
//
@@ -82,16 +86,17 @@ public class GenDepexTask extends Task implements EfiDefine { runner.setAntRun(project);
runner.setCommandline(commandLine.getCommandline());
- log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);
- log(inputFileName);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));
+ EdkLog.log(this, inputFile.toFileList() + " => " + outputFile.toFileList());
+
returnVal = runner.execute();
if (EFI_SUCCESS == returnVal) {
- log("GenDepex succeeded!", Project.MSG_VERBOSE);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenDepex succeeded!");
} else {
//
// command execution fail
//
- log("ERROR = " + Integer.toHexString(returnVal));
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));
throw new BuildException("GenDepex failed!");
}
} catch (Exception e) {
@@ -106,7 +111,7 @@ public class GenDepexTask extends Task implements EfiDefine { @param outputFileName name of output file
**/
public void setOutputFile(String outputFileName) {
- this.outputFile = " -O " + outputFileName;
+ this.outputFile.setArg(" -O ", outputFileName);
}
/**
@@ -117,7 +122,7 @@ public class GenDepexTask extends Task implements EfiDefine { @return name of ouput file
**/
public String getOutputFile() {
- return this.outputFile;
+ return this.outputFile.getValue();
}
/**
@@ -127,8 +132,7 @@ public class GenDepexTask extends Task implements EfiDefine { @param inputFileName name of inputFile
**/
public void setInputFile(String inputFileName) {
- this.inputFileName = (new File(inputFileName)).getName();
- this.inputFile = " -I " + inputFileName;
+ this.inputFile.setArg(" -I ", inputFileName);
}
/**
@@ -138,7 +142,7 @@ public class GenDepexTask extends Task implements EfiDefine { @return name of input file
**/
public String getInputFile() {
- return this.inputFile;
+ return this.inputFile.getValue();
}
/**
@@ -148,7 +152,7 @@ public class GenDepexTask extends Task implements EfiDefine { @param paddingNum padding value
**/
public void setPadding(String paddingNum) {
- this.padding = " -P " + paddingNum;
+ this.padding.setArg(" -P ", paddingNum);
}
/**
@@ -158,6 +162,6 @@ public class GenDepexTask extends Task implements EfiDefine { @return value of padding
**/
public String getPadding() {
- return this.padding;
+ return this.padding.getValue();
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java index d0c4c5b637..e2a65ccdf6 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java @@ -18,12 +18,17 @@ package org.tianocore.framework.tasks; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.LogStreamHandler;
+import org.apache.tools.ant.types.Commandline;
import java.io.File;
import java.io.InputStreamReader;
import java.lang.ProcessBuilder;
import java.util.LinkedList;
+import org.tianocore.common.logger.EdkLog;
+
/**
GenFvImageTask
@@ -31,22 +36,18 @@ import java.util.LinkedList; **/
public class GenFvImageTask extends Task implements EfiDefine{
- ///
- /// tool name
- ///
+ //
+ // tool name
+ //
static final private String toolName = "GenFvImage";
- ///
- /// The name of input inf file
- ///
- private String infFile="";
- ///
- /// Output directory
- ///
+ //
+ // The name of input inf file
+ //
+ private FileArg infFile = new FileArg();
+ //
+ // Output directory
+ //
private String outputDir = ".";
- ///
- /// argument list
- ///
- LinkedList<String> argList = new LinkedList<String>();
/**
execute
@@ -58,30 +59,41 @@ public class GenFvImageTask extends Task implements EfiDefine{ Project project = this.getOwningTarget().getProject();
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
+ String command;
if (path == null) {
- path = "";
+ command = toolName;
} else {
- path += File.separatorChar;
+ command = path + File.separator + toolName;
}
- argList.addFirst(path + toolName);
- /// lauch the program
- ///
- ProcessBuilder pb = new ProcessBuilder(argList);
- pb.directory(new File(outputDir));
+ String argument = "" + infFile;
+ //
+ // lauch the program
+ //
int exitCode = 0;
- log((new File(this.infFile)).getName());
try {
- Process cmdProc = pb.start();
- InputStreamReader cmdOut = new InputStreamReader(cmdProc.getInputStream());
- char[] buf = new char[1024];
+ Commandline cmdline = new Commandline();
+ cmdline.setExecutable(command);
+ cmdline.createArgument().setLine(argument);
+
+ LogStreamHandler streamHandler = new LogStreamHandler(this,
+ Project.MSG_INFO, Project.MSG_WARN);
+ Execute runner = new Execute(streamHandler, null);
- exitCode = cmdProc.waitFor();
+ runner.setAntRun(project);
+ runner.setCommandline(cmdline.getCommandline());
+ runner.setWorkingDirectory(new File(outputDir));
+ //
+ // log command line string.
+ //
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
+ EdkLog.log(this, infFile.toFileList());
+
+ exitCode = runner.execute();
if (exitCode != 0) {
- int len = cmdOut.read(buf, 0, 1024);
- log(new String(buf, 0, len));
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(exitCode));
} else {
- log("GenFvImage succeeded!", Project.MSG_VERBOSE);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenFvImage succeeded!");
}
} catch (Exception e) {
throw new BuildException(e.getMessage());
@@ -90,7 +102,6 @@ public class GenFvImageTask extends Task implements EfiDefine{ throw new BuildException("GenFvImage: failed to generate FV file!");
}
}
-
}
/**
getInfFile
@@ -99,7 +110,7 @@ public class GenFvImageTask extends Task implements EfiDefine{ @return String name of infFile
**/
public String getInfFile() {
- return infFile;
+ return infFile.getValue();
}
/**
@@ -110,9 +121,7 @@ public class GenFvImageTask extends Task implements EfiDefine{ @param infFile name of infFile
**/
public void setInfFile(String infFile) {
- this.infFile = infFile;
- argList.add("-I");
- argList.add(infFile);
+ this.infFile.setArg(" -I ", infFile);
}
/**
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java index fc5ebbf3dc..4d335e0ba6 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenSectionTask.java @@ -31,34 +31,30 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler; import org.apache.tools.ant.types.Commandline;
import org.tianocore.common.logger.EdkLog;
-public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes {
- ///
- /// inputfile name
- ///
- private String inputFile = "";
- ///
- ///
- ///
- private String inputFileName = "";
- ///
- /// outputfile name
- ///
- private String outputFile = "";
- ///
- /// section type
- ///
- private String sectionType = "";
- ///
- /// version number
- ///
- private String versionNum = "";
- ///
- /// interface string
- ///
- private String interfaceString = "";
- ///
- /// Section file list
- ///
+public class GenSectionTask extends Task implements EfiDefine, Section, FfsTypes {
+ //
+ // inputfile name
+ //
+ private FileArg inputFile = new FileArg();
+ //
+ // outputfile name
+ //
+ private FileArg outputFile = new FileArg();
+ //
+ // section type
+ //
+ private ToolArg sectionType = new ToolArg();
+ //
+ // version number
+ //
+ private ToolArg versionNum = new ToolArg();
+ //
+ // interface string
+ //
+ private ToolArg interfaceString = new ToolArg();
+ //
+ // Section file list
+ //
private List<Section> sectFileList = new ArrayList<Section>();
/**
@@ -84,8 +80,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes //
// argument of tools
//
- String argument = inputFile + outputFile + " -s "+ sectionType + versionNum
- + interfaceString;
+ String argument = "" + inputFile + outputFile + sectionType + versionNum + interfaceString;
//
// return value of gensection execution
//
@@ -103,16 +98,17 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline());
- EdkLog.log(this, EdkLog.EDK_INFO, inputFileName);
- EdkLog.log(this, EdkLog.EDK_DEBUG, Commandline.toString(cmdline.getCommandline()));
+ EdkLog.log(this, inputFile.toFileList() + " => " + outputFile.toFileList());
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
+
revl = runner.execute();
if (EFI_SUCCESS == revl) {
- log("GenSection succeeded!", Project.MSG_VERBOSE);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "GenSection succeeded!");
} else {
//
// command execution fail
//
- log("ERROR = " + Integer.toHexString(revl));
+ EdkLog.log(this, EdkLog.EDK_INFO, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("GenSection failed!");
}
} catch (Exception e) {
@@ -128,7 +124,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @return name of input file
**/
public String getInputFile() {
- return this.inputFile;
+ return this.inputFile.getValue();
}
/**
@@ -139,8 +135,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @param inputFile name of input file
**/
public void setInputFile(String inputFile) {
- this.inputFileName = (new File(inputFile)).getName();
- this.inputFile = " -i " + inputFile;
+ this.inputFile.setArg(" -i ", inputFile);
}
/**
@@ -151,7 +146,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @return name of output file
**/
public String getOutputFile() {
- return this.outputFile;
+ return this.outputFile.getValue();
}
/**
@@ -161,7 +156,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @param outputFile name of output file
**/
public void setOutputfile(String outputFile) {
- this.outputFile = " -o " + outputFile;
+ this.outputFile.setArg(" -o ", outputFile);
}
/**
@@ -172,7 +167,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @return sectoin type
**/
public String getSectionType() {
- return this.sectionType;
+ return this.sectionType.getValue();
}
/**
@@ -183,7 +178,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @param sectionType section type
**/
public void setSectionType(String sectionType) {
- this.sectionType = sectionType;
+ this.sectionType.setArg(" -s ", sectionType);
}
/**
@@ -193,7 +188,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @return version number
**/
public String getVersionNum() {
- return this.versionNum;
+ return this.versionNum.getValue();
}
/**
@@ -203,7 +198,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @param versionNum version number
**/
public void setVersionNum(String versionNum) {
- this.versionNum = " -v " + versionNum;
+ this.versionNum.setArg(" -v ", versionNum);
}
/**
@@ -213,7 +208,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @return interface string
**/
public String getInterfaceString() {
- return this.interfaceString;
+ return this.interfaceString.getValue();
}
/**
@@ -223,7 +218,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes @param interfaceString interface string
**/
public void setInterfaceString(String interfaceString) {
- this.interfaceString = " -a " + "\"" + interfaceString + "\"";
+ this.interfaceString.setArg(" -a ", "\"" + interfaceString + "\"");
}
/**
@@ -263,7 +258,7 @@ public class GenSectionTask extends Task implements EfiDefine, Section,FfsTypes // Search SectionList find earch section and call it's
// ToBuffer function.
//
- if (this.sectionType.equalsIgnoreCase("EFI_SECTION_COMPRESSION")){
+ if (this.sectionType.getValue().equalsIgnoreCase("EFI_SECTION_COMPRESSION")){
Section sect;
//
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java index 76ab8e0715..997111ae5d 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java @@ -281,6 +281,7 @@ public class MakeDeps extends Task { private boolean isUptodate() {
File df = new File(depsFile);
if (!df.exists()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, depsFile + " doesn't exist!");
return false;
}
@@ -296,6 +297,7 @@ public class MakeDeps extends Task { for (int i = 0, length = fileList.size(); i < length; ++i) {
File sf = new File(fileList.get(i));
if (sf.lastModified() > depsFileTimeStamp) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, sf.getPath() + " has been changed since last build!");
return false;
}
}
@@ -309,26 +311,53 @@ public class MakeDeps extends Task { //
LineNumberReader lineReader = null;
FileReader fileReader = null;
- boolean ret = true;
+ boolean ret = false;
try {
fileReader = new FileReader(df);
lineReader = new LineNumberReader(fileReader);
String line = null;
+ int lines = 0;
while ((line = lineReader.readLine()) != null) {
- File sourceFile = new File(line);
+ //
+ // check file end flag "\t" to see if the .dep was generated correctly
+ //
+ if (line.equals("\t")) {
+ ret = true;
+ continue;
+ }
+ line = line.trim();
+ //
+ // skip empty line
+ //
+ if (line.length() == 0) {
+ continue;
+ }
+ ++lines;
+
//
// If a file cannot be found (moved or removed) or newer, regenerate the dep file
//
+ File sourceFile = new File(line);
if ((!sourceFile.exists()) || (sourceFile.lastModified() > depsFileTimeStamp)) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, sourceFile.getPath() + " has been (re)moved or changed since last build!");
ret = false;
break;
}
}
+
+ //
+ // check if the .dep file is empty
+ //
+ if (lines == 0) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, depsFile + " is empty!");
+ ret = false;
+ }
+
lineReader.close();
fileReader.close();
} catch (IOException e) {
- log (e.getMessage());
+ throw new BuildException(e.getMessage());
}
return ret;
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java index a402392349..be1d88aa35 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java @@ -35,13 +35,29 @@ public class NestElement extends DataType { private List<String> nameList = new ArrayList<String>();
/**
+ Insert content in the newElement into this NestElement
+
+ @param newElement The new NestElement
+ **/
+ public void insert(NestElement newElement) {
+ this.nameList.addAll(newElement.getNameList());
+ }
+
+ /**
Handle "name" attribute. No delimiter and special treatment are assumed.
@param name A single string value of "name" attribute
**/
public void setName(String name) {
if (name.length() > 0) {
- nameList.add(name);
+ this.nameList.clear();
+ this.nameList.add(name);
+ }
+ }
+
+ public void insName(String name) {
+ if (name.length() > 0) {
+ this.nameList.add(name);
}
}
@@ -56,6 +72,7 @@ public class NestElement extends DataType { return;
}
+ this.nameList.clear();
StringTokenizer tokens = new StringTokenizer(nameList, " \t,;", false);
while (tokens.hasMoreTokens()) {
String name = tokens.nextToken().trim();
@@ -91,6 +108,7 @@ public class NestElement extends DataType { //
// Read line by line
//
+ nameList.clear();
while((str = in.readLine()) != null){
str = str.trim();
if (str.length() == 0){
@@ -98,7 +116,7 @@ public class NestElement extends DataType { }
//getProject().replaceProperties(str);
- nameList.add(str);
+ this.nameList.add(str);
}
} catch (Exception e){
throw new BuildException(e.getMessage());
@@ -129,6 +147,15 @@ public class NestElement extends DataType { }
/**
+ Add a file or file list into the file list
+
+ @param file The path of a file
+ **/
+ public void insFile(String file) {
+ insPath(file);
+ }
+
+ /**
Handle "path" attribute. The value of "path" may contain compound path
separator (/ or \) which should be cleaned up. Because the "path" string
will always be passed to external native program which may not handle
@@ -139,6 +166,16 @@ public class NestElement extends DataType { @param path String value of a file system path
**/
public void setPath(String path) {
+ this.nameList.clear();
+ insPath(path);
+ }
+
+ /**
+ Add a path or path list into the path list
+
+ @param path The path string
+ **/
+ public void insPath(String path) {
if (path.length() == 0) {
return;
}
@@ -184,6 +221,7 @@ public class NestElement extends DataType { //
// Read the file line by line, skipping empty ones
//
+ nameList.clear();
while((path = in.readLine()) != null){
path = path.trim();
if (path.length() == 0){
@@ -254,6 +292,47 @@ public class NestElement extends DataType { return string.toString();
}
+ /**
+ Compose and return the name/path string concatenated by space and
+ with only one "prefix".
+
+ @param prefix The prefix at the beginning of the string
+
+ @return String The string with one prefix at the beginning
+ **/
+ public String toStringWithSinglepPrefix(String prefix) {
+ return prefix + toString(" ");
+ }
+
+ /**
+ Compose a string list with file names only, separated by spcified string
+
+ @param separator The separator string
+
+ @return String The file list
+ **/
+ public String toFileList(String separator) {
+ StringBuffer string = new StringBuffer(1024);
+ int length = nameList.size();
+
+ for (int i = 0; i < length; ++i) {
+ File file = new File(nameList.get(i));
+ string.append(file.getName());
+ string.append(separator);
+ }
+
+ return string.toString();
+ }
+
+ /**
+ Compose a string list with file names only, separated by space
+
+ @return String The list string
+ **/
+ public String toFileList() {
+ return toFileList(" ");
+ }
+
//
// Remove any duplicated path separator or inconsistent path separator
//
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java index d7dfc4193b..76a396c2b5 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java @@ -33,43 +33,39 @@ import org.tianocore.common.logger.EdkLog; PeiReBaseTask is used to call PeiReBase.exe to rebase efi fv file.
**/
public class PeiReBaseTask extends Task implements EfiDefine {
- ///
- /// tool name
- ///
+ //
+ // tool name
+ //
private String toolName = "PeiReBase";
- // /
- // / Input file
- // /
- private String inputFile = "";
- private String inputFileName = "";
- // /
- // / Output file
- // /
- private String outputFile = "";
-
- // /
- // / Output directory, this variable is added by jave wrap
- // /
- private String outputDir = "";
-
- ///
- /// Base address
- ///
- private String baseAddr = "";
-
- ///
- /// Architecture
- ///
- private String arch = "";
+ //
+ // Input file
+ //
+ private FileArg inputFile = new FileArg();
+ //
+ // Output file
+ //
+ private FileArg outputFile = new FileArg();
+ //
+ // Base address
+ //
+ private ToolArg baseAddr = new ToolArg();
+ //
+ //
+ //
+ private FileArg mapFile = new FileArg();
+ //
+ // Architecture
+ //
+ private String arch = "IA32";
/**
- * execute
- *
- * PeiReBaseTask execute function is to assemble tool command line & execute
- * tool command line
- *
- * @throws BuidException
- */
+ execute
+
+ PeiReBaseTask execute function is to assemble tool command line & execute
+ tool command line
+
+ @throws BuidException
+ **/
public void execute() throws BuildException {
Project project = this.getOwningTarget().getProject();
@@ -82,28 +78,24 @@ public class PeiReBaseTask extends Task implements EfiDefine { String argument;
if (this.arch.equalsIgnoreCase("IA32")){
command = toolName + "_IA32";
- }else if (this.arch.equalsIgnoreCase("X64")){
+ } else if (this.arch.equalsIgnoreCase("X64")){
command = toolName + "_X64";
- }else if (this.arch.equalsIgnoreCase("IPF")){
+ } else if (this.arch.equalsIgnoreCase("IPF")){
command = toolName + "_IPF";
- }else {
+ } else {
command = toolName + "_IA32";
}
if (path != null) {
- command = path + File.separatorChar + command;
+ command = path + File.separator + command;
}
//
// argument of tools
//
- File file = new File(outputFile);
- if (!file.isAbsolute() && (!this.outputDir.equalsIgnoreCase(""))) {
- argument = inputFile + " " + "-O " + outputDir + File.separatorChar
- + outputFile + " " + this.baseAddr + " "
- + "-M " + outputDir + + File.separatorChar + outputFile + ".map";
- } else {
- argument = inputFile + " " + "-O " + outputFile + " " + this.baseAddr+ " " + "-M " + outputFile + ".map";
+ if (mapFile.getValue().length() == 0) {
+ mapFile.setArg(" -M ", outputFile.getValue() + ".map");
}
+ argument = "" + inputFile + outputFile + baseAddr + mapFile;
//
// return value of fwimage execution
@@ -125,7 +117,9 @@ public class PeiReBaseTask extends Task implements EfiDefine { // Set debug log information.
//
EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
- EdkLog.log(this, EdkLog.EDK_INFO, this.inputFileName);
+ EdkLog.log(this, EdkLog.EDK_INFO, inputFile.toFileList() + " => "
+ + outputFile.toFileList()
+ + mapFile.toFileList());
revl = runner.execute();
@@ -147,116 +141,110 @@ public class PeiReBaseTask extends Task implements EfiDefine { }
/**
- * getInputFile
- *
- * This function is to get class member "inputFile".
- *
- * @return string of input file name.
- */
+ getInputFile
+
+ This function is to get class member "inputFile".
+
+ @return string of input file name.
+ **/
public String getInputFile() {
- return inputFile;
+ return inputFile.getValue();
}
/**
- * setComponentType
- *
- * This function is to set class member "inputFile".
- *
- * @param inputFile
- * string of input file name.
- */
+ setComponentType
+
+ This function is to set class member "inputFile".
+
+ @param inputFile
+ string of input file name.
+ **/
public void setInputFile(String inputFile) {
- this.inputFileName = (new File(inputFile)).getName();
- this.inputFile = "-I " + inputFile;
+ this.inputFile.setArg(" -I ", inputFile);
}
/**
- * getOutputFile
- *
- * This function is to get class member "outputFile"
- *
- * @return outputFile string of output file name.
- */
+ getOutputFile
+
+ This function is to get class member "outputFile"
+
+ @return outputFile string of output file name.
+ **/
public String getOutputFile() {
- return outputFile;
+ return outputFile.getValue();
}
/**
- * setOutputFile
- *
- * This function is to set class member "outputFile"
- *
- * @param outputFile
- * string of output file name.
- */
+ setOutputFile
+
+ This function is to set class member "outputFile"
+
+ @param outputFile
+ string of output file name.
+ **/
public void setOutputFile(String outputFile) {
- this.outputFile = outputFile;
- }
-
- /**
- * getOutputDir
- *
- * This function is to get class member "outputDir"
- *
- * @return outputDir string of output directory.
- */
- public String getOutputDir() {
- return outputDir;
- }
-
- /**
- * setOutputDir
- *
- * This function is to set class member "outputDir"
- *
- * @param outputDir
- * string of output directory.
- */
- public void setOutputDir(String outputDir) {
- this.outputDir = outputDir;
+ this.outputFile.setArg(" -O ", outputFile);
}
/**
- * getBaseAddr
- *
- * This function is to get class member "baseAddr"
- *
- * @return baseAddr string of base address.
- */
+ getBaseAddr
+
+ This function is to get class member "baseAddr"
+
+ @return baseAddr string of base address.
+ **/
public String getBaseAddr() {
- return baseAddr;
+ return baseAddr.getValue();
}
/**
- * setBaseAddr
- *
- * This function is to set class member "baseAddr"
- *
- * @param baseAddr string of base address
- */
+ setBaseAddr
+
+ This function is to set class member "baseAddr"
+
+ @param baseAddr string of base address
+ **/
public void setBaseAddr(String baseAddr) {
- this.baseAddr = "-B " + baseAddr;
+ this.baseAddr.setArg(" -B ", baseAddr);
}
/**
- * getArch
- *
- * This function is to get class member "arch".
- *
- * @return arch Architecture
- */
+ getArch
+
+ This function is to get class member "arch".
+
+ @return arch Architecture
+ **/
public String getArch() {
return arch;
}
/**
- * setArch
- *
- * This function is to set class member "arch"
- *
- * @param arch Architecture
- */
+ setArch
+
+ This function is to set class member "arch"
+
+ @param arch Architecture
+ **/
public void setArch(String arch) {
this.arch = arch;
}
+
+ /**
+ Get the value of map file
+
+ @return String The map file path
+ **/
+ public String getMapFile() {
+ return mapFile.getValue();
+ }
+
+ /**
+ Set "-M MapFile" argument
+
+ @param mapFile The path of map file
+ **/
+ public void setMapFile(String mapFile) {
+ this.mapFile.setArg(" -M ", mapFile);
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java index b84adf2525..a92f727376 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java @@ -22,6 +22,7 @@ import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
+import org.tianocore.common.logger.EdkLog;
/**
StrGather Task Class
@@ -48,51 +49,51 @@ public class StrGatherTask extends Task implements EfiDefine { ///
/// common options
///
- private String commandType = "";
+ private ToolArg commandType = new ToolArg();
- private String baseName = "";
+ private ToolArg baseName = new ToolArg();
///
/// "all/read/write"
///
- private String verbose = "";
+ private ToolArg verbose = new ToolArg();
- private String outputDatabase = "";
+ private FileArg outputDatabase = new FileArg();
- private List<Database> databaseList = new ArrayList<Database>();
+ private Database databaseList = new Database();
- private List<InputFile> inputFileList = new ArrayList<InputFile>();
+ private InputFile inputFileList = new InputFile();
///
/// parse options newDatabase -- "ture/false" unquoteString -- "ture/false"
///
- private String newDatabase = "";
+ private ToolArg newDatabase = new ToolArg();
- private String unquotedString = "";
+ private ToolArg unquotedString = new ToolArg();
- private List<IncludePath> includePathList = new ArrayList<IncludePath>();
+ private IncludePath includePathList = new IncludePath();
///
/// scan options ignoreNotFound -- "ture/false"
///
- private String ignoreNotFound = "";
+ private ToolArg ignoreNotFound = new ToolArg();
- private List<SkipExt> skipExtList = new ArrayList<SkipExt>();
+ private SkipExt skipExtList = new SkipExt();
///
/// dump options
///
- private String outputString = "";
+ private ToolArg outputString = new ToolArg();
- private String outputDefines = "";
+ private ToolArg outputDefines = new ToolArg();
- private String outputUnicode = "";
+ private ToolArg outputUnicode = new ToolArg();
- private String lang = "";
+ private ToolArg lang = new ToolArg();
- private String indirectionFile = "";
+ private FileArg indirectionFile = new FileArg();
- private String outputHpk = "";
+ private FileArg outputHpk = new FileArg();
///
/// global variable
@@ -119,21 +120,13 @@ public class StrGatherTask extends Task implements EfiDefine { }
///
- /// transfer nested elements into string
- ///
- String databases = list2Str(databaseList);
- String skipExts = list2Str(skipExtList);
- String includePaths = list2Str(includePathList);
- String inputFiles = list2Str(inputFileList);
-
- ///
/// assemble argument
///
- String argument = commandType + verbose + databases + baseName
- + outputDatabase + includePaths + newDatabase + unquotedString
- + skipExts + ignoreNotFound + outputString + outputDefines
+ String argument = "" + commandType + verbose + databaseList + baseName
+ + outputDatabase + includePathList + newDatabase + unquotedString
+ + skipExtList + ignoreNotFound + outputString + outputDefines
+ outputUnicode + lang + indirectionFile + outputHpk
- + inputFiles;
+ + inputFileList;
///
/// return value of fwimage execution
///
@@ -151,16 +144,27 @@ public class StrGatherTask extends Task implements EfiDefine { runner.setAntRun(project);
runner.setCommandline(cmdline.getCommandline());
- log(Commandline.toString(cmdline.getCommandline()), Project.MSG_VERBOSE);
- log(this.commandType.substring(2));
+ String cmdType = getCommandType();
+ if (cmdType.equalsIgnoreCase("parse")) {
+ EdkLog.log(this, "(parse) " + inputFileList.toFileList() + " => "
+ + databaseList.toFileList());
+ } else if (cmdType.equalsIgnoreCase("scan")) {
+ EdkLog.log(this, "(scan) " + databaseList.toFileList() + " => "
+ + outputDatabase.toFileList());
+ } else {
+ EdkLog.log(this, "(dump) " + databaseList.toFileList() + " => "
+ + outputDefines.toFileList() + outputString.toFileList() + outputHpk.toFileList());
+ }
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(cmdline.getCommandline()));
+
revl = runner.execute();
if (EFI_SUCCESS == revl) {
- log("StrGather succeeded!", Project.MSG_VERBOSE);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "StrGather succeeded!");
} else {
///
/// command execution fail
///
- log("ERROR = " + Integer.toHexString(revl));
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(revl));
throw new BuildException("StrGather failed!");
}
} catch (Exception e) {
@@ -174,7 +178,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns commandType parameter
**/
public String getCommandType() {
- return this.commandType;
+ return this.commandType.getValue();
}
/**
@@ -183,7 +187,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param commandType type of strgather command [parse/scan/dump]
**/
public void setCommandType(String commandType) {
- this.commandType = " -" + commandType;
+ this.commandType.setArg(" -", commandType);
}
/**
@@ -192,7 +196,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns verbose parameter
**/
public String getVerbose() {
- return this.verbose;
+ return this.verbose.getValue();
}
/**
@@ -205,17 +209,17 @@ public class StrGatherTask extends Task implements EfiDefine { ///
/// for verbose output
///
- this.verbose = " -v ";
+ this.verbose.setArg(" -", "v");
} else if (verbose.equals("read")) {
///
/// for verbose output when reading database
///
- this.verbose = " -vdbr ";
+ this.verbose.setArg(" -", "vdbr");
} else if (verbose.equals("write")) {
///
/// for verbose output when writing database
///
- this.verbose = " -vdbw ";
+ this.verbose.setArg(" -", "vdbw");
}
}
@@ -225,7 +229,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns baseName parameter
**/
public String getBaseName() {
- return this.baseName;
+ return this.baseName.getValue();
}
/**
@@ -234,7 +238,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param baseName name of the output files of .c and .h
**/
public void setBaseName(String baseName) {
- this.baseName = " -bn " + baseName;
+ this.baseName.setArg(" -bn ", baseName);
}
/**
@@ -243,7 +247,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputDatabase parameter
**/
public String getOutputDatabase() {
- return this.outputDatabase;
+ return this.outputDatabase.getValue();
}
/**
@@ -252,7 +256,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputDatabase filename of output database file
**/
public void setOutputDatabase(String outputDatabase) {
- this.outputDatabase = " -od " + outputDatabase;
+ this.outputDatabase.setArg(" -od ", outputDatabase);
}
/**
@@ -260,8 +264,8 @@ public class StrGatherTask extends Task implements EfiDefine { @returns newDatabase parameter
**/
- public String getNewDatabse() {
- return this.newDatabase;
+ public boolean getNewDatabse() {
+ return this.newDatabase.getPrefix().length() > 0;
}
/**
@@ -269,9 +273,9 @@ public class StrGatherTask extends Task implements EfiDefine { @param newDatabase whether to not read in existing database file
**/
- public void setNewDatabase(String newDatabase) {
- if (newDatabase.equals("true")) {
- this.newDatabase = " -newdb ";
+ public void setNewDatabase(boolean newDatabase) {
+ if (newDatabase) {
+ this.newDatabase.setArg(" -", "newdb");
}
}
@@ -280,8 +284,8 @@ public class StrGatherTask extends Task implements EfiDefine { @returns unquotedString parameter
**/
- public String getUnquotedString() {
- return this.unquotedString;
+ public boolean getUnquotedString() {
+ return this.unquotedString.getValue().length() > 0;
}
/**
@@ -290,9 +294,9 @@ public class StrGatherTask extends Task implements EfiDefine { @param unquotedString :
whether to indicate that unquoted strings are used
**/
- public void setUnquotedString(String unquotedString) {
- if (unquotedString.equals("true")) {
- this.unquotedString = " -uqs ";
+ public void setUnquotedString(boolean unquotedString) {
+ if (unquotedString) {
+ this.unquotedString.setArg(" -", "uqs");
}
}
@@ -301,8 +305,8 @@ public class StrGatherTask extends Task implements EfiDefine { @returns ignoreNotFound parameter
**/
- public String getIgnoreNotFound() {
- return this.ignoreNotFound;
+ public boolean getIgnoreNotFound() {
+ return this.ignoreNotFound.getValue().length() > 0;
}
/**
@@ -311,9 +315,9 @@ public class StrGatherTask extends Task implements EfiDefine { @param ignoreNotFound whether to ignore if a given STRING_TOKEN(STR)
is not found in the database
**/
- public void setIgnoreNotFound(String ignoreNotFound) {
- if (ignoreNotFound.equals("true")) {
- this.ignoreNotFound = " -ignorenotfound ";
+ public void setIgnoreNotFound(boolean ignoreNotFound) {
+ if (ignoreNotFound) {
+ this.ignoreNotFound.setArg(" -", "ignorenotfound");
}
}
@@ -323,7 +327,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputString parameter
**/
public String getOutputString() {
- return this.outputString;
+ return this.outputString.getValue();
}
/**
@@ -332,7 +336,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputString filename of string data file
**/
public void setOutputString(String outputString) {
- this.outputString = " -oc " + outputString;
+ this.outputString.setArg(" -oc ", outputString);
}
/**
@@ -341,7 +345,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputDefines parameter
**/
public String getOutputDefines() {
- return this.outputDefines;
+ return this.outputDefines.getValue();
}
/**
@@ -350,7 +354,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputDefines filename of string defines file
**/
public void setOutputDefines(String outputDefines) {
- this.outputDefines = " -oh " + outputDefines;
+ this.outputDefines.setArg(" -oh ", outputDefines);
}
/**
@@ -359,7 +363,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputUnicode parameter
**/
public String getOutputUnicode() {
- return this.outputUnicode;
+ return this.outputUnicode.getValue();
}
/**
@@ -368,7 +372,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputUnicode filename of unicode file to be dumped database
**/
public void setOutputUnicode(String outputUnicode) {
- this.outputUnicode = " -ou " + outputUnicode;
+ this.outputUnicode.setArg(" -ou ", outputUnicode);
}
/**
@@ -377,7 +381,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns lang parameter
**/
public String getLang() {
- return this.lang;
+ return this.lang.getValue();
}
/**
@@ -386,7 +390,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param lang language of dump
**/
public void setLang(String lang) {
- this.lang = " -lang " + lang;
+ this.lang.setArg(" -lang ", lang);
}
/**
@@ -395,7 +399,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns indirectionFile parameter
**/
public String getIndirectionFile() {
- return this.indirectionFile;
+ return this.indirectionFile.getValue();
}
/**
@@ -404,7 +408,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param indirectionFile filename of indirection file
**/
public void setIndirectionFile(String indirectionFile) {
- this.indirectionFile = " -if " + indirectionFile;
+ this.indirectionFile.setArg(" -if ", indirectionFile);
}
/**
@@ -413,7 +417,7 @@ public class StrGatherTask extends Task implements EfiDefine { @returns outputHpk parameter
**/
public String getOutputHpk() {
- return this.outputHpk;
+ return this.outputHpk.getValue();
}
/**
@@ -422,7 +426,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param outputHpk filename of output HII export pack of the strings
**/
public void setOutputHpk(String outputHpk) {
- this.outputHpk = " -hpk " + outputHpk;
+ this.outputHpk.setArg(" -hpk ", outputHpk);
}
/**
@@ -430,8 +434,8 @@ public class StrGatherTask extends Task implements EfiDefine { @param skipExt skipExt element
**/
- public void addSkipext(SkipExt skipExt) {
- skipExtList.add(skipExt);
+ public void addConfiguredSkipext(SkipExt skipExt) {
+ this.skipExtList.insert(skipExt);
};
/**
@@ -439,8 +443,8 @@ public class StrGatherTask extends Task implements EfiDefine { @param includePath includePath element
**/
- public void addIncludepath(IncludePath includePath) {
- includePathList.add(includePath);
+ public void addConfiguredIncludepath(IncludePath includePath) {
+ this.includePathList.insert(includePath);
};
/**
@@ -448,8 +452,8 @@ public class StrGatherTask extends Task implements EfiDefine { @param inputFile inputFile element
**/
- public void addInputfile(InputFile inputFile) {
- inputFileList.add(inputFile);
+ public void addConfiguredInputfile(InputFile inputFile) {
+ this.inputFileList.insert(inputFile);
};
/**
@@ -458,25 +462,7 @@ public class StrGatherTask extends Task implements EfiDefine { @param database :
database element
**/
- public void addDatabase(Database database) {
- databaseList.add(database);
- }
-
- /**
- Compose the content in each NestElement into a single string.
-
- @param list The NestElement list
-
- @return String
- **/
- private String list2Str(List list) {
- int listLength = list.size();
- String str = "";
- for (int i = 0; i < listLength; ++i) {
- NestElement e = (NestElement)list.get(i);
- str += e.toString();
- }
-
- return str;
+ public void addConfiguredDatabase(Database database) {
+ this.databaseList.insert(database);
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java index ea9546487a..31781eb1d6 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java @@ -32,13 +32,12 @@ import org.tianocore.common.logger.EdkLog; **/
public class Tool implements EfiDefine, Section {
- String toolName = "";
- List<Object> toolArgList = new ArrayList<Object>();
- String outputPath;
- File outputFile ;
- List<Input> inputFiles = new ArrayList<Input>();
- List<Section> gensectList = new ArrayList<Section>();
- String inputArg = "-i ";
+ private String toolName = "";
+ private ToolArg toolArgList = new ToolArg();
+ private Input inputFiles = new Input();
+ private String outputPath;
+ private File outputFile ;
+ private List<Section> gensectList = new ArrayList<Section>();
/**
Call extern tool
@@ -108,11 +107,6 @@ public class Tool implements EfiDefine, Section { String command = "";
String argument = "";
command = toolName;
- Iterator argIter = toolArgList.iterator();
- Iterator inputIter = inputFiles.iterator();
- ToolArg toolArg;
- Input file = null;
-
//
// Get each section which under the compress {};
@@ -126,7 +120,7 @@ public class Tool implements EfiDefine, Section { //
// Parse <genSection> element
//
- File outputFile = File.createTempFile("temp", "sec1",new File(outputPath));
+ File outputFile = File.createTempFile("temp", "sec1", new File(outputPath));
FileOutputStream bo = new FileOutputStream(outputFile);
DataOutputStream Do = new DataOutputStream (bo);
//
@@ -140,33 +134,17 @@ public class Tool implements EfiDefine, Section { throw new BuildException ("GenSection failed at Tool!");
}
Do.close();
- this.inputArg += outputFile.getPath() + " ";
+ this.inputFiles.insFile(outputFile.getPath());
}
} catch (IOException e){
throw new BuildException ("Gensection failed at tool!");
}
-
- ///
- /// argument of tools
- ///
- while (argIter.hasNext()) {
- toolArg = (ToolArg)argIter.next();
- argument = argument + toolArg.getLine() + " ";
-
- }
-
- ///
- /// input files for tools
- ///
- while (inputIter.hasNext()) {
- file = (Input)inputIter.next();
- inputArg += file.toString(" ");
- }
try {
outputFile = File.createTempFile("temp", null, new File(outputPath));
- argument = argument + inputArg + " -o " + outputFile.getPath();
- EdkLog.log(EdkLog.EDK_INFO, argument);
+ argument = toolArgList + inputFiles.toStringWithSinglepPrefix(" -i ")
+ + " -o " + outputFile.getPath();
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, command + " " + argument);
///
/// execute command line
///
@@ -183,8 +161,8 @@ public class Tool implements EfiDefine, Section { @param toolArg The ToolArg object containing arguments for the tool
**/
- public void addToolArg (ToolArg toolArg) {
- toolArgList.add (toolArg);
+ public void addConfiguredToolArg (ToolArg toolArg) {
+ toolArgList.insert(toolArg);
}
/**
@@ -228,8 +206,8 @@ public class Tool implements EfiDefine, Section { @param file The Input objec which represents a file
**/
- public void addInput(Input file) {
- inputFiles.add(file);
+ public void addConfiguredInput(Input file) {
+ inputFiles.insert(file);
}
// /**
@@ -245,8 +223,7 @@ public class Tool implements EfiDefine, Section { public void addGenSection(GenSectionTask genSect){
this.gensectList.add(genSect);
- }
-
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java index b5fbdfe81e..2694f036de 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java @@ -1,5 +1,5 @@ /** @file
-This file is to define nested element which is meant for specifying tool arguments
+This file is used to nest elements which is meant for tool's argument
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -14,29 +14,129 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. package org.tianocore.framework.tasks;
/**
- Class ToolArg is just used to specify arguments for genffsfile tool
+ ToolArg class is defined to represent the argument of a tool. The argument
+ includes the prefix (e.g. -I, -o) and the value.
**/
-public class ToolArg {
+public class ToolArg extends NestElement {
///
- /// keep the argument string
- ///
- private String line = "";
+ /// A constant which is used to represent an empty argument
+ ///
+ public final static ToolArg EMPTY_ARG = new ToolArg();
- /**
- Get method of ANT task/datatype for attribute "line"
+ //
+ // Keep track the prefix of this argument
+ //
+ private String prefix = "";
- @returns The argument string
+ /**
+ Default constructor
**/
- public String getLine() {
- return line;
+ public ToolArg() {
}
/**
- Set method of ANT task/datatype for attribute "line"
+ Constructor which will initialize the prefix of this argument
- @param line The argument string
- **/
+ @param prefix The string of prefix
+ */
+ public ToolArg(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ Constructor which will initialize both the prefix and value of this argument
+
+ @param prefix The prefix of this argument
+ @param value The value of this argument
+ */
+ public ToolArg(String prefix, String value) {
+ setArg(prefix, value);
+ }
+
+ /**
+ Set the prefix and value of this argument
+
+ @param prefix The prefix of this argument
+ @param value The value of this argument
+ */
+ public void setArg(String prefix, String value) {
+ this.prefix = prefix;
+ super.setName(value);
+ }
+
+ /**
+ Set the prefix of this argument
+
+ @param prefix The prefix of this argument
+ */
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ /**
+ Get the prefix of this argument
+
+ @return String The prefix of this argument
+ */
+ public String getPrefix() {
+ return this.prefix.trim();
+ }
+
+ /**
+ Set the value of this argument
+
+ @param value The value of this argument
+ */
+ public void setValue(String value) {
+ super.setName(value);
+ }
+
+ /**
+ Add a value for this argument
+
+ @param value The value of this argument
+ */
+ public void insValue(String value) {
+ super.insName(value);
+ }
+
+ /**
+ Get the value list of this argument, separated by space
+
+ @return String The value list
+ */
+ public String getValue() {
+ return super.toString(" ").trim();
+ }
+
+ /**
+ Set the argument as a whole
+
+ @param line The argument string line
+ */
public void setLine(String line) {
- this.line = line;
- }
-}
\ No newline at end of file + //
+ // Since the prefix is in the "line", we don't need another prefix.
+ //
+ this.prefix = " ";
+ super.setName(line);
+ }
+
+ /**
+ Get the argument line
+
+ @return String The argument string line
+ */
+ public String getLine() {
+ return this.toString();
+ }
+
+ /**
+ Compose a complete argument string.
+
+ @return String The complete argument
+ */
+ public String toString() {
+ return super.toString(prefix);
+ }
+}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java index 198ba5eeef..13b855cdd8 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java @@ -25,6 +25,8 @@ import org.apache.tools.ant.taskdefs.Execute; import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
+import org.tianocore.common.logger.EdkLog;
+
/**
VfrcompilerTask Task Class
class member
@@ -36,23 +38,22 @@ import org.apache.tools.ant.types.Commandline; -includepathList : add IncPath to the search path for VFR included files
**/
public class VfrCompilerTask extends Task implements EfiDefine {
- private String createListFile = "";
- private String outPutDir = "";
- private File outPutFile;
- private String createIfrBinFile = "";
- private String processerArg ="";
- private String vfrFile = "";
- private String vfrFileName = "";
+ private static String toolName = "VfrCompile";
- private List<IncludePath> includepathList = new ArrayList<IncludePath>();
+ private ToolArg createListFile = new ToolArg();
+ private ToolArg createIfrBinFile = new ToolArg();
+ private ToolArg processerArg = new ToolArg();
+ private FileArg vfrFile = new FileArg();
+ private IncludePath includepathList = new IncludePath();
+ private FileArg outPutDir = new FileArg(" -od ", ".");
/**
get class member of createList file
@returns file name of createList
**/
- public String getCreateListFile() {
- return createListFile;
+ public boolean getCreateListFile() {
+ return this.createListFile.getValue().length() > 0;
}
/**
@@ -60,9 +61,10 @@ public class VfrCompilerTask extends Task implements EfiDefine { @param createListFile if createList string equal "on" set '-l' flag
**/
- public void setCreateListFile(String createListFile) {
- if (createListFile.equals("ON")||createListFile.equals("on"))
- this.createListFile = " -l";
+ public void setCreateListFile(boolean createListFile) {
+ if (createListFile) {
+ this.createListFile.setArg(" -", "l");
+ }
}
/**
@@ -71,7 +73,7 @@ public class VfrCompilerTask extends Task implements EfiDefine { @returns name of output dir
**/
public String getOutPutDir() {
- return outPutDir;
+ return this.outPutDir.getValue();
}
/**
@@ -80,10 +82,7 @@ public class VfrCompilerTask extends Task implements EfiDefine { @param outPutDir The directory name for ouput file
**/
public void setOutPutDir(String outPutDir) {
- if (outPutDir != null) {
- outPutFile = new File(outPutDir);
- }
- this.outPutDir = " -od " + outPutDir;
+ this.outPutDir.setArg(" -od ", outPutDir);
}
@@ -92,8 +91,8 @@ public class VfrCompilerTask extends Task implements EfiDefine { @return file name of ifrBinFile
**/
- public String getCreateIfrBinFile() {
- return createIfrBinFile;
+ public boolean getCreateIfrBinFile() {
+ return this.createIfrBinFile.getValue().length() > 0;
}
/**
@@ -102,9 +101,10 @@ public class VfrCompilerTask extends Task implements EfiDefine { @param createIfrBinFile The flag to specify if the IFR binary file should
be generated or not
*/
- public void setCreateIfrBinFile(String createIfrBinFile) {
- if (createIfrBinFile.equals("ON") || createIfrBinFile.equals("on"));
- this.createIfrBinFile = " -ibin";
+ public void setCreateIfrBinFile(boolean createIfrBinFile) {
+ if (createIfrBinFile) {
+ this.createIfrBinFile.setArg(" -", "ibin");
+ }
}
/**
@@ -113,7 +113,7 @@ public class VfrCompilerTask extends Task implements EfiDefine { @returns name of vfrFile
**/
public String getVfrFile() {
- return vfrFile;
+ return this.vfrFile.getValue();
}
/**
@@ -122,8 +122,7 @@ public class VfrCompilerTask extends Task implements EfiDefine { @param vfrFile The name of VFR file
**/
public void setVfrFile(String vfrFile) {
- this.vfrFileName = (new File(vfrFile)).getName();
- this.vfrFile = " " + vfrFile;
+ this.vfrFile.setArg(" ", vfrFile);
}
/**
@@ -131,18 +130,17 @@ public class VfrCompilerTask extends Task implements EfiDefine { @param includepath The IncludePath object which represents include path
**/
- public void addIncludepath(IncludePath includepath){
- includepathList.add(includepath);
+ public void addConfiguredIncludepath(IncludePath includepath){
+ this.includepathList.insert(includepath);
}
-
/**
get class member of processerArg
@returns processer argument
**/
public String getProcesserArg() {
- return processerArg;
+ return this.processerArg.getValue();
}
@@ -152,7 +150,7 @@ public class VfrCompilerTask extends Task implements EfiDefine { @param processerArg The processor argument
*/
public void setProcesserArg(String processerArg) {
- this.processerArg = " -ppflag " + processerArg;
+ this.processerArg.setArg(" -ppflag ", processerArg);
}
/**
@@ -163,23 +161,17 @@ public class VfrCompilerTask extends Task implements EfiDefine { String toolPath= project.getProperty("env.FRAMEWORK_TOOLS_PATH");
String command;
if (toolPath == null) {
- command = "VfrCompile";
+ command = toolName;
} else {
- command = toolPath + "/" + "VfrCompile";
+ command = toolPath + File.separator + toolName;
}
- String incPath = "";
- int count = includepathList.size();
- for (int i = 0; i < count; i++) {
- incPath += includepathList.get(i).toString();
- }
-
- String argument = this.createIfrBinFile +
- this.processerArg +
- incPath +
- this.outPutDir +
- this.createListFile +
- this.vfrFile ;
+ String argument = "" + createIfrBinFile
+ + processerArg
+ + includepathList
+ + outPutDir
+ + createListFile
+ + vfrFile;
try {
///
/// constructs the command-line
@@ -196,21 +188,18 @@ public class VfrCompilerTask extends Task implements EfiDefine { Project.MSG_WARN);
Execute runner = new Execute(streamHandler,null);
- runner.setAntRun(project);
-
+ runner.setAntRun(project);
runner.setCommandline(commandLine.getCommandline());
+ runner.setWorkingDirectory(new File(outPutDir.getValue()));
- if (outPutFile != null && outPutFile.exists()) {
- runner.setWorkingDirectory(outPutFile);
- }
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, Commandline.toString(commandLine.getCommandline()));
+ EdkLog.log(this, vfrFile.toFileList());
- log(Commandline.toString(commandLine.getCommandline()), Project.MSG_VERBOSE);
- log(vfrFileName);
int returnVal = runner.execute();
if (EFI_SUCCESS == returnVal) {
- log("VfrCompile succeeded!", Project.MSG_VERBOSE);
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "VfrCompile succeeded!");
} else {
- log("ERROR = " + Integer.toHexString(returnVal));
+ EdkLog.log(this, "ERROR = " + Integer.toHexString(returnVal));
throw new BuildException("VfrCompile failed!");
}
} catch (IOException e) {
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java index 6f845ea371..84383151fa 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java @@ -21,6 +21,7 @@ import java.util.Map; import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Sequential;
+import org.tianocore.common.logger.EdkLog;
/**
Class OnDepdendency is used to check the timestamp between source files and
@@ -54,7 +55,7 @@ public class OnDependency extends Task { /**
Standard execute method of ANT task
**/
- public void execute() {
+ public void execute() throws BuildException {
if (isOutOfDate() && task != null) {
task.perform();
}
@@ -68,6 +69,7 @@ public class OnDependency extends Task { /// if no source files specified, take it as a fresh start
///
if (sources.nameList.size() == 0) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "No source file spcified!");
return true;
}
@@ -76,6 +78,7 @@ public class OnDependency extends Task { String dstFileName = (String)dstIt.next();
File dstFile = new File(dstFileName);
if (!dstFile.exists()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Target file [" + dstFileName + "] doesn't exist!");
return true;
}
@@ -97,6 +100,7 @@ public class OnDependency extends Task { }
if (dstTimeStamp < srcTimeStamp) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Source file [" + srcFileName + "] has been changed since last build!");
return true;
}
}
diff --git a/Tools/Source/TianoTools/MakeDeps/MakeDeps.c b/Tools/Source/TianoTools/MakeDeps/MakeDeps.c index 62964d0037..3943df0654 100755 --- a/Tools/Source/TianoTools/MakeDeps/MakeDeps.c +++ b/Tools/Source/TianoTools/MakeDeps/MakeDeps.c @@ -286,6 +286,7 @@ Finish: // Close our output file
//
if ((mGlobals.OutFptr != stdout) && (mGlobals.OutFptr != NULL)) {
+ fprintf(mGlobals.OutFptr, "\t\n"); // file ending flag
fclose (mGlobals.OutFptr);
}
|