]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add thread control classes. (2)
authorwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Sep 2006 03:49:31 +0000 (03:49 +0000)
committerwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 4 Sep 2006 03:49:31 +0000 (03:49 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1433 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java
Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java
Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
Tools/Source/GenBuild/org/tianocore/build/global/OnDependency.java

index 66ad11ab5567675fd3e0d79382f51b24fd1fa4b6..ed94da38ed2bc0a3a51a0e5b3049e6a41ed8cfcf 100644 (file)
@@ -84,12 +84,6 @@ public class FfsProcess {
     ///\r
     public static final String[][] sectionExt = EdkDefinitions.SectionTypeExtensions;\r
 \r
-    private SurfaceAreaQuery saq = null;\r
-    \r
-    public FfsProcess(SurfaceAreaQuery saq) {\r
-        this.saq = saq;\r
-    }\r
-    \r
     /**\r
       search in the type, if componentType is listed in type, return true; \r
       otherwise return false.\r
@@ -121,9 +115,8 @@ public class FfsProcess {
         //\r
         // Try to find Ffs layout from FPD file\r
         //\r
-        saq.push(GlobalData.getFpdBuildOptions());\r
+        SurfaceAreaQuery saq = new SurfaceAreaQuery(GlobalData.getFpdBuildOptionsMap());\r
         BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = saq.getFpdFfs();\r
-        saq.pop();\r
         for (int i = 0; i < ffsArray.length; i++) {\r
             if (isMatch(ffsArray[i].getFfsKey(), buildType)) {\r
                 ffsXmlObject = ffsArray[i];\r
index dc12f6e23ed5e48cfb98d328544bcd6950efa817..07da77c2bc65a42c3014384be67a86bc635fc9a2 100644 (file)
@@ -23,6 +23,7 @@ import java.util.Set;
 \r
 import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.Task;\r
+import org.tianocore.build.fpd.FpdParserForThread;\r
 import org.tianocore.build.fpd.FpdParserTask;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.global.PropertyManager;\r
@@ -81,6 +82,16 @@ public class FrameworkBuildTask extends Task{
     \r
     String activePlatform = null;\r
     \r
+    ///\r
+    /// The flag to present current is multi-thread enabled\r
+    ///\r
+    public static boolean multithread = false;\r
+    \r
+    ///\r
+    /// The concurrent thread number\r
+    ///\r
+    public static int MAX_CONCURRENT_THREAD_NUMBER = 1;\r
+    \r
     ///\r
     /// there are three type: all (build), clean and cleanall\r
     ///\r
@@ -175,6 +186,19 @@ public class FrameworkBuildTask extends Task{
         //\r
         if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {\r
             System.out.println("Processing the FPD file [" + buildFile.getPath() + "] ..>> ");\r
+            //\r
+            // Iff for platform build will enable the multi-thread if set in target.txt\r
+            //\r
+            if (multithread && type.equalsIgnoreCase("all")) {\r
+                System.out.println("Multi-thread build is enabled. ");\r
+                FpdParserForThread fpdParserForThread = new FpdParserForThread();\r
+                fpdParserForThread.setType(type);\r
+                fpdParserForThread.setProject(getProject());\r
+                fpdParserForThread.setFpdFile(buildFile);\r
+                fpdParserForThread.execute();\r
+                return ;\r
+            }\r
+            \r
             FpdParserTask fpdParserTask = new FpdParserTask();\r
             fpdParserTask.setType(type);\r
             fpdParserTask.setProject(getProject());\r
@@ -330,6 +354,23 @@ public class FrameworkBuildTask extends Task{
                 }\r
                 activePlatform = str;\r
             }\r
+            \r
+            str = getValue("MULTIPLE_THREAD", targetFileInfo);\r
+            if (str != null && str.trim().equalsIgnoreCase("Enable")) {\r
+                multithread = true;\r
+            }\r
+            \r
+            str = getValue("MAX_CONCURRENT_THREAD_NUMBER", targetFileInfo);\r
+            if (str != null ) {\r
+                try {\r
+                    int threadNum = Integer.parseInt(str);\r
+                    if (threadNum > 0) {\r
+                        MAX_CONCURRENT_THREAD_NUMBER = threadNum;\r
+                    }\r
+                } catch (Exception enuma) {\r
+                    \r
+                }\r
+            }\r
         }\r
         catch (Exception ex) {\r
             throw new BuildException(ex.getMessage());\r
index c5fb00b3e095f475bd424d60f77d36ef1475b157..62304774452967fc01cfedebf814e11b3e80d19e 100644 (file)
@@ -97,7 +97,9 @@ public class GenBuildTask extends Ant {
     /// Module surface area file.\r
     ///\r
     File msaFile;\r
-\r
+    \r
+    public ModuleIdentification parentId;\r
+    \r
     private String type = "all"; \r
     \r
     ///\r
@@ -783,5 +785,10 @@ public class GenBuildTask extends Ant {
                   .replaceFirst("IA32", "Ia32")\r
                   .replaceFirst("ARM", "Arm")\r
                   .replaceFirst("EBC", "Ebc");\r
-   }    \r
+   }\r
+   \r
+   \r
+   public void setExternalProperties(Vector<Property> v) {\r
+       this.properties = v;\r
+   }\r
 }\r
index 1bdae21245f594cadb2a82ebd24582d542d86527..122f04f3d39d4e243591f028e80af32098e3b492 100644 (file)
@@ -91,7 +91,7 @@ public class ModuleBuildFileGenerator {
               Error throws during BaseName_build.xml generating. \r
     **/\r
     public void genBuildFile(String buildFilename) throws BuildException {\r
-        FfsProcess fp = new FfsProcess(saq);\r
+        FfsProcess fp = new FfsProcess();\r
         DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
         try {\r
             DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
@@ -143,7 +143,9 @@ public class ModuleBuildFileGenerator {
             //\r
             // Parse all sourfiles but files specified in sections\r
             //\r
-            applyLibraryInstance(document, ele);\r
+            if (!FrameworkBuildTask.multithread) {\r
+                applyLibraryInstance(document, ele);\r
+            }\r
             root.appendChild(ele);\r
 \r
             //\r
index 8a90ea563dcc3179547402bdf422e8bb784914df..c044856de3674d6620973090be2004c93c8cfe78 100644 (file)
@@ -77,19 +77,19 @@ public class FpdParserTask extends Task {
 \r
     private File fpdFile = null;\r
 \r
-    private PlatformIdentification platformId;\r
+    PlatformIdentification platformId;\r
 \r
     private String type;\r
 \r
     ///\r
     /// Mapping from modules identification to out put file name\r
     ///\r
-    private Map<FpdModuleIdentification, String> outfiles = new LinkedHashMap<FpdModuleIdentification, String>();\r
+    Map<FpdModuleIdentification, String> outfiles = new LinkedHashMap<FpdModuleIdentification, String>();\r
 \r
     ///\r
     /// Mapping from FV name to its modules\r
     ///\r
-    private Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();\r
+    Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();\r
 \r
     ///\r
     /// FpdParserTask can specify some ANT properties.\r
@@ -98,7 +98,7 @@ public class FpdParserTask extends Task {
 \r
     SurfaceAreaQuery saq = null;\r
     \r
-    private boolean isUnified = true;\r
+    boolean isUnified = true;\r
 \r
     /**\r
       Public construct method. It is necessary for ANT task.\r
@@ -195,7 +195,7 @@ public class FpdParserTask extends Task {
       @throws BuildException\r
                   File write FV.inf files error.\r
     **/\r
-    private void genFvInfFiles(String ffsCommonDir) throws BuildException {\r
+    void genFvInfFiles(String ffsCommonDir) throws BuildException {\r
         String[] validFv = saq.getFpdValidImageNames();\r
         for (int i = 0; i < validFv.length; i++) {\r
             //\r
@@ -318,7 +318,7 @@ public class FpdParserTask extends Task {
       @throws BuildException\r
                   FPD file is not valid.\r
      **/\r
-    private void parseFpdFile() throws BuildException {\r
+    void parseFpdFile() throws BuildException {\r
         try {\r
             XmlObject doc = XmlObject.Factory.parse(fpdFile);\r
 \r
@@ -381,7 +381,7 @@ public class FpdParserTask extends Task {
     /**\r
       Parse all modules listed in FPD file.\r
     **/\r
-    private void parseModuleSAFiles() throws EdkException{\r
+    void parseModuleSAFiles() throws EdkException{\r
         Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = saq.getFpdModules();\r
 \r
         //\r
@@ -429,7 +429,7 @@ public class FpdParserTask extends Task {
         }\r
     }\r
 \r
-    private ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
+    ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
         String[][] options = saq.getModuleBuildOptions(toolChainFamilyFlag);\r
         if (options == null || options.length == 0) {\r
             return new ToolChainMap();\r
@@ -475,7 +475,7 @@ public class FpdParserTask extends Task {
       @param fvName current FV name\r
       @param moduleName current module identification\r
     **/\r
-    private void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {\r
+    void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {\r
         if (fvName == null || fvName.trim().length() == 0) {\r
             fvName = "NULL";\r
         }\r
index 7e1e2c68523d31f9e0b2f94c340473a6aa42329e..45f36ee1fa308e2e0f0a8ed2705a0c943aacc7f1 100644 (file)
@@ -87,6 +87,8 @@ public class GlobalData {
 \r
     private static Map<FpdModuleIdentification, Map<String, XmlObject>> fpdModuleSA= new HashMap<FpdModuleIdentification, Map<String, XmlObject>>();\r
 \r
+    private static Map<String, XmlObject> fpdBuildOptionsMap = new HashMap<String, XmlObject>();\r
+    \r
     private static XmlObject fpdBuildOptions;\r
 \r
     private static XmlObject fpdDynamicPcds;\r
@@ -416,14 +418,13 @@ public class GlobalData {
         }\r
     }\r
 \r
-    public static Map<String, XmlObject> getFpdBuildOptions() {\r
-        Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
-        map.put("BuildOptions", fpdBuildOptions);\r
-        return map;\r
+    public static Map<String, XmlObject> getFpdBuildOptionsMap() {\r
+        return fpdBuildOptionsMap;\r
     }\r
 \r
     public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {\r
         GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);\r
+        fpdBuildOptionsMap.put("BuildOptions", GlobalData.fpdBuildOptions);\r
     }\r
 \r
     public static XmlObject getFpdDynamicPcds() {\r
index 4177b50466c043d06b7b726286662583eae75c2c..6f845ea371680f08972439dd445f9443df65342a 100644 (file)
@@ -31,7 +31,7 @@ public class OnDependency extends Task {
     ///\r
     /// cache the modified timestamp of files accessed, to speed up the depencey check\r
     /// \r
-    private static Map<String, Long> timeStampCache = new HashMap<String, Long>();\r
+    private Map<String, Long> timeStampCache = new HashMap<String, Long>();\r
     ///\r
     /// source files list\r
     ///\r