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
This commit is contained in:
jwang36 2006-07-12 02:41:10 +00:00
parent a99a79e46f
commit 196ad8d77c
6 changed files with 75 additions and 38 deletions

View File

@ -14,6 +14,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/ **/
package org.tianocore.framework.tasks; package org.tianocore.framework.tasks;
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.BuildException;
import org.apache.tools.ant.Project; import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
@ -22,18 +36,6 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path; 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.Iterator;
import java.util.List;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
Class MakeDeps is used to wrap MakeDeps.exe as an ANT task. 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 /// Remove any duplicated path separator or inconsistent path separator
/// ///
private String cleanupPathName(String path) { private String cleanupPathName(String path) {
String separator = "\\" + File.separator; try {
String duplicateSeparator = separator + "{2}"; path = (new File(path)).getCanonicalPath();
path = Path.translateFile(path); } catch (IOException e) {
path = path.replaceAll(duplicateSeparator, separator); String separator = "\\" + File.separator;
String duplicateSeparator = separator + "{2}";
path = Path.translateFile(path);
path = path.replaceAll(duplicateSeparator, separator);
return path;
}
return path; return path;
} }
@ -335,6 +342,7 @@ public class MakeDeps extends Task {
LineNumberReader lineReader = null; LineNumberReader lineReader = null;
FileReader fileReader = null; FileReader fileReader = null;
Set<String> lineSet = new HashSet<String>(100); // used to remove duplicated lines
try { try {
fileReader = new FileReader(df); fileReader = new FileReader(df);
lineReader = new LineNumberReader(fileReader); lineReader = new LineNumberReader(fileReader);
@ -343,7 +351,6 @@ public class MakeDeps extends Task {
/// clean-up each line in deps file /// clean-up each line in deps file
// //
String line = null; String line = null;
StringBuffer cleanedLines = new StringBuffer(4096);
while ((line = lineReader.readLine()) != null) { while ((line = lineReader.readLine()) != null) {
Pattern pattern = Pattern.compile(target + "[ ]*:[ ]*(.+)"); Pattern pattern = Pattern.compile(target + "[ ]*:[ ]*(.+)");
Matcher matcher = pattern.matcher(line); Matcher matcher = pattern.matcher(line);
@ -354,8 +361,7 @@ public class MakeDeps extends Task {
/// ///
String filePath = line.substring(matcher.start(1), matcher.end(1)); String filePath = line.substring(matcher.start(1), matcher.end(1));
filePath = cleanupPathName(filePath); filePath = cleanupPathName(filePath);
cleanedLines.append(filePath); lineSet.add(filePath);
cleanedLines.append("\n");
} }
} }
lineReader.close(); lineReader.close();
@ -366,10 +372,19 @@ public class MakeDeps extends Task {
/// ///
StringTokenizer fileTokens = new StringTokenizer(extraDeps, ";"); StringTokenizer fileTokens = new StringTokenizer(extraDeps, ";");
while (fileTokens.hasMoreTokens()) { while (fileTokens.hasMoreTokens()) {
cleanedLines.append(cleanupPathName(fileTokens.nextToken())); lineSet.add(cleanupPathName(fileTokens.nextToken()));
cleanedLines.append("\n");
} }
///
/// 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 /// overwrite old dep file with new content
/// ///

View File

@ -282,7 +282,7 @@ public class FrameworkBuildTask extends Task{
GlobalData.setToolChainEnvInfo(envToolChainInfo); GlobalData.setToolChainEnvInfo(envToolChainInfo);
str = getValue("TOOL_CHAIN_CONF", targetFileInfo); str = getValue("TOOL_CHAIN_CONF", targetFileInfo);
if (str != null) { if (str != null && str.trim().length() > 0) {
toolsDefFilename = str; toolsDefFilename = str;
} }

View File

@ -247,7 +247,7 @@ public class GenBuildTask extends Ant {
// don't do anything if no tools found // don't do anything if no tools found
// //
if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) { 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; continue;
} }
@ -431,7 +431,6 @@ public class GenBuildTask extends Ant {
key[4] = "NAME"; key[4] = "NAME";
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId); String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
File cmdFile = new File(cmdPath + File.separatorChar + cmdName); File cmdFile = new File(cmdPath + File.separatorChar + cmdName);
// GlobalData.log.info("PATH: " + cmdFile.getPath());
getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/")); getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));
// //
@ -439,7 +438,6 @@ public class GenBuildTask extends Ant {
// //
key[4] = "FLAGS"; key[4] = "FLAGS";
String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId); String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);
// GlobalData.log.info("Flags: " + cmdFlags);
Set<String> addset = new LinkedHashSet<String>(); Set<String> addset = new LinkedHashSet<String>();
Set<String> subset = new LinkedHashSet<String>(); Set<String> subset = new LinkedHashSet<String>();
putFlagsToSet(addset, cmdFlags); putFlagsToSet(addset, cmdFlags);
@ -450,7 +448,6 @@ public class GenBuildTask extends Ant {
// //
key[4] = "EXT"; key[4] = "EXT";
String extName = GlobalData.getCommandSetting(key, fpdModuleId); String extName = GlobalData.getCommandSetting(key, fpdModuleId);
// GlobalData.log.info("Ext: " + extName);
if ( extName != null && ! extName.equalsIgnoreCase("")) { if ( extName != null && ! extName.equalsIgnoreCase("")) {
getProject().setProperty(cmd[m] + "_EXT", extName); getProject().setProperty(cmd[m] + "_EXT", extName);
} }
@ -463,7 +460,6 @@ public class GenBuildTask extends Ant {
// //
key[4] = "FAMILY"; key[4] = "FAMILY";
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId); String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
// GlobalData.log.info("FAMILY: " + toolChainFamily);
if (toolChainFamily != null) { if (toolChainFamily != null) {
getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily); getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);
} }
@ -473,7 +469,6 @@ public class GenBuildTask extends Ant {
// //
key[4] = "SPATH"; key[4] = "SPATH";
String spath = GlobalData.getCommandSetting(key, fpdModuleId); String spath = GlobalData.getCommandSetting(key, fpdModuleId);
// GlobalData.log.info("SPATH: " + spath);
if (spath != null) { if (spath != null) {
getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/")); getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
} }
@ -486,7 +481,6 @@ public class GenBuildTask extends Ant {
// //
key[4] = "DPATH"; key[4] = "DPATH";
String dpath = GlobalData.getCommandSetting(key, fpdModuleId); String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
// GlobalData.log.info("DPATH: " + dpath);
if (dpath != null) { if (dpath != null) {
getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/")); getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
} }

View File

@ -549,7 +549,7 @@ public class ModuleBuildFileGenerator {
return ; return ;
} }
if (fp.initSections(ffsKeyword, project, fpdModuleId)) { 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); String[] list = fp.getGenSectionElements(document, "${BASE_NAME}", fpdModuleId.getModule().getGuid(), targetFilename);
for (int i = 0; i < list.length; i++) { for (int i = 0; i < list.length; i++) {

View File

@ -16,10 +16,14 @@ package org.tianocore.build.global;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 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 /// Keep all the file names from all nested DpFile
/// ///
@ -46,5 +50,15 @@ public class DpFileList {
public void addConfiguredFile(DpFile f) { public void addConfiguredFile(DpFile f) {
this.nameList.addAll(f.getList()); 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]);
}
}
} }

View File

@ -13,19 +13,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
--*/ --*/
package org.tianocore.build.global; 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.BuildException;
import org.apache.tools.ant.Task; import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Sequential; 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 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 target files, which can be used to determine if the target files are needed to
be re-generated from source files. be re-generated from source files.
**/ **/
public class OnDependency extends Task { 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 /// source files list
/// ///
@ -77,12 +83,20 @@ public class OnDependency extends Task {
Iterator srcIt = sources.nameList.iterator(); Iterator srcIt = sources.nameList.iterator();
while (srcIt.hasNext()) { while (srcIt.hasNext()) {
String srcFileName = (String)srcIt.next(); String srcFileName = (String)srcIt.next();
File srcFile = new File(srcFileName); long srcTimeStamp;
if (!srcFile.exists()) {
throw new BuildException(srcFileName + " doesn't exist !!!"); 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; return true;
} }
} }