summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2006-08-24 13:40:42 +0000
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>2006-08-24 13:40:42 +0000
commit82810f3b0f9ba49ed2d9f96c5b53e90dd7e66d88 (patch)
tree7dc4f35d069acd24c3f3c2e39ce6ab86bc9ec1f0
parentcb4d97bd83b4a570f84cee128f9021038b21f967 (diff)
downloadedk2-platforms-82810f3b0f9ba49ed2d9f96c5b53e90dd7e66d88.tar.xz
Fixed the issue caused by introducing INCLUDE_PATH property;
Re-designed NestElement class and all classes which implemented its interface because they have many common code; and changed all classes which use those re-designed classes. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1380 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Database.java92
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java6
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java2
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java54
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/IncludePath.java109
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Input.java28
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/InputFile.java81
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java99
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java251
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SkipExt.java63
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java89
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java53
-rw-r--r--Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java18
13 files changed, 361 insertions, 584 deletions
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Database.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Database.java
index 8c3f6be222..ade950807c 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Database.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Database.java
@@ -15,98 +15,16 @@
**/
package org.tianocore.framework.tasks;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
/**
- Database
-
Database represents an exceplicity name list of database file.
-
**/
-public class Database implements NestElement{
- ///
- /// name of database file
- ///
- private String name = "";
- ///
- /// name of file including database files
- ///
- private File file;
- ///
- /// the database file name list
- ///
- private List<String> nameList = new ArrayList<String>();
-
- /**
- getName
-
- This function is to get class member "name".
-
- @return class member "name".
- **/
- public String getName() {
- return this.name;
- }
+public class Database extends NestElement {
/**
- setName
+ Override NestElement.toString() to return a string with leading "-db"
- This function is to set class member "name".
-
- @param name : name of database file.
- **/
- public void setName(String name) {
- this.name = " -db " + name;
- }
-
- /**
- toString
-
- This function is to call getName() function.
- @return class member "name".
+ @return String
**/
public String toString() {
- return getName();
- }
-
- /**
- getFile
-
- This function is to get file which include the database file list.
-
- @return class member "file"
-
- **/
- public File getFile() {
- return this.file;
- }
- /**
- setFile
-
- This function is to set class member "file".
-
- @param file The file which include the database file list.
- **/
- public void setFile(File file) {
- this.file = file;
- }
-
-
- public void setList(String fileNameList) {
- if (fileNameList != null && fileNameList.length() > 0) {
- StringTokenizer tokens = new StringTokenizer(fileNameList, " \t,;", false);
- while (tokens.hasMoreTokens()) {
- String fileName = tokens.nextToken().trim();
- if (fileName.length() > 0) {
- this.nameList.add(fileName);
- }
- }
- }
- }
-
- public List<String> getList() {
- return nameList;
- }
+ return super.toString(" -db ");
+ }
} \ No newline at end of file
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java
index e54fd06d67..0eba56ea83 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java
@@ -137,7 +137,7 @@ public class EfiRomTask extends Task implements EfiDefine {
argList.add("-b");
Iterator binList = this.binaryFileList.iterator();
while (binList.hasNext()){
- argList.add(((Input)binList.next()).getFile());
+ argList.addAll(((Input)binList.next()).getNameList());
}
}
@@ -148,7 +148,7 @@ public class EfiRomTask extends Task implements EfiDefine {
argList.add("-e");
Iterator pe32List = this.pe32FileList.iterator();
while (pe32List.hasNext()){
- argList.add(((Input)pe32List.next()).getFile());
+ argList.addAll(((Input)pe32List.next()).getNameList());
}
}
@@ -159,7 +159,7 @@ public class EfiRomTask extends Task implements EfiDefine {
argList.add("-ec");
Iterator pe32ComprList = this.pe32ComprFileList.iterator();
while (pe32ComprList.hasNext()){
- argList.add(((Input)pe32ComprList.next()).getFile());
+ argList.addAll(((Input)pe32ComprList.next()).getNameList());
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
index 9b6268903d..ce0939f4b1 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
@@ -178,7 +178,7 @@ public class FlashMapTask extends Task implements EfiDefine {
argList.add("-mcmerge");
Iterator mciList = mciFileArray.iterator();
while (mciList.hasNext()) {
- argList.add(((Input) mciList.next()).getFile());
+ argList.addAll(((Input) mciList.next()).getNameList());
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java
index 46a1120b88..d7184cd5d3 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java
@@ -30,7 +30,7 @@ import org.apache.tools.ant.types.Commandline;
GenCRC32SectionTask is to call GenCRC32Section.exe to generate crc32 section.
**/
-public class GenCRC32SectionTask extends Task implements EfiDefine{
+public class GenCRC32SectionTask extends Task implements EfiDefine {
///
/// output file
///
@@ -38,7 +38,7 @@ public class GenCRC32SectionTask extends Task implements EfiDefine{
///
/// inputFile list
///
- private List<Object> inputFileList = new ArrayList<Object>();
+ private List<NestElement> inputFileList = new ArrayList<NestElement>();
///
/// Project
@@ -69,7 +69,11 @@ public class GenCRC32SectionTask extends Task implements EfiDefine{
//
// string line of input files
//
- String inputFiles = list2Str(inputFileList, "");
+ String inputFiles = " -i ";
+ for (int i = 0; i < inputFileList.size(); ++i) {
+ inputFiles += inputFileList.get(i).toString(" ");
+ }
+
//
// assemble argument
//
@@ -133,47 +137,5 @@ public class GenCRC32SectionTask extends Task implements EfiDefine{
*/
public void setOutputFile(String outputFile) {
this.outputFile = " -o " + outputFile;
- };
-
- /**
- * transfer List to String
- * @param list : nested element list
- * @param tag : interval tag of parameter
- * @return string line of parameters
- */
- private String list2Str(List list, String tag) {
- /*
- * string line for return
- */
- String paraStr = " -i";
- /*
- * nested element in list
- */
- NestElement element;
- /*
- * iterator of nested element list
- */
- Iterator elementIter = list.iterator();
- /*
- * string parameter list
- */
- List<Object> strList = new ArrayList<Object>();
-
- while (elementIter.hasNext()) {
- element = (NestElement) elementIter.next();
- if (null != element.getFile()) {
- FileParser.loadFile(project, strList, element.getFile(), tag);
- } else {
- paraStr = paraStr + element.getName();
- }
- }
- /*
- * iterator of string parameter list
- */
- Iterator strIter = strList.iterator();
- while (strIter.hasNext()) {
- paraStr = paraStr + " " + strIter.next();
- }
- return paraStr;
- }
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/IncludePath.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/IncludePath.java
index c2865cb907..4591406bbf 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/IncludePath.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/IncludePath.java
@@ -14,110 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
package org.tianocore.framework.tasks;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-public class IncludePath implements NestElement {
- /**
- IncludePath nested element Class
- class member
- -name : name of include path
- -file : name of file including include path
- **/
- private String path = "";
- private File file;
- private List<String> nameList = new ArrayList<String>();
-
- /**
- get class member "file"
-
- @returns The File object
- **/
- public File getFile() {
- return this.file;
- }
-
- /**
- set class member "file"
-
- @param file The name of include path
- **/
- public void setFile(File file) {
- this.file = file;
- }
-
- /**
- get class member "file"
-
- @returns The name of include path
- **/
- public String getPath() {
- return this.path;
- }
-
- /**
- get class member "name"
-
- @returns The name of include path
- **/
- public String getName() {
- return this.path;
- }
-
- /**
- set class member "name"
-
- @param name The name of include path
- **/
- public void setName(String name){
- this.path = " -I " + name;
- }
-
- /**
- set class member "path"
-
- @param name name of file including include paths
- **/
- public void setPath(String name) {
- this.path = " -I " + name;
- }
-
- /**
- override Object.toString()
-
- @returns name of file including include paths
- **/
+/**
+ IncludePath class is generally used to pass arguments with "-i" before each
+ of them.
+ **/
+public class IncludePath extends NestElement {
public String toString() {
- return getPath();
- }
-
- /**
- set class member "list"
-
- @param fileNameList name list of include paths, sperated by space, tab,
- comma or semi-comma
- **/
- public void setList(String fileNameList) {
- if (fileNameList != null && fileNameList.length() > 0) {
- StringTokenizer tokens = new StringTokenizer(fileNameList, " \t,;", false);
- while (tokens.hasMoreTokens()) {
- String fileName = tokens.nextToken().trim();
- if (fileName.length() > 0) {
- this.nameList.add(fileName);
- }
- }
- }
- }
-
- /**
- get class member "list"
-
- @returns The include paths list.
- **/
- public List<String> getList() {
- return nameList;
+ return super.toString(" -i ");
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Input.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Input.java
index b940e8da4b..088d37883b 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Input.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Input.java
@@ -15,30 +15,10 @@ package org.tianocore.framework.tasks;
/**
Input class is defined to be as nested elements of other elements, to specify
- the path of file(s)
+ the path of file(s).
**/
-public class Input {
- private String filePath;
-
- public Input() {
-
- }
-
- /**
- Standard set method of ANT task, for "file" attribute
-
- @param path The path of a file
- **/
- public void setFile(String path) {
- filePath = path;
- }
-
- /**
- Standard get method of ANT task, for "file" attribute
-
- @returns The path of current specified file.
- **/
- public String getFile() {
- return filePath;
+public class Input extends NestElement {
+ public String toString() {
+ return super.toString(" -f ");
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/InputFile.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/InputFile.java
index b08a38007b..fe0cc83eb2 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/InputFile.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/InputFile.java
@@ -13,83 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.framework.tasks;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-public class InputFile implements NestElement {
- /**
- InputFile nested element Class
- class member
- -name : name of input file
- -file : name of file including input files
- **/
- private String name = "";
- private File file;
- private List<String> nameList = new ArrayList<String>();
-
- /**
- get class member "name"
- @returns name parameter
- **/
- public String getName() {
- return this.name;
- }
-
- /**
- set class member "name"
- @param name name of input file
- **/
- public void setName(String name) {
- this.name = " " + name;
- }
-
+/**
+ InputFile is always used to pass arguments separated by space
+ **/
+public class InputFile extends NestElement {
public String toString() {
- return getName();
- }
-
- /**
- get class member "file"
- @returns file parameter
- **/
- public File getFile() {
- return this.file;
- }
-
- /**
- set class member "file"
- @param ext name of file including input files
- **/
- public void setFile(File file) {
- this.file = file;
- }
-
- /**
- set class member "list"
-
- @param fileNameList name list of include paths, sperated by space, tab,
- comma or semi-comma
- **/
- public void setList(String fileNameList) {
- if (fileNameList != null && fileNameList.length() > 0) {
- StringTokenizer tokens = new StringTokenizer(fileNameList, " \t,;", false);
- while (tokens.hasMoreTokens()) {
- String fileName = tokens.nextToken().trim();
- if (fileName.length() > 0) {
- this.nameList.add(fileName);
- }
- }
- }
- }
-
- /**
- get class member "list"
-
- @returns The include paths list.
- **/
- public List<String> getList() {
- return nameList;
+ return super.toString(" ");
}
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
index 6a02c1c590..f41bcfc6d3 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
@@ -45,7 +45,6 @@ public class MakeDeps extends Task {
// private members, use set/get to access them
//
private static final String cmdName = "MakeDeps";
- private String includePath = null;
private String depsFile = null;
private String subDir = null;
private boolean quietMode = true;
@@ -84,12 +83,12 @@ public class MakeDeps extends Task {
/// compose full tool path
///
if (toolPath == null || toolPath.length() == 0) {
- toolPath = "./" + cmdName;
+ toolPath = cmdName;
} else {
if (toolPath.endsWith("/") || toolPath.endsWith("\\")) {
toolPath = toolPath + cmdName;
} else {
- toolPath = toolPath + "/" + cmdName;
+ toolPath = toolPath + File.separator + cmdName;
}
}
@@ -98,10 +97,10 @@ public class MakeDeps extends Task {
///
StringBuffer args = new StringBuffer(4096);
if (ignoreError) {
- args.append(" -ignorenotfound");
+ args.append(" -ignorenotfound ");
}
if (quietMode) {
- args.append(" -q");
+ args.append(" -q ");
}
if (subDir != null && subDir.length() > 0) {
args.append(" -s ");
@@ -118,43 +117,20 @@ public class MakeDeps extends Task {
///
/// compose source file arguments
///
- Iterator iterator = inputFileList.iterator();
- while (iterator.hasNext()) {
- Input inputFile = (Input)iterator.next();
- String inputFileString = cleanupPathName(inputFile.getFile());
- args.append(" -f ");
- args.append(inputFileString);
+ for (int i = 0, listLength = inputFileList.size(); i < listLength; ++i) {
+ args.append(inputFileList.get(i).toString());
}
- ///
- /// compose search pathes argument
- ///
- StringBuffer includePathArg = new StringBuffer(4096);
- if (includePath != null && includePath.length() > 0) {
- StringTokenizer pathTokens = new StringTokenizer(includePath, ";");
- while (pathTokens.hasMoreTokens()) {
- String tmpPath = pathTokens.nextToken().trim();
- if (tmpPath.length() == 0) {
- continue;
- }
-
- includePathArg.append(" -i ");
- includePathArg.append(cleanupPathName(tmpPath));
- }
+ for (int i = 0, listLength = includePathList.size(); i < listLength; ++i) {
+ args.append(includePathList.get(i).toString());
}
- iterator = includePathList.iterator();
- while (iterator.hasNext()) {
- IncludePath path = (IncludePath)iterator.next();
- includePathArg.append(cleanupPathName(path.getPath()));
- }
- args.append(includePathArg);
///
/// We don't need a real target. So just a "dummy" is given
///
args.append(" -target dummy");
args.append(" -o ");
- args.append(cleanupPathName(depsFile));
+ args.append(depsFile);
///
/// prepare to execute the tool
@@ -180,7 +156,7 @@ public class MakeDeps extends Task {
if (result != 0) {
EdkLog.log(EdkLog.EDK_INFO, "MakeDeps failed!");
- return;
+ throw new BuildException("MakeDeps: failed to generate dependency file!");
}
}
@@ -255,7 +231,7 @@ public class MakeDeps extends Task {
@param dir The name of sub-directory in which source files will be scanned
**/
public void setSubDir(String dir) {
- subDir = dir;
+ subDir = cleanupPathName(dir);
}
/**
@@ -268,30 +244,12 @@ public class MakeDeps extends Task {
}
/**
- Set method for "IncludePath" attribute
-
- @param path The name of include path
- **/
- public void setIncludePath(String path) {
- includePath = cleanupPathName(path);
- }
-
- /**
- Get method for "IncludePath" attribute
-
- @returns The name of include path
- **/
- public String getIncludePath() {
- return includePath;
- }
-
- /**
Set method for "ExtraDeps" attribute
@param deps The name of dependency file specified separately
**/
public void setExtraDeps(String deps) {
- extraDeps = deps;
+ extraDeps = cleanupPathName(deps);
}
/**
@@ -333,26 +291,29 @@ public class MakeDeps extends Task {
return false;
}
- ///
- /// If the source file(s) is newer than dependency list file, we need to
- /// re-generate the dependency list file
- ///
+ //
+ // If the source file(s) is newer than dependency list file, we need to
+ // re-generate the dependency list file
+ //
long depsFileTimeStamp = df.lastModified();
- Iterator iterator = inputFileList.iterator();
+ Iterator<Input> iterator = (Iterator<Input>)inputFileList.iterator();
while (iterator.hasNext()) {
- Input inputFile = (Input)iterator.next();
- File sf = new File(inputFile.getFile());
- if (sf.lastModified() > depsFileTimeStamp) {
- return false;
+ Input inputFile = iterator.next();
+ List<String> fileList = inputFile.getNameList();
+ for (int i = 0, length = fileList.size(); i < length; ++i) {
+ File sf = new File(fileList.get(i));
+ if (sf.lastModified() > depsFileTimeStamp) {
+ return false;
+ }
}
}
- ///
- /// If the source files haven't been changed since last time the dependency
- /// list file was generated, we need to check each file in the file list to
- /// see if any of them is changed or not. If anyone of them is newer than
- /// the dependency list file, MakeDeps.exe is needed to run again.
- ///
+ //
+ // If the source files haven't been changed since last time the dependency
+ // list file was generated, we need to check each file in the file list to
+ // see if any of them is changed or not. If anyone of them is newer than
+ // the dependency list file, MakeDeps.exe is needed to run again.
+ //
LineNumberReader lineReader = null;
FileReader fileReader = null;
boolean ret = true;
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java
index f64fa7cab9..a402392349 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java
@@ -15,26 +15,255 @@ package org.tianocore.framework.tasks;
import java.io.File;
import java.util.List;
+import java.util.ArrayList;
+import java.io.FileReader;
+import java.io.BufferedReader;
+import java.util.StringTokenizer;
+
+import org.apache.tools.ant.types.DataType;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.BuildException;
/**
- Interface NestElement is just to define common interfaces for nested element
+ Interface NestElement is to define common interfaces for nested element
**/
-public interface NestElement {
+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>();
+
+ /**
+ Handle "name" attribute. No delimiter and special treatment are assumed.
+
+ @param name A single string value of "name" attribute
+ **/
+ public void setName(String name) {
+ if (name.length() > 0) {
+ nameList.add(name);
+ }
+ }
+
+ /**
+ Handle "list" attribute. The value of "list" is assumed as string
+ separated by space, tab, comma or semmicolon.
+
+ @param nameList The value of "list" separated by " \t,;"
+ **/
+ public void setList(String nameList) {
+ if (nameList.length() == 0) {
+ return;
+ }
+
+ StringTokenizer tokens = new StringTokenizer(nameList, " \t,;", false);
+ while (tokens.hasMoreTokens()) {
+ String name = tokens.nextToken().trim();
+ if (name.length() > 0) {
+ this.nameList.add(name);
+ }
+ }
+ }
+
+ /**
+ Handle "ListFile" attribute. The value of "ListFile" should be the path of
+ a file which contains name strings, one name per line.
+
+ @param listFileName The file path
+ **/
+ public void setListFile(String listFileName) {
+ FileReader fileReader = null;
+ BufferedReader in = null;
+ String str;
+
+ //
+ // Check if the file exists or not
+ //
+ File file = new File(listFileName);
+ if (!file.exists()) {
+ throw new BuildException("The file, " + file + " does not exist!");
+ }
+
+ try {
+ fileReader = new FileReader(file);
+ in = new BufferedReader(fileReader);
+
+ //
+ // Read line by line
+ //
+ while((str = in.readLine()) != null){
+ str = str.trim();
+ if (str.length() == 0){
+ continue;
+ }
+
+ //getProject().replaceProperties(str);
+ nameList.add(str);
+ }
+ } catch (Exception e){
+ throw new BuildException(e.getMessage());
+ } finally {
+ try {
+ //
+ // close the file
+ //
+ if (in != null) {
+ in.close();
+ }
+ if (fileReader != null) {
+ fileReader.close();
+ }
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+ }
+
+ /**
+ Handle "file" attribute. The value of "file" should be a path.
+
+ @param file The path name of a file
+ **/
+ public void setFile(String file) {
+ setPath(file);
+ }
+
+ /**
+ Handle "path" attribute. The value of "path" may contain compound path
+ separator (/ or \) which should be cleaned up. Because the "path" string
+ will always be passed to external native program which may not handle
+ non-native path separator, the clean-up action is a must. And the value
+ of "path" may contains several path separated by space, tab, comma or
+ semmicolon. We need to split it and put each part in nameList.
+
+ @param path String value of a file system path
+ **/
+ public void setPath(String path) {
+ if (path.length() == 0) {
+ return;
+ }
+
+ //
+ // split the value of "path" into separated single path
+ //
+ StringTokenizer tokens = new StringTokenizer(path, " \t,;", false);
+ while (tokens.hasMoreTokens()) {
+ String pathName = tokens.nextToken().trim();
+ if (pathName.length() > 0) {
+ //
+ // Make clean the path string before storing it
+ //
+ this.nameList.add(cleanupPath(pathName));
+ }
+ }
+ }
+
+ /**
+ Handle "FileName" attribute. The value of "FileName" should be the path
+ of a file which contains path strings, one path per line.
+
+ @param pathFileName
+ **/
+ public void setPathFile(String pathFileName) {
+ FileReader fileReader = null;
+ BufferedReader in = null;
+ String path;
+
+ //
+ // Check if the file exists or not
+ //
+ File file = new File(pathFileName);
+ if (!file.exists()) {
+ throw new BuildException("The file, " + file + " does not exist!");
+ }
+
+ try {
+ fileReader = new FileReader(file);
+ in = new BufferedReader(fileReader);
+
+ //
+ // Read the file line by line, skipping empty ones
+ //
+ while((path = in.readLine()) != null){
+ path = path.trim();
+ if (path.length() == 0){
+ continue;
+ }
+ //getProject().replaceProperties(path);
+
+ //
+ // Make clean the path string before storing it.
+ //
+ nameList.add(cleanupPath(path));
+ }
+ } catch (Exception e){
+ throw new BuildException(e.getMessage());
+ } finally {
+ try {
+ //
+ // close the file
+ //
+ if (in != null) {
+ in.close();
+ }
+ if (fileReader != null) {
+ fileReader.close();
+ }
+ } catch (Exception e) {
+ throw new BuildException(e.getMessage());
+ }
+ }
+ }
+
/**
- nested element Interface for up-casting
+ Return the name list.
+
+ @return List<String> The list contains the name(path) strings
**/
-
- public String getName();
+ public List<String> getNameList() {
+ return nameList;
+ }
+
+ /**
+ Compose and return the the name/path string without any delimiter. The trick
+ here is that it's actually used to return the value of nameList which
+ has just one name/string.
- public void setName(String name);
+ @return String
+ **/
+ public String toString() {
+ return toString("");
+ }
+
+ /**
+ Compose and return the name/path string concatenated by leading "prefix".
+
+ @param prefix The string will be put before each name/string in nameList
+
+ @return String The string concatenated with "prefix"
+ **/
+ public String toString(String prefix) {
+ StringBuffer string = new StringBuffer(1024);
+ int length = nameList.size();
- public String toString();
+ for (int i = 0; i < length; ++i) {
+ string.append(prefix);
+ string.append(nameList.get(i));
+ }
- public File getFile();
+ return string.toString();
+ }
- public void setFile(File file);
+ //
+ // Remove any duplicated path separator or inconsistent path separator
+ //
+ private String cleanupPath(String path) {
+ String separator = "\\" + File.separator;
+ String duplicateSeparator = separator + "{2}";
- public void setList(String fileNameList);
+ path = Path.translateFile(path);
+ path = path.replaceAll(duplicateSeparator, separator);
- public List<String> getList();
+ return path;
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SkipExt.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SkipExt.java
index d766ed2c58..20883c98e3 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SkipExt.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SkipExt.java
@@ -13,71 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.framework.tasks;
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
/**
SkipExt nested element Class
- class member
- -name : extension name of skiped file
- -file : name of file including ext
**/
-public class SkipExt implements NestElement {
- private String name = "";
- private File file;
- private List<String> nameList = new ArrayList<String>();
-
- /**
- get class member "name"
- @returns name parameter
- **/
- public String getName() {
- return this.name;
- }
- /**
- set class member "name"
- @param name extension name of skiped file
- **/
- public void setName(String name) {
- this.name = " -skipext " + name;
- }
-
+public class SkipExt extends NestElement {
public String toString() {
- return getName();
- }
-
- /**
- get class member "file"
- @returns file parameter
- **/
- public File getFile() {
- return this.file;
- }
- /**
- set class member "file"
- @param name of file including ext
- **/
- public void setFile(File file) {
- this.file = file;
- }
-
- public void setList(String fileNameList) {
- if (fileNameList != null && fileNameList.length() > 0) {
- StringTokenizer tokens = new StringTokenizer(fileNameList, " \t,;", false);
- while (tokens.hasMoreTokens()) {
- String fileName = tokens.nextToken().trim();
- if (fileName.length() > 0) {
- this.nameList.add(fileName);
- }
- }
- }
- }
-
- public List<String> getList() {
- return nameList;
+ return super.toString(" -skipext ");
}
-
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java
index 6f9fc73d3d..b84adf2525 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java
@@ -13,10 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.framework.tasks;
+import java.io.File;
import java.util.*;
+
+import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.LogStreamHandler;
import org.apache.tools.ant.types.Commandline;
@@ -57,9 +59,9 @@ public class StrGatherTask extends Task implements EfiDefine {
private String outputDatabase = "";
- private List<Object> databaseList = new ArrayList<Object>();
+ private List<Database> databaseList = new ArrayList<Database>();
- private List<Object> inputFileList = new ArrayList<Object>();
+ private List<InputFile> inputFileList = new ArrayList<InputFile>();
///
/// parse options newDatabase -- "ture/false" unquoteString -- "ture/false"
@@ -68,14 +70,14 @@ public class StrGatherTask extends Task implements EfiDefine {
private String unquotedString = "";
- private List<Object> includePathList = new ArrayList<Object>();
+ private List<IncludePath> includePathList = new ArrayList<IncludePath>();
///
/// scan options ignoreNotFound -- "ture/false"
///
private String ignoreNotFound = "";
- private List<Object> skipExtList = new ArrayList<Object>();
+ private List<SkipExt> skipExtList = new ArrayList<SkipExt>();
///
/// dump options
@@ -113,16 +115,16 @@ public class StrGatherTask extends Task implements EfiDefine {
if (path == null) {
command = "StrGather";
} else {
- command = path + "/" + "StrGather";
+ command = path + File.separator + "StrGather";
}
///
/// transfer nested elements into string
///
- String databases = list2Str(databaseList, "-db");
- String skipExts = list2Str(skipExtList, "-skipext");
- String includePaths = list2Str(includePathList, "-I");
- String inputFiles = list2Str(inputFileList, "");
+ String databases = list2Str(databaseList);
+ String skipExts = list2Str(skipExtList);
+ String includePaths = list2Str(includePathList);
+ String inputFiles = list2Str(inputFileList);
///
/// assemble argument
@@ -461,63 +463,20 @@ public class StrGatherTask extends Task implements EfiDefine {
}
/**
- transfer List to String
-
- @param list nested element list
- @param tag interval tag of parameter
+ Compose the content in each NestElement into a single string.
- @returns string line of parameters
+ @param list The NestElement list
+
+ @return String
**/
- private String list2Str(List list, String tag) {
- ///
- /// string line for return
- ///
- String paraStr = "";
- ///
- /// nested element in list
- ///
- NestElement element;
- ///
- /// iterator of nested element list
- ///
- Iterator elementIter = list.iterator();
- ///
- /// string parameter list
- ///
- List<Object> strList = new ArrayList<Object>();
-
- while (elementIter.hasNext()) {
- element = (NestElement) elementIter.next();
- if (null != element.getFile()) {
- ///
- /// nested element include file
- ///
- FileParser.loadFile(project, strList, element.getFile(), tag);
- }
-
- if (element.getName().length() > 0) {
- ///
- /// nested element include name
- ///
- paraStr = paraStr + " " + element.getName();
- }
-
- List<String> nameList = element.getList();
- if (nameList.size() > 0) {
- Iterator nameIter = nameList.iterator();
- while (nameIter.hasNext()) {
- paraStr = paraStr + " " + tag + " " + (String)nameIter.next();
- }
- }
- }
- ///
- /// iterator of string parameter list
- ///
- Iterator strIter = strList.iterator();
- while (strIter.hasNext()) {
- paraStr = paraStr + " " + strIter.next();
+ private String list2Str(List list) {
+ int listLength = list.size();
+ String str = "";
+ for (int i = 0; i < listLength; ++i) {
+ NestElement e = (NestElement)list.get(i);
+ str += e.toString();
}
- return paraStr;
- }
+ return str;
+ }
}
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java
index 4cc4d374c4..7f04bf231b 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java
@@ -31,7 +31,7 @@ public class Tool implements EfiDefine, Section {
String toolName = "";
List<Object> toolArgList = new ArrayList<Object>();
String outputPath;
- String outPutFileName ;
+ File outputFile ;
List<Input> inputFiles = new ArrayList<Input>();
/**
@@ -40,9 +40,6 @@ public class Tool implements EfiDefine, Section {
@param buffer The buffer to put the result with alignment
**/
public void toBuffer (DataOutputStream buffer){
- File OutputFile;
- byte data;
-
///
/// call extern tool
///
@@ -55,25 +52,25 @@ public class Tool implements EfiDefine, Section {
///
/// check if file exist
///
- OutputFile = new File (this.outPutFileName);
- long fileLen = OutputFile.length();
- if (!OutputFile.exists()) {
- throw new BuildException("The file " + outPutFileName + " does not exist!\n");
+ //File OutputFile = new File (this.outPutFileName);
+ if (!outputFile.exists()) {
+ throw new BuildException("The file " + outputFile.getPath() + " does not exist!\n");
}
///
/// Read output file and write it's cotains to buffer
///
+ FileInputStream fs = null;
+ DataInputStream in = null;
try {
- FileInputStream fs = new FileInputStream (this.outPutFileName);
- DataInputStream In = new DataInputStream (fs);
-
- int i = 0;
- while (i < fileLen) {
- data = In.readByte();
- buffer.writeByte(data);
- i ++;
- }
+ fs = new FileInputStream (outputFile);
+ in = new DataInputStream (fs);
+
+
+ int fileLen = (int)outputFile.length();
+ byte[] data = new byte[fileLen];
+ in.read(data);
+ buffer.write(data, 0, fileLen);
///
/// 4 byte alignment
@@ -82,11 +79,20 @@ public class Tool implements EfiDefine, Section {
fileLen++;
buffer.writeByte(0);
}
- In.close();
-
} catch (Exception e) {
System.out.print(e.getMessage());
throw new BuildException("Tool call, toBuffer failed!\n");
+ } finally {
+ try {
+ if (in != null) {
+ in.close();
+ }
+ if (fs != null) {
+ fs.close();
+ }
+ } catch (Exception e) {
+ System.out.println("WARNING: Cannot close " + outputFile.getPath());
+ }
}
}
@@ -114,16 +120,15 @@ public class Tool implements EfiDefine, Section {
///
/// input files for tools
///
- argument = argument + "-i ";
+ argument += " -i ";
while (inputIter.hasNext()) {
file = (Input)inputIter.next();
- argument = argument + file.getFile() + " ";
+ argument += file.toString(" ");
}
- outPutFileName = outputPath + File.separatorChar + (new File(file.getFile())).getName() + ".crc";
- argument = argument + " -o " + outPutFileName;
-
try {
+ outputFile = File.createTempFile("temp", ".crc", new File(outputPath));
+ argument = argument + " -o " + outputFile.getPath();
///
/// execute command line
diff --git a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java
index 3d940cb297..d99f2399dc 100644
--- a/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java
+++ b/Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java
@@ -44,7 +44,7 @@ public class VfrCompilerTask extends Task implements EfiDefine {
private String vfrFile = "";
private String vfrFileName = "";
- private List<Object> includepathList = new ArrayList<Object>();
+ private List<IncludePath> includepathList = new ArrayList<IncludePath>();
/**
get class member of createList file
@@ -170,21 +170,11 @@ public class VfrCompilerTask extends Task implements EfiDefine {
List<Object> includePath = new ArrayList<Object>();
String incPath = "";
- int count = includepathList.size();
- IncludePath path;
+ int count = includepathList.size();
for (int i = 0; i < count; i++) {
- path = (IncludePath) includepathList.get(i);
- if (path.getFile() != null) {
- FileParser.loadFile( project,includePath,path.getFile(), "-I");
- }
- }
- for (int i = 0; i < count; i++) {
- incPath = incPath + " " + includepathList.get(i);
- }
- count = includePath.size();
- for (int i = 0; i < count; i++) {
- incPath = incPath + " " + includePath.get(i);
+ incPath += includepathList.get(i).toString();
}
+
String argument = this.createIfrBinFile +
this.processerArg +
incPath +