X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Fglobal%2FOnDependency.java;h=4177b50466c043d06b7b726286662583eae75c2c;hp=936dac8ea332f595ec47c58b1b9bfb52e1378cfc;hb=391dbbb1c00daefe78e7e44499d048943ca866ae;hpb=878ddf1fc3540a715f63594ed22b6929e881afb4 diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java index 936dac8ea3..4177b50466 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java @@ -13,19 +13,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. --*/ package org.tianocore.build.global; +import java.io.File; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.Sequential; -import java.io.File; -import java.util.Iterator; - /** Class OnDepdendency is used to check the timestamp between source files and target files, which can be used to determine if the target files are needed to be re-generated from source files. **/ public class OnDependency extends Task { + /// + /// cache the modified timestamp of files accessed, to speed up the depencey check + /// + private static Map timeStampCache = new HashMap(); /// /// source files list /// @@ -77,12 +83,20 @@ public class OnDependency extends Task { Iterator srcIt = sources.nameList.iterator(); while (srcIt.hasNext()) { String srcFileName = (String)srcIt.next(); - File srcFile = new File(srcFileName); - if (!srcFile.exists()) { - throw new BuildException(srcFileName + " doesn't exist !!!"); + long srcTimeStamp; + + if (timeStampCache.containsKey(srcFileName)) { + srcTimeStamp = ((Long)timeStampCache.get(srcFileName)).longValue(); + } else { + File srcFile = new File(srcFileName); + if (!srcFile.exists()) { + throw new BuildException("Source File name: " + srcFileName + " doesn't exist!!!"); + } + srcTimeStamp = srcFile.lastModified(); + timeStampCache.put(srcFileName, new Long(srcTimeStamp)); } - if (dstTimeStamp < srcFile.lastModified()) { + if (dstTimeStamp < srcTimeStamp) { return true; } }