]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Remove TianoToolsException.java. Add code to stop all threads once one corrupts.
authorwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Sep 2006 06:29:26 +0000 (06:29 +0000)
committerwuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 11 Sep 2006 06:29:26 +0000 (06:29 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1507 6f19259b-4bc3-4df7-8a09-765794883524

Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java
Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java [deleted file]
Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java
Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java

index cce4e331350b14241ce09fd14a85bc4623028df3..9c8e47c4ef881c9a299631f762cf0410d4fcf0a9 100644 (file)
@@ -18,6 +18,7 @@ import java.util.LinkedHashSet;
 import java.util.Set;\r
 import java.util.Vector;\r
 \r
+import org.apache.tools.ant.BuildException;\r
 import org.apache.tools.ant.BuildListener;\r
 import org.apache.tools.ant.Project;\r
 import org.apache.tools.ant.taskdefs.Property;\r
@@ -52,107 +53,106 @@ public class GenBuildThread implements Runnable {
 \r
     private Thread thread;\r
 \r
-    public GenBuildThread() {\r
-        thread = new Thread(this);\r
+    public GenBuildThread(ModuleIdentification moduleId, String arch) {\r
+        this.moduleId = moduleId;\r
+        this.arch = arch;\r
+        thread = new Thread(FpdParserForThread.tg, this, moduleId + ":" + arch);\r
     }\r
 \r
     public boolean start() {\r
         if (highPriority) {\r
             thread.setPriority(Thread.MAX_PRIORITY);\r
         }\r
-        \r
+\r
         status = FpdParserForThread.STATUS_START_RUN;\r
         thread.start();\r
         return true;\r
     }\r
 \r
     public void run() {\r
-        \r
-        FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);\r
-\r
-        //\r
-        // Prepare pass down properties\r
-        // ARCH, MODULE_GUID, MODULE_VERSION, PACKAGE_GUID, PACKAGE_VERSION, PLATFORM_FILE\r
-        //\r
-        Vector<Property> properties = new Vector<Property>();\r
-        Property property = new Property();\r
-        property.setName("ARCH");\r
-        property.setValue(arch);\r
-        properties.add(property);\r
-\r
-        property = new Property();\r
-        property.setName("MODULE_GUID");\r
-        property.setValue(moduleId.getGuid());\r
-        properties.add(property);\r
-\r
-        property = new Property();\r
-        property.setName("MODULE_VERSION");\r
-        if (moduleId.getVersion() == null) {\r
-            property.setValue("");\r
-        } else {\r
-            property.setValue(moduleId.getVersion());\r
-        }\r
-        properties.add(property);\r
-\r
-        property = new Property();\r
-        property.setName("PACKAGE_GUID");\r
-        property.setValue(moduleId.getPackage().getGuid());\r
-        properties.add(property);\r
-\r
-        property = new Property();\r
-        property.setName("PACKAGE_VERSION");\r
-        if (moduleId.getPackage().getVersion() == null) {\r
-            property.setValue("");\r
-        } else {\r
-            property.setValue(moduleId.getPackage().getVersion());\r
-        }\r
-        properties.add(property);\r
-\r
-        //      property = new Property();\r
-        //      property.setName("PLATFORM_FILE");\r
-        //      property.setValue(arch);\r
-        //      properties.add(property);\r
 \r
-        //\r
-        // Build the Module\r
-        //\r
-        GenBuildTask genBuildTask = new GenBuildTask();\r
-\r
-        Project newProject = new Project();\r
-\r
-        Hashtable passdownProperties = project.getProperties();\r
-        Iterator iter = passdownProperties.keySet().iterator();\r
-        while (iter.hasNext()) {\r
-            String item = (String) iter.next();\r
-            newProject.setProperty(item, (String) passdownProperties.get(item));\r
-        }\r
-\r
-        newProject.setInputHandler(project.getInputHandler());\r
-\r
-        Iterator listenerIter = project.getBuildListeners().iterator();\r
-        while (listenerIter.hasNext()) {\r
-            BuildListener item = (BuildListener) listenerIter.next();\r
+        FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);\r
+        \r
+        try {\r
+            //\r
+            // Prepare pass down properties\r
+            // ARCH, MODULE_GUID, MODULE_VERSION, PACKAGE_GUID, PACKAGE_VERSION, PLATFORM_FILE\r
+            //\r
+            Vector<Property> properties = new Vector<Property>();\r
+            Property property = new Property();\r
+            property.setName("ARCH");\r
+            property.setValue(arch);\r
+            properties.add(property);\r
+    \r
+            property = new Property();\r
+            property.setName("MODULE_GUID");\r
+            property.setValue(moduleId.getGuid());\r
+            properties.add(property);\r
+    \r
+            property = new Property();\r
+            property.setName("MODULE_VERSION");\r
+            if (moduleId.getVersion() == null) {\r
+                property.setValue("");\r
+            } else {\r
+                property.setValue(moduleId.getVersion());\r
+            }\r
+            properties.add(property);\r
+    \r
+            property = new Property();\r
+            property.setName("PACKAGE_GUID");\r
+            property.setValue(moduleId.getPackage().getGuid());\r
+            properties.add(property);\r
+    \r
+            property = new Property();\r
+            property.setName("PACKAGE_VERSION");\r
+            if (moduleId.getPackage().getVersion() == null) {\r
+                property.setValue("");\r
+            } else {\r
+                property.setValue(moduleId.getPackage().getVersion());\r
+            }\r
+            properties.add(property);\r
+    \r
+            //\r
+            // Build the Module\r
+            //\r
+            GenBuildTask genBuildTask = new GenBuildTask();\r
+    \r
+            Project newProject = new Project();\r
+    \r
+            Hashtable passdownProperties = project.getProperties();\r
+            Iterator iter = passdownProperties.keySet().iterator();\r
+            while (iter.hasNext()) {\r
+                String item = (String) iter.next();\r
+                newProject.setProperty(item, (String) passdownProperties.get(item));\r
+            }\r
+    \r
+            newProject.setInputHandler(project.getInputHandler());\r
+    \r
+            Iterator listenerIter = project.getBuildListeners().iterator();\r
+            while (listenerIter.hasNext()) {\r
+                newProject.addBuildListener((BuildListener)listenerIter.next());\r
+            }\r
+    \r
+            project.initSubProject(newProject);\r
+    \r
+            genBuildTask.setProject(newProject);\r
+    \r
+            genBuildTask.setExternalProperties(properties);\r
+    \r
+            genBuildTask.parentId = parentModuleId;\r
+    \r
+            genBuildTask.execute();\r
+        } catch (BuildException be) {\r
+            FpdParserForThread.tg.interrupt();\r
+            EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, moduleId + " with Arch " + arch +" build error. \n" + be.getMessage());\r
+            FpdParserForThread.isError = true; \r
             \r
-//            if (item instanceof BuildLogger) {\r
-//                BuildLogger newLogger = new GenBuildLogger(newProject);\r
-//                BuildLogger oldLogger = (BuildLogger)item;\r
-//                newLogger.setEmacsMode(true);\r
-//                EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, "########");\r
-//            } else {\r
-                newProject.addBuildListener(item);\r
-//            }\r
+            synchronized (FpdParserForThread.deamonSemaphore) {\r
+                FpdParserForThread.deamonSemaphore.notifyAll();\r
+            }\r
+            return ;\r
         }\r
-\r
-        project.initSubProject(newProject);\r
-\r
-        genBuildTask.setProject(newProject);\r
-\r
-        genBuildTask.setExternalProperties(properties);\r
-\r
-        genBuildTask.parentId = parentModuleId;\r
-\r
-        genBuildTask.perform();\r
-\r
+        \r
         status = FpdParserForThread.STATUS_END_RUN;\r
 \r
         EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, fpdModuleId + " build finished. ");\r
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java
deleted file mode 100644 (file)
index bcfe37a..0000000
+++ /dev/null
@@ -1,41 +0,0 @@
-/** @file\r
-  TianoToolsException class.\r
-\r
-  The class handle the exception throwed by entity class.\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
-which accompanies this distribution.  The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-package org.tianocore.build.exception;\r
-\r
-import org.tianocore.common.exception.EdkException;\r
-\r
-/**\r
-  The class handle the exception throwed by entity class.\r
-**/\r
-public class TianoToolsException extends EdkException {\r
-    static final long serialVersionUID = -8034897190740066935L;\r
-    /**\r
-      Constructure function\r
-\r
-      @param expStr exception message string.\r
-    **/\r
-    public TianoToolsException(String expStr) {\r
-        super(expStr);\r
-    }\r
-\r
-    public TianoToolsException() {\r
-        super();\r
-    }\r
-\r
-    public TianoToolsException (Exception e, String message){\r
-        super(e, message);\r
-    }\r
-}\r
index 66d188383bd5e5395e96bd9f51ea96f2c33996f6..8767b8ff976f2b77d5420aabfe9bd8ca06e190d7 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 boolean isError = false;\r
+    \r
     /**\r
       Public construct method. It is necessary for ANT task.\r
     **/\r
@@ -227,6 +231,16 @@ public class FpdParserForThread extends FpdParserTask {
 \r
                 try {\r
                     deamonSemaphore.wait();\r
+                    if (isError) {\r
+                        GenBuildLogger.setCacheEnable(false);\r
+                        EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));\r
+                        \r
+                        GenBuildLogger.maskAllLog(true);\r
+                        FpdParserForThread.tg.destroy();\r
+                        GenBuildLogger.maskAllLog(false);\r
+                        \r
+                        throw new BuildException("One thread 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 +248,7 @@ public class FpdParserForThread extends FpdParserTask {
                 }\r
             }\r
         }\r
+        \r
         GenBuildLogger.setCacheEnable(false);\r
         //\r
         // call fvs, postbuild\r
@@ -277,10 +292,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 +318,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 +328,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
index 0af9d9f1e8e92eb1e0517f52182456014634ad3d..898fbc70dfa04f80e3cf913a2da8b5eb041b01f0 100644 (file)
@@ -49,6 +49,8 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod {
     /// true means to cache.\r
     ///\r
     private static boolean flag = false;\r
+    \r
+    private static boolean enableFlag = true;\r
 \r
     private static Map<Identification, List<String>> map = new HashMap<Identification, List<String> >(256);\r
     \r
@@ -148,6 +150,9 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod {
     }\r
     \r
     public void messageLogged(BuildEvent event) {\r
+        if (!enableFlag) {\r
+            return ;\r
+        }\r
         int currentLevel = event.getPriority();\r
         //\r
         // If current level is upper than Ant Level, skip it\r
@@ -201,6 +206,10 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod {
         flag = enable;\r
     }\r
     \r
+    public static void maskAllLog(boolean enable) {\r
+        enableFlag = !enable;\r
+    }\r
+    \r
     protected synchronized void log(String message) {\r
         //\r
         // cache log\r