]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Java/Source/GenBuild/org/tianocore/build/FileProcess.java
Support using @ToolChainFamily in <Filename> to do the filter. This is also to fix...
[mirror_edk2.git] / Tools / Java / Source / GenBuild / org / tianocore / build / FileProcess.java
index 09ccd1f94cd8497fab603cfad122fc332b494cc8..59a2e587bde413b522331038631ac416662f5a2e 100644 (file)
@@ -53,14 +53,14 @@ import org.w3c.dom.Node;
 **/\r
 public class FileProcess {\r
     ///\r
-    ///  The mapping information about source suffix, result suffix, file type.\r
+    ///  The mapping information about source suffix, tool code, file type.\r
     ///\r
     public final String[][] fileTypes = { {".h", "", "CHeader" }, \r
-                                          {".c", "", "CCode" },\r
+                                          {".c", "CC", "CCode" },\r
                                           {".inc", "", "ASMHeader" },\r
-                                          {".asm", "", "ASM" }, \r
-                                          {".S", "", "ASM" },\r
-                                          {".s", "", "ASM" },\r
+                                          {".asm", "ASM", "ASM" }, \r
+                                          {".S", "ASM", "ASM" },\r
+                                          {".s", "ASM", "ASM" },\r
                                           {".uni", "", "UNI" },\r
                                           {".vfr", "", "VFR" },\r
                                           {".Vfr", "", "VFR" },\r
@@ -74,7 +74,7 @@ public class FileProcess {
                                           {".FYI", "", "FFS" },\r
                                           {".FFS", "", "FFS" },\r
                                           {".bmp", "", "BMP" },\r
-                                          {".i", "", "PPCode"}};\r
+                                          {".i", "PP", "PPCode"}};\r
     ///\r
     /// Current ANT context. \r
     ///\r
@@ -121,9 +121,9 @@ public class FileProcess {
       @param root Root node\r
       @param unicodeFirst whether build Unicode file firstly or not\r
     **/\r
-    public synchronized void parseFile(String filename, Node root, boolean unicodeFirst) {\r
+    public synchronized void parseFile(String filename, String family, Node root, boolean unicodeFirst) {\r
         this.unicodeFirst = unicodeFirst;\r
-        parseFile(filename, root);\r
+        parseFile(filename, family, root);\r
     }\r
     \r
     /**\r
@@ -143,9 +143,9 @@ public class FileProcess {
       @param root Root node\r
       @param unicodeFirst whether build Unicode file firstly or not\r
     **/\r
-    public synchronized void parseFile(String filename, String filetype, Node root, boolean unicodeFirst) {\r
+    public synchronized void parseFile(String filename, String filetype, String family, Node root, boolean unicodeFirst) {\r
         this.unicodeFirst = unicodeFirst;\r
-        parseFile(filename, filetype, root);\r
+        parseFile(filename, filetype, family, root);\r
     }\r
     \r
     /**\r
@@ -154,10 +154,10 @@ public class FileProcess {
       @param filename Source file name\r
       @param root Root node\r
     **/\r
-    public synchronized void parseFile(String filename, Node root) throws BuildException {\r
+    public synchronized void parseFile(String filename, String family, Node root) throws BuildException {\r
         for (int i = 0; i < fileTypes.length; i++) {\r
             if (filename.endsWith(fileTypes[i][0])) {\r
-                parseFile(filename, fileTypes[i][2], root);\r
+                parseFile(filename, fileTypes[i][2], family, root);\r
                 return ;\r
             }\r
         }\r
@@ -175,7 +175,21 @@ public class FileProcess {
       @param filetype Source file type\r
       @param root Root node\r
     **/\r
-    public synchronized void parseFile(String filename, String filetype, Node root) {\r
+    public synchronized void parseFile(String filename, String filetype, String family, Node root) {\r
+        //\r
+        // Filter file with family. Only family is specified in source file and\r
+        // not include current family will skip the file. \r
+        //\r
+        String toolCode = getToolCodeByFileType(filetype);\r
+        if (family != null && !family.trim().equalsIgnoreCase("")) {\r
+            String toolChainFamily = project.getProperty(toolCode + "_FAMILY");\r
+            if (toolChainFamily != null) {\r
+                if(!toolChainFamily.equalsIgnoreCase(family)) {\r
+                    return ;\r
+                }\r
+            }\r
+        }\r
+        \r
         if (unicodeFirst) {\r
             if ( ! filetype.equalsIgnoreCase("UNI")){\r
                 return ;\r
@@ -205,7 +219,7 @@ public class FileProcess {
         // 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
+        String toolsDefExtName = project.getProperty(toolCode + "_EXT");\r
         if (toolsDefExtName != null) {\r
             String[] exts = toolsDefExtName.split(" ");\r
             for (int i = 0; i < exts.length; i++) {\r
@@ -260,4 +274,13 @@ public class FileProcess {
         ele.appendChild(includesEle);\r
         root.appendChild(ele);\r
     }\r
+    \r
+    private String getToolCodeByFileType(String fileType) {\r
+        for (int i = 0; i < fileTypes.length; i++) {\r
+            if (fileTypes[i][2].equalsIgnoreCase(fileType)) {\r
+                return fileTypes[i][1];\r
+            }\r
+        }\r
+        return null;\r
+    }\r
 }
\ No newline at end of file