mirror of https://github.com/acidanthera/audk.git
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:
parent
a99a79e46f
commit
196ad8d77c
|
@ -14,6 +14,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
**/
|
||||
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.Project;
|
||||
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.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.
|
||||
**/
|
||||
|
@ -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,10 +372,19 @@ 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
|
||||
///
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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("(\\\\)", "/"));
|
||||
}
|
||||
|
|
|
@ -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++) {
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String, Long> timeStampCache = new HashMap<String, Long>();
|
||||
///
|
||||
/// 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(srcFileName + " doesn't exist !!!");
|
||||
}
|
||||
srcTimeStamp = srcFile.lastModified();
|
||||
timeStampCache.put(srcFileName, new Long(srcTimeStamp));
|
||||
}
|
||||
|
||||
if (dstTimeStamp < srcFile.lastModified()) {
|
||||
if (dstTimeStamp < srcTimeStamp) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue