diff options
author | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-11 06:29:26 +0000 |
---|---|---|
committer | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-11 06:29:26 +0000 |
commit | 3067c4b0c099362ae18b2d366e4bae91f8539fb1 (patch) | |
tree | a178dd9c96bae6f34b97f3fc6f362143b93982f8 /Tools | |
parent | a1ffb10f211fa712dfd6d54156a412cce24014f4 (diff) | |
download | edk2-platforms-3067c4b0c099362ae18b2d366e4bae91f8539fb1.tar.xz |
Remove TianoToolsException.java. Add code to stop all threads once one corrupts.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1507 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Tools')
4 files changed, 116 insertions, 136 deletions
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java index cce4e33135..9c8e47c4ef 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java @@ -18,6 +18,7 @@ import java.util.LinkedHashSet; import java.util.Set;
import java.util.Vector;
+import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildListener;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Property;
@@ -52,107 +53,106 @@ public class GenBuildThread implements Runnable { private Thread thread;
- public GenBuildThread() {
- thread = new Thread(this);
+ public GenBuildThread(ModuleIdentification moduleId, String arch) {
+ this.moduleId = moduleId;
+ this.arch = arch;
+ thread = new Thread(FpdParserForThread.tg, this, moduleId + ":" + arch);
}
public boolean start() {
if (highPriority) {
thread.setPriority(Thread.MAX_PRIORITY);
}
-
+
status = FpdParserForThread.STATUS_START_RUN;
thread.start();
return true;
}
public void run() {
-
- FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);
-
- //
- // Prepare pass down properties
- // ARCH, MODULE_GUID, MODULE_VERSION, PACKAGE_GUID, PACKAGE_VERSION, PLATFORM_FILE
- //
- Vector<Property> properties = new Vector<Property>();
- Property property = new Property();
- property.setName("ARCH");
- property.setValue(arch);
- properties.add(property);
-
- property = new Property();
- property.setName("MODULE_GUID");
- property.setValue(moduleId.getGuid());
- properties.add(property);
-
- property = new Property();
- property.setName("MODULE_VERSION");
- if (moduleId.getVersion() == null) {
- property.setValue("");
- } else {
- property.setValue(moduleId.getVersion());
- }
- properties.add(property);
-
- property = new Property();
- property.setName("PACKAGE_GUID");
- property.setValue(moduleId.getPackage().getGuid());
- properties.add(property);
-
- property = new Property();
- property.setName("PACKAGE_VERSION");
- if (moduleId.getPackage().getVersion() == null) {
- property.setValue("");
- } else {
- property.setValue(moduleId.getPackage().getVersion());
- }
- properties.add(property);
-
- // property = new Property();
- // property.setName("PLATFORM_FILE");
- // property.setValue(arch);
- // properties.add(property);
- //
- // Build the Module
- //
- GenBuildTask genBuildTask = new GenBuildTask();
-
- Project newProject = new Project();
-
- Hashtable passdownProperties = project.getProperties();
- Iterator iter = passdownProperties.keySet().iterator();
- while (iter.hasNext()) {
- String item = (String) iter.next();
- newProject.setProperty(item, (String) passdownProperties.get(item));
- }
-
- newProject.setInputHandler(project.getInputHandler());
-
- Iterator listenerIter = project.getBuildListeners().iterator();
- while (listenerIter.hasNext()) {
- BuildListener item = (BuildListener) listenerIter.next();
+ FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);
+
+ try {
+ //
+ // Prepare pass down properties
+ // ARCH, MODULE_GUID, MODULE_VERSION, PACKAGE_GUID, PACKAGE_VERSION, PLATFORM_FILE
+ //
+ Vector<Property> properties = new Vector<Property>();
+ Property property = new Property();
+ property.setName("ARCH");
+ property.setValue(arch);
+ properties.add(property);
+
+ property = new Property();
+ property.setName("MODULE_GUID");
+ property.setValue(moduleId.getGuid());
+ properties.add(property);
+
+ property = new Property();
+ property.setName("MODULE_VERSION");
+ if (moduleId.getVersion() == null) {
+ property.setValue("");
+ } else {
+ property.setValue(moduleId.getVersion());
+ }
+ properties.add(property);
+
+ property = new Property();
+ property.setName("PACKAGE_GUID");
+ property.setValue(moduleId.getPackage().getGuid());
+ properties.add(property);
+
+ property = new Property();
+ property.setName("PACKAGE_VERSION");
+ if (moduleId.getPackage().getVersion() == null) {
+ property.setValue("");
+ } else {
+ property.setValue(moduleId.getPackage().getVersion());
+ }
+ properties.add(property);
+
+ //
+ // Build the Module
+ //
+ GenBuildTask genBuildTask = new GenBuildTask();
+
+ Project newProject = new Project();
+
+ Hashtable passdownProperties = project.getProperties();
+ Iterator iter = passdownProperties.keySet().iterator();
+ while (iter.hasNext()) {
+ String item = (String) iter.next();
+ newProject.setProperty(item, (String) passdownProperties.get(item));
+ }
+
+ newProject.setInputHandler(project.getInputHandler());
+
+ Iterator listenerIter = project.getBuildListeners().iterator();
+ while (listenerIter.hasNext()) {
+ newProject.addBuildListener((BuildListener)listenerIter.next());
+ }
+
+ project.initSubProject(newProject);
+
+ genBuildTask.setProject(newProject);
+
+ genBuildTask.setExternalProperties(properties);
+
+ genBuildTask.parentId = parentModuleId;
+
+ genBuildTask.execute();
+ } catch (BuildException be) {
+ FpdParserForThread.tg.interrupt();
+ EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, moduleId + " with Arch " + arch +" build error. \n" + be.getMessage());
+ FpdParserForThread.isError = true;
-// if (item instanceof BuildLogger) {
-// BuildLogger newLogger = new GenBuildLogger(newProject);
-// BuildLogger oldLogger = (BuildLogger)item;
-// newLogger.setEmacsMode(true);
-// EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, "########");
-// } else {
- newProject.addBuildListener(item);
-// }
+ synchronized (FpdParserForThread.deamonSemaphore) {
+ FpdParserForThread.deamonSemaphore.notifyAll();
+ }
+ return ;
}
-
- project.initSubProject(newProject);
-
- genBuildTask.setProject(newProject);
-
- genBuildTask.setExternalProperties(properties);
-
- genBuildTask.parentId = parentModuleId;
-
- genBuildTask.perform();
-
+
status = FpdParserForThread.STATUS_END_RUN;
EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, fpdModuleId + " build finished. ");
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 index bcfe37a8d6..0000000000 --- a/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java +++ /dev/null @@ -1,41 +0,0 @@ -/** @file
- TianoToolsException class.
-
- The class handle the exception throwed by entity class.
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution. The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-package org.tianocore.build.exception;
-
-import org.tianocore.common.exception.EdkException;
-
-/**
- The class handle the exception throwed by entity class.
-**/
-public class TianoToolsException extends EdkException {
- static final long serialVersionUID = -8034897190740066935L;
- /**
- Constructure function
-
- @param expStr exception message string.
- **/
- public TianoToolsException(String expStr) {
- super(expStr);
- }
-
- public TianoToolsException() {
- super();
- }
-
- public TianoToolsException (Exception e, String message){
- super(e, message);
- }
-}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java index 66d188383b..8767b8ff97 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java +++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java @@ -45,9 +45,9 @@ public class FpdParserForThread extends FpdParserTask { List<String> queueList = new ArrayList<String>();
- public static Object deamonSemaphore = new Object();
+ public final static Object deamonSemaphore = new Object();
- static Object countSemaphore = new Object();
+ private final static Object countSemaphore = new Object();
public static int STATUS_DEPENDENCY_NOT_READY = 1;
@@ -65,6 +65,10 @@ public class FpdParserForThread extends FpdParserTask { public static int remainNumber = 0;
+ public static ThreadGroup tg = new ThreadGroup("Framework");
+
+ public static boolean isError = false;
+
/**
Public construct method. It is necessary for ANT task.
**/
@@ -227,6 +231,16 @@ public class FpdParserForThread extends FpdParserTask { try {
deamonSemaphore.wait();
+ if (isError) {
+ GenBuildLogger.setCacheEnable(false);
+ EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));
+
+ GenBuildLogger.maskAllLog(true);
+ FpdParserForThread.tg.destroy();
+ GenBuildLogger.maskAllLog(false);
+
+ throw new BuildException("One thread error. ");
+ }
} catch (InterruptedException ex) {
BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());
e.setStackTrace(ex.getStackTrace());
@@ -234,6 +248,7 @@ public class FpdParserForThread extends FpdParserTask { }
}
}
+
GenBuildLogger.setCacheEnable(false);
//
// call fvs, postbuild
@@ -277,10 +292,8 @@ public class FpdParserForThread extends FpdParserTask { //
// Generate GenBuildThread
//
- GenBuildThread genBuildThread = new GenBuildThread();
- genBuildThread.setArch(fpdModuleId.getArch());
+ GenBuildThread genBuildThread = new GenBuildThread(fpdModuleId.getModule(), fpdModuleId.getArch());
genBuildThread.setParentModuleId(null);
- genBuildThread.setModuleId(fpdModuleId.getModule());
genBuildThread.setProject(getProject());
Set<FpdModuleIdentification> dependencies = new LinkedHashSet<FpdModuleIdentification>();
@@ -305,10 +318,8 @@ public class FpdParserForThread extends FpdParserTask { //
// Create thread for library instances
//
- GenBuildThread liBuildThread = new GenBuildThread();
- liBuildThread.setArch(fpdModuleId.getArch());
+ GenBuildThread liBuildThread = new GenBuildThread(libinstances[i], fpdModuleId.getArch());
liBuildThread.setParentModuleId(fpdModuleId.getModule());
- liBuildThread.setModuleId(libinstances[i]);
liBuildThread.setProject(getProject());
liBuildThread.setStatus(STATUS_DEPENDENCY_READY);
liBuildThread.setHighPriority(true);
@@ -317,7 +328,8 @@ public class FpdParserForThread extends FpdParserTask { updateFvs("libqueue", libFpdModuleId);
}
- genBuildThread.setDependencies(dependencies);
+ genBuildThread.setDependencies(dependencies);
+
// if (dependencies.size() == 0) {
genBuildThread.setStatus(STATUS_DEPENDENCY_READY);
// }
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java b/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java index 0af9d9f1e8..898fbc70df 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java @@ -49,6 +49,8 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { /// true means to cache.
///
private static boolean flag = false;
+
+ private static boolean enableFlag = true;
private static Map<Identification, List<String>> map = new HashMap<Identification, List<String> >(256);
@@ -148,6 +150,9 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { }
public void messageLogged(BuildEvent event) {
+ if (!enableFlag) {
+ return ;
+ }
int currentLevel = event.getPriority();
//
// If current level is upper than Ant Level, skip it
@@ -201,6 +206,10 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { flag = enable;
}
+ public static void maskAllLog(boolean enable) {
+ enableFlag = !enable;
+ }
+
protected synchronized void log(String message) {
//
// cache log
|