]> git.proxmox.com Git - mirror_edk2.git/blobdiff - Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java
Support "Defining Module Sequence in FV.inf". Since modules sequences in Fv.inf can...
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / fpd / FpdParserForThread.java
index 66d188383bd5e5395e96bd9f51ea96f2c33996f6..aa0ebe51b64f5553a8240d8505b3e62c87348f7b 100644 (file)
@@ -45,9 +45,9 @@ public class FpdParserForThread extends FpdParserTask {
     \r
     List<String> queueList = new ArrayList<String>();\r
     \r
-    public static Object deamonSemaphore =  new Object();\r
+    public final static Object deamonSemaphore =  new Object();\r
     \r
-    static Object countSemaphore =  new Object();\r
+    private final static Object countSemaphore =  new Object();\r
     \r
     public static int STATUS_DEPENDENCY_NOT_READY = 1;\r
     \r
@@ -65,6 +65,10 @@ public class FpdParserForThread extends FpdParserTask {
     \r
     public static int remainNumber = 0;\r
     \r
+    public static ThreadGroup tg = new ThreadGroup("Framework");\r
+    \r
+    public static FpdModuleIdentification errorModule = null;\r
+    \r
     /**\r
       Public construct method. It is necessary for ANT task.\r
     **/\r
@@ -159,10 +163,7 @@ public class FpdParserForThread extends FpdParserTask {
         // Waiting for all thread over, or time out\r
         //\r
         synchronized (deamonSemaphore) {\r
-            //\r
-            // Initialize BUGBUG\r
-            //\r
-            \r
+\r
             while (true) {\r
                 //\r
                 // If all modules are already built\r
@@ -204,7 +205,7 @@ public class FpdParserForThread extends FpdParserTask {
                     //\r
                     // Exist ready thread\r
                     //\r
-//                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Exist ready thread");\r
+                    EdkLog.log(this, EdkLog.EDK_DEBUG, "Exist ready thread");\r
 \r
                 } else if (existNoneReady && currentRunNumber == 0) {\r
                     //\r
@@ -215,18 +216,35 @@ public class FpdParserForThread extends FpdParserTask {
                     //\r
                     // Current queue build finish, move to next\r
                     //\r
-                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Current queue build finish, move to next");\r
+                    EdkLog.log(this, EdkLog.EDK_DEBUG, "Current queue build finish, move to next");\r
                     ++currentQueueCode;\r
                     continue ;\r
                 } else {\r
                     //\r
                     // active thread exist, but no ready thread\r
                     //\r
-                    EdkLog.log(this, EdkLog.EDK_ALWAYS, "Active thread exist, but no ready thread. Current running number is " + currentRunNumber);\r
+                    EdkLog.log(this, EdkLog.EDK_DEBUG, "Active thread exist, but no ready thread. Current running number is " + currentRunNumber);\r
                 }\r
 \r
                 try {\r
                     deamonSemaphore.wait();\r
+                    \r
+                    //\r
+                    // if find error. Waiting running threads to finish\r
+                    //\r
+                    if (errorModule != null) {\r
+                        while (currentRunNumber > 0) {\r
+                            deamonSemaphore.wait();\r
+                        }\r
+                        \r
+                        GenBuildLogger.setCacheEnable(false);\r
+                        \r
+                        GenBuildLogger.flushErrorModuleLog(errorModule);\r
+                        \r
+                        EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));\r
+                        \r
+                        throw new BuildException(errorModule + " build error. ");\r
+                    }\r
                 } catch (InterruptedException ex) {\r
                     BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());\r
                     e.setStackTrace(ex.getStackTrace());\r
@@ -234,6 +252,7 @@ public class FpdParserForThread extends FpdParserTask {
                 }\r
             }\r
         }\r
+        \r
         GenBuildLogger.setCacheEnable(false);\r
         //\r
         // call fvs, postbuild\r
@@ -255,7 +274,6 @@ public class FpdParserForThread extends FpdParserTask {
         ant.execute();\r
         \r
         EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));\r
-        \r
     }\r
 \r
     \r
@@ -277,10 +295,8 @@ public class FpdParserForThread extends FpdParserTask {
             //\r
             // Generate GenBuildThread\r
             //\r
-            GenBuildThread genBuildThread = new GenBuildThread();\r
-            genBuildThread.setArch(fpdModuleId.getArch());\r
+            GenBuildThread genBuildThread = new GenBuildThread(fpdModuleId.getModule(), fpdModuleId.getArch());\r
             genBuildThread.setParentModuleId(null);\r
-            genBuildThread.setModuleId(fpdModuleId.getModule());\r
             genBuildThread.setProject(getProject());\r
             \r
             Set<FpdModuleIdentification> dependencies = new LinkedHashSet<FpdModuleIdentification>();\r
@@ -305,10 +321,8 @@ public class FpdParserForThread extends FpdParserTask {
                 //\r
                 // Create thread for library instances\r
                 //\r
-                GenBuildThread liBuildThread = new GenBuildThread();\r
-                liBuildThread.setArch(fpdModuleId.getArch());\r
+                GenBuildThread liBuildThread = new GenBuildThread(libinstances[i], fpdModuleId.getArch());\r
                 liBuildThread.setParentModuleId(fpdModuleId.getModule());\r
-                liBuildThread.setModuleId(libinstances[i]);\r
                 liBuildThread.setProject(getProject());\r
                 liBuildThread.setStatus(STATUS_DEPENDENCY_READY);\r
                 liBuildThread.setHighPriority(true);\r
@@ -317,7 +331,8 @@ public class FpdParserForThread extends FpdParserTask {
                 updateFvs("libqueue", libFpdModuleId);\r
             }\r
             \r
-            genBuildThread.setDependencies(dependencies); \r
+            genBuildThread.setDependencies(dependencies);\r
+            \r
 //            if (dependencies.size() == 0) {\r
                 genBuildThread.setStatus(STATUS_DEPENDENCY_READY);\r
 //            }\r