X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2FFrameworkBuildTask.java;h=fe7a8ce70da7475efe752f7ae7e843e41b46fb83;hp=2617f06bdd6961f87bfe1ebbdbb2ceae2c0bda94;hb=2d16dcec6f602d218ae95a823fca6ae542e03a8f;hpb=391dbbb1c00daefe78e7e44499d048943ca866ae
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
index 2617f06bdd..fe7a8ce70d 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
@@ -27,7 +27,43 @@ 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;
+/**
+
+ FrameworkBuildTask
is an Ant task. The main function is finding
+ and processing a FPD or MSA file, then building a platform or stand-alone
+ module.
+
+
+ The task search current directory and find out all MSA and FPD files by file
+ extension. Base on ACTIVE_PLATFORM policy, decide to build a platform or a
+ stand-alone module. The ACTIVE_PLATFORM policy is:
+
+
+ 1. More than one MSA files, report error;
+ 2. Only one MSA file, but ACTIVE_PLATFORM is not specified, report error;
+ 3. Only one MSA file, and ACTIVE_PLATFORM is also specified, build this module;
+ 4. No MSA file, and ACTIVE_PLATFORM is specified, build the active platform;
+ 5. No MSA file, no ACTIVE_PLATFORM, and no FPD file, report error;
+ 6. No MSA file, no ACTIVE_PLATFORM, and only one FPD file, build the platform;
+ 7. No MSA file, no ACTIVE_PLATFORM, and more than one FPD files, list all platform
+ and let user choose one.
+
+
+
+ Framework build task also parse target file [${WORKSPACE_DIR}/Tools/Conf/target.txt].
+ And load all system environment variables to Ant properties.
+
+
+ The usage for this task is :
+
+
+ <FrameworkBuild type="cleanall" />
+
+
+ @since GenBuild 1.0
+**/
public class FrameworkBuildTask extends Task{
private Set buildFiles = new LinkedHashSet();
@@ -36,9 +72,11 @@ public class FrameworkBuildTask extends Task{
private Set msaFiles = new LinkedHashSet();
- String toolsDefFilename = "Tools" + File.separatorChar + "Conf" + File.separatorChar + "tools_def.txt";
+ String toolsDefFilename = ToolDefinitions.DEFAULT_TOOLS_DEF_FILE_PATH;
+
+ String targetFilename = ToolDefinitions.TARGET_FILE_PATH;
- String targetFilename = "target.txt";
+ String dbFilename = ToolDefinitions.FRAMEWORK_DATABASE_FILE_PATH;
String activePlatform = null;
@@ -66,12 +104,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,10 +136,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);
//
// If find MSA file and ACTIVE_PLATFORM is set, build the module;
@@ -113,23 +148,18 @@ public class FrameworkBuildTask extends Task{
File buildFile = null;
if (msaFiles.size() > 1) {
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 [Tool/Conf/target.txt]. ");
- }
- else if (msaFiles.size() == 1 && activePlatform != null) {
+ } 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();
}
//
@@ -142,7 +172,7 @@ public class FrameworkBuildTask extends Task{
//
// Build every FPD files (PLATFORM build)
//
- if (buildFile.getName().endsWith(".fpd")) {
+ if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {
System.out.println("Processing the FPD file [" + buildFile.getPath() + "] ..>> ");
FpdParserTask fpdParserTask = new FpdParserTask();
fpdParserTask.setType(type);
@@ -154,7 +184,7 @@ 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 the FPD file [" + tmpFile.getPath() + "] for the active platform. ");
System.out.println("Processing the MSA file [" + buildFile.getPath() + "] ..>> ");
@@ -191,20 +221,16 @@ 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 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("Finding " + 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());
}
@@ -234,13 +260,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,52 +270,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[][] targetFileInfo = ConfigReader.parse(getProject().getProperty("WORKSPACE_DIR"), "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 extension must be \".fpd\"!");
+ throw new BuildException("FPD file's extension must be \"" + ToolDefinitions.FPD_EXTENSION + "\"!");
}
activePlatform = str;
}