diff options
author | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-05 05:47:21 +0000 |
---|---|---|
committer | wuyizhong <wuyizhong@6f19259b-4bc3-4df7-8a09-765794883524> | 2006-09-05 05:47:21 +0000 |
commit | c8df018e44c9a88a582472339b645d4087848fd6 (patch) | |
tree | fb52f3c755b298180953a7bef5b54149fdf0e03c | |
parent | 97fc032b57b1d189139df778272942d6eaeb132d (diff) | |
download | edk2-platforms-c8df018e44c9a88a582472339b645d4087848fd6.tar.xz |
Add two definitions to ToolDefinitions. Enhance EdkLog and GenBuildLogger. GenBuildLogger contains two behaviors now, one is for normal; while another is for multi-thread. (4)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1450 6f19259b-4bc3-4df7-8a09-765794883524
9 files changed, 206 insertions, 139 deletions
diff --git a/Tools/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java b/Tools/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java index 74e783d904..5a1986f246 100644 --- a/Tools/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java +++ b/Tools/Source/Common/org/tianocore/common/definitions/ToolDefinitions.java @@ -97,4 +97,7 @@ public class ToolDefinitions { public final static String TARGET_KEY_TOOLCHAIN = "TOOL_CHAIN_TAG";
public final static String TARGET_KEY_ARCH = "TARGET_ARCH";
public final static String TARGET_KEY_TOOLS_DEF = "TOOL_CHAIN_CONF";
+ public final static String TARGET_KEY_MULTIPLE_THREAD = "MULTIPLE_THREAD";
+ public final static String TARGET_KEY_MAX_CONCURRENT_THREAD_NUMBER
+ = "MAX_CONCURRENT_THREAD_NUMBER";
}
diff --git a/Tools/Source/Common/org/tianocore/common/exception/EdkException.java b/Tools/Source/Common/org/tianocore/common/exception/EdkException.java index 0b7f5787a3..6d4fc52dae 100644 --- a/Tools/Source/Common/org/tianocore/common/exception/EdkException.java +++ b/Tools/Source/Common/org/tianocore/common/exception/EdkException.java @@ -20,7 +20,7 @@ package org.tianocore.common.exception; public class EdkException extends Exception {
static final long serialVersionUID = -8494188017252114029L;
- private StackTraceElement[] stackTrace;
+
public static boolean isPrintStack = false;
public EdkException(String message) {
diff --git a/Tools/Source/Common/org/tianocore/common/logger/DefaultLogger.java b/Tools/Source/Common/org/tianocore/common/logger/DefaultLogger.java index d0f9be4da8..b1d9d6de85 100644 --- a/Tools/Source/Common/org/tianocore/common/logger/DefaultLogger.java +++ b/Tools/Source/Common/org/tianocore/common/logger/DefaultLogger.java @@ -18,6 +18,7 @@ Abstract: package org.tianocore.common.logger;
+import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -28,10 +29,16 @@ class DefaultLogger implements LogMethod { };
public DefaultLogger() {
-
}
public void putMessage(Object msgSource, int msgLevel, String msg) {
+ if (msgLevel < 0 || msgLevel > levelMap.length) {
+ msgLevel = 2;
+ }
logger.log(levelMap[msgLevel], msg);
}
+
+ public void flushToFile(File file){
+
+ }
}
\ No newline at end of file diff --git a/Tools/Source/Common/org/tianocore/common/logger/EdkLog.java b/Tools/Source/Common/org/tianocore/common/logger/EdkLog.java index 220b9899f7..cfa7d53e4a 100644 --- a/Tools/Source/Common/org/tianocore/common/logger/EdkLog.java +++ b/Tools/Source/Common/org/tianocore/common/logger/EdkLog.java @@ -1,91 +1,100 @@ /*++
-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
+ 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.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
- EdkLogger.java
+ Module Name:
+ EdkLogger.java
-Abstract:
-
---*/
+ Abstract:
+ --*/
package org.tianocore.common.logger;
-import org.tianocore.common.logger.LogMethod;
+import java.io.File;
public class EdkLog {
- private static final String error = "ERROR";
- private static final String warning = "WARNING";
- private static final String info = "INFO";
- private static final String verbose = "VERBOSE";
- private static final String debug = "DEBUG";
+ public static final String always = "ALWAYS";
+
+ public static final String error = "ERROR";
+
+ public static final String warning = "WARNING";
+
+ public static final String info = "INFO";
+
+ public static final String verbose = "VERBOSE";
+
+ public static final String debug = "DEBUG";
+
+ public static final int EDK_ALWAYS = -1;
+
+ public static final int EDK_ERROR = 0;
- public static final int EDK_ERROR = 0;
public static final int EDK_WARNING = 1;
- public static final int EDK_INFO = 2;
+
+ public static final int EDK_INFO = 2;
+
public static final int EDK_VERBOSE = 3;
- public static final int EDK_DEBUG = 4;
+
+ public static final int EDK_DEBUG = 4;
private static int logLevel = EDK_INFO;
+
private static LogMethod logger = new DefaultLogger();
public static void log(int level, String message) {
- if (level <= logLevel){
- logger.putMessage(null, logLevel, message);
+ if (level <= logLevel) {
+ logger.putMessage(null, level, message);
}
-
}
- public static void log(int logLevel, String message, Exception cause) {
-
- }
-
- public static void log(int logLevel, Exception cause) {
-
+ public static void log(String message) {
+ if (EDK_INFO <= logLevel) {
+ logger.putMessage(null, EDK_INFO, message);
+ }
}
- public static void log(Exception cause) {
-
+ public static void flushLogToFile(File file) {
+ logger.flushToFile(file);
}
public static void setLogger(LogMethod l) {
logger = l;
}
- public static void setLogLevel (int level){
+ public static void setLogLevel(int level) {
logLevel = level;
}
- public static void setLogLevel (String level){
- if (level == null){
- return;
- }
- String levelStr = level.trim();
- if (levelStr.equalsIgnoreCase(error)){
- logLevel = EDK_ERROR;
- }
- if (levelStr.equalsIgnoreCase(debug)){
- logLevel = EDK_DEBUG;
- }
- if (levelStr.equalsIgnoreCase(info)){
- logLevel = EDK_INFO;
- }
- if (levelStr.equalsIgnoreCase(verbose)){
- logLevel = EDK_VERBOSE;
- }
- if (levelStr.equalsIgnoreCase(warning)){
- logLevel = EDK_WARNING;
- }
+
+ public static void setLogLevel(String level) {
+ if (level == null) {
+ return;
+ }
+ String levelStr = level.trim();
+ if (levelStr.equalsIgnoreCase(error)) {
+ logLevel = EDK_ERROR;
+ }
+ if (levelStr.equalsIgnoreCase(debug)) {
+ logLevel = EDK_DEBUG;
+ }
+ if (levelStr.equalsIgnoreCase(info)) {
+ logLevel = EDK_INFO;
+ }
+ if (levelStr.equalsIgnoreCase(verbose)) {
+ logLevel = EDK_VERBOSE;
+ }
+ if (levelStr.equalsIgnoreCase(warning)) {
+ logLevel = EDK_WARNING;
+ }
}
- public static int getLogLevel (){
+
+ public static int getLogLevel() {
return logLevel;
}
}
-
-
diff --git a/Tools/Source/Common/org/tianocore/common/logger/LogMethod.java b/Tools/Source/Common/org/tianocore/common/logger/LogMethod.java index 28d30020c3..f9a6802430 100644 --- a/Tools/Source/Common/org/tianocore/common/logger/LogMethod.java +++ b/Tools/Source/Common/org/tianocore/common/logger/LogMethod.java @@ -1,23 +1,27 @@ /*++
-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
+ 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.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
- LogMethod.java
+ Module Name:
+ LogMethod.java
-Abstract:
+ Abstract:
---*/
+ --*/
package org.tianocore.common.logger;
+import java.io.File;
+
public interface LogMethod {
public void putMessage(Object msgSource, int msgLevel, String msg);
+
+ public void flushToFile(File file);
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java index 04cf84c04f..ea5657cdf9 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java @@ -26,10 +26,12 @@ import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Task;
import org.tianocore.build.fpd.FpdParserForThread;
import org.tianocore.build.fpd.FpdParserTask;
+import org.tianocore.build.global.GenBuildLogger;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.toolchain.ConfigReader;
import org.tianocore.build.toolchain.ToolChainInfo;
import org.tianocore.common.definitions.ToolDefinitions;
+import org.tianocore.common.logger.EdkLog;
/**
<p>
@@ -104,6 +106,13 @@ public class FrameworkBuildTask extends Task{ public void execute() throws BuildException {
//
+ // set Logger
+ //
+ GenBuildLogger logger = new GenBuildLogger(getProject());
+ EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
+ EdkLog.setLogger(logger);
+
+ //
// Seach build.xml -> .FPD -> .MSA file
//
try {
@@ -200,7 +209,7 @@ public class FrameworkBuildTask extends Task{ fpdParserForThread.setType(type);
fpdParserForThread.setProject(getProject());
fpdParserForThread.setFpdFile(buildFile);
- fpdParserForThread.execute();
+ fpdParserForThread.perform();
return ;
}
@@ -208,7 +217,7 @@ public class FrameworkBuildTask extends Task{ fpdParserTask.setType(type);
fpdParserTask.setProject(getProject());
fpdParserTask.setFpdFile(buildFile);
- fpdParserTask.execute();
+ fpdParserTask.perform();
//
// If cleanall delete the Platform_build.xml
@@ -239,7 +248,7 @@ public class FrameworkBuildTask extends Task{ }
genBuildTask.setProject(getProject());
genBuildTask.setMsaFile(buildFile);
- genBuildTask.execute();
+ genBuildTask.perform();
}
}
@@ -268,7 +277,6 @@ public class FrameworkBuildTask extends Task{ String name = (String)piter.next();
originalProperties.put(new String(name), new String((String)allProperties.get(name)));
}
-
}
private File intercommuniteWithUser(){
@@ -370,12 +378,12 @@ public class FrameworkBuildTask extends Task{ activePlatform = str;
}
- str = getValue("MULTIPLE_THREAD", targetFileInfo);
+ str = getValue(ToolDefinitions.TARGET_KEY_MULTIPLE_THREAD, targetFileInfo);
if (str != null && str.trim().equalsIgnoreCase("Enable")) {
multithread = true;
}
- str = getValue("MAX_CONCURRENT_THREAD_NUMBER", targetFileInfo);
+ str = getValue(ToolDefinitions.TARGET_KEY_MAX_CONCURRENT_THREAD_NUMBER, targetFileInfo);
if (str != null ) {
try {
int threadNum = Integer.parseInt(str);
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java index bb9a2dfbcf..978b11fe2b 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java +++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java @@ -35,10 +35,8 @@ import org.apache.xmlbeans.XmlObject; import org.tianocore.common.definitions.ToolDefinitions;
import org.tianocore.common.exception.EdkException;
-import org.tianocore.common.logger.EdkLog;
import org.tianocore.build.autogen.AutoGen;
import org.tianocore.build.fpd.FpdParserTask;
-import org.tianocore.build.global.GenBuildLogger;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.OutputManager;
import org.tianocore.build.global.SurfaceAreaQuery;
@@ -130,13 +128,6 @@ public class GenBuildTask extends Ant { if (!FrameworkBuildTask.multithread) {
cleanupProperties();
}
-
- //
- // set Logger
- //
- GenBuildLogger logger = new GenBuildLogger(getProject());
- EdkLog.setLogLevel(getProject().getProperty("env.LOGLEVEL"));
- EdkLog.setLogger(logger);
//
// Enable all specified properties
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java index b16530b59f..6551664520 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java +++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserForThread.java @@ -1,9 +1,6 @@ /** @file
This file is ANT task FpdParserTask.
- FpdParserTask is used to parse FPD (Framework Platform Description) and generate
- build.out.xml. It is for Package or Platform build use.
-
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
@@ -37,31 +34,6 @@ import org.tianocore.build.GenBuildThread; import org.tianocore.common.exception.EdkException;
/**
- <code>FpdParserTask</code> is an ANT task. The main function is parsing Framework
- Platform Descritpion (FPD) XML file and generating its ANT build script for
- corresponding platform.
-
- <p>The task sets global properties PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
- and BUILD_DIR. </p>
-
- <p>The task generates ${PLATFORM}_build.xml file which will be called by top level
- build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage)
- and flash definition file (File is for Tool FlashMap) if necessary. </p>
-
- <p>FpdParserTask task stores all FPD information to GlobalData. And parse
- tools definition file to set up compiler options for different Target and
- different ToolChainTag. </p>
-
- <p>The method parseFpdFile is also prepared for single module build. </p>
-
- <p>The usage is (take NT32 Platform for example):</p>
-
- <pre>
- <FPDParser platformName="Nt32" />
- </pre>
-
- <p>The task will initialize all information through parsing Framework Database,
- SPD, Tool chain configuration files. </p>
@since GenBuild 1.0
**/
@@ -94,19 +66,8 @@ public class FpdParserForThread extends FpdParserTask { }
/**
- ANT task's entry method. The main steps is described as following:
-
- <ul>
- <li>Initialize global information (Framework DB, SPD files and all MSA files
- listed in SPD). This step will execute only once in whole build process;</li>
- <li>Parse specified FPD file; </li>
- <li>Generate FV.inf files; </li>
- <li>Generate PlatformName_build.xml file for Flatform build; </li>
- <li>Collect PCD information. </li>
- </ul>
- @throws BuildException
- Surface area is not valid.
+
**/
public void execute() throws BuildException {
//
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java b/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java index e1bafd668a..9bc3f2d176 100644 --- a/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java +++ b/Tools/Source/GenBuild/org/tianocore/build/global/GenBuildLogger.java @@ -1,38 +1,122 @@ /*++
-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
+ 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.
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-Module Name:
- GenBuildLogger.java
+ Module Name:
+ GenBuildLogger.java
-Abstract:
+ Abstract:
---*/
+ --*/
package org.tianocore.build.global;
+import java.io.File;
+import java.util.List;
+import java.util.Vector;
+
import org.apache.tools.ant.Project;
+import org.tianocore.common.logger.EdkLog;
import org.tianocore.common.logger.LogMethod;
public class GenBuildLogger implements LogMethod {
- private Project project;
- public GenBuildLogger(Project project) {
+ private Project project = null;
+
+ ///
+ /// flag to present whether cache all msg or not
+ /// true means not to cache.
+ ///
+ private boolean flag = true;
+
+ private List<String> v = null;
+
+ public GenBuildLogger (Project project) {
+ this.project = project;
+ }
+
+ public GenBuildLogger (Project project, boolean flag) {
this.project = project;
+ this.flag = flag;
+ //
+ // Only flag is false, v will be initialized and used.
+ //
+ if (!flag) {
+ v = new Vector<String>(2048);
+ }
}
- public void putMessage(Object msgSource, int msgLevel, String msg) {
- if (this.project != null){
+ /**
+ Rules: flag = true: means no cache Action: Print it to console
+
+ flag = false: mean cache all msg exception some special Action: loglevel
+ is EDK_ALWAYS -- Print but no cache loglevel is EDK_ERROR -- Print and
+ cache the msg others -- No print and cache the msg
+ **/
+ public synchronized void putMessage(Object msgSource, int msgLevel,
+ String msg) {
+ if (this.project == null) {
+ return;
+ }
+
+ //
+ // If msgLevel is always print, then print it
+ //
+ switch (msgLevel) {
+ case EdkLog.EDK_ALWAYS:
this.project.log(msg, Project.MSG_INFO);
+ break;
+ case EdkLog.EDK_ERROR:
+ if (flag) {
+ this.project.log(msg, Project.MSG_ERR);
+ } else {
+ this.project.log(msg, Project.MSG_ERR);
+ v.add(msg);
+ }
+ break;
+ case EdkLog.EDK_WARNING:
+ if (flag) {
+ this.project.log(msg, Project.MSG_WARN);
+ } else {
+ v.add(msg);
+ }
+ break;
+ case EdkLog.EDK_INFO:
+ if (flag) {
+ this.project.log(msg, Project.MSG_INFO);
+ } else {
+ v.add(msg);
+ }
+ break;
+ case EdkLog.EDK_VERBOSE:
+ if (flag) {
+ this.project.log(msg, Project.MSG_VERBOSE);
+ } else {
+ v.add(msg);
+ }
+ break;
+ case EdkLog.EDK_DEBUG:
+ if (flag) {
+ this.project.log(msg, Project.MSG_DEBUG);
+ } else {
+ v.add(msg);
+ }
+ break;
}
+ }
+
+ public void flushToFile(File file) {
+ //
+ // Sort msg and store to the file (TBD)
+ //
}
}
\ No newline at end of file |