import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.toolchain.ConfigReader;\r
import org.tianocore.build.toolchain.ToolChainInfo;\r
+import org.tianocore.common.definitions.ToolDefinitions;\r
\r
+/**\r
+ <p>\r
+ <code>FrameworkBuildTask</code> is an Ant task. The main function is finding\r
+ and processing a FPD or MSA file, then building a platform or stand-alone \r
+ module. \r
+ \r
+ <p>\r
+ The task search current directory and find out all MSA and FPD files by file\r
+ extension. Base on ACTIVE_PLATFORM policy, decide to build a platform or a\r
+ stand-alone module. The ACTIVE_PLATFORM policy is: \r
+ \r
+ <pre>\r
+ 1. More than one MSA files, report error; \r
+ 2. Only one MSA file, but ACTIVE_PLATFORM is not specified, report error;\r
+ 3. Only one MSA file, and ACTIVE_PLATFORM is also specified, build this module;\r
+ 4. No MSA file, and ACTIVE_PLATFORM is specified, build the active platform;\r
+ 5. No MSA file, no ACTIVE_PLATFORM, and no FPD file, report error;\r
+ 6. No MSA file, no ACTIVE_PLATFORM, and only one FPD file, build the platform;\r
+ 7. No MSA file, no ACTIVE_PLATFORM, and more than one FPD files, list all platform\r
+ and let user choose one. \r
+ </pre>\r
+ \r
+ <p>\r
+ Framework build task also parse target file [${WORKSPACE_DIR}/Tools/Conf/target.txt].\r
+ And load all system environment variables to Ant properties. \r
+ \r
+ <p>\r
+ The usage for this task is : \r
+ \r
+ <pre>\r
+ <FrameworkBuild type="cleanall" />\r
+ </pre>\r
+ \r
+ @since GenBuild 1.0\r
+**/\r
public class FrameworkBuildTask extends Task{\r
\r
private Set<File> buildFiles = new LinkedHashSet<File>();\r
\r
private Set<File> msaFiles = new LinkedHashSet<File>();\r
\r
- String toolsDefFilename = "Tools" + File.separatorChar + "Conf" + File.separatorChar + "tools_def.txt";\r
+ String toolsDefFilename = ToolDefinitions.DEFAULT_TOOLS_DEF_FILE_PATH;\r
+ \r
+ String targetFilename = ToolDefinitions.TARGET_FILE_PATH;\r
\r
- String targetFilename = "target.txt";\r
+ String dbFilename = ToolDefinitions.FRAMEWORK_DATABASE_FILE_PATH;\r
\r
String activePlatform = null;\r
\r
//\r
buildFiles.add(files[i]);\r
\r
- } else if (files[i].getName().endsWith(".fpd")) {\r
+ } else if (files[i].getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {\r
//\r
// Second, search FPD file, if found, build it\r
//\r
fpdFiles.add(files[i]);\r
- } else if (files[i].getName().endsWith(".msa")) {\r
+ } else if (files[i].getName().endsWith(ToolDefinitions.MSA_EXTENSION)) {\r
//\r
// Third, search MSA file, if found, build it\r
//\r
//\r
File workspacePath = new File(getProject().getProperty("WORKSPACE"));\r
getProject().setProperty("WORKSPACE_DIR", workspacePath.getPath().replaceAll("(\\\\)", "/"));\r
- GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db",\r
- workspacePath.getPath(), toolsDefFilename);\r
- \r
-\r
+ GlobalData.initInfo(dbFilename, workspacePath.getPath(), toolsDefFilename);\r
\r
//\r
// If find MSA file and ACTIVE_PLATFORM is set, build the module; \r
if (msaFiles.size() > 1) {\r
throw new BuildException("Having more than one MSA file in a directory is not allowed!");\r
} else if (msaFiles.size() == 1 && activePlatform == null) {\r
- throw new BuildException("If trying to build a single module, please set ACTIVE_PLATFORM in file [Tool/Conf/target.txt]. ");\r
+ throw new BuildException("If trying to build a single module, please set ACTIVE_PLATFORM in file [" + targetFilename + "]. ");\r
} else if (msaFiles.size() == 1 && activePlatform != null) {\r
//\r
// Build the single module\r
//\r
// Build every FPD files (PLATFORM build)\r
//\r
- if (buildFile.getName().endsWith(".fpd")) {\r
+ if (buildFile.getName().endsWith(ToolDefinitions.FPD_EXTENSION)) {\r
System.out.println("Processing the FPD file [" + buildFile.getPath() + "] ..>> ");\r
FpdParserTask fpdParserTask = new FpdParserTask();\r
fpdParserTask.setType(type);\r
//\r
// Build every MSA files (SINGLE MODULE BUILD)\r
//\r
- else if (buildFile.getName().endsWith(".msa")) {\r
+ else if (buildFile.getName().endsWith(ToolDefinitions.MSA_EXTENSION)) {\r
File tmpFile = new File(GlobalData.getWorkspacePath() + File.separatorChar + activePlatform);\r
System.out.println("Using the FPD file [" + tmpFile.getPath() + "] for the active platform. ");\r
System.out.println("Processing the MSA file [" + buildFile.getPath() + "] ..>> ");\r
\r
private void readTargetFile(){\r
try {\r
- String[][] targetFileInfo = ConfigReader.parse(getProject().getProperty("WORKSPACE_DIR"), "Tools" + File.separatorChar + "Conf" + File.separatorChar + targetFilename);\r
+ String targetFile = getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + targetFilename;\r
+ \r
+ String[][] targetFileInfo = ConfigReader.parse(targetFile);\r
\r
//\r
// Get ToolChain Info from target.txt\r
//\r
ToolChainInfo envToolChainInfo = new ToolChainInfo(); \r
- String str = getValue("TARGET", targetFileInfo);\r
+ String str = getValue(ToolDefinitions.TARGET_KEY_TARGET, targetFileInfo);\r
if (str == null || str.trim().equals("")) {\r
envToolChainInfo.addTargets("*");\r
} else {\r
envToolChainInfo.addTargets(str);\r
}\r
- str = getValue("TOOL_CHAIN_TAG", targetFileInfo);\r
+ str = getValue(ToolDefinitions.TARGET_KEY_TOOLCHAIN, targetFileInfo);\r
if (str == null || str.trim().equals("")) {\r
envToolChainInfo.addTagnames("*");\r
} else {\r
envToolChainInfo.addTagnames(str);\r
}\r
- str = getValue("TARGET_ARCH", targetFileInfo);\r
+ str = getValue(ToolDefinitions.TARGET_KEY_ARCH, targetFileInfo);\r
if (str == null || str.trim().equals("")) {\r
envToolChainInfo.addArchs("*");\r
} else {\r
}\r
GlobalData.setToolChainEnvInfo(envToolChainInfo);\r
\r
- str = getValue("TOOL_CHAIN_CONF", targetFileInfo);\r
+ str = getValue(ToolDefinitions.TARGET_KEY_TOOLS_DEF, targetFileInfo);\r
if (str != null && str.trim().length() > 0) {\r
toolsDefFilename = str;\r
}\r
\r
- str = getValue("ACTIVE_PLATFORM", targetFileInfo);\r
+ str = getValue(ToolDefinitions.TARGET_KEY_ACTIVE_PLATFORM, targetFileInfo);\r
if (str != null && ! str.trim().equals("")) {\r
if ( ! str.endsWith(".fpd")) {\r
- throw new BuildException("FPD file's extension must be \".fpd\"!");\r
+ throw new BuildException("FPD file's extension must be \"" + ToolDefinitions.FPD_EXTENSION + "\"!");\r
}\r
activePlatform = str;\r
}\r