]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java
1) Changed ToolArg class to abstract generic arguments of a tool
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / OnDependency.java
index 936dac8ea332f595ec47c58b1b9bfb52e1378cfc..84383151fa4b7957a6f85f19c89a5fdae847d293 100644 (file)
@@ -13,12 +13,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 --*/\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
@@ -26,6 +29,10 @@ import java.util.Iterator;
  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
@@ -48,7 +55,7 @@ public class OnDependency extends Task {
     /**\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
@@ -62,6 +69,7 @@ public class OnDependency extends Task {
         /// 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
@@ -70,6 +78,7 @@ public class OnDependency extends Task {
             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
@@ -77,12 +86,21 @@ public class OnDependency extends Task {
             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