summaryrefslogtreecommitdiff
path: root/Tools/Source/FrameworkTasks
diff options
context:
space:
mode:
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2006-09-21 05:11:58 +0000
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2006-09-21 05:11:58 +0000
commit4b1348478851a4b30978fabf9c4315cdbc44e99f (patch)
tree22c653eb898431b347c4716a98dd8c3f7ec706e7 /Tools/Source/FrameworkTasks
parent37e5cd656db059c9b7f506aacd7ca0044f0b2388 (diff)
downloadedk2-4b1348478851a4b30978fabf9c4315cdbc44e99f.zip
edk2-4b1348478851a4b30978fabf9c4315cdbc44e99f.tar.gz
edk2-4b1348478851a4b30978fabf9c4315cdbc44e99f.tar.bz2
1) Add FileTimeStamp class to centralize the cache mechanism for file time stamp check, and changed related classes
2) Fixed the FlashMapTask dependency issue 3) Fixed empty target issue in OnDenpendency class git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1584 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools/Source/FrameworkTasks')
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java105
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java11
2 files changed, 107 insertions, 9 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
index 5c3e889..c6f5099 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
@@ -17,6 +17,14 @@
package org.tianocore.framework.tasks;
import java.io.File;
+import java.io.FileReader;
+import java.io.BufferedReader;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
import org.apache.tools.ant.Task;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.BuildException;
@@ -35,9 +43,15 @@ public class FlashMapTask extends Task implements EfiDefine {
//
// tool name
//
- private final String toolName = "FlashMap";
+ private static final String toolName = "FlashMap";
//
+ //
+ //
+ private static Pattern fileBlock = Pattern.compile("\\s*File\\s*\\{([^\\{\\}]+)\\}");
+ private static Pattern fileNameDef = Pattern.compile("\\bName\\s*=\\s*\"([^\"]+)\"");
+
+ //
// Flash definition file
//
private FileArg flashDefFile = new FileArg();
@@ -135,7 +149,6 @@ 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()
@@ -143,10 +156,9 @@ public class FlashMapTask extends Task implements EfiDefine {
+ dscFile.toFileList()
+ asmIncFile.toFileList()
+ outStrFile
- + " is/are up-to-date!");
+ + " is up-to-date!");
return;
}
- */
Project project = this.getOwningTarget().getProject();
//
@@ -689,6 +701,13 @@ public class FlashMapTask extends Task implements EfiDefine {
EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
return false;
}
+
+ //
+ // we need to check the time stamp of each FV file specified in fdf file
+ //
+ if (!isFdUptodate(dstName, getFvFiles(flashDefFile.getValue()))) {
+ return false;
+ }
}
if (!mcoFile.isEmpty()) {
@@ -749,4 +768,82 @@ public class FlashMapTask extends Task implements EfiDefine {
return true;
}
+
+ //
+ // Parse the flash definition file and find out the FV file names
+ //
+ private List<String> getFvFiles(String fdfFileName) {
+ File fdfFile = new File(fdfFileName);
+ int fileLength = (int)fdfFile.length();
+ char[] fdfContent = new char[fileLength];
+ List<String> fileList = new ArrayList<String>();
+
+ try {
+ FileReader reader = new FileReader(fdfFile);
+ BufferedReader in = new BufferedReader(reader);
+
+ in.read(fdfContent, 0, fileLength);
+ String str = new String(fdfContent);
+
+ //
+ // match the
+ // File {
+ // ...
+ // }
+ // block
+ //
+ Matcher matcher = fileBlock.matcher(str);
+ while (matcher.find()) {
+ String fileBlockContent = str.substring(matcher.start(1), matcher.end(1));
+ //
+ // match the definition like
+ // Name = "..."
+ //
+ Matcher nameMatcher = fileNameDef.matcher(fileBlockContent);
+ if (nameMatcher.find()) {
+ fileList.add(fileBlockContent.substring(nameMatcher.start(1), nameMatcher.end(1)));
+ }
+ }
+
+ in.close();
+ reader.close();
+ } catch (Exception ex) {
+ throw new BuildException(ex.getMessage());
+ }
+
+ return fileList;
+ }
+
+ private boolean isFdUptodate(String fdFile, List<String> fvFileList) {
+ String fvDir = ".";
+ File fd = new File(fdFile);
+
+ if (outputDir.equals(".")) {
+ if (!fd.isAbsolute()) {
+ //
+ // If we cannot get the absolute path of fd file, we caanot
+ // get its time stamp. Re-generate it always in such situation.
+ //
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Cannot retrieve the time stamp of " + fdFile);
+ return false;
+ }
+ fvDir = fd.getParent();
+ } else {
+ fvDir = outputDir;
+ if (!fd.isAbsolute()) {
+ fd = new File(fvDir + File.separator + fdFile);
+ }
+ }
+
+ long fdTimeStamp = fd.lastModified();
+ for (int i = 0; i < fvFileList.size(); ++i) {
+ File fv = new File(fvDir + File.separator + fvFileList.get(i));
+ if (fv.lastModified() > fdTimeStamp) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, fv.getPath() + " has been changed since last build!");
+ return false;
+ }
+ }
+
+ return true;
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
index bd305fa..1486bd3 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
@@ -31,6 +31,7 @@ import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
import org.tianocore.common.logger.EdkLog;
+import org.tianocore.common.cache.FileTimeStamp;
/**
Class MakeDeps is used to wrap MakeDeps.exe as an ANT task.
@@ -233,12 +234,12 @@ public class MakeDeps extends Task {
// If the source file(s) is newer than dependency list file, we need to
// re-generate the dependency list file
//
- long depsFileTimeStamp = df.lastModified();
+ long depsFileTimeStamp = FileTimeStamp.get(dfName);
List<String> fileList = inputFileList.getNameList();
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!");
+ String sf = fileList.get(i);
+ if (FileTimeStamp.get(sf) > depsFileTimeStamp) {
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, sf + " has been changed since last build!");
return false;
}
}
@@ -279,7 +280,7 @@ public class MakeDeps extends Task {
// 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)) {
+ if ((!sourceFile.exists()) || (FileTimeStamp.get(line) > depsFileTimeStamp)) {
EdkLog.log(this, EdkLog.EDK_VERBOSE, sourceFile.getPath() + " has been (re)moved or changed since last build!");
ret = false;
break;