]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java
Adding new Logger instead of Ant's.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / fpd / FpdParserForThread.java
index b16530b59f4c9765ea4122c5450ace702e383af5..66d188383bd5e5395e96bd9f51ea96f2c33996f6 100644 (file)
@@ -1,9 +1,6 @@
 /** @file\r
  This file is ANT task FpdParserTask. \r
  \r
- FpdParserTask is used to parse FPD (Framework Platform Description) and generate\r
- build.out.xml. It is for Package or Platform build use. \r
\r
  Copyright (c) 2006, Intel Corporation\r
  All rights reserved. This program and the accompanying materials\r
  are licensed and made available under the terms and conditions of the BSD License\r
@@ -28,6 +25,7 @@ import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.taskdefs.Ant;\r
 import org.apache.xmlbeans.XmlObject;\r
 \r
+import org.tianocore.build.global.GenBuildLogger;\r
 import org.tianocore.build.global.GlobalData;\r
 import org.tianocore.build.global.OutputManager;\r
 import org.tianocore.build.id.FpdModuleIdentification;\r
@@ -35,33 +33,9 @@ import org.tianocore.build.id.ModuleIdentification;
 import org.tianocore.build.FrameworkBuildTask;\r
 import org.tianocore.build.GenBuildThread;\r
 import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
 \r
 /**\r
-  <code>FpdParserTask</code> is an ANT task. The main function is parsing Framework\r
-  Platform Descritpion (FPD) XML file and generating its ANT build script for \r
-  corresponding platform.  \r
-\r
-  <p>The task sets global properties PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR\r
-  and BUILD_DIR. </p>\r
-  \r
-  <p>The task generates ${PLATFORM}_build.xml file which will be called by top level\r
-  build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage) \r
-  and flash definition file (File is for Tool FlashMap) if necessary. </p>\r
-  \r
-  <p>FpdParserTask task stores all FPD information to GlobalData. And parse\r
-  tools definition file to set up compiler options for different Target and\r
-  different ToolChainTag. </p>\r
-  \r
-  <p>The method parseFpdFile is also prepared for single module build. </p>\r
-  \r
-  <p>The usage is (take NT32 Platform for example):</p>\r
-\r
-  <pre>\r
-  &lt;FPDParser platformName="Nt32" /&gt;\r
-  </pre>\r
-\r
-  <p>The task will initialize all information through parsing Framework Database, \r
-  SPD, Tool chain configuration files. </p>\r
 \r
   @since GenBuild 1.0\r
 **/\r
