Introduce a new property INCLUDE_PATHS. This property can used by customized build...
authorwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 22 Aug 2006 05:54:55 +0000 (05:54 +0000)
committerwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 22 Aug 2006 05:54:55 +0000 (05:54 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1347 6f19259b-4bc3-4df7-8a09-765794883524

EdkNt32Pkg/Sec/SecMain_build.xml
Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java

index cfadcef..56b2635 100644 (file)
@@ -76,58 +76,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
   <target name="sourcefiles">\r
       <Build_AUTOGEN FILEEXT="c" FILENAME="AutoGen" FILEPATH=".">\r
          <EXTRA.INC>\r
-            <includepath path="${WORKSPACE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include\${ARCH}"/>\r
-            <includepath path="${DEST_DIR_DEBUG}"/>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
          </EXTRA.INC>\r
        </Build_AUTOGEN>\r
       <Build_CCode FILEEXT="c" FILENAME="FwVol" FILEPATH=".">\r
          <EXTRA.INC>\r
-            <includepath path="${WORKSPACE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include\${ARCH}"/>\r
-            <includepath path="${DEST_DIR_DEBUG}"/>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
          </EXTRA.INC>\r
       </Build_CCode>\r
       <Build_CCode FILEEXT="c" FILENAME="WinNtThunk" FILEPATH=".">\r
          <EXTRA.INC>\r
-            <includepath path="${WORKSPACE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include\${ARCH}"/>\r
-            <includepath path="${DEST_DIR_DEBUG}"/>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
          </EXTRA.INC>\r
       </Build_CCode>\r
       <Build_CCode FILEEXT="c" FILENAME="SecMain" FILEPATH=".">\r
          <EXTRA.INC>\r
-            <includepath path="${WORKSPACE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}"/>\r
-            <includepath path="${MODULE_DIR}\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\MdePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkModulePkg\Include\${ARCH}"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include"/>\r
-            <includepath path="${WORKSPACE_DIR}\EdkNt32Pkg\Include\${ARCH}"/>\r
-            <includepath path="${DEST_DIR_DEBUG}"/>\r
+            <includepath path="${INCLUDE_PATHS}"/>\r
          </EXTRA.INC>\r
       </Build_CCode>\r
     </target>\r
index dcc5209..09ccd1f 100644 (file)
@@ -14,7 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 package org.tianocore.build;\r
 \r
 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
@@ -84,7 +83,7 @@ public class FileProcess {
     ///\r
     /// Current module's include pathes\r
     ///\r
-    private Set<String> includes;\r
+    private String[] includes;\r
     \r
     ///\r
     /// Xml Document.\r
@@ -109,7 +108,7 @@ public class FileProcess {
       @param sourceFiles Modules source files\r
       @param document XML document\r
     **/\r
-    public void init(Project project, Set<String> includes, Document document) {\r
+    public void init(Project project, String[] includes, Document document) {\r
         this.document = document;\r
         this.includes = includes;\r
         this.project = project;\r
@@ -252,11 +251,10 @@ public class FileProcess {
         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
+        for (int i = 0; i < includes.length; i++) {\r
             Element includeEle = document.createElement("includepath");\r
-            includeEle.setAttribute("path", project.replaceProperties(includePaths[i]));\r
+            includeEle.setAttribute("path", project.replaceProperties(includes[i]));\r
             includesEle.appendChild(includeEle);\r
         }\r
         ele.appendChild(includesEle);\r
index 8e7ee3b..42d3313 100644 (file)
@@ -16,13 +16,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 package org.tianocore.build;\r
 \r
 import java.io.File;\r
-import java.util.Hashtable;\r
 import java.util.Iterator;\r
 import java.util.LinkedHashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
 import java.util.Set;\r
-import java.util.Stack;\r
 import java.util.Vector;\r
 import java.util.regex.Matcher;\r
 import java.util.regex.Pattern;\r
@@ -109,8 +107,6 @@ public class GenBuildTask extends Ant {
 \r
     private Vector<Property> properties = new Vector<Property>();\r
 \r
-    private static Stack<Hashtable> backupPropertiesStack = new Stack<Hashtable>();\r
-\r
     private boolean isSingleModuleBuild = false;\r
 \r
     /**\r
@@ -569,6 +565,11 @@ public class GenBuildTask extends Ant {
         }\r
         PropertyManager.setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));\r
 \r
+        //\r
+        // Get all includepath and set to INCLUDE_PATHS\r
+        //\r
+        String[] includes = prepareIncludePaths(fpdModuleId);\r
+        \r
         //\r
         // if it is CUSTOM_BUILD\r
         // then call the exist BaseName_build.xml directly.\r
@@ -587,7 +588,7 @@ public class GenBuildTask extends Ant {
         // TBD\r
         //\r
         String ffsKeyword = SurfaceAreaQuery.getModuleFfsKeyword();\r
-        ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId);\r
+        ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId, includes);\r
         String buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";\r
         fileGenerator.genBuildFile(buildFilename);\r
 \r
@@ -697,4 +698,89 @@ public class GenBuildTask extends Ant {
     public void setSingleModuleBuild(boolean isSingleModuleBuild) {\r
         this.isSingleModuleBuild = isSingleModuleBuild;\r
     }\r
+    \r
+    private String[] prepareIncludePaths(FpdModuleIdentification fpdModuleId) {\r
+        //\r
+        // Prepare the includes: PackageDependencies and Output debug direactory\r
+        //\r
+        Set<String> includes = new LinkedHashSet<String>();\r
+        String arch = fpdModuleId.getArch();\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
+        // set to INCLUDE_PATHS property\r
+        //\r
+        Iterator<String> iter = includes.iterator();\r
+        StringBuffer includePaths = new StringBuffer();\r
+        while (iter.hasNext()) {\r
+            includePaths.append(iter.next());\r
+            includePaths.append("; ");\r
+        }\r
+        PropertyManager.setProperty("INCLUDE_PATHS", getProject().replaceProperties(includePaths.toString()).replaceAll("(\\\\)", "/"));\r
+        \r
+        return includes.toArray(new String[includes.size()]);\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
index 059b8ee..34b3771 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