]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
Change to new XML Schema.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / FileProcess.java
index 87650af8278864c14d8150ccf3a8800d77a1767e..e615802c009c5beed8610fdab7a82e79db26f85b 100644 (file)
@@ -16,6 +16,7 @@ package org.tianocore.build;
 import java.io.File;\r
 import java.util.Set;\r
 \r
+import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.Project;\r
 import org.w3c.dom.Document;\r
 import org.w3c.dom.Element;\r
@@ -29,17 +30,24 @@ import org.w3c.dom.Node;
   by its extension. Following is the current supported extensions. </p>\r
   \r
   <pre>   \r
-          .c         |      C_Code\r
-          .asm       |      Assembly\r
-          .s         |      IPF_Assembly_Code\r
-          .h         |      Header\r
-          .lib       |      Static_Library\r
-          .i         |      IPF_PP_Code\r
-          .vfr       |      Vfr\r
-          .uni       |      Unicode\r
-          .dxs       |      Dependency_File\r
-          .bmp       |      Graphics\r
-          .efi       |      EFI\r
+ Source File Suffix     File Type       Description\r
+    .h                   CHeader      C header file\r
+    .c                   CCode        C source file\r
+    .inc                 ASMHeader    Assembly header file\r
+    .asm                 ASM          Assembly source file, usually for IA32 and X64 Arch and MSFT tool chain\r
+    .S                   ASM          Assembly source file, usually for IPF Arch\r
+    .s                   ASM          Assembly source file, usually for IA32 and X64 Arch and GCC tool chain\r
+    .uni                 UNI          Unicode file\r
+    .vfr                 VFR          Visual Forms Representation File\r
+    .fv                  FV           Firmware Volume\r
+    .SEC                 FFS          Firmware File System file\r
+    .PEI                 FFS          Firmware File System file\r
+    .DXE                 FFS          Firmware File System file\r
+    .APP                 FFS          Firmware File System file\r
+    .FVI                 FFS          Firmware File System file\r
+    .FFS                 FFS          Firmware File System file\r
+    .bmp                 BMP          Graphic File\r
+    .i                   PPCode       IPF PreProcessor Code\r
   </pre>\r
   \r
   @since GenBuild 1.0\r
