Introduce a new property INCLUDE_PATHS. This property can used by customized build...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / ModuleBuildFileGenerator.java
index 059b8ee76506da275f3cf27cb45fc235956c5319..34b3771a993c6a7306ea24251167c727a2ca8a25 100644 (file)
@@ -13,9 +13,7 @@ package org.tianocore.build;
 \r
 import java.io.File;\r
 import java.util.LinkedHashMap;\r
-import java.util.LinkedHashSet;\r
 import java.util.Map;\r
-import java.util.Set;\r
 import java.io.FileOutputStream;\r
 import java.io.OutputStreamWriter;\r
 \r
@@ -32,7 +30,6 @@ import javax.xml.transform.stream.StreamResult;
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.Project;\r
 import org.tianocore.build.fpd.FpdParserTask;\r
-import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.global.SurfaceAreaQuery;\r
 import org.tianocore.build.global.PropertyManager;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
@@ -66,10 +63,13 @@ public class ModuleBuildFileGenerator {
     \r
     private String ffsKeyword;\r
     \r
-    public ModuleBuildFileGenerator(Project project, String ffsKeyword, FpdModuleIdentification fpdModuleId) {\r
+    private String[] includes;\r
+    \r
+    public ModuleBuildFileGenerator(Project project, String ffsKeyword, FpdModuleIdentification fpdModuleId, String[] includes) {\r
         this.project = project;\r
         this.fpdModuleId = fpdModuleId;\r
         this.ffsKeyword = ffsKeyword;\r
+        this.includes = includes;\r
     }\r
     \r
     /**\r
@@ -330,20 +330,6 @@ public class ModuleBuildFileGenerator {
             root.appendChild(ele);\r
         }\r
     }\r
-    \r
-     /**\r
-      Return the name of the directory that corresponds to the architecture.\r
-      This is a translation from the XML Schema tag to a directory that\r
-      corresponds to our directory name coding convention.\r
-     \r
-      **/\r
-    private String archDir(String arch) {\r
-        return arch.replaceFirst("X64", "x64")\r
-                   .replaceFirst("IPF", "Ipf")\r
-                   .replaceFirst("IA32", "Ia32")\r
-                   .replaceFirst("ARM", "Arm")\r
-                   .replaceFirst("EBC", "Ebc");\r
-    }\r
 \r
     /**\r
       Generate the build source files elements for BaseName_build.xml. \r
@@ -352,62 +338,6 @@ public class ModuleBuildFileGenerator {
       @param root Root element for current\r
     **/\r
     private void applyCompileElement(Document document, Node root) {\r
-        //\r
-        // Prepare the includes: PackageDependencies and Output debug direactory\r
-        //\r
-        Set<String> includes = new LinkedHashSet<String>();\r
-        String arch = project.getProperty("ARCH");\r
-        \r
-        //\r
-        // WORKSPACE\r
-        //\r
-        includes.add("${WORKSPACE_DIR}" + File.separatorChar);\r
-        \r
-        //\r
-        // Module iteself\r
-        //\r
-        includes.add("${MODULE_DIR}");\r
-        includes.add("${MODULE_DIR}" + File.separatorChar + archDir(arch));\r
-        \r
-        //\r
-        // Packages in PackageDenpendencies\r
-        //\r
-        PackageIdentification[] packageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch());\r
-        for (int i = 0; i < packageDependencies.length; i++) {\r
-            GlobalData.refreshPackageIdentification(packageDependencies[i]);\r
-            File packageFile = packageDependencies[i].getSpdFile();\r
-            includes.add(packageFile.getParent() + File.separatorChar + "Include");\r
-            includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch));\r
-        }\r
-\r
-        //\r
-        // All Dependency Library Instance's PackageDependencies\r
-        //\r
-        ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch());\r
-        for (int i = 0; i < libinstances.length; i++) {\r
-            SurfaceAreaQuery.push(GlobalData.getDoc(libinstances[i], fpdModuleId.getArch()));\r
-            PackageIdentification[] libraryPackageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch());\r
-            for (int j = 0; j < libraryPackageDependencies.length; j++) {\r
-                GlobalData.refreshPackageIdentification(libraryPackageDependencies[j]);\r
-                File packageFile = libraryPackageDependencies[j].getSpdFile();\r
-                includes.add(packageFile.getParent() + File.separatorChar + "Include");\r
-                includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + archDir(arch));\r
-            }\r
-            SurfaceAreaQuery.pop();\r
-        }\r
-        \r
-        \r
-        //\r
-        // The package which the module belongs to\r
-        // TBD\r
-        includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include");\r
-        includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include" + File.separatorChar + archDir(arch));\r
-\r
-        //\r
-        // Debug files output directory\r
-        //\r
-        includes.add("${DEST_DIR_DEBUG}");\r
-        \r
         //\r
         // sourceFiles[][0] is FileType, [][1] is File name relative to Module_Dir\r
         //\r
@@ -447,11 +377,10 @@ public class ModuleBuildFileGenerator {
             Element ele = document.createElement("Build_Unicode_Database");\r
             ele.setAttribute("FILEPATH", ".");\r
             ele.setAttribute("FILENAME", "${BASE_NAME}");\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
+            for (int i = 0; i < includes.length; i++) {\r
                 Element includeEle = document.createElement("includepath");\r
-                includeEle.setAttribute("path", includePaths[i]);\r
+                includeEle.setAttribute("path", includes[i]);\r
                 includesEle.appendChild(includeEle);\r
             }\r
             ele.appendChild(includesEle);\r