]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fixed the issue caused by introducing INCLUDE_PATH property;
authorjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 24 Aug 2006 13:40:42 +0000 (13:40 +0000)
committerjwang36 <jwang36@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 24 Aug 2006 13:40:42 +0000 (13:40 +0000)
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

13 files changed:
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Database.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/EfiRomTask.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/FlashMapTask.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/GenCRC32SectionTask.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/IncludePath.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Input.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/InputFile.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/MakeDeps.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/NestElement.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/SkipExt.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/StrGatherTask.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/Tool.java
Tools/Source/FrameworkTasks/org/tianocore/framework/tasks/VfrCompilerTask.java

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