@@ -48,13 +56,25 @@ public class FileProcess {
     ///\r
     ///  The mapping information about source suffix, result suffix, file type.\r
     ///\r
-    public final String[][] fileTypes = { { ".c", ".obj", "C_Code" }, { ".asm", ".obj", "Assembly" },\r
-                                         { ".s", ".obj", "IPF_Assembly_Code" }, { ".h", "", "Header" },\r
-                                         { ".lib", "", "Static_Library" }, { ".src", ".c", "" },\r
-                                         { ".i", ".obj", "IPF_PP_Code" }, { ".vfr", ".obj", "Vfr" },\r
-                                         { ".uni", "", "Unicode" }, { ".dxs", "", "Dependency_File" },\r
-                                         { ".bmp", "", "Graphics" }, { ".efi", "", "EFI" } };\r
-\r
+    public final String[][] fileTypes = { {".h", "", "CHeader" }, \r
+                                          {".c", "", "CCode" },\r
+                                          {".inc", "", "ASMHeader" },\r
+                                          {".asm", "", "ASM" }, \r
+                                          {".S", "", "ASM" },\r
+                                          {".s", "", "ASM" },\r
+                                          {".uni", "", "UNI" },\r
+                                          {".vfr", "", "VFR" },\r
+                                          {".dxs", "", "DPX"},\r
+                                          {".fv", "", "FV" },\r
+                                          {".efi", "", "EFI" },\r
+                                          {".SEC", "", "FFS" },\r
+                                          {".PEI", "", "FFS" },\r
+                                          {".DXE", "", "FFS" },\r
+                                          {".APP", "", "FFS" },\r
+                                          {".FYI", "", "FFS" },\r
+                                          {".FFS", "", "FFS" },\r
+                                          {".bmp", "", "BMP" },\r
+                                          {".i", "", "PPCode"}};\r
     ///\r
     /// Current ANT context. \r
     ///\r
@@ -64,11 +84,6 @@ public class FileProcess {
     /// Current module's include pathes\r
     ///\r
     private Set<String> includes;\r
-\r
-    ///\r
-    /// Current source files. \r
-    ///\r
-    private Set<String> sourceFiles;\r
     \r
     ///\r
     /// Xml Document.\r
@@ -93,11 +108,10 @@ public class FileProcess {
       @param sourceFiles Modules source files\r
       @param document XML document\r
     **/\r
-    public void init(Project project, Set<String> includes, Set<String> sourceFiles, Document document) {\r
+    public void init(Project project, Set<String> includes, Document document) {\r
         this.document = document;\r
         this.includes = includes;\r
         this.project = project;\r
-        this.sourceFiles = sourceFiles;\r
     }\r
 \r
     /**\r
@@ -140,16 +154,16 @@ public class FileProcess {
       @param filename Source file name\r
       @param root Root node\r
     **/\r
-    public synchronized void parseFile(String filename, Node root) {\r
+    public synchronized void parseFile(String filename, Node root) throws BuildException {\r
         boolean flag = false;\r
         for (int i = 0; i < fileTypes.length; i++) {\r
-            if (filename.toLowerCase().endsWith(fileTypes[i][0])) {\r
+            if (filename.endsWith(fileTypes[i][0])) {\r
                 flag = true;\r
                 parseFile(filename, fileTypes[i][2], root);\r
             }\r
         }\r
         if (!flag) {\r
-            System.out.println("Warning: File " + filename + " is not known from its suffix.");\r
+            throw new BuildException("File [" + filename + "] is not known from its suffix.");\r
         }\r
     }\r
 \r
@@ -167,31 +181,58 @@ public class FileProcess {
     **/\r
     public synchronized void parseFile(String filename, String filetype, Node root) {\r
         if (unicodeFirst) {\r
-            if ( ! filetype.equalsIgnoreCase("Unicode")){\r
+            if ( ! filetype.equalsIgnoreCase("UNI")){\r
                 return ;\r
             }\r
             unicodeExist= true;\r
         } else {\r
-            if (filetype.equalsIgnoreCase("Unicode")){\r
+            if (filetype.equalsIgnoreCase("UNI")){\r
                 return ;\r
             }\r
         }\r
-        sourceFiles.add(filename);\r
-        if (filetype.equalsIgnoreCase("Header")) {\r
+        \r
+        //\r
+        // If file is C or ASM header file, skip it\r
+        //\r
+        if (filetype.equalsIgnoreCase("CHeader") || filetype.equalsIgnoreCase("ASMHeader")) {\r
             return;\r
         }\r
-        if (filetype.equalsIgnoreCase("IPF_PP_Code")) {\r
+        \r
+        //\r
+        // If file is pre-processor file, skip it\r
+        // \r
+        if (filetype.equalsIgnoreCase("PPCode")) {\r
             return;\r
         }\r
+        \r
+        //\r
+        // If define CC_EXT in tools_def.txt file, the source file with \r
+        // different suffix is skipped\r
+        //\r
+        String toolsDefExtName = project.getProperty(filetype + "_EXT");\r
+        if (toolsDefExtName != null) {\r
+            String[] exts = toolsDefExtName.split(" ");\r
+            for (int i = 0; i < exts.length; i++) {\r
+                if ( ! filename.endsWith(exts[i])) {\r
+                    return ;\r
+                }\r
+            }\r
+        }\r
+        \r
         String module_path = project.getProperty("MODULE_DIR");\r
         File moduleFile = new File(module_path);\r
         File sourceFile = new File(filename);\r
+        \r
+        //\r
         // If source file is AutoGen.c, then Filepath is .\r
-        String sourceFilepath;\r
-        String sourceFilename;\r
+        //\r
+        String sourceFilepath = "";\r
+        String sourceFilename = "";\r
+        String sourceFileext = "";\r
         if (sourceFile.getPath().endsWith("AutoGen.c")) {\r
             sourceFilepath = ".";\r
             sourceFilename = "AutoGen";\r
+            sourceFileext = ".c";\r
             filetype = "AUTOGEN";\r
         } else {\r
             // sourceFile.\r
@@ -206,12 +247,14 @@ public class FileProcess {
             index = str.lastIndexOf('.');\r
             if (index > 0) {\r
                 sourceFilename = str.substring(0, index);\r
+                sourceFileext = str.substring(index);\r
             }\r
         }\r
         // <Build_filetype FILEPATH="" FILENAME="" />\r
         Element ele = document.createElement("Build_" + filetype);\r
         ele.setAttribute("FILEPATH", sourceFilepath);\r
         ele.setAttribute("FILENAME", sourceFilename);\r
+        ele.setAttribute("FILEEXT", sourceFileext.substring(1));\r
         String[] includePaths = includes.toArray(new String[includes.size()]);\r
         Element includesEle = document.createElement("EXTRA.INC");\r
         for (int i = 0; i < includePaths.length; i++) {\r