--*/\r
package org.tianocore.build.global;\r
\r
+import java.io.File;\r
+import java.util.HashMap;\r
+import java.util.Iterator;\r
+import java.util.Map;\r
+\r
import org.apache.tools.ant.BuildException;\r
import org.apache.tools.ant.Task;\r
import org.apache.tools.ant.taskdefs.Sequential;\r
-\r
-import java.io.File;\r
-import java.util.Iterator;\r
+import org.tianocore.common.logger.EdkLog;\r
\r
/**\r
Class OnDepdendency is used to check the timestamp between source files and\r
be re-generated from source files.\r
**/\r
public class OnDependency extends Task {\r
+ ///\r
+ /// cache the modified timestamp of files accessed, to speed up the depencey check\r
+ /// \r
+ private Map<String, Long> timeStampCache = new HashMap<String, Long>();\r
///\r
/// source files list\r
///\r
/**\r
Standard execute method of ANT task\r
**/\r
- public void execute() {\r
+ public void execute() throws BuildException {\r
if (isOutOfDate() && task != null) {\r
task.perform();\r
}\r
/// if no source files specified, take it as a fresh start\r
///\r
if (sources.nameList.size() == 0) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "No source file spcified!");\r
return true;\r
}\r
\r
String dstFileName = (String)dstIt.next();\r
File dstFile = new File(dstFileName);\r
if (!dstFile.exists()) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Target file [" + dstFileName + "] doesn't exist!");\r
return true;\r
}\r
\r
Iterator srcIt = sources.nameList.iterator();\r
while (srcIt.hasNext()) {\r
String srcFileName = (String)srcIt.next();\r
- File srcFile = new File(srcFileName);\r
- if (!srcFile.exists()) {\r
- throw new BuildException(srcFileName + " doesn't exist !!!");\r
+ long srcTimeStamp;\r
+\r
+ if (timeStampCache.containsKey(srcFileName)) {\r
+ srcTimeStamp = ((Long)timeStampCache.get(srcFileName)).longValue();\r
+ } else {\r
+ File srcFile = new File(srcFileName);\r
+ if (!srcFile.exists()) {\r
+ throw new BuildException("Source File name: " + srcFileName + " doesn't exist!!!");\r
+ }\r
+ srcTimeStamp = srcFile.lastModified();\r
+ timeStampCache.put(srcFileName, new Long(srcTimeStamp));\r
}\r
\r
- if (dstTimeStamp < srcFile.lastModified()) {\r
+ if (dstTimeStamp < srcTimeStamp) {\r
+ EdkLog.log(this, EdkLog.EDK_VERBOSE, "Source file [" + srcFileName + "] has been changed since last build!");\r
return true;\r
}\r
}\r