summaryrefslogtreecommitdiff
path: root/Tools
diff options
context:
space:
mode:
Diffstat (limited to 'Tools')
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java149
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenFvImageTask.java132
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java2
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/PeiReBaseTask.java18
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/ToolArg.java9
-rw-r--r--Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java6
6 files changed, 315 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 be6c21a..5265f7c 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 cba7a4e..d37156d 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 be1d88a..271dee6 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 76a396c..1f8a4d1 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 2694f03..ade6817 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());
+ }
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
index 3d2c36a..addb43a 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
@@ -193,6 +193,12 @@ public class FpdParserTask extends Task {
getProject().setProperty("FV_FILENAME", validFv[i]);
File fvFile = new File(getProject().replaceProperties( getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i] + ".inf"));
+ if (fvFile.exists() && (fvFile.lastModified() >= fpdFile.lastModified())) {
+ //
+ // don't re-generate FV.inf if fpd has not been changed
+ //
+ continue;
+ }
fvFile.getParentFile().mkdirs();
try {