mirror of https://github.com/acidanthera/audk.git
1) Added dependency check for flashmap, genfvimage, peirebase tasks
2) Added code in FpdParserTask.java to avoid re-generate FV.inf file 3) Added isEmpty() to ToolArg class to check if an argument is empty or not git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1556 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
d1760183fd
commit
d946661a82
|
@ -7209,7 +7209,7 @@
|
|||
</Ffs>
|
||||
</BuildOptions>
|
||||
<UserExtensions UserID="TianoCore" Identifier="1">
|
||||
<concat destfile="${FV_DIR}/FV_RECOVERY.fd" binary="true">
|
||||
<concat destfile="${FV_DIR}/FV_RECOVERY.fd" binary="true" force="no">
|
||||
<fileset dir="${FV_DIR}" includes="*.fv"/>
|
||||
</concat>
|
||||
<!--Generate Run.cmd file. This file will call SecMain.exe to start shell.-->
|
||||
|
|
|
@ -135,6 +135,16 @@ public class FlashMapTask extends Task implements EfiDefine {
|
|||
@throws BuidException
|
||||
**/
|
||||
public void execute() throws BuildException {
|
||||
if (isUptodate()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, headerFile.toFileList()
|
||||
+ imageOutFile.toFileList()
|
||||
+ mcoFile.toFileList()
|
||||
+ dscFile.toFileList()
|
||||
+ asmIncFile.toFileList()
|
||||
+ outStrFile
|
||||
+ " is/are up-to-date!");
|
||||
return;
|
||||
}
|
||||
|
||||
Project project = this.getOwningTarget().getProject();
|
||||
//
|
||||
|
@ -598,4 +608,143 @@ public class FlashMapTask extends Task implements EfiDefine {
|
|||
public void setOutputDir(String outputDir) {
|
||||
this.outputDir = outputDir;
|
||||
}
|
||||
|
||||
//
|
||||
// Dependency check
|
||||
//
|
||||
private boolean isUptodate() {
|
||||
long srcTimeStamp = 0;
|
||||
String srcName = "";
|
||||
long dstTimeStamp = 0;
|
||||
String dstName = "";
|
||||
long timeStamp = 0;
|
||||
|
||||
if (!flashDefFile.isEmpty()) {
|
||||
srcName = flashDefFile.getValue();
|
||||
timeStamp = new File(srcName).lastModified();
|
||||
if (timeStamp > srcTimeStamp) {
|
||||
srcTimeStamp = timeStamp;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mciFile.isEmpty()) {
|
||||
srcName = mciFile.getValue();
|
||||
timeStamp = new File(srcName).lastModified();
|
||||
if (timeStamp > srcTimeStamp) {
|
||||
srcTimeStamp = timeStamp;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fdImage.isEmpty()) {
|
||||
srcName = fdImage.getValue();
|
||||
timeStamp = new File(srcName).lastModified();
|
||||
if (timeStamp > srcTimeStamp) {
|
||||
srcTimeStamp = timeStamp;
|
||||
}
|
||||
}
|
||||
|
||||
if (inStrFile.length() != 0) {
|
||||
srcName = inStrFile;
|
||||
timeStamp = new File(srcName).lastModified();
|
||||
if (timeStamp > srcTimeStamp) {
|
||||
srcTimeStamp = timeStamp;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mciFileArray.isEmpty()) {
|
||||
for (int i = 0; i < mciFileArray.nameList.size(); ++i) {
|
||||
srcName += mciFileArray.nameList.get(i) + " ";
|
||||
timeStamp = new File(mciFileArray.nameList.get(i)).lastModified();
|
||||
if (timeStamp > srcTimeStamp) {
|
||||
srcTimeStamp = timeStamp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!headerFile.isEmpty()) {
|
||||
dstName = headerFile.getValue();
|
||||
File dstFile = new File(dstName);
|
||||
if (!dstFile.isAbsolute()) {
|
||||
dstName = outputDir + File.separator + dstName;
|
||||
dstFile = new File(dstName);
|
||||
}
|
||||
|
||||
if (srcTimeStamp > dstFile.lastModified()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!imageOutFile.isEmpty()) {
|
||||
dstName = imageOutFile.getValue();
|
||||
File dstFile = new File(dstName);
|
||||
if (!dstFile.isAbsolute()) {
|
||||
dstName = outputDir + File.separator + dstName;
|
||||
dstFile = new File(dstName);
|
||||
}
|
||||
|
||||
if (srcTimeStamp > dstFile.lastModified()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mcoFile.isEmpty()) {
|
||||
dstName = mcoFile.getValue();
|
||||
File dstFile = new File(dstName);
|
||||
if (!dstFile.isAbsolute()) {
|
||||
dstName = outputDir + File.separator + dstName;
|
||||
dstFile = new File(dstName);
|
||||
}
|
||||
|
||||
if (srcTimeStamp > dstFile.lastModified()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!dscFile.isEmpty()) {
|
||||
dstName = dscFile.getValue();
|
||||
File dstFile = new File(dstName);
|
||||
if (!dstFile.isAbsolute()) {
|
||||
dstName = outputDir + File.separator + dstName;
|
||||
dstFile = new File(dstName);
|
||||
}
|
||||
|
||||
if (srcTimeStamp > dstFile.lastModified()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!asmIncFile.isEmpty()) {
|
||||
dstName = asmIncFile.getValue();
|
||||
File dstFile = new File(dstName);
|
||||
if (!dstFile.isAbsolute()) {
|
||||
dstName = outputDir + File.separator + dstName;
|
||||
dstFile = new File(dstName);
|
||||
}
|
||||
|
||||
if (srcTimeStamp > dstFile.lastModified()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (outStrFile.length() != 0) {
|
||||
dstName = outStrFile;
|
||||
File dstFile = new File(dstName);
|
||||
if (!dstFile.isAbsolute()) {
|
||||
dstName = outputDir + File.separator + dstName;
|
||||
dstFile = new File(dstName);
|
||||
}
|
||||
|
||||
if (srcTimeStamp > dstFile.lastModified()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, srcName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,16 @@ import org.apache.tools.ant.taskdefs.LogStreamHandler;
|
|||
import org.apache.tools.ant.types.Commandline;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.lang.ProcessBuilder;
|
||||
import java.util.LinkedList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Iterator;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
|
||||
import org.tianocore.common.logger.EdkLog;
|
||||
|
||||
|
@ -38,6 +48,10 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
|||
//
|
||||
static final private String toolName = "GenFvImage";
|
||||
//
|
||||
// Pattern to match the section header (e.g. [options], [files])
|
||||
//
|
||||
static final private Pattern sectionHeader = Pattern.compile("\\[([^\\[\\]]+)\\]");
|
||||
//
|
||||
// The name of input inf file
|
||||
//
|
||||
private FileArg infFile = new FileArg();
|
||||
|
@ -56,6 +70,11 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
|||
Project project = this.getOwningTarget().getProject();
|
||||
String path = project.getProperty("env.FRAMEWORK_TOOLS_PATH");
|
||||
|
||||
if (isUptodate()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, infFile.toFileList() + " is uptodate!");
|
||||
return;
|
||||
}
|
||||
|
||||
String command;
|
||||
if (path == null) {
|
||||
command = toolName;
|
||||
|
@ -142,4 +161,117 @@ public class GenFvImageTask extends Task implements EfiDefine{
|
|||
public void setOutputDir(String outputDir) {
|
||||
this.outputDir = outputDir;
|
||||
}
|
||||
|
||||
//
|
||||
// dependency check
|
||||
//
|
||||
private boolean isUptodate() {
|
||||
String infName = this.infFile.getValue();
|
||||
String fvName = "";
|
||||
List<String> ffsFiles = new LinkedList<String>();
|
||||
File inf = new File(infName);
|
||||
|
||||
try {
|
||||
FileReader reader = new FileReader(inf);
|
||||
BufferedReader in = new BufferedReader(reader);
|
||||
String str;
|
||||
|
||||
//
|
||||
// Read the inf file line by line
|
||||
//
|
||||
boolean inFiles = false;
|
||||
boolean inOptions = false;
|
||||
while ((str = in.readLine()) != null) {
|
||||
str = str.trim();
|
||||
if (str.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Matcher matcher = sectionHeader.matcher(str);
|
||||
if (matcher.find()) {
|
||||
//
|
||||
// We take care of only "options" and "files" section
|
||||
//
|
||||
String sectionName = str.substring(matcher.start(1), matcher.end(1));
|
||||
if (sectionName.equalsIgnoreCase("options")) {
|
||||
inOptions = true;
|
||||
inFiles = false;
|
||||
} else if (sectionName.equalsIgnoreCase("files")) {
|
||||
inFiles = true;
|
||||
inOptions = false;
|
||||
} else {
|
||||
inFiles = false;
|
||||
inOptions = false;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// skip invalid line
|
||||
//
|
||||
int equalMarkPos = str.indexOf("=");
|
||||
if (equalMarkPos < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
// we have only interest in EFI_FILE_NAME
|
||||
//
|
||||
String fileNameFlag = str.substring(0, equalMarkPos).trim();
|
||||
String fileName = str.substring(equalMarkPos + 1).trim();
|
||||
if (!fileNameFlag.equalsIgnoreCase("EFI_FILE_NAME")
|
||||
|| fileName.length() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inFiles) {
|
||||
//
|
||||
// files specified beneath the [files] section are source files
|
||||
//
|
||||
ffsFiles.add(fileName);
|
||||
} else if (inOptions) {
|
||||
//
|
||||
// file specified beneath the [options] section is the target file
|
||||
//
|
||||
fvName = outputDir + File.separator + fileName;
|
||||
}
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
throw new BuildException(ex.getMessage());
|
||||
}
|
||||
|
||||
//
|
||||
// if destionation file doesn't exist, we need to generate it.
|
||||
//
|
||||
File fvFile = new File(fvName);
|
||||
if (!fvFile.exists()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, fvName + " doesn't exist!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// the inf file itself will be taken as source file, check its timestamp
|
||||
// against the target file
|
||||
//
|
||||
long fvFileTimeStamp = fvFile.lastModified();
|
||||
if (inf.lastModified() > fvFileTimeStamp) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, infName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// no change in the inf file, we need to check each source files in it
|
||||
// against the target file
|
||||
//
|
||||
for (Iterator it = ffsFiles.iterator(); it.hasNext(); ) {
|
||||
String fileName = (String)it.next();
|
||||
File file = new File(fileName);
|
||||
if (file.lastModified() > fvFileTimeStamp) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, fileName + " has been changed since last build!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ public class NestElement extends DataType {
|
|||
// The name list. All the name strings got from setXXX methods will be put
|
||||
// in here.
|
||||
//
|
||||
private List<String> nameList = new ArrayList<String>();
|
||||
protected List<String> nameList = new ArrayList<String>();
|
||||
|
||||
/**
|
||||
Insert content in the newElement into this NestElement
|
||||
|
|
|
@ -67,6 +67,10 @@ public class PeiReBaseTask extends Task implements EfiDefine {
|
|||
@throws BuidException
|
||||
**/
|
||||
public void execute() throws BuildException {
|
||||
if (isUptodate()) {
|
||||
EdkLog.log(this, EdkLog.EDK_VERBOSE, outputFile.toFileList() + " is up-to-date!");
|
||||
return;
|
||||
}
|
||||
|
||||
Project project = this.getOwningTarget().getProject();
|
||||
|
||||
|
@ -247,4 +251,18 @@ public class PeiReBaseTask extends Task implements EfiDefine {
|
|||
public void setMapFile(String mapFile) {
|
||||
this.mapFile.setArg(" -M ", mapFile);
|
||||
}
|
||||
|
||||
//
|
||||
// Dependency check
|
||||
//
|
||||
private boolean isUptodate() {
|
||||
File srcFile = new File(inputFile.getValue());
|
||||
File dstFile = new File(outputFile.getValue());
|
||||
|
||||
if (srcFile.lastModified() > dstFile.lastModified()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,4 +139,13 @@ public class ToolArg extends NestElement {
|
|||
public String toString() {
|
||||
return super.toString(prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
Check if the argument is empty or not
|
||||
|
||||
@return boolean
|
||||
**/
|
||||
public boolean isEmpty() {
|
||||
return (prefix.length() == 0) && (nameList.isEmpty());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -193,6 +193,12 @@ public class FpdParserTask extends Task {
|
|||
getProject().setProperty("FV_FILENAME", validFv[i]);
|
||||
|
||||
File fvFile = new File(getProject().replaceProperties( getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i] + ".inf"));
|
||||
if (fvFile.exists() && (fvFile.lastModified() >= fpdFile.lastModified())) {
|
||||
//
|
||||
// don't re-generate FV.inf if fpd has not been changed
|
||||
//
|
||||
continue;
|
||||
}
|
||||
fvFile.getParentFile().mkdirs();
|
||||
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue