Using Common Definitions. Remove some unused codes.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1304 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
wuyizhong 2006-08-17 05:29:15 +00:00
parent 5823a8e9bd
commit 4a6a5026fc
13 changed files with 70 additions and 111 deletions

View File

@ -80,7 +80,7 @@ public class ToolDefinitions {
public final static String TOOLS_DEF_ATTRIBUTE_SPATH = "SPATH";
public final static String TOOLS_DEF_ATTRIBUTE_EXT = "EXT";
public final static String TOOLS_DEF_ATTRIBUTE_FAMILY = "FAMILY";
public final static String TOOLS_DEF_ATTRIBUTE_FLAGS = "FALGS";
public final static String TOOLS_DEF_ATTRIBUTE_FLAGS = "FLAGS";
///
/// Tool Chain Families in the Tools Definition file

View File

@ -25,6 +25,7 @@ import org.tianocore.BuildOptionsDocument;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.common.definitions.EdkDefinitions;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -82,19 +83,7 @@ public class FfsProcess {
///
/// mapping from section type to section output file extension
///
public static final String[][] sectionExt = { { "EFI_SECTION_FREEFORM_SUBTYPE_GUID", ".sec" },
{ "EFI_SECTION_VERSION", ".ver" },
{ "EFI_SECTION_USER_INTERFACE", ".ui" },
{ "EFI_SECTION_DXE_DEPEX", ".dpx" },
{ "EFI_SECTION_PEI_DEPEX", ".dpx" },
{ "EFI_SECTION_PE32", ".pe32" },
{ "EFI_SECTION_PIC", ".pic" },
{ "EFI_SECTION_TE", ".tes" },
{ "EFI_SECTION_RAW", ".sec" },
{ "EFI_SECTION_COMPRESSION", ".sec" },
{ "EFI_SECTION_GUID_DEFINED", ".sec" },
{ "EFI_SECTION_COMPATIBILITY16", ".sec" },
{ "EFI_SECTION_FIRMWARE_VOLUME_IMAGE", ".sec" } };
public static final String[][] sectionExt = EdkDefinitions.SectionTypeExtensions;
/**
search in the type, if componentType is listed in type, return true;

View File

@ -27,6 +27,7 @@ import org.tianocore.build.fpd.FpdParserTask;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.toolchain.ConfigReader;
import org.tianocore.build.toolchain.ToolChainInfo;
import org.tianocore.common.definitions.ToolDefinitions;
public class FrameworkBuildTask extends Task{
@ -36,9 +37,11 @@ public class FrameworkBuildTask extends Task{
private Set<File> msaFiles = new LinkedHashSet<File>();
String toolsDefFilename = "Tools" + File.separatorChar + "Conf" + File.separatorChar + "tools_def.txt";
String toolsDefFilename = ToolDefinitions.DEFAULT_TOOLS_DEF_FILE_PATH;
String targetFilename = "target.txt";
String targetFilename = ToolDefinitions.TARGET_FILE_PATH;
String dbFilename = ToolDefinitions.FRAMEWORK_DATABASE_FILE_PATH;
String activePlatform = null;
@ -66,12 +69,12 @@ public class FrameworkBuildTask extends Task{
//
buildFiles.add(files[i]);
} else if (files[i].getName().endsWith(".fpd")) {
} else if (files[i].getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {
//
// Second, search FPD file, if found, build it
//
fpdFiles.add(files[i]);
} else if (files[i].getName().endsWith(".msa")) {
} else if (files[i].getName().endsWith(ToolDefinitions.MSA_EXTENSION)) {
//
// Third, search MSA file, if found, build it
//
@ -98,8 +101,7 @@ public class FrameworkBuildTask extends Task{
//
File workspacePath = new File(getProject().getProperty("WORKSPACE"));
getProject().setProperty("WORKSPACE_DIR", workspacePath.getPath().replaceAll("(\\\\)", "/"));
GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db",
workspacePath.getPath(), toolsDefFilename);
GlobalData.initInfo(dbFilename, workspacePath.getPath(), toolsDefFilename);
@ -112,38 +114,33 @@ public class FrameworkBuildTask extends Task{
//
File buildFile = null;
if (msaFiles.size() > 1) {
throw new BuildException("More than one MSA file under current directory. It is not allowd. ");
}
else if (msaFiles.size() == 1 && activePlatform == null) {
throw new BuildException("If try to build a single module, please set ACTIVE_PLATFORM in file [Tool/Conf/target.txt]. ");
}
else if (msaFiles.size() == 1 && activePlatform != null) {
throw new BuildException("Having more than one MSA file in a directory is not allowed!");
} else if (msaFiles.size() == 1 && activePlatform == null) {
throw new BuildException("If trying to build a single module, please set ACTIVE_PLATFORM in file [" + targetFilename + "]. ");
} else if (msaFiles.size() == 1 && activePlatform != null) {
//
// Build the single module
//
buildFile = msaFiles.toArray(new File[1])[0];
}
else if (activePlatform != null) {
} else if (activePlatform != null) {
buildFile = new File(GlobalData.getWorkspacePath() + File.separatorChar + activePlatform);
}
else if (fpdFiles.size() == 1) {
} else if (fpdFiles.size() == 1) {
buildFile = fpdFiles.toArray(new File[1])[0];
}
else if (fpdFiles.size() > 1) {
} else if (fpdFiles.size() > 1) {
buildFile = intercommuniteWithUser();
}
//
// If there is no build files or FPD files or MSA files, stop build
//
else {
throw new BuildException("Can't find any FPD files or MSA files in current directory. ");
throw new BuildException("Can't find any FPD or MSA files in the current directory. ");
}
//
// Build every FPD files (PLATFORM build)
//
if (buildFile.getName().endsWith(".fpd")) {
System.out.println("Start to build FPD file [" + buildFile.getPath() + "] ..>> ");
if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {
System.out.println("Processing the FPD file [" + buildFile.getPath() + "] ..>> ");
FpdParserTask fpdParserTask = new FpdParserTask();
fpdParserTask.setType(type);
fpdParserTask.setProject(getProject());
@ -154,10 +151,10 @@ public class FrameworkBuildTask extends Task{
//
// Build every MSA files (SINGLE MODULE BUILD)
//
else if (buildFile.getName().endsWith(".msa")) {
else if (buildFile.getName().endsWith(ToolDefinitions.MSA_EXTENSION)) {
File tmpFile = new File(GlobalData.getWorkspacePath() + File.separatorChar + activePlatform);
System.out.println("Using FPD file [" + tmpFile.getPath() + "] as active platform. ");
System.out.println("Start to build MSA file [" + buildFile.getPath() + "] ..>> ");
System.out.println("Using the FPD file [" + tmpFile.getPath() + "] for the active platform. ");
System.out.println("Processing the MSA file [" + buildFile.getPath() + "] ..>> ");
GenBuildTask genBuildTask = new GenBuildTask();
genBuildTask.setSingleModuleBuild(true);
genBuildTask.setType(type);
@ -191,26 +188,22 @@ public class FrameworkBuildTask extends Task{
private File intercommuniteWithUser(){
File file = null;
if (fpdFiles.size() + msaFiles.size() > 1) {
File[] allFiles = new File[fpdFiles.size() + msaFiles.size()];
if (fpdFiles.size() > 1) {
File[] allFiles = new File[fpdFiles.size()];
int index = 0;
Iterator<File> iter = fpdFiles.iterator();
while (iter.hasNext()) {
allFiles[index] = iter.next();
index++;
}
iter = msaFiles.iterator();
while (iter.hasNext()) {
allFiles[index] = iter.next();
index++;
}
System.out.println("Find " + allFiles.length + " FPD and MSA files: ");
System.out.println("Finding " + allFiles.length + " FPD files: ");
for (int i = 0; i < allFiles.length; i++) {
System.out.println("[" + (i + 1) + "]: " + allFiles[i].getName());
}
boolean flag = true;
System.out.print("Please select one file to build:[1] ");
System.out.print("Please select one of the following FPD files to build:[1] ");
do{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
@ -234,13 +227,9 @@ public class FrameworkBuildTask extends Task{
flag = true;
}
} while (flag);
}
else if (fpdFiles.size() == 1) {
} else if (fpdFiles.size() == 1) {
file = fpdFiles.toArray(new File[1])[0];
}
else if (msaFiles.size() == 1) {
file = msaFiles.toArray(new File[1])[0];
}
return file;
}
@ -248,54 +237,50 @@ public class FrameworkBuildTask extends Task{
public void setType(String type) {
if (type.equalsIgnoreCase("clean") || type.equalsIgnoreCase("cleanall")) {
this.type = type.toLowerCase();
}
else {
} else {
this.type = "all";
}
}
private void readTargetFile(){
try {
String targetFile = getProject().getProperty("WORKSPACE_DIR") + File.separatorChar
+ "Tools" + File.separatorChar + "Conf" + File.separatorChar + targetFilename;
String targetFile = getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + targetFilename;
String[][] targetFileInfo = ConfigReader.parse(targetFile);
//
// Get ToolChain Info from target.txt
//
ToolChainInfo envToolChainInfo = new ToolChainInfo();
String str = getValue("TARGET", targetFileInfo);
String str = getValue(ToolDefinitions.TARGET_KEY_TARGET, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addTargets("*");
}
else {
} else {
envToolChainInfo.addTargets(str);
}
str = getValue("TOOL_CHAIN_TAG", targetFileInfo);
str = getValue(ToolDefinitions.TARGET_KEY_TOOLCHAIN, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addTagnames("*");
}
else {
} else {
envToolChainInfo.addTagnames(str);
}
str = getValue("TARGET_ARCH", targetFileInfo);
str = getValue(ToolDefinitions.TARGET_KEY_ARCH, targetFileInfo);
if (str == null || str.trim().equals("")) {
envToolChainInfo.addArchs("*");
}
else {
} else {
envToolChainInfo.addArchs(str);
}
GlobalData.setToolChainEnvInfo(envToolChainInfo);
str = getValue("TOOL_CHAIN_CONF", targetFileInfo);
str = getValue(ToolDefinitions.TARGET_KEY_TOOLS_DEF, targetFileInfo);
if (str != null && str.trim().length() > 0) {
toolsDefFilename = str;
}
str = getValue("ACTIVE_PLATFORM", targetFileInfo);
str = getValue(ToolDefinitions.TARGET_KEY_ACTIVE_PLATFORM, targetFileInfo);
if (str != null && ! str.trim().equals("")) {
if ( ! str.endsWith(".fpd")) {
throw new BuildException("FPD file's file extension must be \".fpd\"");
throw new BuildException("FPD file's extension must be \"" + ToolDefinitions.FPD_EXTENSION + "\"!");
}
activePlatform = str;
}

View File

@ -32,6 +32,7 @@ import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
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;
@ -49,11 +50,15 @@ import org.tianocore.build.tools.ModuleItem;
/**
<p>
<code>GenBuildTask</code> is an ANT task that can be used in ANT build
system. The main function of this task is to parse module's surface area,
system.
<p>The main function of this task is to parse module's surface area (MSA),
then generate the corresponding <em>BaseName_build.xml</em> (the real ANT
build script) and call this to build the module. The whole process including:
1. generate AutoGen.c and AutoGen.h; 2. build all dependent library instances;
3. build all source files inlcude AutoGen.c; 4. generate sections;
1. generate AutoGen.c and AutoGen.h;
2. build all dependent library instances;
3. build all source files inlcude AutoGen.c;
4. generate sections;
5. generate FFS file if it is driver module while LIB file if it is Library module.
</p>
@ -426,9 +431,9 @@ public class GenBuildTask extends Ant {
// Set cmd, like CC, DLINK
//
String[] key = new String[]{target, toolchain, fpdModuleId.getArch(), cmd[m], null};
key[4] = "PATH";
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_PATH;
String cmdPath = GlobalData.getCommandSetting(key, fpdModuleId);
key[4] = "NAME";
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_NAME;
String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
File cmdFile = new File(cmdPath + File.separatorChar + cmdName);
getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));
@ -436,7 +441,7 @@ public class GenBuildTask extends Ant {
//
// set CC_FLAGS
//
key[4] = "FLAGS";
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FLAGS;
String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);
Set<String> addset = new LinkedHashSet<String>();
Set<String> subset = new LinkedHashSet<String>();
@ -446,7 +451,7 @@ public class GenBuildTask extends Ant {
//
// Set CC_EXT
//
key[4] = "EXT";
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_EXT;
String extName = GlobalData.getCommandSetting(key, fpdModuleId);
if ( extName != null && ! extName.equalsIgnoreCase("")) {
getProject().setProperty(cmd[m] + "_EXT", extName);
@ -457,7 +462,7 @@ public class GenBuildTask extends Ant {
//
// set CC_FAMILY
//
key[4] = "FAMILY";
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_FAMILY;
String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
if (toolChainFamily != null) {
getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);
@ -466,7 +471,7 @@ public class GenBuildTask extends Ant {
//
// set CC_SPATH
//
key[4] = "SPATH";
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_SPATH;
String spath = GlobalData.getCommandSetting(key, fpdModuleId);
if (spath != null) {
getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
@ -477,7 +482,7 @@ public class GenBuildTask extends Ant {
//
// set CC_DPATH
//
key[4] = "DPATH";
key[4] = ToolDefinitions.TOOLS_DEF_ATTRIBUTE_DPATH;
String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
if (dpath != null) {
getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));

View File

@ -33,13 +33,8 @@ import java.util.Set;
import org.apache.tools.ant.BuildException;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.GuidsDocument;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.PPIsDocument;
import org.tianocore.ProtocolsDocument;
import org.tianocore.build.exception.*;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.Spd;
import org.tianocore.build.global.SurfaceAreaQuery;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.build.id.PackageIdentification;
@ -2043,7 +2038,6 @@ public class AutoGen {
private void collectLibInstanceInfo(){
int index;
String moduleType = SurfaceAreaQuery.getModuleType();
String libConstructName = null;
String libDestructName = null;
String[] setVirtuals = null;

View File

@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.SurfaceAreaQuery;

View File

@ -15,7 +15,6 @@
**/
package org.tianocore.build.autogen;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Set;

View File

@ -32,6 +32,7 @@ import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject;
import org.tianocore.common.definitions.EdkDefinitions;
import org.tianocore.common.exception.EdkException;
import org.tianocore.pcd.action.ActionMessage;
import org.tianocore.build.global.GlobalData;
@ -530,13 +531,7 @@ public class FpdParserTask extends Task {
throw new BuildException("Module type is not specified.");
}
String[][] suffix = { { "BASE", ".FFS"},
{ "SEC", ".SEC" }, { "PEI_CORE", ".PEI" },
{ "PEIM", ".PEI" }, { "DXE_CORE", ".DXE" },
{ "DXE_DRIVER", ".DXE" }, { "DXE_RUNTIME_DRIVER", ".DXE" },
{ "DXE_SAL_DRIVER", ".DXE" }, { "DXE_SMM_DRIVER", ".DXE" },
{ "TOOL", ".FFS" }, { "UEFI_DRIVER", ".DXE" },
{ "UEFI_APPLICATION", ".APP" }, { "USER_DEFINED", ".FFS" } };
String[][] suffix = EdkDefinitions.ModuleTypeExtensions;
for (int i = 0; i < suffix.length; i++) {
if (suffix[i][0].equalsIgnoreCase(moduleType)) {

View File

@ -16,14 +16,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.pcd.action;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.tianocore.build.autogen.CommonDefinition;
import org.tianocore.build.exception.PcdAutogenException;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.id.ModuleIdentification;
import org.tianocore.pcd.action.ActionMessage;

View File

@ -13,14 +13,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.pcd.action;
import java.io.File;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.tianocore.build.global.GlobalData;
import org.tianocore.pcd.entity.DynamicTokenValue;
import org.tianocore.pcd.entity.Token;
import org.tianocore.pcd.exception.EntityException;

View File

@ -30,7 +30,6 @@ import org.tianocore.DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitio
import org.tianocore.PcdBuildDefinitionDocument;
import org.tianocore.PlatformSurfaceAreaDocument;
import org.tianocore.build.exception.PlatformPcdPreprocessBuildException;
import org.tianocore.build.fpd.FpdParserTask;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.id.FpdModuleIdentification;
import org.tianocore.pcd.action.ActionMessage;

View File

@ -15,9 +15,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
package org.tianocore.build.toolchain;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
/**

View File

@ -113,7 +113,7 @@ public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainK
public int compareTo(ToolChainKey dstKey) {
String[] dstKeySet = dstKey.getKeySet();
int result = 0;
for (int i = 0; i < this.keyLength; ++i) {
for (int i = 0; i < ToolChainKey.keyLength; ++i) {
result = this.keySet[i].compareToIgnoreCase(dstKeySet[i]);
if (result != 0) {
break;
@ -138,11 +138,11 @@ public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainK
return true;
}
if (dstKeySet.length != this.keyLength) {
if (dstKeySet.length != ToolChainKey.keyLength) {
return false;
}
for (int i = 0; i < this.keyLength; ++i) {
for (int i = 0; i < ToolChainKey.keyLength; ++i) {
if (!this.keySet[i].equalsIgnoreCase(dstKeySet[i])) {
return false;
}
@ -157,16 +157,16 @@ public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainK
@param keySet The string array of key value
**/
public void setKey(String[] keySet) throws EdkException {
if (keySet.length != this.keyLength) {
if (keySet.length != ToolChainKey.keyLength) {
throw new EdkException("Invalid ToolChain key");
}
//
// Clone the string array because we don't want to change original one
//
this.keySet = new String[this.keyLength];
System.arraycopy(keySet, 0, this.keySet, 0, this.keyLength);
for (int i = 0; i < this.keyLength; ++i) {
this.keySet = new String[ToolChainKey.keyLength];
System.arraycopy(keySet, 0, this.keySet, 0, ToolChainKey.keyLength);
for (int i = 0; i < ToolChainKey.keyLength; ++i) {
if (this.keySet[i] == null || this.keySet[i].length() == 0) {
this.keySet[i] = "*";
}
@ -186,7 +186,7 @@ public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainK
@param index The key part index
**/
public void setKey(String keySetString, int index) throws EdkException {
if (index >= this.keyLength) {
if (index >= ToolChainKey.keyLength) {
throw new EdkException("Invalid ToolChain key index");
}
@ -213,7 +213,7 @@ public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainK
public void setKey(String keyString) throws EdkException {
this.keySet = keyString.split(this.delimiter);
if (this.keySet.length != this.keyLength) {
if (this.keySet.length != ToolChainKey.keyLength) {
throw new EdkException("Invalid ToolChain key");
}
@ -233,7 +233,7 @@ public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainK
public void setKey(String keyString, String delimiter) throws EdkException {
this.keySet = keyString.split(delimiter);
if (this.keySet.length != this.keyLength) {
if (this.keySet.length != ToolChainKey.keyLength) {
throw new EdkException("Invalid ToolChain key");
}
@ -264,7 +264,7 @@ public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainK
StringBuffer keyStringBuf = new StringBuffer(64);
keyStringBuf.append(this.keySet[0]);
for (int i = 1; i < this.keyLength; ++i) {
for (int i = 1; i < ToolChainKey.keyLength; ++i) {
keyStringBuf.append(this.delimiter);
keyStringBuf.append(this.keySet[i]);
}