@@ -87,6 +61,10 @@ public class FpdParserForThread extends FpdParserTask {
     \r
     public static int currentRunNumber = 0;\r
     \r
+    public static int totalNumber = 0;\r
+    \r
+    public static int remainNumber = 0;\r
+    \r
     /**\r
       Public construct method. It is necessary for ANT task.\r
     **/\r
@@ -94,21 +72,12 @@ public class FpdParserForThread extends FpdParserTask {
     }\r
 \r
     /**\r
-     ANT task's entry method. The main steps is described as following: \r
-     \r
-     <ul>\r
-     <li>Initialize global information (Framework DB, SPD files and all MSA files \r
-     listed in SPD). This step will execute only once in whole build process;</li>\r
-     <li>Parse specified FPD file; </li>\r
-     <li>Generate FV.inf files; </li>\r
-     <li>Generate PlatformName_build.xml file for Flatform build; </li>\r
-     <li>Collect PCD information. </li>\r
-     </ul>\r
      \r
-     @throws BuildException\r
-     Surface area is not valid. \r
+\r
     **/\r
     public void execute() throws BuildException {\r
+        \r
+        this.setTaskName(".........");\r
         //\r
         // Parse FPD file\r
         //\r
@@ -118,7 +87,8 @@ public class FpdParserForThread extends FpdParserTask {
         // Prepare BUILD_DIR\r
         //\r
         isUnified = OutputManager.getInstance().prepareBuildDir(getProject());\r
-\r
+        String buildDir = getProject().getProperty("BUILD_DIR");\r
+        \r
         //\r
         // For every Target and ToolChain\r
         //\r
@@ -129,8 +99,8 @@ public class FpdParserForThread extends FpdParserTask {
                 //\r
                 // Prepare FV_DIR\r
                 //\r
-                String ffsCommonDir = getProject().getProperty("BUILD_DIR") + File.separatorChar\r
-                                + targetList[i] + File.separatorChar\r
+                String ffsCommonDir = buildDir + File.separatorChar\r
+                                + targetList[i] + "_"\r
                                 + toolchainList[j];\r
                 File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");\r
                 fvDir.mkdirs();\r
@@ -146,7 +116,8 @@ public class FpdParserForThread extends FpdParserTask {
         //\r
         // Gen build.xml\r
         //\r
-        PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq);\r
+        String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";\r
+        PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);\r
         fileGenerator.genBuildFile();\r
         \r
         //\r
@@ -174,14 +145,16 @@ public class FpdParserForThread extends FpdParserTask {
         //\r
         Ant ant = new Ant();\r
         ant.setProject(getProject());\r
-        ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
+        ant.setAntfile(platformBuildFile);\r
         ant.setTarget("prebuild");\r
         ant.setInheritAll(true);\r
         ant.init();\r
         ant.execute();\r
         \r
-        System.out.println("Task number is " + allThreads.size());\r
+        remainNumber = totalNumber = allThreads.size();\r
         \r
+        EdkLog.log(this, EdkLog.EDK_ALWAYS, "Total thread number is " + totalNumber);\r
+        GenBuildLogger.setCacheEnable(true);\r
         //\r
         // Waiting for all thread over, or time out\r
         //\r
@@ -197,6 +170,9 @@ public class FpdParserForThread extends FpdParserTask {
                 if (currentQueueCode >= queueList.size()) {\r
                     break ;\r
                 }\r
+                \r
+                int percentage = (totalNumber - remainNumber) * 100 / totalNumber;\r
+                EdkLog.log(this, EdkLog.EDK_ALWAYS, percentage + "% finished. Has built " + (totalNumber - remainNumber) + " modules of " + totalNumber + " total. ");\r
 \r
                 Set<FpdModuleIdentification> currentQueueModules = fvs.get(queueList.get(currentQueueCode));\r
                 \r
@@ -228,41 +204,43 @@ public class FpdParserForThread extends FpdParserTask {
                     //\r
                     // Exist ready thread\r
                     //\r
-                    System.out.println("## Exist ready thread");\r
+//                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Exist ready thread");\r
 \r
                 } else if (existNoneReady && currentRunNumber == 0) {\r
                     //\r
                     // No active thread, but still have dependency not read thread\r
                     //\r
-                    throw new BuildException("Found can't resolve dependencies. ");\r
+                    throw new BuildException("Existing some modules can't resolve depedencies. ");\r
                 } else if (!existNoneReady && currentRunNumber == 0) {\r
                     //\r
                     // Current queue build finish, move to next\r
                     //\r
-                    System.out.println("## Current queue build finish, move to next");\r
+                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Current queue build finish, move to next");\r
                     ++currentQueueCode;\r
                     continue ;\r
                 } else {\r
                     //\r
                     // active thread exist, but no ready thread\r
                     //\r
-                    System.out.println("## active thread exist, but no ready thread" + currentRunNumber);\r
+                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Active thread exist, but no ready thread. Current running number is " + currentRunNumber);\r
                 }\r
 \r
                 try {\r
                     deamonSemaphore.wait();\r
-                } catch (InterruptedException e) {\r
-                   e.printStackTrace();\r
+                } catch (InterruptedException ex) {\r
+                    BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());\r
+                    e.setStackTrace(ex.getStackTrace());\r
+                    throw e;\r
                 }\r
             }\r
         }\r
-        \r
+        GenBuildLogger.setCacheEnable(false);\r
         //\r
         // call fvs, postbuild\r
         //\r
         ant = new Ant();\r
         ant.setProject(getProject());\r
-        ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
+        ant.setAntfile(platformBuildFile);\r
         ant.setTarget("fvs");\r
         ant.setInheritAll(true);\r
         ant.init();\r
@@ -270,12 +248,14 @@ public class FpdParserForThread extends FpdParserTask {
         \r
         ant = new Ant();\r
         ant.setProject(getProject());\r
-        ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
+        ant.setAntfile(platformBuildFile);\r
         ant.setTarget("postbuild");\r
         ant.setInheritAll(true);\r
         ant.init();\r
         ant.execute();\r
         \r
+        EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));\r
+        \r
     }\r
 \r
     \r
@@ -394,6 +374,7 @@ public class FpdParserForThread extends FpdParserTask {
     public synchronized static void subCount() {\r
         synchronized (countSemaphore) {\r
             --currentRunNumber;\r
+            --remainNumber;\r
         }\r
     }\r
 }\r