**/\r
package org.tianocore.framework.tasks;\r
\r
-import org.apache.tools.ant.BuildException;\r
-import org.apache.tools.ant.Project;\r
-import org.apache.tools.ant.Task;\r
-import org.apache.tools.ant.taskdefs.Execute;\r
-import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
-import org.apache.tools.ant.types.Commandline;\r
-import org.apache.tools.ant.types.Path;\r
-\r
import java.io.File;\r
import java.io.FileReader;\r
import java.io.FileWriter;\r
import java.io.IOException;\r
import java.io.LineNumberReader;\r
import java.util.ArrayList;\r
+import java.util.HashSet;\r
import java.util.Iterator;\r
import java.util.List;\r
+import java.util.Set;\r
import java.util.StringTokenizer;\r
import java.util.regex.Matcher;\r
import java.util.regex.Pattern;\r
\r
+import org.apache.tools.ant.BuildException;\r
+import org.apache.tools.ant.Project;\r
+import org.apache.tools.ant.Task;\r
+import org.apache.tools.ant.taskdefs.Execute;\r
+import org.apache.tools.ant.taskdefs.LogStreamHandler;\r
+import org.apache.tools.ant.types.Commandline;\r
+import org.apache.tools.ant.types.Path;\r
+\r
/**\r
Class MakeDeps is used to wrap MakeDeps.exe as an ANT task.\r
**/\r
/// Remove any duplicated path separator or inconsistent path separator\r
///\r
private String cleanupPathName(String path) {\r
- String separator = "\\" + File.separator;\r
- String duplicateSeparator = separator + "{2}";\r
- path = Path.translateFile(path);\r
- path = path.replaceAll(duplicateSeparator, separator);\r
+ try {\r
+ path = (new File(path)).getCanonicalPath();\r
+ } catch (IOException e) {\r
+ String separator = "\\" + File.separator;\r
+ String duplicateSeparator = separator + "{2}";\r
+ path = Path.translateFile(path);\r
+ path = path.replaceAll(duplicateSeparator, separator);\r
+ return path;\r
+ }\r
\r
return path;\r
}\r
\r
LineNumberReader lineReader = null;\r
FileReader fileReader = null;\r
+ Set<String> lineSet = new HashSet<String>(100); // used to remove duplicated lines\r
try {\r
fileReader = new FileReader(df);\r
lineReader = new LineNumberReader(fileReader);\r
/// clean-up each line in deps file\r
//\r
String line = null;\r
- StringBuffer cleanedLines = new StringBuffer(4096);\r
while ((line = lineReader.readLine()) != null) {\r
Pattern pattern = Pattern.compile(target + "[ ]*:[ ]*(.+)");\r
Matcher matcher = pattern.matcher(line);\r
///\r
String filePath = line.substring(matcher.start(1), matcher.end(1));\r
filePath = cleanupPathName(filePath);\r
- cleanedLines.append(filePath);\r
- cleanedLines.append("\n");\r
+ lineSet.add(filePath);\r
}\r
}\r
lineReader.close();\r
///\r
StringTokenizer fileTokens = new StringTokenizer(extraDeps, ";");\r
while (fileTokens.hasMoreTokens()) {\r
- cleanedLines.append(cleanupPathName(fileTokens.nextToken()));\r
- cleanedLines.append("\n");\r
+ lineSet.add(cleanupPathName(fileTokens.nextToken()));\r
}\r
\r
+ ///\r
+ /// compose the final file content\r
+ /// \r
+ StringBuffer cleanedLines = new StringBuffer(40960);\r
+ Iterator<String> it = lineSet.iterator();\r
+ while (it.hasNext()) {\r
+ String filePath = it.next();\r
+ cleanedLines.append(filePath);\r
+ cleanedLines.append("\n");\r
+ }\r
///\r
/// overwrite old dep file with new content\r
///\r
GlobalData.setToolChainEnvInfo(envToolChainInfo);\r
\r
str = getValue("TOOL_CHAIN_CONF", targetFileInfo);\r
- if (str != null) {\r
+ if (str != null && str.trim().length() > 0) {\r
toolsDefFilename = str;\r
}\r
\r
// don't do anything if no tools found\r
// \r
if (GlobalData.isCommandSet(targetList[i], toolchainList[j], archList[k]) == false) {\r
- System.out.println("!!!Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");\r
+ System.out.println("Warning: No build issued. No tools found for [target=" + targetList[i] + " toolchain=" + toolchainList[j] + " arch=" + archList[k] + "]\n");\r
continue;\r
}\r
\r
key[4] = "NAME";\r
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);\r
File cmdFile = new File(cmdPath + File.separatorChar + cmdName);\r
-// GlobalData.log.info("PATH: " + cmdFile.getPath());\r
getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));\r
\r
//\r
//\r
key[4] = "FLAGS";\r
String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);\r
-// GlobalData.log.info("Flags: " + cmdFlags);\r
Set<String> addset = new LinkedHashSet<String>();\r
Set<String> subset = new LinkedHashSet<String>();\r
putFlagsToSet(addset, cmdFlags);\r
//\r
key[4] = "EXT";\r
String extName = GlobalData.getCommandSetting(key, fpdModuleId);\r
-// GlobalData.log.info("Ext: " + extName);\r
if ( extName != null && ! extName.equalsIgnoreCase("")) {\r
getProject().setProperty(cmd[m] + "_EXT", extName);\r
}\r
//\r
key[4] = "FAMILY";\r
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);\r
-// GlobalData.log.info("FAMILY: " + toolChainFamily);\r
if (toolChainFamily != null) {\r
getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);\r
}\r
//\r
key[4] = "SPATH";\r
String spath = GlobalData.getCommandSetting(key, fpdModuleId);\r
-// GlobalData.log.info("SPATH: " + spath);\r
if (spath != null) {\r
getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));\r
}\r
//\r
key[4] = "DPATH";\r
String dpath = GlobalData.getCommandSetting(key, fpdModuleId);\r
-// GlobalData.log.info("DPATH: " + dpath);\r
if (dpath != null) {\r
getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));\r
}\r
return ;\r
}\r
if (fp.initSections(ffsKeyword, project, fpdModuleId)) {\r
- String targetFilename = fpdModuleId.getModule().getGuid() + "-" + fpdModuleId.getModule().getName() + FpdParserTask.getSuffix(fpdModuleId.getModule().getModuleType());\r
+ String targetFilename = fpdModuleId.getModule().getGuid() + "-" + "${BASE_NAME}" + FpdParserTask.getSuffix(fpdModuleId.getModule().getModuleType());\r
String[] list = fp.getGenSectionElements(document, "${BASE_NAME}", fpdModuleId.getModule().getGuid(), targetFilename);\r
\r
for (int i = 0; i < list.length; i++) {\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
+import org.apache.tools.ant.DirectoryScanner;\r
+import org.apache.tools.ant.types.DataType;\r
+import org.apache.tools.ant.types.FileSet;\r
+\r
/**\r
DpFileList is a container of Dpfile at the point of ANT task/datatype\r
**/\r
-public class DpFileList {\r
+public class DpFileList extends DataType {\r
///\r
/// Keep all the file names from all nested DpFile\r
///\r
public void addConfiguredFile(DpFile f) {\r
this.nameList.addAll(f.getList());\r
}\r
+\r
+ public void addConfiguredFileSet(FileSet fileSet) {\r
+ DirectoryScanner ds = fileSet.getDirectoryScanner(getProject());\r
+ String dir = fileSet.getDir(getProject()).getAbsolutePath();\r
+ String[] files = ds.getIncludedFiles();\r
+\r
+ for (int i = 0; i < files.length; ++i) {\r
+ nameList.add(dir + "/" + files[i]);\r
+ }\r
+ }\r
}\r
\r
--*/\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
-\r
/**\r
Class OnDepdendency is used to check the timestamp between source files and\r
target files, which can be used to determine if the target files are needed to\r
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 static Map<String, Long> timeStampCache = new HashMap<String, Long>();\r
///\r
/// source files list\r
///\r
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(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
return true;\r
}\r
}\r