diff options
author | jwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-12 02:41:10 +0000 |
---|---|---|
committer | jwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-07-12 02:41:10 +0000 |
commit | 196ad8d77c4a256e6a9b432541d688d2f40f4614 (patch) | |
tree | b6de194d16f7a8134111e2dce0b7925b8ca58a76 /Tools | |
parent | a99a79e46fbb1773772cfa25d33305539f18c58b (diff) | |
download | edk2-196ad8d77c4a256e6a9b432541d688d2f40f4614.tar.gz edk2-196ad8d77c4a256e6a9b432541d688d2f40f4614.tar.bz2 edk2-196ad8d77c4a256e6a9b432541d688d2f40f4614.zip |
Fixed EDKT102;
Fixed some dependency check issue and made several optimizations on the dependency check logic. Now the rebuild is speeded up enormously.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@885 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
6 files changed, 71 insertions, 34 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java index c538403b36..c72b1f6672 100644 --- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java +++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java @@ -14,26 +14,28 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/
package org.tianocore.framework.tasks;
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Execute;
-import org.apache.tools.ant.taskdefs.LogStreamHandler;
-import org.apache.tools.ant.types.Commandline;
-import org.apache.tools.ant.types.Path;
-
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.LineNumberReader;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.LogStreamHandler;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.Path;
+
/**
Class MakeDeps is used to wrap MakeDeps.exe as an ANT task.
**/
@@ -185,10 +187,15 @@ public class MakeDeps extends Task { /// Remove any duplicated path separator or inconsistent path separator
///
private String cleanupPathName(String path) {
- String separator = "\\" + File.separator;
- String duplicateSeparator = separator + "{2}";
- path = Path.translateFile(path);
- path = path.replaceAll(duplicateSeparator, separator);
+ try {
+ path = (new File(path)).getCanonicalPath();
+ } catch (IOException e) {
+ String separator = "\\" + File.separator;
+ String duplicateSeparator = separator + "{2}";
+ path = Path.translateFile(path);
+ path = path.replaceAll(duplicateSeparator, separator);
+ return path;
+ }
return path;
}
@@ -335,6 +342,7 @@ public class MakeDeps extends Task { LineNumberReader lineReader = null;
FileReader fileReader = null;
+ Set<String> lineSet = new HashSet<String>(100); // used to remove duplicated lines
try {
fileReader = new FileReader(df);
lineReader = new LineNumberReader(fileReader);
@@ -343,7 +351,6 @@ public class MakeDeps extends Task { /// clean-up each line in deps file
//
String line = null;
- StringBuffer cleanedLines = new StringBuffer(4096);
while ((line = lineReader.readLine()) != null) {
Pattern pattern = Pattern.compile(target + "[ ]*:[ ]*(.+)");
Matcher matcher = pattern.matcher(line);
@@ -354,8 +361,7 @@ public class MakeDeps extends Task { ///
String filePath = line.substring(matcher.start(1), matcher.end(1));
filePath = cleanupPathName(filePath);
- cleanedLines.append(filePath);
- cleanedLines.append("\n");
+ lineSet.add(filePath);
}
}
lineReader.close();
@@ -366,11 +372,20 @@ public class MakeDeps extends Task { ///
StringTokenizer fileTokens = new StringTokenizer(extraDeps, ";");
while (fileTokens.hasMoreTokens()) {
- cleanedLines.append(cleanupPathName(fileTokens.nextToken()));
- cleanedLines.append("\n");
+ lineSet.add(cleanupPathName(fileTokens.nextToken()));
}
///
+ /// compose the final file content
+ ///
+ StringBuffer cleanedLines = new StringBuffer(40960);
+ Iterator<String> it = lineSet.iterator();
+ while (it.hasNext()) {
+ String filePath = it.next();
+ cleanedLines.append(filePath);
+ cleanedLines.append("\n");
+ }
+ ///
/// overwrite old dep file with new content
///
FileWriter fileWriter = null;
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java index f09becbad0..286fd69490 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java @@ -282,7 +282,7 @@ public class FrameworkBuildTask extends Task{ GlobalData.setToolChainEnvInfo(envToolChainInfo);
str = getValue("TOOL_CHAIN_CONF", targetFileInfo);
- if (str != null) {
+ if (str != null && str.trim().length() > 0) {
toolsDefFilename = str;
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index 665ab89232..bac506abfa 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -247,7 +247,7 @@ public class GenBuildTask extends Ant { // don't do anything if no tools found
//
if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) {
- System.out.println("!!!Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
+ System.out.println("Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");
continue;
}
@@ -431,7 +431,6 @@ public class GenBuildTask extends Ant { key[4] = "NAME";
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
File cmdFile = new File(cmdPath + File.separatorChar + cmdName);
-// GlobalData.log.info("PATH: " + cmdFile.getPath());
getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));
//
@@ -439,7 +438,6 @@ public class GenBuildTask extends Ant { //
key[4] = "FLAGS";
String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);
-// GlobalData.log.info("Flags: " + cmdFlags);
Set<String> addset = new LinkedHashSet<String>();
Set<String> subset = new LinkedHashSet<String>();
putFlagsToSet(addset, cmdFlags);
@@ -450,7 +448,6 @@ public class GenBuildTask extends Ant { //
key[4] = "EXT";
String extName = GlobalData.getCommandSetting(key, fpdModuleId);
-// GlobalData.log.info("Ext: " + extName);
if ( extName != null && ! extName.equalsIgnoreCase("")) {
getProject().setProperty(cmd[m] + "_EXT", extName);
}
@@ -463,7 +460,6 @@ public class GenBuildTask extends Ant { //
key[4] = "FAMILY";
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
-// GlobalData.log.info("FAMILY: " + toolChainFamily);
if (toolChainFamily != null) {
getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);
}
@@ -473,7 +469,6 @@ public class GenBuildTask extends Ant { //
key[4] = "SPATH";
String spath = GlobalData.getCommandSetting(key, fpdModuleId);
-// GlobalData.log.info("SPATH: " + spath);
if (spath != null) {
getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
}
@@ -486,7 +481,6 @@ public class GenBuildTask extends Ant { //
key[4] = "DPATH";
String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
-// GlobalData.log.info("DPATH: " + dpath);
if (dpath != null) {
getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java index 0680146cec..b4f34f762a 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java +++ b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java @@ -549,7 +549,7 @@ public class ModuleBuildFileGenerator { return ;
}
if (fp.initSections(ffsKeyword, project, fpdModuleId)) {
- String targetFilename = fpdModuleId.getModule().getGuid() + "-" + fpdModuleId.getModule().getName() + FpdParserTask.getSuffix(fpdModuleId.getModule().getModuleType());
+ String targetFilename = fpdModuleId.getModule().getGuid() + "-" + "${BASE_NAME}" + FpdParserTask.getSuffix(fpdModuleId.getModule().getModuleType());
String[] list = fp.getGenSectionElements(document, "${BASE_NAME}", fpdModuleId.getModule().getGuid(), targetFilename);
for (int i = 0; i < list.length; i++) {
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/DpFileList.java b/Tools/Source/GenBuild/org/tianocore/build/global/DpFileList.java index 8b4b4a0add..dd032526d8 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/DpFileList.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/DpFileList.java @@ -16,10 +16,14 @@ package org.tianocore.build.global; import java.util.ArrayList;
import java.util.List;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.FileSet;
+
/**
DpFileList is a container of Dpfile at the point of ANT task/datatype
**/
-public class DpFileList {
+public class DpFileList extends DataType {
///
/// Keep all the file names from all nested DpFile
///
@@ -46,5 +50,15 @@ public class DpFileList { public void addConfiguredFile(DpFile f) {
this.nameList.addAll(f.getList());
}
+
+ public void addConfiguredFileSet(FileSet fileSet) {
+ DirectoryScanner ds = fileSet.getDirectoryScanner(getProject());
+ String dir = fileSet.getDir(getProject()).getAbsolutePath();
+ String[] files = ds.getIncludedFiles();
+
+ for (int i = 0; i < files.length; ++i) {
+ nameList.add(dir + "/" + files[i]);
+ }
+ }
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java index 936dac8ea3..ba388a1000 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java @@ -13,13 +13,15 @@ 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
@@ -27,6 +29,10 @@ import java.util.Iterator; **/
public class OnDependency extends Task {
///
+ /// cache the modified timestamp of files accessed, to speed up the depencey check
+ ///
+ private static Map<String, Long> timeStampCache = new HashMap<String, Long>();
+ ///
/// source files list
///
private DpFileList sources = null;
@@ -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(srcFileName + " doesn't exist !!!");
+ }
+ srcTimeStamp = srcFile.lastModified();
+ timeStampCache.put(srcFileName, new Long(srcTimeStamp));
}
- if (dstTimeStamp < srcFile.lastModified()) {
+ if (dstTimeStamp < srcTimeStamp) {
return true;
}
}
|