diff options
author | jwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-19 05:55:19 +0000 |
---|---|---|
committer | jwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-19 05:55:19 +0000 |
commit | d946661a82d929b61603cf60fa2fd51fae654926 (patch) | |
tree | 69a59f79ea0429c6520e9376b592d404c0178fff /Tools/Source/FrameworkTasks | |
parent | d1760183fdfac71899bbe0c41894dd34ee022da1 (diff) | |
download | edk2-platforms-d946661a82d929b61603cf60fa2fd51fae654926.tar.xz |
1) Added dependency check for flashmap, genfvimage, peirebase tasks
2) Added code in FpdParserTask.java to avoid re-generate FV.inf file
3) Added isEmpty() to ToolArg class to check if an argument is empty or not
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1556 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Source/FrameworkTasks')
5 files changed, 309 insertions, 1 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java index be6c21a292..5265f7c7d6 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java @@ -135,6 +135,16 @@ public class FlashMapTask extends Task implements EfiDefine { @throws BuidException
**/
public void execute() throws BuildException {
+ if (isUptodate()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, headerFile.toFileList()
+ + imageOutFile.toFileList()
+ + mcoFile.toFileList()
+ + dscFile.toFileList()
+ + asmIncFile.toFileList()
+ + outStrFile
+ + " is/are up-to-date!");
+ return;
+ }
Project project = this.getOwningTarget().getProject();
//
@@ -598,4 +608,143 @@ public class FlashMapTask extends Task implements EfiDefine { public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
}
+
+ //
+ // Dependency check
+ //
+ private boolean isUptodate() {
+ long srcTimeStamp = 0;
+ String srcName = "";
+ long dstTimeStamp = 0;
+ String dstName = "";
+ long timeStamp = 0;
+
+ if (!flashDefFile.isEmpty()) {
+ srcName = flashDefFile.getValue();
+ timeStamp = new File(srcName).lastModified();
+ if (timeStamp > srcTimeStamp) {
+ srcTimeStamp = timeStamp;
+ }
+ }
+
+ if (!mciFile.isEmpty()) {
+ srcName = mciFile.getValue();
+ timeStamp = new File(srcName).lastModified();
+ if (timeStamp > srcTimeStamp) {
+ srcTimeStamp = timeStamp;
+ }
+ }
+
+ if (!fdImage.isEmpty()) {
+ srcName = fdImage.getValue();
+ timeStamp = new File(srcName).lastModified();
+ if (timeStamp > srcTimeStamp) {
+ srcTimeStamp = timeStamp;
+ }
+ }
+
+ if (inStrFile.length() != 0) {
+ srcName = inStrFile;
+ timeStamp = new File(srcName).lastModified();
+ if (timeStamp > srcTimeStamp) {
+ srcTimeStamp = timeStamp;
+ }
+ }
+
+ if (!mciFileArray.isEmpty()) {
+ for (int i = 0; i < mciFileArray.nameList.size(); ++i) {
+ srcName += mciFileArray.nameList.get(i) + " ";
+ timeStamp = new File(mciFileArray.nameList.get(i)).lastModified();
+ if (timeStamp > srcTimeStamp) {
+ srcTimeStamp = timeStamp;
+ }
+ }
+ }
+
+ if (!headerFile.isEmpty()) {
+ dstName = headerFile.getValue();
+ File dstFile = new File(dstName);
+ if (!dstFile.isAbsolute()) {
+ dstName = outputDir + File.separator + dstName;
+ dstFile = new File(dstName);
+ }
+
+ if (srcTimeStamp > dstFile.lastModified()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ if (!imageOutFile.isEmpty()) {
+ dstName = imageOutFile.getValue();
+ File dstFile = new File(dstName);
+ if (!dstFile.isAbsolute()) {
+ dstName = outputDir + File.separator + dstName;
+ dstFile = new File(dstName);
+ }
+
+ if (srcTimeStamp > dstFile.lastModified()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ if (!mcoFile.isEmpty()) {
+ dstName = mcoFile.getValue();
+ File dstFile = new File(dstName);
+ if (!dstFile.isAbsolute()) {
+ dstName = outputDir + File.separator + dstName;
+ dstFile = new File(dstName);
+ }
+
+ if (srcTimeStamp > dstFile.lastModified()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ if (!dscFile.isEmpty()) {
+ dstName = dscFile.getValue();
+ File dstFile = new File(dstName);
+ if (!dstFile.isAbsolute()) {
+ dstName = outputDir + File.separator + dstName;
+ dstFile = new File(dstName);
+ }
+
+ if (srcTimeStamp > dstFile.lastModified()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ if (!asmIncFile.isEmpty()) {
+ dstName = asmIncFile.getValue();
+ File dstFile = new File(dstName);
+ if (!dstFile.isAbsolute()) {
+ dstName = outputDir + File.separator + dstName;
+ dstFile = new File(dstName);
+ }
+
+ if (srcTimeStamp > dstFile.lastModified()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ if (outStrFile.length() != 0) {
+ dstName = outStrFile;
+ File dstFile = new File(dstName);
+ if (!dstFile.isAbsolute()) {
+ dstName = outputDir + File.separator + dstName;
+ dstFile = new File(dstName);
+ }
+
+ if (srcTimeStamp > dstFile.lastModified()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java index cba7a4e4bc..d37156dd70 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java @@ -23,6 +23,16 @@ 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 java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Iterator;
+import java.io.BufferedReader;
+import java.io.FileReader;
import org.tianocore.common.logger.EdkLog;
@@ -38,6 +48,10 @@ public class GenFvImageTask extends Task implements EfiDefine{ //
static final private String toolName = "GenFvImage";
//
+ // Pattern to match the section header (e.g. [options], [files])
+ //
+ static final private Pattern sectionHeader = Pattern.compile("\\[([^\\[\\]]+)\\]");
+ //
// The name of input inf file
//
private FileArg infFile = new FileArg();
@@ -56,6 +70,11 @@ public class GenFvImageTask extends Task implements EfiDefine{ Project project = this.getOwningTarget().getProject();
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
+ if (isUptodate()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, infFile.toFileList() + " is uptodate!");
+ return;
+ }
+
String command;
if (path == null) {
command = toolName;
@@ -142,4 +161,117 @@ public class GenFvImageTask extends Task implements EfiDefine{ public void setOutputDir(String outputDir) {
this.outputDir = outputDir;
}
+
+ //
+ // dependency check
+ //
+ private boolean isUptodate() {
+ String infName = this.infFile.getValue();
+ String fvName = "";
+ List<String> ffsFiles = new LinkedList<String>();
+ File inf = new File(infName);
+
+ try {
+ FileReader reader = new FileReader(inf);
+ BufferedReader in = new BufferedReader(reader);
+ String str;
+
+ //
+ // Read the inf file line by line
+ //
+ boolean inFiles = false;
+ boolean inOptions = false;
+ while ((str = in.readLine()) != null) {
+ str = str.trim();
+ if (str.length() == 0) {
+ continue;
+ }
+
+ Matcher matcher = sectionHeader.matcher(str);
+ if (matcher.find()) {
+ //
+ // We take care of only "options" and "files" section
+ //
+ String sectionName = str.substring(matcher.start(1), matcher.end(1));
+ if (sectionName.equalsIgnoreCase("options")) {
+ inOptions = true;
+ inFiles = false;
+ } else if (sectionName.equalsIgnoreCase("files")) {
+ inFiles = true;
+ inOptions = false;
+ } else {
+ inFiles = false;
+ inOptions = false;
+ }
+ continue;
+ }
+
+ //
+ // skip invalid line
+ //
+ int equalMarkPos = str.indexOf("=");
+ if (equalMarkPos < 0) {
+ continue;
+ }
+
+ //
+ // we have only interest in EFI_FILE_NAME
+ //
+ String fileNameFlag = str.substring(0, equalMarkPos).trim();
+ String fileName = str.substring(equalMarkPos + 1).trim();
+ if (!fileNameFlag.equalsIgnoreCase("EFI_FILE_NAME")
+ || fileName.length() == 0) {
+ continue;
+ }
+
+ if (inFiles) {
+ //
+ // files specified beneath the [files] section are source files
+ //
+ ffsFiles.add(fileName);
+ } else if (inOptions) {
+ //
+ // file specified beneath the [options] section is the target file
+ //
+ fvName = outputDir + File.separator + fileName;
+ }
+ }
+ } catch (Exception ex) {
+ throw new BuildException(ex.getMessage());
+ }
+
+ //
+ // if destionation file doesn't exist, we need to generate it.
+ //
+ File fvFile = new File(fvName);
+ if (!fvFile.exists()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, fvName + " doesn't exist!");
+ return false;
+ }
+
+ //
+ // the inf file itself will be taken as source file, check its timestamp
+ // against the target file
+ //
+ long fvFileTimeStamp = fvFile.lastModified();
+ if (inf.lastModified() > fvFileTimeStamp) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, infName + " has been changed since last build!");
+ return false;
+ }
+
+ //
+ // no change in the inf file, we need to check each source files in it
+ // against the target file
+ //
+ for (Iterator it = ffsFiles.iterator(); it.hasNext(); ) {
+ String fileName = (String)it.next();
+ File file = new File(fileName);
+ if (file.lastModified() > fvFileTimeStamp) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, fileName + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java index be1d88aa35..271dee6c88 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java @@ -32,7 +32,7 @@ public class NestElement extends DataType { // The name list. All the name strings got from setXXX methods will be put
// in here.
//
- private List<String> nameList = new ArrayList<String>();
+ protected List<String> nameList = new ArrayList<String>();
/**
Insert content in the newElement into this NestElement
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java index 76a396c2b5..1f8a4d1f3c 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java @@ -67,6 +67,10 @@ public class PeiReBaseTask extends Task implements EfiDefine { @throws BuidException
**/
public void execute() throws BuildException {
+ if (isUptodate()) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, outputFile.toFileList() + " is up-to-date!");
+ return;
+ }
Project project = this.getOwningTarget().getProject();
@@ -247,4 +251,18 @@ public class PeiReBaseTask extends Task implements EfiDefine { public void setMapFile(String mapFile) {
this.mapFile.setArg(" -M ", mapFile);
}
+
+ //
+ // Dependency check
+ //
+ private boolean isUptodate() {
+ File srcFile = new File(inputFile.getValue());
+ File dstFile = new File(outputFile.getValue());
+
+ if (srcFile.lastModified() > dstFile.lastModified()) {
+ return false;
+ }
+
+ return true;
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java index 2694f036de..ade6817955 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java @@ -139,4 +139,13 @@ public class ToolArg extends NestElement { public String toString() {
return super.toString(prefix);
}
+
+ /**
+ Check if the argument is empty or not
+
+ @return boolean
+ **/
+ public boolean isEmpty() {
+ return (prefix.length() == 0) && (nameList.isEmpty());
+ }
}
|