Adding new Logger instead of Ant's.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1502 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -42,6 +42,8 @@ public class CompressSection implements Section, FfsTypes{
|
|||||||
//
|
//
|
||||||
List<Object> SectList = new ArrayList<Object>();
|
List<Object> SectList = new ArrayList<Object>();
|
||||||
|
|
||||||
|
public static Object semaphore = new Object();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
toBuffer
|
toBuffer
|
||||||
|
|
||||||
@ -85,6 +87,8 @@ public class CompressSection implements Section, FfsTypes{
|
|||||||
}
|
}
|
||||||
Do.close();
|
Do.close();
|
||||||
|
|
||||||
|
|
||||||
|
synchronized (semaphore) {
|
||||||
//
|
//
|
||||||
// Call compress
|
// Call compress
|
||||||
//
|
//
|
||||||
@ -144,6 +148,7 @@ public class CompressSection implements Section, FfsTypes{
|
|||||||
//
|
//
|
||||||
//di.close();
|
//di.close();
|
||||||
//compressOut.delete();
|
//compressOut.delete();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e){
|
catch (Exception e){
|
||||||
|
@ -154,11 +154,9 @@ public class FfsProcess {
|
|||||||
}
|
}
|
||||||
Vector<String> sectionList = new Vector<String>();
|
Vector<String> sectionList = new Vector<String>();
|
||||||
XmlCursor cursor = null;
|
XmlCursor cursor = null;
|
||||||
try {
|
|
||||||
cursor = ffsXmlObject.newCursor();
|
cursor = ffsXmlObject.newCursor();
|
||||||
} catch (Exception e) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
int mode = MODE_NONE;
|
int mode = MODE_NONE;
|
||||||
Element genffsfileEle = document.createElement("genffsfile");
|
Element genffsfileEle = document.createElement("genffsfile");
|
||||||
genffsfileEle.setAttribute("outputDir", "${BIN_DIR}");
|
genffsfileEle.setAttribute("outputDir", "${BIN_DIR}");
|
||||||
|
@ -581,7 +581,7 @@ public class GenBuildTask extends Ant {
|
|||||||
//
|
//
|
||||||
// Call AutoGen to generate AutoGen.c and AutoGen.h
|
// Call AutoGen to generate AutoGen.c and AutoGen.h
|
||||||
//
|
//
|
||||||
AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch(), saq);
|
AutoGen autogen = new AutoGen(getProject().getProperty("FV_DIR"), getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId.getModule(),fpdModuleId.getArch(), saq, parentId);
|
||||||
autogen.genAutogen();
|
autogen.genAutogen();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -131,7 +131,16 @@ public class GenBuildThread implements Runnable {
|
|||||||
|
|
||||||
Iterator listenerIter = project.getBuildListeners().iterator();
|
Iterator listenerIter = project.getBuildListeners().iterator();
|
||||||
while (listenerIter.hasNext()) {
|
while (listenerIter.hasNext()) {
|
||||||
newProject.addBuildListener((BuildListener) listenerIter.next());
|
BuildListener item = (BuildListener) listenerIter.next();
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
project.initSubProject(newProject);
|
project.initSubProject(newProject);
|
||||||
@ -146,7 +155,7 @@ public class GenBuildThread implements Runnable {
|
|||||||
|
|
||||||
status = FpdParserForThread.STATUS_END_RUN;
|
status = FpdParserForThread.STATUS_END_RUN;
|
||||||
|
|
||||||
EdkLog.log("GenBuildThread", fpdModuleId + " build finished. ");
|
EdkLog.log("GenBuild", EdkLog.EDK_ALWAYS, fpdModuleId + " build finished. ");
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -14,21 +14,26 @@ package org.tianocore.build;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
import javax.xml.transform.OutputKeys;
|
import javax.xml.transform.OutputKeys;
|
||||||
import javax.xml.transform.Result;
|
import javax.xml.transform.Result;
|
||||||
import javax.xml.transform.Source;
|
import javax.xml.transform.Source;
|
||||||
import javax.xml.transform.Transformer;
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
import javax.xml.transform.TransformerFactory;
|
import javax.xml.transform.TransformerFactory;
|
||||||
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.dom.DOMSource;
|
||||||
import javax.xml.transform.stream.StreamResult;
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
|
import org.tianocore.build.exception.GenBuildException;
|
||||||
import org.tianocore.build.fpd.FpdParserTask;
|
import org.tianocore.build.fpd.FpdParserTask;
|
||||||
import org.tianocore.build.global.SurfaceAreaQuery;
|
import org.tianocore.build.global.SurfaceAreaQuery;
|
||||||
import org.tianocore.build.id.FpdModuleIdentification;
|
import org.tianocore.build.id.FpdModuleIdentification;
|
||||||
@ -90,7 +95,7 @@ public class ModuleBuildFileGenerator {
|
|||||||
@throws BuildException
|
@throws BuildException
|
||||||
Error throws during BaseName_build.xml generating.
|
Error throws during BaseName_build.xml generating.
|
||||||
**/
|
**/
|
||||||
public void genBuildFile(String buildFilename) throws BuildException {
|
public void genBuildFile(String buildFilename) throws GenBuildException, EdkException {
|
||||||
FfsProcess fp = new FfsProcess();
|
FfsProcess fp = new FfsProcess();
|
||||||
DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
|
DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
|
||||||
try {
|
try {
|
||||||
@ -229,8 +234,22 @@ public class ModuleBuildFileGenerator {
|
|||||||
xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
|
||||||
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
xformer.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
xformer.transform(source, result);
|
xformer.transform(source, result);
|
||||||
} catch (Exception ex) {
|
} catch (ParserConfigurationException ex) {
|
||||||
throw new BuildException("Generating the module [" + fpdModuleId.getModule().getName() + "] build.xml file failed!.\n" + ex.getMessage());
|
GenBuildException e = new GenBuildException("Generating the module [" + fpdModuleId.getModule().getName() + "] build.xml file failed!.\n" + ex.getMessage());
|
||||||
|
e.setStackTrace(ex.getStackTrace());
|
||||||
|
throw e;
|
||||||
|
} catch (FileNotFoundException ex) {
|
||||||
|
GenBuildException e = new GenBuildException("Generating the module [" + fpdModuleId.getModule().getName() + "] build.xml file failed!.\n" + ex.getMessage());
|
||||||
|
e.setStackTrace(ex.getStackTrace());
|
||||||
|
throw e;
|
||||||
|
} catch (TransformerConfigurationException ex) {
|
||||||
|
GenBuildException e = new GenBuildException("Generating the module [" + fpdModuleId.getModule().getName() + "] build.xml file failed!.\n" + ex.getMessage());
|
||||||
|
e.setStackTrace(ex.getStackTrace());
|
||||||
|
throw e;
|
||||||
|
} catch (TransformerException ex) {
|
||||||
|
GenBuildException e = new GenBuildException("Generating the module [" + fpdModuleId.getModule().getName() + "] build.xml file failed!.\n" + ex.getMessage());
|
||||||
|
e.setStackTrace(ex.getStackTrace());
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +119,8 @@ public class AutoGen {
|
|||||||
|
|
||||||
private SurfaceAreaQuery saq = null;
|
private SurfaceAreaQuery saq = null;
|
||||||
|
|
||||||
|
private ModuleIdentification parentId = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Construct function
|
Construct function
|
||||||
|
|
||||||
@ -133,12 +135,13 @@ public class AutoGen {
|
|||||||
@param arch
|
@param arch
|
||||||
Target architecture.
|
Target architecture.
|
||||||
**/
|
**/
|
||||||
public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch, SurfaceAreaQuery saq) {
|
public AutoGen(String fvDir, String outputPath, ModuleIdentification moduleId, String arch, SurfaceAreaQuery saq, ModuleIdentification parentId) {
|
||||||
this.outputPath = outputPath;
|
this.outputPath = outputPath;
|
||||||
this.moduleId = moduleId;
|
this.moduleId = moduleId;
|
||||||
this.arch = arch;
|
this.arch = arch;
|
||||||
this.fvDir = fvDir;
|
this.fvDir = fvDir;
|
||||||
this.saq = saq;
|
this.saq = saq;
|
||||||
|
this.parentId = parentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -496,7 +499,8 @@ public class AutoGen {
|
|||||||
arch,
|
arch,
|
||||||
false,
|
false,
|
||||||
null,
|
null,
|
||||||
pcdDriverType);
|
pcdDriverType,
|
||||||
|
parentId);
|
||||||
|
|
||||||
this.myPcdAutogen.execute();
|
this.myPcdAutogen.execute();
|
||||||
if (this.myPcdAutogen != null) {
|
if (this.myPcdAutogen != null) {
|
||||||
@ -653,7 +657,8 @@ public class AutoGen {
|
|||||||
arch,
|
arch,
|
||||||
true,
|
true,
|
||||||
saq.getModulePcdEntryNameArray(),
|
saq.getModulePcdEntryNameArray(),
|
||||||
pcdDriverType);
|
pcdDriverType,
|
||||||
|
parentId);
|
||||||
this.myPcdAutogen.execute();
|
this.myPcdAutogen.execute();
|
||||||
if (this.myPcdAutogen != null) {
|
if (this.myPcdAutogen != null) {
|
||||||
fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);
|
fileBuffer.append(ToolDefinitions.LINE_SEPARATOR);
|
||||||
|
@ -25,6 +25,7 @@ import org.apache.tools.ant.BuildException;
|
|||||||
import org.apache.tools.ant.taskdefs.Ant;
|
import org.apache.tools.ant.taskdefs.Ant;
|
||||||
import org.apache.xmlbeans.XmlObject;
|
import org.apache.xmlbeans.XmlObject;
|
||||||
|
|
||||||
|
import org.tianocore.build.global.GenBuildLogger;
|
||||||
import org.tianocore.build.global.GlobalData;
|
import org.tianocore.build.global.GlobalData;
|
||||||
import org.tianocore.build.global.OutputManager;
|
import org.tianocore.build.global.OutputManager;
|
||||||
import org.tianocore.build.id.FpdModuleIdentification;
|
import org.tianocore.build.id.FpdModuleIdentification;
|
||||||
@ -60,6 +61,10 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
|
|
||||||
public static int currentRunNumber = 0;
|
public static int currentRunNumber = 0;
|
||||||
|
|
||||||
|
public static int totalNumber = 0;
|
||||||
|
|
||||||
|
public static int remainNumber = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Public construct method. It is necessary for ANT task.
|
Public construct method. It is necessary for ANT task.
|
||||||
**/
|
**/
|
||||||
@ -71,6 +76,8 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
|
|
||||||
|
this.setTaskName(".........");
|
||||||
//
|
//
|
||||||
// Parse FPD file
|
// Parse FPD file
|
||||||
//
|
//
|
||||||
@ -93,7 +100,7 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
// Prepare FV_DIR
|
// Prepare FV_DIR
|
||||||
//
|
//
|
||||||
String ffsCommonDir = buildDir + File.separatorChar
|
String ffsCommonDir = buildDir + File.separatorChar
|
||||||
+ targetList[i] + File.separatorChar
|
+ targetList[i] + "_"
|
||||||
+ toolchainList[j];
|
+ toolchainList[j];
|
||||||
File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");
|
File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");
|
||||||
fvDir.mkdirs();
|
fvDir.mkdirs();
|
||||||
@ -144,8 +151,10 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
ant.init();
|
ant.init();
|
||||||
ant.execute();
|
ant.execute();
|
||||||
|
|
||||||
EdkLog.log(this, "Task number is " + allThreads.size());
|
remainNumber = totalNumber = allThreads.size();
|
||||||
|
|
||||||
|
EdkLog.log(this, EdkLog.EDK_ALWAYS, "Total thread number is " + totalNumber);
|
||||||
|
GenBuildLogger.setCacheEnable(true);
|
||||||
//
|
//
|
||||||
// Waiting for all thread over, or time out
|
// Waiting for all thread over, or time out
|
||||||
//
|
//
|
||||||
@ -162,6 +171,9 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int percentage = (totalNumber - remainNumber) * 100 / totalNumber;
|
||||||
|
EdkLog.log(this, EdkLog.EDK_ALWAYS, percentage + "% finished. Has built " + (totalNumber - remainNumber) + " modules of " + totalNumber + " total. ");
|
||||||
|
|
||||||
Set<FpdModuleIdentification> currentQueueModules = fvs.get(queueList.get(currentQueueCode));
|
Set<FpdModuleIdentification> currentQueueModules = fvs.get(queueList.get(currentQueueCode));
|
||||||
|
|
||||||
if (currentQueueModules == null) {
|
if (currentQueueModules == null) {
|
||||||
@ -192,35 +204,37 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
//
|
//
|
||||||
// Exist ready thread
|
// Exist ready thread
|
||||||
//
|
//
|
||||||
EdkLog.log(this, "## Exist ready thread");
|
// EdkLog.log(this, EdkLog.EDK_ALWAYS, "Exist ready thread");
|
||||||
|
|
||||||
} else if (existNoneReady && currentRunNumber == 0) {
|
} else if (existNoneReady && currentRunNumber == 0) {
|
||||||
//
|
//
|
||||||
// No active thread, but still have dependency not read thread
|
// No active thread, but still have dependency not read thread
|
||||||
//
|
//
|
||||||
throw new BuildException("Found can't resolve dependencies. ");
|
throw new BuildException("Existing some modules can't resolve depedencies. ");
|
||||||
} else if (!existNoneReady && currentRunNumber == 0) {
|
} else if (!existNoneReady && currentRunNumber == 0) {
|
||||||
//
|
//
|
||||||
// Current queue build finish, move to next
|
// Current queue build finish, move to next
|
||||||
//
|
//
|
||||||
EdkLog.log(this, "## Current queue build finish, move to next");
|
EdkLog.log(this, EdkLog.EDK_ALWAYS, "Current queue build finish, move to next");
|
||||||
++currentQueueCode;
|
++currentQueueCode;
|
||||||
continue ;
|
continue ;
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// active thread exist, but no ready thread
|
// active thread exist, but no ready thread
|
||||||
//
|
//
|
||||||
EdkLog.log(this, "## active thread exist, but no ready thread" + currentRunNumber);
|
EdkLog.log(this, EdkLog.EDK_ALWAYS, "Active thread exist, but no ready thread. Current running number is " + currentRunNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
deamonSemaphore.wait();
|
deamonSemaphore.wait();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException ex) {
|
||||||
e.printStackTrace();
|
BuildException e = new BuildException("Thread wait Error. \n" + ex.getMessage());
|
||||||
|
e.setStackTrace(ex.getStackTrace());
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
GenBuildLogger.setCacheEnable(false);
|
||||||
//
|
//
|
||||||
// call fvs, postbuild
|
// call fvs, postbuild
|
||||||
//
|
//
|
||||||
@ -240,6 +254,8 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
ant.init();
|
ant.init();
|
||||||
ant.execute();
|
ant.execute();
|
||||||
|
|
||||||
|
EdkLog.flushLogToFile(new File(buildDir + File.separatorChar + "build.log"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -358,6 +374,7 @@ public class FpdParserForThread extends FpdParserTask {
|
|||||||
public synchronized static void subCount() {
|
public synchronized static void subCount() {
|
||||||
synchronized (countSemaphore) {
|
synchronized (countSemaphore) {
|
||||||
--currentRunNumber;
|
--currentRunNumber;
|
||||||
|
--remainNumber;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,52 +18,63 @@
|
|||||||
|
|
||||||
package org.tianocore.build.global;
|
package org.tianocore.build.global;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.BuildEvent;
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.apache.tools.ant.DefaultLogger;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
|
import org.apache.tools.ant.util.StringUtils;
|
||||||
|
|
||||||
|
import org.tianocore.build.id.Identification;
|
||||||
import org.tianocore.common.logger.EdkLog;
|
import org.tianocore.common.logger.EdkLog;
|
||||||
import org.tianocore.common.logger.LogMethod;
|
import org.tianocore.common.logger.LogMethod;
|
||||||
|
|
||||||
public class GenBuildLogger implements LogMethod {
|
public class GenBuildLogger extends DefaultLogger implements LogMethod {
|
||||||
|
|
||||||
private Project project = null;
|
private Project project = null;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// flag to present whether cache all msg or not
|
/// flag to present whether cache all msg or not
|
||||||
/// true means not to cache.
|
/// true means to cache.
|
||||||
///
|
///
|
||||||
private boolean flag = true;
|
private static boolean flag = false;
|
||||||
|
|
||||||
private List<String> v = null;
|
private static Map<Identification, List<String>> map = new HashMap<Identification, List<String> >(256);
|
||||||
|
|
||||||
|
private Identification id = null;
|
||||||
|
|
||||||
|
public GenBuildLogger () {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public GenBuildLogger (Project project) {
|
public GenBuildLogger (Project project) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GenBuildLogger (Project project, boolean flag) {
|
public GenBuildLogger (Project project, Identification id) {
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.flag = flag;
|
this.id = id;
|
||||||
|
|
||||||
//
|
|
||||||
// Only flag is false, v will be initialized and used.
|
|
||||||
//
|
|
||||||
if (!flag) {
|
|
||||||
v = new Vector<String>(2048);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Rules: flag = true: means no cache Action: Print it to console
|
Rules: flag = false: means no cache Action: Print it to console
|
||||||
|
|
||||||
flag = false: mean cache all msg exception some special Action: loglevel
|
flag = true: mean cache all msg exception some special Action: loglevel
|
||||||
is EDK_ALWAYS -- Print but no cache loglevel is EDK_ERROR -- Print and
|
is EDK_ALWAYS -- Print but no cache loglevel is EDK_ERROR -- Print and
|
||||||
cache the msg others -- No print and cache the msg
|
cache the msg others -- No print and cache the msg
|
||||||
**/
|
**/
|
||||||
public synchronized void putMessage(Object msgSource, int msgLevel,
|
public synchronized void putMessage(Object msgSource, int msgLevel, String msg) {
|
||||||
String msg) {
|
|
||||||
if (this.project == null) {
|
if (this.project == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -73,51 +84,47 @@ public class GenBuildLogger implements LogMethod {
|
|||||||
//
|
//
|
||||||
switch (msgLevel) {
|
switch (msgLevel) {
|
||||||
case EdkLog.EDK_ALWAYS:
|
case EdkLog.EDK_ALWAYS:
|
||||||
log(msgSource, msg, Project.MSG_INFO);
|
//
|
||||||
|
// Do some special
|
||||||
|
//
|
||||||
|
log(msgSource, msg, Project.MSG_ERR);
|
||||||
break;
|
break;
|
||||||
case EdkLog.EDK_ERROR:
|
case EdkLog.EDK_ERROR:
|
||||||
if (flag) {
|
|
||||||
log(msgSource, msg, Project.MSG_ERR);
|
log(msgSource, msg, Project.MSG_ERR);
|
||||||
} else {
|
|
||||||
log(msgSource, msg, Project.MSG_ERR);
|
|
||||||
v.add(msg);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EdkLog.EDK_WARNING:
|
case EdkLog.EDK_WARNING:
|
||||||
if (flag) {
|
|
||||||
log(msgSource, msg, Project.MSG_WARN);
|
log(msgSource, msg, Project.MSG_WARN);
|
||||||
} else {
|
|
||||||
v.add(msg);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EdkLog.EDK_INFO:
|
case EdkLog.EDK_INFO:
|
||||||
if (flag) {
|
|
||||||
log(msgSource, msg, Project.MSG_INFO);
|
log(msgSource, msg, Project.MSG_INFO);
|
||||||
} else {
|
|
||||||
v.add(msg);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EdkLog.EDK_VERBOSE:
|
case EdkLog.EDK_VERBOSE:
|
||||||
if (flag) {
|
|
||||||
log(msgSource, msg, Project.MSG_VERBOSE);
|
log(msgSource, msg, Project.MSG_VERBOSE);
|
||||||
} else {
|
|
||||||
v.add(msg);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case EdkLog.EDK_DEBUG:
|
case EdkLog.EDK_DEBUG:
|
||||||
if (flag) {
|
|
||||||
log(msgSource, msg, Project.MSG_DEBUG);
|
log(msgSource, msg, Project.MSG_DEBUG);
|
||||||
} else {
|
|
||||||
v.add(msg);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flushToFile(File file) {
|
public void flushToFile(File file) {
|
||||||
//
|
//
|
||||||
// Sort msg and store to the file (TBD)
|
// Put all messages in map to file
|
||||||
//
|
//
|
||||||
|
String msg = "Writing log to file [" + file.getPath() + "]";
|
||||||
|
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));
|
||||||
|
bw.newLine();
|
||||||
|
}
|
||||||
|
bw.flush();
|
||||||
|
bw.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
new BuildException("Writing log error. " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,9 +132,8 @@ public class GenBuildLogger implements LogMethod {
|
|||||||
if (msgSource instanceof Task) {
|
if (msgSource instanceof Task) {
|
||||||
this.project.log((Task)msgSource, msg, level);
|
this.project.log((Task)msgSource, msg, level);
|
||||||
} else if (msgSource instanceof String){
|
} else if (msgSource instanceof String){
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pad 12 space to keep message
|
// Pad 12 space to keep message in unify format
|
||||||
//
|
//
|
||||||
msg = msg.replaceAll("\n", "\n ");
|
msg = msg.replaceAll("\n", "\n ");
|
||||||
this.project.log(String.format("%12s", "[" + msgSource + "] ") + msg, level);
|
this.project.log(String.format("%12s", "[" + msgSource + "] ") + msg, level);
|
||||||
@ -135,4 +141,76 @@ public class GenBuildLogger implements LogMethod {
|
|||||||
this.project.log(msg, level);
|
this.project.log(msg, level);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void targetStarted(BuildEvent event) {
|
||||||
|
if (!flag) {
|
||||||
|
super.targetStarted(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void messageLogged(BuildEvent event) {
|
||||||
|
int currentLevel = event.getPriority();
|
||||||
|
//
|
||||||
|
// If current level is upper than Ant Level, skip it
|
||||||
|
//
|
||||||
|
if (currentLevel <= this.msgOutputLevel) {
|
||||||
|
String originalMessage = event.getMessage();
|
||||||
|
|
||||||
|
StringBuffer message = new StringBuffer();
|
||||||
|
if (!emacsMode && event.getTask() != null) {
|
||||||
|
String label = String.format("%12s", "[" + event.getTask().getTaskName() + "] ");
|
||||||
|
//
|
||||||
|
// Append label first
|
||||||
|
//
|
||||||
|
message.append(label);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Format all output message's line separator
|
||||||
|
//
|
||||||
|
try {
|
||||||
|
BufferedReader r = new BufferedReader(new StringReader(originalMessage));
|
||||||
|
boolean ifFirstLine = true;
|
||||||
|
String line = null;
|
||||||
|
while ((line = r.readLine()) != null) {
|
||||||
|
if (!ifFirstLine) {
|
||||||
|
message.append(StringUtils.LINE_SEP);
|
||||||
|
}
|
||||||
|
ifFirstLine = false;
|
||||||
|
message.append(line);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
message.append(originalMessage);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
message.append(originalMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
String msg = message.toString();
|
||||||
|
if (currentLevel == Project.MSG_ERR) {
|
||||||
|
printMessage(msg, err, currentLevel);
|
||||||
|
} else if(currentLevel == Project.MSG_WARN) {
|
||||||
|
printMessage(msg, out, currentLevel);
|
||||||
|
} else if(!flag) {
|
||||||
|
printMessage(msg, out, currentLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
log(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setCacheEnable(boolean enable) {
|
||||||
|
flag = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected synchronized void log(String message) {
|
||||||
|
//
|
||||||
|
// cache log
|
||||||
|
//
|
||||||
|
if (map.containsKey(this.id)) {
|
||||||
|
map.get(this.id).add(message);
|
||||||
|
} else {
|
||||||
|
List<String> list = new Vector<String>(1024);
|
||||||
|
list.add(message);
|
||||||
|
map.put(this.id, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -162,7 +162,7 @@ public class GlobalData {
|
|||||||
// CONF dir + tools definition file name
|
// CONF dir + tools definition file name
|
||||||
//
|
//
|
||||||
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);
|
File toolsDefFile = new File(workspaceDir + File.separatorChar + toolsDefFilename);
|
||||||
EdkLog.log("Init", "Using tool definition file [" + toolsDefFile.getPath() + "].");
|
EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Using tool definition file [" + toolsDefFile.getPath() + "].");
|
||||||
toolsDef = new ToolChainConfig(toolsDefFile);
|
toolsDef = new ToolChainConfig(toolsDefFile);
|
||||||
|
|
||||||
|
|
||||||
@ -686,8 +686,8 @@ public class GlobalData {
|
|||||||
}
|
}
|
||||||
toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());
|
toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());
|
||||||
toolChainInfo.normalize();
|
toolChainInfo.normalize();
|
||||||
EdkLog.log("Init", "Current build tool chain information summary: ");
|
EdkLog.log("Init", EdkLog.EDK_ALWAYS, "Current build tool chain information summary: ");
|
||||||
EdkLog.log("Init", toolChainInfo + "");
|
EdkLog.log("Init", EdkLog.EDK_ALWAYS, toolChainInfo + "");
|
||||||
}
|
}
|
||||||
return toolChainInfo;
|
return toolChainInfo;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import java.util.List;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
import org.tianocore.build.FrameworkBuildTask;
|
||||||
import org.tianocore.build.autogen.CommonDefinition;
|
import org.tianocore.build.autogen.CommonDefinition;
|
||||||
import org.tianocore.build.global.GlobalData;
|
import org.tianocore.build.global.GlobalData;
|
||||||
import org.tianocore.build.id.ModuleIdentification;
|
import org.tianocore.build.id.ModuleIdentification;
|
||||||
@ -72,6 +73,7 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
///
|
///
|
||||||
private String[] pcdNameArrayInMsa;
|
private String[] pcdNameArrayInMsa;
|
||||||
|
|
||||||
|
private UsageIdentification parentId = null;
|
||||||
/**
|
/**
|
||||||
Set parameter moduleId
|
Set parameter moduleId
|
||||||
|
|
||||||
@ -142,7 +144,8 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
String arch,
|
String arch,
|
||||||
boolean isBuildUsedLibrary,
|
boolean isBuildUsedLibrary,
|
||||||
String[] pcdNameArrayInMsa,
|
String[] pcdNameArrayInMsa,
|
||||||
CommonDefinition.PCD_DRIVER_TYPE pcdDriverType) {
|
CommonDefinition.PCD_DRIVER_TYPE pcdDriverType,
|
||||||
|
ModuleIdentification parentId) {
|
||||||
dbManager = null;
|
dbManager = null;
|
||||||
hAutoGenString = "";
|
hAutoGenString = "";
|
||||||
cAutoGenString = "";
|
cAutoGenString = "";
|
||||||
@ -154,6 +157,15 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
arch,
|
arch,
|
||||||
moduleId.getVersion(),
|
moduleId.getVersion(),
|
||||||
moduleId.getModuleType()));
|
moduleId.getModuleType()));
|
||||||
|
if (parentId != null) {
|
||||||
|
this.parentId = new UsageIdentification(parentId.getName(),
|
||||||
|
parentId.getGuid(),
|
||||||
|
parentId.getPackage().getName(),
|
||||||
|
parentId.getPackage().getGuid(),
|
||||||
|
arch,
|
||||||
|
parentId.getVersion(),
|
||||||
|
parentId.getModuleType());
|
||||||
|
}
|
||||||
setIsBuildUsedLibrary(isBuildUsedLibrary);
|
setIsBuildUsedLibrary(isBuildUsedLibrary);
|
||||||
setPcdNameArrayInMsa(pcdNameArrayInMsa);
|
setPcdNameArrayInMsa(pcdNameArrayInMsa);
|
||||||
setPcdDriverType(pcdDriverType);
|
setPcdDriverType(pcdDriverType);
|
||||||
@ -211,6 +223,53 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
boolean found = false;
|
boolean found = false;
|
||||||
|
|
||||||
usageInstanceArray = null;
|
usageInstanceArray = null;
|
||||||
|
|
||||||
|
if (FrameworkBuildTask.multithread) {
|
||||||
|
if (parentId == null) {
|
||||||
|
usageInstanceArray = dbManager.getUsageInstanceArrayById(usageId);
|
||||||
|
} else if ((pcdNameArrayInMsa != null) && (pcdNameArrayInMsa.length > 0)) {
|
||||||
|
usageContext = dbManager.getUsageInstanceArrayById(parentId);
|
||||||
|
//
|
||||||
|
// For building library package, although all module are library, but PCD entries of
|
||||||
|
// these library should be used to autogen.
|
||||||
|
//
|
||||||
|
if (usageContext == null) {
|
||||||
|
usageInstanceArray = dbManager.getUsageInstanceArrayById(usageId);
|
||||||
|
} else {
|
||||||
|
usageInstanceArray = new ArrayList<UsageInstance>();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Try to find all PCD defined in library's PCD in all <PcdEntry> in module's
|
||||||
|
// <ModuleSA> in FPD file.
|
||||||
|
//
|
||||||
|
for (index = 0; index < pcdNameArrayInMsa.length; index++) {
|
||||||
|
found = false;
|
||||||
|
for (index2 = 0; index2 < usageContext.size(); index2 ++) {
|
||||||
|
if (pcdNameArrayInMsa[index].equalsIgnoreCase(usageContext.get(index2).parentToken.cName)) {
|
||||||
|
usageInstanceArray.add(usageContext.get(index2));
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found) {
|
||||||
|
//
|
||||||
|
// All library's PCD should instanted in module's <ModuleSA> who
|
||||||
|
// use this library instance. If not, give errors.
|
||||||
|
//
|
||||||
|
throw new BuildActionException (String.format("Module %s using library instance %s; the PCD %s " +
|
||||||
|
"is required by this library instance, but can not be found " +
|
||||||
|
"in the %s's <ModuleSA> in the FPD file!",
|
||||||
|
MemoryDatabaseManager.CurrentModuleName,
|
||||||
|
moduleName,
|
||||||
|
pcdNameArrayInMsa[index],
|
||||||
|
MemoryDatabaseManager.CurrentModuleName
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
if (!isBuildUsedLibrary) {
|
if (!isBuildUsedLibrary) {
|
||||||
usageInstanceArray = dbManager.getUsageInstanceArrayById(usageId);
|
usageInstanceArray = dbManager.getUsageInstanceArrayById(usageId);
|
||||||
MemoryDatabaseManager.UsageInstanceContext = usageInstanceArray;
|
MemoryDatabaseManager.UsageInstanceContext = usageInstanceArray;
|
||||||
@ -257,7 +316,7 @@ public class PCDAutoGenAction extends BuildAction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (usageInstanceArray == null) {
|
if (usageInstanceArray == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -9,4 +9,4 @@
|
|||||||
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
#
|
#
|
||||||
|
|
||||||
ant -f $WORKSPACE/build.xml $*
|
ant -logger org.tianocore.build.global.GenBuildLogger -f $WORKSPACE/build.xml $*
|
||||||
|
@ -9,4 +9,4 @@
|
|||||||
@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
@REM
|
@REM
|
||||||
|
|
||||||
ant -f %WORKSPACE%/build.xml %*
|
ant -logger org.tianocore.build.global.GenBuildLogger -f %WORKSPACE%/build.xml %*
|
||||||
|
Reference in New Issue
Block a user