mirror of https://github.com/acidanthera/audk.git
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
This commit is contained in:
parent
a1ffb10f21
commit
3067c4b0c0
|
@ -18,6 +18,7 @@ import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.BuildListener;
|
import org.apache.tools.ant.BuildListener;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.taskdefs.Property;
|
import org.apache.tools.ant.taskdefs.Property;
|
||||||
|
@ -52,107 +53,106 @@ public class GenBuildThread implements Runnable {
|
||||||
|
|
||||||
private Thread thread;
|
private Thread thread;
|
||||||
|
|
||||||
public GenBuildThread() {
|
public GenBuildThread(ModuleIdentification moduleId, String arch) {
|
||||||
thread = new Thread(this);
|
this.moduleId = moduleId;
|
||||||
|
this.arch = arch;
|
||||||
|
thread = new Thread(FpdParserForThread.tg, this, moduleId + ":" + arch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean start() {
|
public boolean start() {
|
||||||
if (highPriority) {
|
if (highPriority) {
|
||||||
thread.setPriority(Thread.MAX_PRIORITY);
|
thread.setPriority(Thread.MAX_PRIORITY);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = FpdParserForThread.STATUS_START_RUN;
|
status = FpdParserForThread.STATUS_START_RUN;
|
||||||
thread.start();
|
thread.start();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);
|
FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);
|
||||||
|
|
||||||
//
|
try {
|
||||||
// Prepare pass down properties
|
//
|
||||||
// ARCH, MODULE_GUID, MODULE_VERSION, PACKAGE_GUID, PACKAGE_VERSION, PLATFORM_FILE
|
// 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();
|
Vector<Property> properties = new Vector<Property>();
|
||||||
property.setName("ARCH");
|
Property property = new Property();
|
||||||
property.setValue(arch);
|
property.setName("ARCH");
|
||||||
properties.add(property);
|
property.setValue(arch);
|
||||||
|
properties.add(property);
|
||||||
property = new Property();
|
|
||||||
property.setName("MODULE_GUID");
|
property = new Property();
|
||||||
property.setValue(moduleId.getGuid());
|
property.setName("MODULE_GUID");
|
||||||
properties.add(property);
|
property.setValue(moduleId.getGuid());
|
||||||
|
properties.add(property);
|
||||||
property = new Property();
|
|
||||||
property.setName("MODULE_VERSION");
|
property = new Property();
|
||||||
if (moduleId.getVersion() == null) {
|
property.setName("MODULE_VERSION");
|
||||||
property.setValue("");
|
if (moduleId.getVersion() == null) {
|
||||||
} else {
|
property.setValue("");
|
||||||
property.setValue(moduleId.getVersion());
|
} else {
|
||||||
}
|
property.setValue(moduleId.getVersion());
|
||||||
properties.add(property);
|
}
|
||||||
|
properties.add(property);
|
||||||
property = new Property();
|
|
||||||
property.setName("PACKAGE_GUID");
|
property = new Property();
|
||||||
property.setValue(moduleId.getPackage().getGuid());
|
property.setName("PACKAGE_GUID");
|
||||||
properties.add(property);
|
property.setValue(moduleId.getPackage().getGuid());
|
||||||
|
properties.add(property);
|
||||||
property = new Property();
|
|
||||||
property.setName("PACKAGE_VERSION");
|
property = new Property();
|
||||||
if (moduleId.getPackage().getVersion() == null) {
|
property.setName("PACKAGE_VERSION");
|
||||||
property.setValue("");
|
if (moduleId.getPackage().getVersion() == null) {
|
||||||
} else {
|
property.setValue("");
|
||||||
property.setValue(moduleId.getPackage().getVersion());
|
} else {
|
||||||
}
|
property.setValue(moduleId.getPackage().getVersion());
|
||||||
properties.add(property);
|
}
|
||||||
|
properties.add(property);
|
||||||
// property = new Property();
|
|
||||||
// property.setName("PLATFORM_FILE");
|
//
|
||||||
// property.setValue(arch);
|
// Build the Module
|
||||||
// properties.add(property);
|
//
|
||||||
|
GenBuildTask genBuildTask = new GenBuildTask();
|
||||||
//
|
|
||||||
// Build the Module
|
Project newProject = new Project();
|
||||||
//
|
|
||||||
GenBuildTask genBuildTask = new GenBuildTask();
|
Hashtable passdownProperties = project.getProperties();
|
||||||
|
Iterator iter = passdownProperties.keySet().iterator();
|
||||||
Project newProject = new Project();
|
while (iter.hasNext()) {
|
||||||
|
String item = (String) iter.next();
|
||||||
Hashtable passdownProperties = project.getProperties();
|
newProject.setProperty(item, (String) passdownProperties.get(item));
|
||||||
Iterator iter = passdownProperties.keySet().iterator();
|
}
|
||||||
while (iter.hasNext()) {
|
|
||||||
String item = (String) iter.next();
|
newProject.setInputHandler(project.getInputHandler());
|
||||||
newProject.setProperty(item, (String) passdownProperties.get(item));
|
|
||||||
}
|
Iterator listenerIter = project.getBuildListeners().iterator();
|
||||||
|
while (listenerIter.hasNext()) {
|
||||||
newProject.setInputHandler(project.getInputHandler());
|
newProject.addBuildListener((BuildListener)listenerIter.next());
|
||||||
|
}
|
||||||
Iterator listenerIter = project.getBuildListeners().iterator();
|
|
||||||
while (listenerIter.hasNext()) {
|
project.initSubProject(newProject);
|
||||||
BuildListener item = (BuildListener) listenerIter.next();
|
|
||||||
|
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) {
|
synchronized (FpdParserForThread.deamonSemaphore) {
|
||||||
// BuildLogger newLogger = new GenBuildLogger(newProject);
|
FpdParserForThread.deamonSemaphore.notifyAll();
|
||||||
// BuildLogger oldLogger = (BuildLogger)item;
|
}
|
||||||
// newLogger.setEmacsMode(true);
|
return ;
|
||||||
// EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, "########");
|
|
||||||
// } else {
|
|
||||||
newProject.addBuildListener(item);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.initSubProject(newProject);
|
|
||||||
|
|
||||||
genBuildTask.setProject(newProject);
|
|
||||||
|
|
||||||
genBuildTask.setExternalProperties(properties);
|
|
||||||
|
|
||||||
genBuildTask.parentId = parentModuleId;
|
|
||||||
|
|
||||||
genBuildTask.perform();
|
|
||||||
|
|
||||||
status = FpdParserForThread.STATUS_END_RUN;
|
status = FpdParserForThread.STATUS_END_RUN;
|
||||||
|
|
||||||
EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, fpdModuleId + " build finished. ");
|
EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, fpdModuleId + " build finished. ");
|
||||||
|
|
|
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -45,9 +45,9 @@ public class FpdParserForThread extends FpdParserTask {
|
||||||
|
|
||||||
List<String> queueList = new ArrayList<String>();
|
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;
|
public static int STATUS_DEPENDENCY_NOT_READY = 1;
|
||||||
|
|
||||||
|
@ -65,6 +65,10 @@ public class FpdParserForThread extends FpdParserTask {
|
||||||
|
|
||||||
public static int remainNumber = 0;
|
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.
|
Public construct method. It is necessary for ANT task.
|
||||||
**/
|
**/
|
||||||
|
@ -227,6 +231,16 @@ public class FpdParserForThread extends FpdParserTask {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deamonSemaphore.wait();
|
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) {
|
} catch (InterruptedException ex) {
|
||||||
BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());
|
BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());
|
||||||
e.setStackTrace(ex.getStackTrace());
|
e.setStackTrace(ex.getStackTrace());
|
||||||
|
@ -234,6 +248,7 @@ public class FpdParserForThread extends FpdParserTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GenBuildLogger.setCacheEnable(false);
|
GenBuildLogger.setCacheEnable(false);
|
||||||
//
|
//
|
||||||
// call fvs, postbuild
|
// call fvs, postbuild
|
||||||
|
@ -277,10 +292,8 @@ public class FpdParserForThread extends FpdParserTask {
|
||||||
//
|
//
|
||||||
// Generate GenBuildThread
|
// Generate GenBuildThread
|
||||||
//
|
//
|
||||||
GenBuildThread genBuildThread = new GenBuildThread();
|
GenBuildThread genBuildThread = new GenBuildThread(fpdModuleId.getModule(), fpdModuleId.getArch());
|
||||||
genBuildThread.setArch(fpdModuleId.getArch());
|
|
||||||
genBuildThread.setParentModuleId(null);
|
genBuildThread.setParentModuleId(null);
|
||||||
genBuildThread.setModuleId(fpdModuleId.getModule());
|
|
||||||
genBuildThread.setProject(getProject());
|
genBuildThread.setProject(getProject());
|
||||||
|
|
||||||
Set<FpdModuleIdentification> dependencies = new LinkedHashSet<FpdModuleIdentification>();
|
Set<FpdModuleIdentification> dependencies = new LinkedHashSet<FpdModuleIdentification>();
|
||||||
|
@ -305,10 +318,8 @@ public class FpdParserForThread extends FpdParserTask {
|
||||||
//
|
//
|
||||||
// Create thread for library instances
|
// Create thread for library instances
|
||||||
//
|
//
|
||||||
GenBuildThread liBuildThread = new GenBuildThread();
|
GenBuildThread liBuildThread = new GenBuildThread(libinstances[i], fpdModuleId.getArch());
|
||||||
liBuildThread.setArch(fpdModuleId.getArch());
|
|
||||||
liBuildThread.setParentModuleId(fpdModuleId.getModule());
|
liBuildThread.setParentModuleId(fpdModuleId.getModule());
|
||||||
liBuildThread.setModuleId(libinstances[i]);
|
|
||||||
liBuildThread.setProject(getProject());
|
liBuildThread.setProject(getProject());
|
||||||
liBuildThread.setStatus(STATUS_DEPENDENCY_READY);
|
liBuildThread.setStatus(STATUS_DEPENDENCY_READY);
|
||||||
liBuildThread.setHighPriority(true);
|
liBuildThread.setHighPriority(true);
|
||||||
|
@ -317,7 +328,8 @@ public class FpdParserForThread extends FpdParserTask {
|
||||||
updateFvs("libqueue", libFpdModuleId);
|
updateFvs("libqueue", libFpdModuleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
genBuildThread.setDependencies(dependencies);
|
genBuildThread.setDependencies(dependencies);
|
||||||
|
|
||||||
// if (dependencies.size() == 0) {
|
// if (dependencies.size() == 0) {
|
||||||
genBuildThread.setStatus(STATUS_DEPENDENCY_READY);
|
genBuildThread.setStatus(STATUS_DEPENDENCY_READY);
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -49,6 +49,8 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod {
|
||||||
/// true means to cache.
|
/// true means to cache.
|
||||||
///
|
///
|
||||||
private static boolean flag = false;
|
private static boolean flag = false;
|
||||||
|
|
||||||
|
private static boolean enableFlag = true;
|
||||||
|
|
||||||
private static Map<Identification, List<String>> map = new HashMap<Identification, List<String> >(256);
|
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) {
|
public void messageLogged(BuildEvent event) {
|
||||||
|
if (!enableFlag) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
int currentLevel = event.getPriority();
|
int currentLevel = event.getPriority();
|
||||||
//
|
//
|
||||||
// If current level is upper than Ant Level, skip it
|
// If current level is upper than Ant Level, skip it
|
||||||
|
@ -201,6 +206,10 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod {
|
||||||
flag = enable;
|
flag = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void maskAllLog(boolean enable) {
|
||||||
|
enableFlag = !enable;
|
||||||
|
}
|
||||||
|
|
||||||
protected synchronized void log(String message) {
|
protected synchronized void log(String message) {
|
||||||
//
|
//
|
||||||
// cache log
|
// cache log
|
||||||
|
|
Loading…
Reference in New Issue