--*/\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
-\r
/**\r
Class OnDepdendency is used to check the timestamp between source files and\r
target files, which can be used to determine if the target files are needed to\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 static Map<String, Long> timeStampCache = new HashMap<String, Long>();\r
///\r
/// source files list\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
return true;\r
}\r
}\r