diff options
5 files changed, 102 insertions, 33 deletions
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java index 45a46b0..df9c242 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java @@ -103,7 +103,7 @@ public class FrameworkBuildTask extends Task{ ///
/// The concurrent thread number
///
- public static int MAX_CONCURRENT_THREAD_NUMBER = 1;
+ public static int MAX_CONCURRENT_THREAD_NUMBER = 2;
///
/// there are three type: all (build), clean and cleanall
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index a541f87..7990989 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -600,7 +600,7 @@ public class GenBuildTask extends Ant { ModuleIdentification[] libinstances = saq.getLibraryInstance(fpdModuleId.getArch());
String propertyLibs = "";
for (int i = 0; i < libinstances.length; i++) {
- propertyLibs += " " + getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib";
+ propertyLibs += getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib" + " ";
}
getProject().setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java index 9c8e47c..3490c10 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildThread.java @@ -24,6 +24,7 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.Property;
import org.tianocore.build.GenBuildTask;
import org.tianocore.build.fpd.FpdParserForThread;
+import org.tianocore.build.global.GenBuildLogger;
import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.common.logger.EdkLog;
@@ -65,7 +66,9 @@ public class GenBuildThread implements Runnable { }
status = FpdParserForThread.STATUS_START_RUN;
+
thread.start();
+
return true;
}
@@ -129,27 +132,40 @@ public class GenBuildThread implements Runnable { newProject.setInputHandler(project.getInputHandler());
Iterator listenerIter = project.getBuildListeners().iterator();
+ GenBuildLogger newLogger = null;
while (listenerIter.hasNext()) {
- newProject.addBuildListener((BuildListener)listenerIter.next());
+ BuildListener item = (BuildListener)listenerIter.next();
+ if (item instanceof GenBuildLogger) {
+ newLogger = (GenBuildLogger)((GenBuildLogger)item).clone();
+ newLogger.setId(fpdModuleId);
+ newProject.addBuildListener(newLogger);
+ } else {
+ newProject.addBuildListener(item);
+ }
}
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 (FpdParserForThread.errorModule == null) {
+ FpdParserForThread.errorModule = fpdModuleId;
+ }
synchronized (FpdParserForThread.deamonSemaphore) {
+ FpdParserForThread.subCount();
FpdParserForThread.deamonSemaphore.notifyAll();
}
+
return ;
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java index 8767b8f..de9a28c 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java +++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java @@ -67,7 +67,7 @@ public class FpdParserForThread extends FpdParserTask { public static ThreadGroup tg = new ThreadGroup("Framework");
- public static boolean isError = false;
+ public static FpdModuleIdentification errorModule = null;
/**
Public construct method. It is necessary for ANT task.
@@ -163,10 +163,7 @@ public class FpdParserForThread extends FpdParserTask { // Waiting for all thread over, or time out
//
synchronized (deamonSemaphore) {
- //
- // Initialize BUGBUG
- //
-
+
while (true) {
//
// If all modules are already built
@@ -231,15 +228,22 @@ public class FpdParserForThread extends FpdParserTask { try {
deamonSemaphore.wait();
- if (isError) {
+
+ //
+ // if find error. Let other threads to finish
+ //
+ if (errorModule != null) {
+ while (currentRunNumber > 0) {
+ deamonSemaphore.wait();
+ }
+
GenBuildLogger.setCacheEnable(false);
- EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));
- GenBuildLogger.maskAllLog(true);
- FpdParserForThread.tg.destroy();
- GenBuildLogger.maskAllLog(false);
+ GenBuildLogger.flushErrorModuleLog(errorModule);
- throw new BuildException("One thread error. ");
+ EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));
+
+ throw new BuildException(errorModule + " build error. ");
}
} catch (InterruptedException ex) {
BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());
@@ -270,7 +274,6 @@ public class FpdParserForThread extends FpdParserTask { ant.execute();
EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));
-
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java b/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java index 898fbc7..93ed51e 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java @@ -24,7 +24,8 @@ import java.io.File; import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
-import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
@@ -36,13 +37,13 @@ import org.apache.tools.ant.Project; import org.apache.tools.ant.Task;
import org.apache.tools.ant.util.StringUtils;
-import org.tianocore.build.id.Identification;
+import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.common.logger.EdkLog;
import org.tianocore.common.logger.LogMethod;
public class GenBuildLogger extends DefaultLogger implements LogMethod {
- private Project project = null;
+ Project project = null;
///
/// flag to present whether cache all msg or not
@@ -52,9 +53,9 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { private static boolean enableFlag = true;
- private static Map<Identification, List<String>> map = new HashMap<Identification, List<String> >(256);
+ private static Map<FpdModuleIdentification, List<String>> map = new LinkedHashMap<FpdModuleIdentification, List<String> >(256);
- private Identification id = null;
+ private FpdModuleIdentification id = null;
public GenBuildLogger () {
@@ -64,11 +65,6 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { this.project = project;
}
- public GenBuildLogger (Project project, Identification id) {
- this.project = project;
- this.id = id;
- }
-
/**
Rules: flag = false: means no cache Action: Print it to console
@@ -108,6 +104,16 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { break;
}
}
+
+ public static void flushErrorModuleLog(FpdModuleIdentification errorModuleId) {
+ List<String> errorLogs = map.get(errorModuleId);
+ if (errorLogs != null) {
+ EdkLog.log("ErrorLog", EdkLog.EDK_ERROR, errorModuleId + " error logs: ");
+ for(int i = 0; i < errorLogs.size(); i++) {
+ EdkLog.log(EdkLog.EDK_ERROR, errorLogs.get(i));
+ }
+ }
+ }
public void flushToFile(File file) {
//
@@ -117,10 +123,33 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { log("Logging", msg, Project.MSG_INFO);
try {
BufferedWriter bw = new BufferedWriter(new FileWriter(file));
- List<String> allMessages = map.get(null);
- for(int i = 0; i < allMessages.size(); i++) {
- bw.write(allMessages.get(i));
+ Iterator<FpdModuleIdentification> iter = map.keySet().iterator();
+ List<String> mainLogs = null;
+ while (iter.hasNext()) {
+ FpdModuleIdentification item = iter.next();
+ if(item == null) {
+ mainLogs = map.get(item);
+ continue ;
+ }
+ bw.write(">>>>>>>>>>>>>");
+ bw.write(" " + item + " Build Log ");
+ bw.write(">>>>>>>>>>>>>");
+ bw.newLine();
+ List<String> allMessages = map.get(item);
+ for(int i = 0; i < allMessages.size(); i++) {
+ bw.write(allMessages.get(i));
+ bw.newLine();
+ }
+ }
+ if (mainLogs != null) {
+ bw.write(">>>>>>>>>>>>>");
+ bw.write(" Main Logs (already print to command) ");
+ bw.write(">>>>>>>>>>>>>");
bw.newLine();
+ for(int i = 0; i < mainLogs.size(); i++) {
+ bw.write(mainLogs.get(i));
+ bw.newLine();
+ }
}
bw.flush();
bw.close();
@@ -197,7 +226,6 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { } else if(!flag) {
printMessage(msg, out, currentLevel);
}
-
log(msg);
}
}
@@ -222,4 +250,26 @@ public class GenBuildLogger extends DefaultLogger implements LogMethod { map.put(this.id, list);
}
}
+
+ public Object clone() {
+ GenBuildLogger newLogger = new GenBuildLogger();
+ //
+ // Transfer emacs mode, out, err, level to new Logger
+ //
+ newLogger.setEmacsMode(this.emacsMode);
+ newLogger.setOutputPrintStream(this.out);
+ newLogger.setErrorPrintStream(this.err);
+ newLogger.setMessageOutputLevel(this.msgOutputLevel);
+
+ //
+ // Transfer project
+ //
+ newLogger.project = this.project;
+ return newLogger;
+ }
+
+ public void setId(FpdModuleIdentification id) {
+ this.id = id;
+ }
+
}
\ No newline at end of file |