From a29c47e01d9689fad735bbeccfaef67676a425d1 Mon Sep 17 00:00:00 2001
From: wuyizhong
Date: Fri, 30 Jun 2006 18:17:09 +0000
Subject: Change to new XML Schema.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@687 6f19259b-4bc3-4df7-8a09-765794883524
---
.../GenBuild/org/tianocore/build/ExpandTask.java | 54 -
.../GenBuild/org/tianocore/build/FfsProcess.java | 50 +-
.../GenBuild/org/tianocore/build/FileProcess.java | 113 +-
.../org/tianocore/build/FrameworkBuildTask.java | 210 ++
.../GenBuild/org/tianocore/build/GenBuildTask.java | 1480 +++++---------
.../tianocore/build/ModuleBuildFileGenerator.java | 591 ++++++
.../org/tianocore/build/OutputDirSetup.java | 271 +++
.../org/tianocore/build/OutputDirSetupTask.java | 190 --
.../org/tianocore/build/autogen/AutoGen.java | 1104 +++++------
.../tianocore/build/autogen/AutogenLibOrder.java | 122 +-
.../tianocore/build/autogen/CommonDefinition.java | 86 +-
.../build/exception/AutoGenException.java | 39 +
.../tianocore/build/exception/EdkException.java | 36 +
.../build/exception/GenBuildException.java | 40 +
.../build/exception/PcdAutogenException.java | 35 +
.../build/exception/TianoToolsException.java | 41 +
.../build/exception/XmlParseException.java | 35 +
.../build/fpd/FpdModuleIdentification.java | 131 --
.../org/tianocore/build/fpd/FpdParserTask.java | 930 ++++-----
.../build/fpd/PlatformBuildFileGenerator.java | 479 +++++
.../org/tianocore/build/global/GlobalData.java | 1079 +++++-----
.../org/tianocore/build/global/GlobalShare.java | 178 --
.../build/global/LibBuildFileGenerator.java | 412 ----
.../build/global/ModuleIdentification.java | 55 -
.../org/tianocore/build/global/OutputManager.java | 272 +--
.../tianocore/build/global/OverrideProcess.java | 361 ----
.../GenBuild/org/tianocore/build/global/Spd.java | 481 ++---
.../tianocore/build/global/SurfaceAreaParser.java | 213 --
.../tianocore/build/global/SurfaceAreaQuery.java | 2085 ++++++++++++++------
.../build/id/FpdModuleIdentification.java | 108 +
.../org/tianocore/build/id/Identification.java | 74 +
.../tianocore/build/id/ModuleIdentification.java | 124 ++
.../tianocore/build/id/PackageIdentification.java | 73 +
.../tianocore/build/id/PlatformIdentification.java | 43 +
.../tianocore/build/toolchain/ConfigReader.java | 172 +-
.../build/toolchain/ToolChainAttribute.java | 37 +
.../tianocore/build/toolchain/ToolChainConfig.java | 142 ++
.../build/toolchain/ToolChainElement.java | 35 +
.../build/toolchain/ToolChainFactory.java | 529 -----
.../tianocore/build/toolchain/ToolChainInfo.java | 219 ++
.../tianocore/build/toolchain/ToolChainKey.java | 177 ++
.../tianocore/build/toolchain/ToolChainMap.java | 165 ++
.../tianocore/build/toolchain/ToolChainTask.java | 17 +-
43 files changed, 7020 insertions(+), 6068 deletions(-)
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/ExpandTask.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/OutputDirSetup.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/OutputDirSetupTask.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/exception/AutoGenException.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/exception/EdkException.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/exception/XmlParseException.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/fpd/FpdModuleIdentification.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/global/GlobalShare.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/global/LibBuildFileGenerator.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/global/ModuleIdentification.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/global/SurfaceAreaParser.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/id/FpdModuleIdentification.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/id/Identification.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/id/ModuleIdentification.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/id/PackageIdentification.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/id/PlatformIdentification.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainAttribute.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainConfig.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainElement.java
delete mode 100644 Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainFactory.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainInfo.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainKey.java
create mode 100644 Tools/Source/GenBuild/org/tianocore/build/toolchain/ToolChainMap.java
(limited to 'Tools/Source/GenBuild')
diff --git a/Tools/Source/GenBuild/org/tianocore/build/ExpandTask.java b/Tools/Source/GenBuild/org/tianocore/build/ExpandTask.java
deleted file mode 100644
index c4c53e04b9..0000000000
--- a/Tools/Source/GenBuild/org/tianocore/build/ExpandTask.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/** @file
- This file is ANT task Expand.
-
- Expand task is used to prepare ANT properties for further build.
-
-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.
-
-**/
-package org.tianocore.build;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-import org.tianocore.build.global.GlobalData;
-
-/**
- Expand task is used to prepare ANT properties for further build.
-
Current, prepare the dependent Library instance list for LIBS
-
- @since GenBuild 1.0
-**/
-public class ExpandTask extends Task {
-
- /**
- Public construct method. It is necessary for ANT task.
- **/
- public ExpandTask () {
- }
-
- /**
- ANT task's entry point, will be called after init().
-
- Set LIBS for further build usage.
- **/
- public void execute() throws BuildException {
- String basename = getProject().getProperty("BASE_NAME");
- String arch = getProject().getProperty("ARCH");
- arch = arch.toUpperCase();
- String[] libraries = GlobalData.getModuleLibrary(basename, arch);
- String str = "";
- for (int i = 0; i < libraries.length; i ++){
- str += " " + GlobalData.getLibrary(libraries[i], arch);
- }
- getProject().setProperty("LIBS", str);
-
- }
-}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java b/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java
index 267a50e4e3..02eca2abef 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/FfsProcess.java
@@ -26,6 +26,10 @@ import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.xmlbeans.XmlCursor;
import org.apache.xmlbeans.XmlObject;
+import org.tianocore.BuildOptionsDocument;
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.id.FpdModuleIdentification;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
@@ -60,6 +64,8 @@ public class FfsProcess {
/// Xml Document Node for corresponding FFS layout
///
private Node ffs;
+
+ private BuildOptionsDocument.BuildOptions.Ffs ffsXmlObject;
///
/// ANT script to call GenFfs
@@ -131,11 +137,31 @@ public class FfsProcess {
@throws BuildException
If specified COMMON_FILE XML file is not valide.
**/
- public boolean initSections(String buildType, Project project) throws BuildException {
+ public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException {
//
- // first try to sections defined in PLATFORM level
+ // Firstly, try to find in ModuleSA
//
-
+// BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getModuleFfs();
+// for (int i = 0; i < ffsArray.length; i++) {
+// if (isMatch(ffsArray[i].getFfsKey(), buildType)) {
+// ffsXmlObject = ffsArray[i];
+// return true;
+// }
+// }
+
+ //
+ // secondly, try to sections defined in PLATFORM level
+ //
+ SurfaceAreaQuery.push(GlobalData.getFpdBuildOptions());
+ BuildOptionsDocument.BuildOptions.Ffs[] ffsArray = SurfaceAreaQuery.getFpdFfs();
+ SurfaceAreaQuery.pop();
+ for (int i = 0; i < ffsArray.length; i++) {
+ if (isMatch(ffsArray[i].getFfsKey(), buildType)) {
+ ffsXmlObject = ffsArray[i];
+ return true;
+ }
+ }
+
//
// if module specify sections itself, it's okay
// otherwise find sections from WORKSPACE default setting with
@@ -194,22 +220,30 @@ public class FfsProcess {
**/
public String[] getGenSectionElements(Document document, String basename, String guid, String targetFilename) {
this.basename = basename;
- if (ffs == null) {
+ if (ffs == null && ffsXmlObject == null) {
return new String[0];
}
Vector sectionList = new Vector();
XmlCursor cursor = null;
try {
- cursor = XmlObject.Factory.parse(ffs).newCursor();
+ if (ffsXmlObject == null) {
+ cursor = XmlObject.Factory.parse(ffs).newCursor();
+ }
+ else {
+ cursor = ffsXmlObject.newCursor();
+ }
} catch (Exception e) {
return null;
}
int mode = MODE_NONE;
Element root = document.createElement("genffsfile");
root.setAttribute("outputDir", "${BIN_DIR}");
+ root.setAttribute("moduleType", "${MODULE_TYPE}");
root.setAttribute("BaseName", basename);
root.setAttribute("fileGuid", guid);
- cursor.toFirstChild();
+ if (ffsXmlObject == null) {
+ cursor.toFirstChild();
+ }
if (cursor.toFirstChild()) {
do {
if (cursor.getName().getLocalPart().equalsIgnoreCase("Attribute")) {
@@ -315,7 +349,7 @@ public class FfsProcess {
// outputPath = "${DEST_DIR_OUTPUT}">
//
ele = doc.createElement("tool");
- ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "bin"
+ ele.setAttribute("toolName", "${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "Bin"
+ File.separatorChar + "GenCRC32Section");
ele.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");
}
@@ -365,7 +399,7 @@ public class FfsProcess {
}
/**
- Get the corresponding section file suffix.
+ Get the corresponding section file suffix.
@param type Section type
@return Corresponding section file extension
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java b/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
index 87650af827..e615802c00 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/FileProcess.java
@@ -16,6 +16,7 @@ package org.tianocore.build;
import java.io.File;
import java.util.Set;
+import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -29,17 +30,24 @@ import org.w3c.dom.Node;
by its extension. Following is the current supported extensions.
- .c | C_Code
- .asm | Assembly
- .s | IPF_Assembly_Code
- .h | Header
- .lib | Static_Library
- .i | IPF_PP_Code
- .vfr | Vfr
- .uni | Unicode
- .dxs | Dependency_File
- .bmp | Graphics
- .efi | EFI
+ Source File Suffix File Type Description
+ .h CHeader C header file
+ .c CCode C source file
+ .inc ASMHeader Assembly header file
+ .asm ASM Assembly source file, usually for IA32 and X64 Arch and MSFT tool chain
+ .S ASM Assembly source file, usually for IPF Arch
+ .s ASM Assembly source file, usually for IA32 and X64 Arch and GCC tool chain
+ .uni UNI Unicode file
+ .vfr VFR Visual Forms Representation File
+ .fv FV Firmware Volume
+ .SEC FFS Firmware File System file
+ .PEI FFS Firmware File System file
+ .DXE FFS Firmware File System file
+ .APP FFS Firmware File System file
+ .FVI FFS Firmware File System file
+ .FFS FFS Firmware File System file
+ .bmp BMP Graphic File
+ .i PPCode IPF PreProcessor Code
@since GenBuild 1.0
@@ -48,13 +56,25 @@ public class FileProcess {
///
/// The mapping information about source suffix, result suffix, file type.
///
- public final String[][] fileTypes = { { ".c", ".obj", "C_Code" }, { ".asm", ".obj", "Assembly" },
- { ".s", ".obj", "IPF_Assembly_Code" }, { ".h", "", "Header" },
- { ".lib", "", "Static_Library" }, { ".src", ".c", "" },
- { ".i", ".obj", "IPF_PP_Code" }, { ".vfr", ".obj", "Vfr" },
- { ".uni", "", "Unicode" }, { ".dxs", "", "Dependency_File" },
- { ".bmp", "", "Graphics" }, { ".efi", "", "EFI" } };
-
+ public final String[][] fileTypes = { {".h", "", "CHeader" },
+ {".c", "", "CCode" },
+ {".inc", "", "ASMHeader" },
+ {".asm", "", "ASM" },
+ {".S", "", "ASM" },
+ {".s", "", "ASM" },
+ {".uni", "", "UNI" },
+ {".vfr", "", "VFR" },
+ {".dxs", "", "DPX"},
+ {".fv", "", "FV" },
+ {".efi", "", "EFI" },
+ {".SEC", "", "FFS" },
+ {".PEI", "", "FFS" },
+ {".DXE", "", "FFS" },
+ {".APP", "", "FFS" },
+ {".FYI", "", "FFS" },
+ {".FFS", "", "FFS" },
+ {".bmp", "", "BMP" },
+ {".i", "", "PPCode"}};
///
/// Current ANT context.
///
@@ -64,11 +84,6 @@ public class FileProcess {
/// Current module's include pathes
///
private Set includes;
-
- ///
- /// Current source files.
- ///
- private Set sourceFiles;
///
/// Xml Document.
@@ -93,11 +108,10 @@ public class FileProcess {
@param sourceFiles Modules source files
@param document XML document
**/
- public void init(Project project, Set includes, Set sourceFiles, Document document) {
+ public void init(Project project, Set includes, Document document) {
this.document = document;
this.includes = includes;
this.project = project;
- this.sourceFiles = sourceFiles;
}
/**
@@ -140,16 +154,16 @@ public class FileProcess {
@param filename Source file name
@param root Root node
**/
- public synchronized void parseFile(String filename, Node root) {
+ public synchronized void parseFile(String filename, Node root) throws BuildException {
boolean flag = false;
for (int i = 0; i < fileTypes.length; i++) {
- if (filename.toLowerCase().endsWith(fileTypes[i][0])) {
+ if (filename.endsWith(fileTypes[i][0])) {
flag = true;
parseFile(filename, fileTypes[i][2], root);
}
}
if (!flag) {
- System.out.println("Warning: File " + filename + " is not known from its suffix.");
+ throw new BuildException("File [" + filename + "] is not known from its suffix.");
}
}
@@ -167,31 +181,58 @@ public class FileProcess {
**/
public synchronized void parseFile(String filename, String filetype, Node root) {
if (unicodeFirst) {
- if ( ! filetype.equalsIgnoreCase("Unicode")){
+ if ( ! filetype.equalsIgnoreCase("UNI")){
return ;
}
unicodeExist= true;
} else {
- if (filetype.equalsIgnoreCase("Unicode")){
+ if (filetype.equalsIgnoreCase("UNI")){
return ;
}
}
- sourceFiles.add(filename);
- if (filetype.equalsIgnoreCase("Header")) {
+
+ //
+ // If file is C or ASM header file, skip it
+ //
+ if (filetype.equalsIgnoreCase("CHeader") || filetype.equalsIgnoreCase("ASMHeader")) {
return;
}
- if (filetype.equalsIgnoreCase("IPF_PP_Code")) {
+
+ //
+ // If file is pre-processor file, skip it
+ //
+ if (filetype.equalsIgnoreCase("PPCode")) {
return;
}
+
+ //
+ // If define CC_EXT in tools_def.txt file, the source file with
+ // different suffix is skipped
+ //
+ String toolsDefExtName = project.getProperty(filetype + "_EXT");
+ if (toolsDefExtName != null) {
+ String[] exts = toolsDefExtName.split(" ");
+ for (int i = 0; i < exts.length; i++) {
+ if ( ! filename.endsWith(exts[i])) {
+ return ;
+ }
+ }
+ }
+
String module_path = project.getProperty("MODULE_DIR");
File moduleFile = new File(module_path);
File sourceFile = new File(filename);
+
+ //
// If source file is AutoGen.c, then Filepath is .
- String sourceFilepath;
- String sourceFilename;
+ //
+ String sourceFilepath = "";
+ String sourceFilename = "";
+ String sourceFileext = "";
if (sourceFile.getPath().endsWith("AutoGen.c")) {
sourceFilepath = ".";
sourceFilename = "AutoGen";
+ sourceFileext = ".c";
filetype = "AUTOGEN";
} else {
// sourceFile.
@@ -206,12 +247,14 @@ public class FileProcess {
index = str.lastIndexOf('.');
if (index > 0) {
sourceFilename = str.substring(0, index);
+ sourceFileext = str.substring(index);
}
}
//
Element ele = document.createElement("Build_" + filetype);
ele.setAttribute("FILEPATH", sourceFilepath);
ele.setAttribute("FILENAME", sourceFilename);
+ ele.setAttribute("FILEEXT", sourceFileext.substring(1));
String[] includePaths = includes.toArray(new String[includes.size()]);
Element includesEle = document.createElement("EXTRA.INC");
for (int i = 0; i < includePaths.length; i++) {
diff --git a/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
new file mode 100644
index 0000000000..b9afc57bad
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/FrameworkBuildTask.java
@@ -0,0 +1,210 @@
+package org.tianocore.build;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.InputStreamReader;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.tianocore.build.fpd.FpdParserTask;
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.toolchain.ToolChainInfo;
+
+public class FrameworkBuildTask extends Task{
+
+ private Set buildFiles = new LinkedHashSet();
+
+ private Set fpdFiles = new LinkedHashSet();
+
+ private Set msaFiles = new LinkedHashSet();
+
+ ///
+ /// there are three type: all (build), clean and cleanall
+ ///
+ private String type = "all";
+
+ public void execute() throws BuildException {
+ //
+ // Seach build.xml -> .FPD -> .MSA file
+ //
+ try {
+ //
+ // Gen Current Working Directory
+ //
+ File dummyFile = new File(".");
+ File cwd = dummyFile.getCanonicalFile();
+ File[] files = cwd.listFiles();
+ for (int i = 0; i < files.length; i++) {
+ if (files[i].isFile()) {
+ if (files[i].getName().equalsIgnoreCase("build.xml")) {
+ //
+ // First, search build.xml, if found, ANT call it
+ //
+ buildFiles.add(files[i]);
+
+ } else if (files[i].getName().endsWith(".fpd")) {
+ //
+ // Second, search FPD file, if found, build it
+ //
+ fpdFiles.add(files[i]);
+ } else if (files[i].getName().endsWith(".msa")) {
+ //
+ // Third, search MSA file, if found, build it
+ //
+ msaFiles.add(files[i]);
+ }
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new BuildException(e.getMessage());
+ }
+
+ //
+ // If there is no build files or FPD files or MSA files, stop build
+ //
+ if (fpdFiles.size() == 0 && msaFiles.size() == 0) {
+ throw new BuildException("Can't find any build.xml file or FPD files or MSA files in current directory. ");
+ }
+
+ File buildFile = intercommuniteWithUser();
+ System.out.println("Start to build file [" + buildFile.getPath() + "] ..>> ");
+
+ //
+ // Deal with all environment variable (Add them to properties)
+ //
+ backupSystemProperties();
+
+ //
+ // Get ToolChain Info from environment
+ //
+ ToolChainInfo envToolChainInfo = new ToolChainInfo();
+ envToolChainInfo.addTargets(getProject().getProperty("TARGET"));
+ envToolChainInfo.addTagnames(getProject().getProperty("TAGNAME"));
+ envToolChainInfo.addArchs(getProject().getProperty("ARCH"));
+ GlobalData.setToolChainEnvInfo(envToolChainInfo);
+
+ //
+ // Global Data initialization
+ //
+ String toolsDefFilename = "tools_def.txt";
+ if (getProject().getProperty("TOOLS_DEF") != null) {
+ toolsDefFilename = getProject().getProperty("TOOLS_DEF");
+ }
+
+ GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db",
+ getProject().getProperty("WORKSPACE_DIR"), toolsDefFilename);
+
+ //
+ // Build every FPD files (PLATFORM build)
+ //
+ if (buildFile.getName().endsWith(".fpd")) {
+ FpdParserTask fpdParserTask = new FpdParserTask();
+ fpdParserTask.setType(type);
+ fpdParserTask.setProject(getProject());
+ fpdParserTask.setFpdFile(buildFile);
+ fpdParserTask.execute();
+ }
+
+ //
+ // Build every MSA files (SINGLE MODULE BUILD)
+ //
+ else if (buildFile.getName().endsWith(".msa")) {
+ GenBuildTask genBuildTask = new GenBuildTask();
+ genBuildTask.setType(type);
+ genBuildTask.setProject(getProject());
+ genBuildTask.setMsaFile(buildFile);
+ genBuildTask.execute();
+ }
+ }
+
+ /**
+ Transfer system environment variables to ANT properties. If system variable
+ already exiests in ANT properties, skip it.
+
+ **/
+ private void backupSystemProperties() {
+ Map sysProperties = System.getenv();
+ Set keys = sysProperties.keySet();
+ Iterator iter = keys.iterator();
+ while (iter.hasNext()) {
+ String name = iter.next();
+
+ //
+ // If system environment variable is not in ANT properties, add it
+ //
+ if (getProject().getProperty(name) == null) {
+ getProject().setProperty(name, sysProperties.get(name));
+ }
+ }
+ }
+
+ private File intercommuniteWithUser(){
+ File file = null;
+ if (fpdFiles.size() + msaFiles.size() > 1) {
+ File[] allFiles = new File[fpdFiles.size() + msaFiles.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("Find " + allFiles.length + " FPD and MSA 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] ");
+ do{
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+ try {
+ String str = br.readLine();
+ if (str.trim().length() == 0) {
+ file = allFiles[0];
+ flag = false;
+ continue ;
+ }
+ int indexSelect = Integer.parseInt(str);
+ if (indexSelect <=0 || indexSelect > allFiles.length) {
+ System.out.print("Please enter a number between [1.." + allFiles.length + "]:[1] ");
+ continue ;
+ } else {
+ file = allFiles[indexSelect - 1];
+ flag = false;
+ continue ;
+ }
+ } catch (Exception e) {
+ System.out.print("Please enter a valid number:[1] ");
+ flag = true;
+ }
+ } while (flag);
+ }
+ 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;
+ }
+
+
+ public void setType(String type) {
+ if (type.equalsIgnoreCase("clean") || type.equalsIgnoreCase("cleanall")) {
+ this.type = type.toLowerCase();
+ }
+ else {
+ this.type = "all";
+ }
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
index 3127b8706d..0e807f8abb 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/GenBuildTask.java
@@ -16,56 +16,42 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
package org.tianocore.build;
import java.io.File;
-import java.util.HashMap;
-import java.util.HashSet;
+import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.Stack;
import java.util.Vector;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Ant;
+import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.tianocore.build.autogen.AutoGen;
-import org.tianocore.build.autogen.CommonDefinition;
+import org.tianocore.build.exception.EdkException;
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;
-import org.tianocore.build.toolchain.ToolChainFactory;
-import org.tianocore.logger.EdkLog;
-import org.tianocore.FilenameDocument;
-import org.tianocore.MsaHeaderDocument;
-import org.tianocore.MsaLibHeaderDocument;
+import org.tianocore.build.id.FpdModuleIdentification;
+import org.tianocore.build.id.ModuleIdentification;
+import org.tianocore.build.id.PackageIdentification;
+import org.tianocore.build.id.PlatformIdentification;
+import org.tianocore.build.tools.ModuleItem;
/**
GenBuildTask 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,
then generate the corresponding BaseName_build.xml (the real ANT
- build script) and call this to build the module.
+ 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;
+ 5. generate FFS file if it is driver module while LIB file if it is Library module.
processTo provides a way to customize the whole build process.
+ processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.
+ Default is ALL, means whole
+
+
This task calls AutoGen to generate AutoGen.c and
AutoGen.h. The task also parses the development environment
@@ -88,85 +79,30 @@ import org.tianocore.MsaLibHeaderDocument;
@since GenBuild 1.0
**/
-public class GenBuildTask extends Task {
-
+public class GenBuildTask extends Ant {
+
///
/// Module surface area file.
///
- File msaFilename;
-
- ///
- /// Module build description file.
- ///
- File mbdFilename;
-
- ///
- /// Module surface area information after overrided.
- ///
- public Map map = new HashMap();
-
- ///
- /// Module's base name.
- ///
- private String baseName;
+ File msaFile;
///
- /// Current build Arch, such as IA32, X64, IPF and so on.
- ///
- private String arch;
-
- ///
- /// Module's GUID (Globally Unique Identifier).
- ///
- private String guid;
-
- ///
- /// Module's component type, such as SEC, LIBRARY, BS_DRIVER and so on.
- ///
- private String componentType;
-
- ///
- /// This value is used in build time. Override module's component type. When
- /// search FFS (Sections information) in common file, buildtype instead of
- /// component type.
- ///
- private String buildType;
-
- ///
- /// List all required includes for current build module.
- ///
- public Set includes = new LinkedHashSet();
-
- ///
- /// List all libraries for current build module.
- ///
- public Set libraries = new LinkedHashSet();
-
- ///
- /// List all source files for current build module.
- ///
- public Set sourceFiles = new LinkedHashSet();
-
- ///
- /// Flag to identify what surface area files are specified. Current value is
- /// NO_SA, ONLY_MSA, ONLY_LIBMSA,
- /// MSA_AND_MBD or LIBMSA_AND_LIBMBD.
///
- /// @see org.tianocore.build.global.GlobaData
///
- private int flag = GlobalData.NO_SA;
-
+ private String type = "all"; // = "build";
+
///
- /// The information at the header of build.xml.
+ /// Module's Identification.
///
- private String info = "====================================================================\n"
- + "DO NOT EDIT \n"
- + "File auto-generated by build utility\n"
- + "\n"
- + "Abstract:\n"
- + "Auto-generated ANT build file for building of EFI Modules/Platforms\n"
- + "=====================================================================";
+ private ModuleIdentification moduleId;
+ private Vector properties = new Vector();
+
+ private static Stack backupPropertiesStack = new Stack();
+
+
+ private static Hashtable backupProperties;
+
/**
Public construct method. It is necessary for ANT task.
**/
@@ -174,945 +110,537 @@ public class GenBuildTask extends Task {
}
/**
- ANT task's entry point, will be called after init(). The main steps is described
- as following:
-
-
Judge current build mode (MODULE | PACKAGE | PLATFORM). This step will execute
- only once in whole build process;
-
Initialize global information (Framework DB, SPD files and all MSA files
- listed in SPD). This step will execute only once in whole build process;
-
Restore some important ANT property. If current build is single module
- build, here will set many default values;
-
Get the current module's overridded surface area information from
- global data;
-
Set up the output directories, including BIN_DIR, DEST_DIR_OUTPUT and
- DEST_DIR_DEBUG;
-
Get module dependent library instances and include pathes;
-
Judge whether current module is built. If yes, skip it;
-
Call AutoGen and PCD to generate AutoGen.c & AutoGen.h
-
Set up the compile flags;
-
Generate BaseName_build.xml;
-
Call to BaseName_build.xml, and build the current module.
-
-
-
Build is dependent on BuildMacro.xml which define many macro.
-
+
@throws BuildException
From module build, exception from module surface area invalid.
**/
public void execute() throws BuildException {
- System.out.println("Module [" + baseName + "] start.");
- //
- // Inital GenBuild log method
- //
- GenBuildLogger logger = new GenBuildLogger(getProject());
- EdkLog.setLogger(logger);
- EdkLog.setLogLevel(1);
-
- OutputManager.update(getProject());
- GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db",
- getProject().getProperty("WORKSPACE_DIR"));
- recallFixedProperties();
- arch = getProject().getProperty("ARCH");
- arch = arch.toUpperCase();
- map = GlobalData.getDoc(baseName);
- //
- // Initialize SurfaceAreaQuery
- //
- SurfaceAreaQuery.setDoc(map);
- //
- // Setup Output Management
- //
- String[] outdir = SurfaceAreaQuery.getOutputDirectory();
- OutputManager.update(getProject(), outdir[1], outdir[0]);
-
- updateIncludesAndLibraries();
-
- if (GlobalData.isModuleBuilt(baseName, arch)) {
- return;
- } else {
- GlobalData.registerBuiltModule(baseName, arch);
- }
+ try{
+ pushProperties();
//
- // Call AutoGen
+ // Enable all specified properties
//
- AutoGen autogen = new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), baseName, arch);
- autogen.genAutogen();
- //
- // Update parameters
- //
- updateParameters();
- //
- // Update flags like CC_FLAGS, LIB_FLAGS etc.
- //
- flagsSetup();
- GlobalData.addLibrary(baseName, arch, getProject().getProperty("BIN_DIR") + File.separatorChar + baseName + ".lib");
- GlobalData.addModuleLibrary(baseName, arch, libraries);
- //
- // If ComponentType is USER_DEFINED,
- // then call the exist BaseName_build.xml directly.
- //
- if (buildType.equalsIgnoreCase("CUSTOM_BUILD")) {
- System.out.println("Call user-defined " + baseName + "_build.xml");
- Ant ant = new Ant();
- ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + baseName + "_build.xml");
- ant.setInheritAll(true);
- ant.init();
- ant.execute();
- return;
+ Iterator iter = properties.iterator();
+ while (iter.hasNext()) {
+ Property item = iter.next();
+ getProject().setProperty(item.getName(), item.getValue());
}
+
//
- // Generate ${BASE_NAME}_build.xml file
+ // GenBuild should specify either msaFile or moduleGuid & packageGuid
//
- System.out.println("Generate " + baseName + "_build.xml");
- genBuildFile();
- System.out.println("Call the " + baseName + "_build.xml");
- Ant ant = new Ant();
- ant.setProject(getProject());
- ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + baseName + "_build.xml");
- ant.setInheritAll(true);
- ant.init();
- ant.execute();
- }
-
- /**
- Return the name of the directory that corresponds to the architecture.
- This is a translation from the XML Schema tag to a directory that
- corresponds to our directory name coding convention.
-
- **/
- private String archDir(String arch) {
- return arch.replaceFirst("X64", "x64")
- .replaceFirst("IPF", "Ipf")
- .replaceFirst("IA32", "Ia32")
- .replaceFirst("ARM", "Arm")
- .replaceFirst("EBC", "Ebc");
- }
-
- /**
- Get the dependent library instances and include package name from
- surface area, and initialize module include pathes.
-
- **/
- private void updateIncludesAndLibraries() {
- List rawIncludes = SurfaceAreaQuery.getIncludePackageName(arch);
- if (rawIncludes != null) {
- Iterator iter = rawIncludes.iterator();
- while (iter.hasNext()) {
- String packageName = (String) iter.next();
- includes.add("${WORKSPACE_DIR}" + File.separatorChar + GlobalData.getPackagePath(packageName)
- + File.separatorChar + "Include");
- includes.add("${WORKSPACE_DIR}" + File.separatorChar + GlobalData.getPackagePath(packageName)
- + File.separatorChar + "Include" + File.separatorChar + archDir(arch));
+ if (msaFile == null ) {
+ String moduleGuid = getProject().getProperty("MODULE_GUID");
+ String moduleVersion = getProject().getProperty("MODULE_VERSION");
+ String packageGuid = getProject().getProperty("PACKAGE_GUID");
+ String packageVersion = getProject().getProperty("PACKAGE_VERSION");
+ if (moduleGuid == null || packageGuid == null) {
+ throw new BuildException("GenBuild parameters error. ");
}
+ PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);
+ moduleId = new ModuleIdentification(moduleGuid, moduleVersion);
+ moduleId.setPackage(packageId);
+ Map doc = GlobalData.getNativeMsa(moduleId);
+ SurfaceAreaQuery.setDoc(doc);
+ moduleId = SurfaceAreaQuery.getMsaHeader();
}
- includes.add("${DEST_DIR_DEBUG}");
- List rawLibraries = SurfaceAreaQuery.getLibraryInstance(this.arch, CommonDefinition.AlwaysConsumed);
- if (rawLibraries != null) {
- Iterator iter = rawLibraries.iterator();
- while (iter.hasNext()) {
- libraries.add((String) iter.next());
- }
+ else {
+ Map doc = GlobalData.getNativeMsa(msaFile);
+ SurfaceAreaQuery.setDoc(doc);
+ moduleId = SurfaceAreaQuery.getMsaHeader();
}
- normalize();
- }
-
- /**
- Normalize all dependent library instance and include pathes' format.
-
- **/
- private void normalize() {
- String[] includesArray = includes.toArray(new String[includes.size()]);
- includes.clear();
- for (int i = 0; i < includesArray.length; i++) {
- includes.add((new File(includesArray[i])).getPath());
+ String[] producedLibraryClasses = SurfaceAreaQuery.getLibraryClasses("ALWAYS_PRODUCED");
+ if (producedLibraryClasses.length == 0) {
+ moduleId.setLibrary(false);
}
- String[] librariesArray = libraries.toArray(new String[libraries.size()]);
- libraries.clear();
- for (int i = 0; i < librariesArray.length; i++) {
- libraries.add((new File(librariesArray[i])).getPath());
+ else {
+ moduleId.setLibrary(true);
}
- }
-
- /**
- Restore some important ANT property. If current build is single module
- build, here will set many default values.
-
-
If current build is single module build, then the default ARCH
- is IA32. Also set up the properties PACKAGE,
- PACKAGE_DIR, TARGET and MODULE_DIR
-
-
Note that for package build, package name is stored in PLATFORM
- and package directory is stored in PLATFORM_DIR.
-
- @see org.tianocore.build.global.OutputManager
- **/
- private void recallFixedProperties() {
+
//
- // If build is for module build
+ // Judge whether it is single module build or not
//
- if (getProject().getProperty("PACKAGE_DIR") == null) {
- ToolChainFactory toolChainFactory = new ToolChainFactory(getProject());
- toolChainFactory.setupToolChain();
+ if (getProject().getProperty("PLATFORM") == null) {
//
- // PACKAGE PACKAGE_DIR ARCH (Default) COMMON_FILE BUILD_MACRO
+ // Single Module build
//
- if (getProject().getProperty("ARCH") == null) {
- getProject().setProperty("ARCH", "IA32");
- }
- String packageName = GlobalData.getPackageNameForModule(baseName);
- getProject().setProperty("PACKAGE", packageName);
-
- String packageDir = GlobalData.getPackagePath(packageName);
- getProject().setProperty("PACKAGE_DIR",
- getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + packageDir);
-
- getProject().setProperty("TARGET", toolChainFactory.getCurrentTarget());
+ prepareSingleModuleBuild();
+ }
+ else {
+ //
+ // Platform build. Restore the platform related info
+ //
+ String platformName = getProject().getProperty("PLATFORM");
+ PlatformIdentification platformId = GlobalData.getPlatform(platformName);
+ getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
- getProject().setProperty("MODULE_DIR",
- getProject().replaceProperties(getProject().getProperty("MODULE_DIR")));
+ String packageGuid = getProject().getProperty("PACKAGE_GUID");
+ String packageVersion = getProject().getProperty("PACKAGE_VERSION");
+ PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);
+ moduleId.setPackage(packageId);
}
- if (OutputManager.PLATFORM != null) {
- getProject().setProperty("PLATFORM", OutputManager.PLATFORM);
+
+ //
+ // If single module : intersection MSA supported ARCHs and tools def!!
+ // else, get arch from pass down
+ //
+ String[] archList = new String[0];
+ if ( getProject().getProperty("ARCH") != null ) {
+ archList = getProject().getProperty("ARCH").split(" ");
}
- if (OutputManager.PLATFORM_DIR != null) {
- getProject().setProperty("PLATFORM_DIR", OutputManager.PLATFORM_DIR);
+ else {
+ archList = GlobalData.getToolChainInfo().getArchs();
}
- }
-
- /**
- The whole BaseName_build.xml is composed of seven part.
-
-
ANT properties;
-
Dependent module (dependent library instances in most case);
-
Source files;
-
Sections if module is not library;
-
Output (different for library module and driver module);
-
Clean;
-
Clean all.
-
-
- @throws BuildException
- Error throws during BaseName_build.xml generating.
- **/
- private void genBuildFile() throws BuildException {
- FfsProcess fp = new FfsProcess();
- DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
- try {
- DocumentBuilder dombuilder = domfac.newDocumentBuilder();
- Document document = dombuilder.newDocument();
- Comment rootComment = document.createComment(info);
- //
- // create root element and its attributes
- //
- Element root = document.createElement("project");
- //
- // root.setAttribute("name", base_name);
- //
- root.setAttribute("default", "main");
- root.setAttribute("basedir", ".");
- //
- // element for External ANT tasks
- //
- root.appendChild(document.createComment("Apply external ANT tasks"));
- Element ele = document.createElement("taskdef");
- ele.setAttribute("resource", "frameworktasks.tasks");
- root.appendChild(ele);
- ele = document.createElement("taskdef");
- ele.setAttribute("resource", "cpptasks.tasks");
- root.appendChild(ele);
- ele = document.createElement("typedef");
- ele.setAttribute("resource", "cpptasks.types");
- root.appendChild(ele);
- ele = document.createElement("taskdef");
- ele.setAttribute("resource", "net/sf/antcontrib/antlib.xml");
- root.appendChild(ele);
- //
- // elements for Properties
- //
- root.appendChild(document.createComment("All Properties"));
- ele = document.createElement("property");
- ele.setAttribute("name", "BASE_NAME");
- ele.setAttribute("value", baseName);
- root.appendChild(ele);
- //
- // Generate the default target,
- // which depends on init, sections and output target
- //
- root.appendChild(document.createComment("Default target"));
- ele = document.createElement("target");
- ele.setAttribute("name", "main");
- ele.setAttribute("depends", "libraries, sourcefiles, sections, output");
- root.appendChild(ele);
- //
- // compile all source files
- //
- root.appendChild(document.createComment("Compile all dependency Library instances."));
- ele = document.createElement("target");
- ele.setAttribute("name", "libraries");
- //
- // Parse all sourfiles but files specified in sections
- //
- applyLibraryInstance(document, ele);
- root.appendChild(ele);
- //
- // compile all source files
- //
- root.appendChild(document.createComment("sourcefiles target"));
- ele = document.createElement("target");
- ele.setAttribute("name", "sourcefiles");
- //
- // Parse all sourfiles but files specified in sections
- //
- applyCompileElement(document, ele);
- root.appendChild(ele);
- //
- // generate the init target
- // main purpose is create all nessary pathes
- // generate the sections target
- //
- root.appendChild(document.createComment("sections target"));
- ele = document.createElement("target");
- ele.setAttribute("name", "sections");
- applySectionsElement(document, ele, fp);
- root.appendChild(ele);
- //
- // generate the output target
- //
- root.appendChild(document.createComment("output target"));
- ele = document.createElement("target");
- ele.setAttribute("name", "output");
- applyOutputElement(document, ele, fp);
- root.appendChild(ele);
- //
- // generate the clean target
- //
- root.appendChild(document.createComment("clean target"));
- ele = document.createElement("target");
- ele.setAttribute("name", "clean");
- applyCleanElement(document, ele);
- root.appendChild(ele);
- //
- // generate the Clean All target
- //
- root.appendChild(document.createComment("Clean All target"));
- ele = document.createElement("target");
- ele.setAttribute("name", "cleanall");
- applyDeepcleanElement(document, ele);
- root.appendChild(ele);
- //
- // add the root element to the document
- //
- document.appendChild(rootComment);
- document.appendChild(root);
- //
- // Prepare the DOM document for writing
- //
- Source source = new DOMSource(document);
- //
- // Prepare the output file
- //
- File file = new File(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + baseName
- + "_build.xml");
- //
- // generate all directory path
- //
- (new File(file.getParent())).mkdirs();
- Result result = new StreamResult(file);
- //
- // Write the DOM document to the file
- //
- Transformer xformer = TransformerFactory.newInstance().newTransformer();
- xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
- xformer.setOutputProperty(OutputKeys.INDENT, "yes");
- xformer.transform(source, result);
- } catch (Exception ex) {
- throw new BuildException("Module [" + baseName + "] generating build file failed.\n" + ex.getMessage());
+
+
+ //
+ // Judge if arch is all supported by current module. If not, throw Exception.
+ //
+ List moduleSupportedArchs = SurfaceAreaQuery.getModuleSupportedArchs();
+ if (moduleSupportedArchs != null) {
+ for (int k = 0; k < archList.length; k++) {
+ if ( ! moduleSupportedArchs.contains(archList[k])) {
+ throw new BuildException("ARCH [" + archList[k] + "] is not supported by " + moduleId + ". " + moduleId + " only supports [" + moduleSupportedArchs + "].");
+ }
+ }
}
- }
-
- /**
- Generate the clean elements for BaseName_build.xml.
-
- @param document current BaseName_build.xml XML document
- @param root Root element for current
- **/
- private void applyCleanElement(Document document, Node root) {
- String[] libinstances = libraries.toArray(new String[libraries.size()]);
- for (int i = 0; i < libinstances.length; i++) {
- File file = new File(GlobalData.getModulePath(libinstances[i]) + File.separatorChar + "build.xml");
-
- Element ifEle = document.createElement("if");
- Element availableEle = document.createElement("available");
- availableEle.setAttribute("file", file.getPath());
- ifEle.appendChild(availableEle);
- Element elseEle = document.createElement("then");
-
- Element ele = document.createElement("ant");
- ele.setAttribute("antfile", file.getPath());
- ele.setAttribute("inheritAll", "false");
- ele.setAttribute("target", libinstances[i] + "_clean");
- //
- // Workspace_DIR
- //
- Element property = document.createElement("property");
- property.setAttribute("name", "WORKSPACE_DIR");
- property.setAttribute("value", "${WORKSPACE_DIR}");
- ele.appendChild(property);
- //
- // Package Dir
- //
- property = document.createElement("property");
- property.setAttribute("name", "PACKAGE_DIR");
- property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar
- + GlobalData.getPackagePathForModule(libinstances[i]));
- ele.appendChild(property);
- //
- // ARCH
- //
- property = document.createElement("property");
- property.setAttribute("name", "ARCH");
- property.setAttribute("value", "${ARCH}");
- ele.appendChild(property);
- //
- // TARGET
+
+ for (int k = 0; k < archList.length; k++) {
+ getProject().setProperty("ARCH", archList[k]);
+
+ FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]);
+
//
- property = document.createElement("property");
- property.setAttribute("name", "TARGET");
- property.setAttribute("value", "${TARGET}");
- ele.appendChild(property);
+ // Whether the module is built before
//
- // PACKAGE
+ if (GlobalData.isModuleBuilt(fpdModuleId)) {
+ return ;
+ }
+ else {
+ GlobalData.registerBuiltModule(fpdModuleId);
+ }
+
//
- property = document.createElement("property");
- property.setAttribute("name", "PACKAGE");
- property.setAttribute("value", GlobalData.getPackageNameForModule(libinstances[i]));
- ele.appendChild(property);
-
- elseEle.appendChild(ele);
- ifEle.appendChild(elseEle);
- root.appendChild(ifEle);
+ // For Every TOOLCHAIN, TARGET
+ //
+ String[] targetList = GlobalData.getToolChainInfo().getTargets();
+ for (int i = 0; i < targetList.length; i ++){
+ //
+ // Prepare for target related common properties
+ // TARGET
+ //
+ getProject().setProperty("TARGET", targetList[i]);
+ String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
+ for(int j = 0; j < toolchainList.length; j ++){
+ //
+ // Prepare for toolchain related common properties
+ // TOOLCHAIN
+ //
+ getProject().setProperty("TOOLCHAIN", toolchainList[j]);
+
+ System.out.println("Build " + moduleId + " start >>>");
+ System.out.println("Target: " + targetList[i] + " Tagname: " + toolchainList[j] + " Arch: " + archList[k]);
+ SurfaceAreaQuery.setDoc(GlobalData.getDoc(fpdModuleId));
+
+ //
+ // Prepare for all other common properties
+ // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
+ // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
+ // MODULE_DIR, MODULE_RELATIVE_DIR
+ // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
+ // LIBS, OBJECTS, SDB_FILES
+ //
+ setModuleCommonProperties(archList[k]);
+
+ //
+ // OutputManage prepare for
+ // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
+ //
+ OutputManager.getInstance().update(getProject());
+
+ if (type.equalsIgnoreCase("all") || type.equalsIgnoreCase("build")) {
+ applyBuild(targetList[i], toolchainList[j], fpdModuleId);
+ }
+ else if (type.equalsIgnoreCase("clean")) {
+ applyClean(fpdModuleId);
+ }
+ else if (type.equalsIgnoreCase("cleanall")) {
+ applyCleanall(fpdModuleId);
+ }
+ }
+ }
}
- }
-
- /**
- Generate the cleanall elements for BaseName_build.xml.
-
- @param document current BaseName_build.xml XML document
- @param root Root element for current
- **/
- private void applyDeepcleanElement(Document document, Node root) {
- String[] libinstances = libraries.toArray(new String[libraries.size()]);
- for (int i = 0; i < libinstances.length; i++) {
- File file = new File(GlobalData.getModulePath(libinstances[i]) + File.separatorChar + "build.xml");
-
- Element ifEle = document.createElement("if");
- Element availableEle = document.createElement("available");
- availableEle.setAttribute("file", file.getPath());
- ifEle.appendChild(availableEle);
- Element elseEle = document.createElement("then");
-
- Element ele = document.createElement("ant");
- ele.setAttribute("antfile", file.getPath());
- ele.setAttribute("inheritAll", "false");
- ele.setAttribute("target", libinstances[i] + "_cleanall");
- //
- // Workspace_DIR
- //
- Element property = document.createElement("property");
- property.setAttribute("name", "WORKSPACE_DIR");
- property.setAttribute("value", "${WORKSPACE_DIR}");
- ele.appendChild(property);
- //
- // Package Dir
- //
- property = document.createElement("property");
- property.setAttribute("name", "PACKAGE_DIR");
- property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar
- + GlobalData.getPackagePathForModule(libinstances[i]));
- ele.appendChild(property);
- //
- // ARCH
- //
- property = document.createElement("property");
- property.setAttribute("name", "ARCH");
- property.setAttribute("value", "${ARCH}");
- ele.appendChild(property);
- //
- // TARGET
- //
- property = document.createElement("property");
- property.setAttribute("name", "TARGET");
- property.setAttribute("value", "${TARGET}");
- ele.appendChild(property);
- //
- // PACKAGE
- //
- property = document.createElement("property");
- property.setAttribute("name", "PACKAGE");
- property.setAttribute("value", GlobalData.getPackageNameForModule(libinstances[i]));
- ele.appendChild(property);
-
- elseEle.appendChild(ele);
- ifEle.appendChild(elseEle);
- root.appendChild(ifEle);
+ popProperties();
+ }catch (Exception e){
+ e.printStackTrace();
+ throw new BuildException(e.getMessage());
}
}
/**
- Generate the dependent library instances elements for BaseName_build.xml.
+ This method is used to prepare Platform-related information.
- @param document current BaseName_build.xml XML document
- @param root Root element for current
- **/
- private void applyLibraryInstance(Document document, Node root) {
- String[] libinstances = libraries.toArray(new String[libraries.size()]);
- for (int i = 0; i < libinstances.length; i++) {
- Element ele = document.createElement("ant");
- File file = new File(GlobalData.getModulePath(libinstances[i]) + File.separatorChar + "build.xml");
- ele.setAttribute("antfile", file.getPath());
- ele.setAttribute("inheritAll", "false");
- ele.setAttribute("target", libinstances[i]);
- //
- // Workspace_DIR
- //
- Element property = document.createElement("property");
- property.setAttribute("name", "WORKSPACE_DIR");
- property.setAttribute("value", "${WORKSPACE_DIR}");
- ele.appendChild(property);
- //
- // Package Dir
- //
- property = document.createElement("property");
- property.setAttribute("name", "PACKAGE_DIR");
- property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar
- + GlobalData.getPackagePathForModule(libinstances[i]));
- ele.appendChild(property);
- //
- // ARCH
- //
- property = document.createElement("property");
- property.setAttribute("name", "ARCH");
- property.setAttribute("value", "${ARCH}");
- ele.appendChild(property);
- //
- // TARGET
- //
- property = document.createElement("property");
- property.setAttribute("name", "TARGET");
- property.setAttribute("value", "${TARGET}");
- ele.appendChild(property);
- //
- // PACKAGE
- //
- property = document.createElement("property");
- property.setAttribute("name", "PACKAGE");
- property.setAttribute("value", GlobalData.getPackageNameForModule(libinstances[i]));
- ele.appendChild(property);
- root.appendChild(ele);
- }
- Element expand = document.createElement("Expand");
- root.appendChild(expand);
- }
-
- /**
- Generate the build source files elements for BaseName_build.xml.
-
- @param document current BaseName_build.xml XML document
- @param root Root element for current
+
In Single Module Build mode, platform-related information is not ready.
+ The method read the system environment variable ACTIVE_PLATFORM
+ and search in the Framework Database. Note that platform name in the Framework
+ Database must be unique.
+
**/
- private void applyCompileElement(Document document, Node root) {
- FileProcess fileProcess = new FileProcess();
- fileProcess.init(getProject(), includes, sourceFiles, document);
- Node[] files = this.getSourceFiles();
+ private void prepareSingleModuleBuild(){
//
- // Parse all unicode files
+ // Find out the package which the module belongs to
+ // TBD: Enhance it!!!!
//
- for (int i = 0; i < files.length; i++) {
- String filetype = getFiletype(files[i]);
- if (filetype != null) {
- fileProcess.parseFile(getFilename(files[i]), filetype, root, true);
- } else {
- fileProcess.parseFile(getFilename(files[i]), root, true);
- }
- }
- if (fileProcess.isUnicodeExist()) {
- Element ele = document.createElement("Build_Unicode_Database");
- ele.setAttribute("FILEPATH", ".");
- ele.setAttribute("FILENAME", "${BASE_NAME}");
- root.appendChild(ele);
- }
-
+ PackageIdentification packageId = GlobalData.getPackageForModule(moduleId);
+
+ moduleId.setPackage(packageId);
+
//
- // Parse AutoGen.c & AutoGen.h
+ // Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method)
//
- if (!baseName.equalsIgnoreCase("Shell")) {
- fileProcess.parseFile(getProject().getProperty("DEST_DIR_DEBUG") + File.separatorChar + "AutoGen.c", root,
- false);
+ String activePlatformName = getProject().getProperty("ACTIVE_PLATFORM");
+
+ if (activePlatformName == null){
+ throw new BuildException("Plese set ACTIVE_PLATFORM if you want to build a single module. ");
}
+
+ PlatformIdentification platformId = GlobalData.getPlatform(activePlatformName);
+
//
- // Parse all source files
+ // Read FPD file
//
- for (int i = 0; i < files.length; i++) {
- String filetype = getFiletype(files[i]);
- if (filetype != null) {
- fileProcess.parseFile(getFilename(files[i]), filetype, root, false);
- } else {
- fileProcess.parseFile(getFilename(files[i]), root, false);
- }
- }
+ FpdParserTask fpdParser = new FpdParserTask();
+ fpdParser.setProject(getProject());
+ fpdParser.parseFpdFile(platformId.getFpdFile());
+
//
- // root.appendChild(parallelEle);
+ // Prepare for Platform related common properties
+ // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
//
- Iterator iter = sourceFiles.iterator();
- String str = "";
- while (iter.hasNext()) {
- str += " " + (String) iter.next();
- }
- getProject().setProperty("SOURCE_FILES", str);
+ getProject().setProperty("PLATFORM", activePlatformName);
+ getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
}
- /**
- Generate the section elements for BaseName_build.xml. Library module will
- skip this process.
-
- @param document current BaseName_build.xml XML document
- @param root Root element for current
- **/
- private void applySectionsElement(Document document, Node root, FfsProcess fp) {
- if (fp.initSections(buildType, getProject())) {
- String targetFilename = guid + "-" + baseName + FpdParserTask.getSuffix(componentType);
- String[] list = fp.getGenSectionElements(document, baseName, guid, targetFilename);
-
- for (int i = 0; i < list.length; i++) {
- Element ele = document.createElement(list[i]);
- ele.setAttribute("FILEPATH", ".");
- ele.setAttribute("FILENAME", "${BASE_NAME}");
- root.appendChild(ele);
- }
- }
- }
/**
- Generate the output elements for BaseName_build.xml. If module is library,
- call the LIB command, else call the GenFfs command.
-
- @param document current BaseName_build.xml XML document
- @param root Root element for current
+ Set Module-Related information to properties.
**/
- private void applyOutputElement(Document document, Node root, FfsProcess fp) {
- if (flag == GlobalData.ONLY_LIBMSA || flag == GlobalData.LIBMSA_AND_LIBMBD) {
- //
- // call Lib command
- //
- Element cc = document.createElement("Build_Library");
- cc.setAttribute("FILENAME", baseName);
- root.appendChild(cc);
- }
+ private void setModuleCommonProperties(String arch) {
//
- // if it is a module but library
+ // Prepare for all other common properties
+ // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
//
+ PackageIdentification packageId = moduleId.getPackage();
+ getProject().setProperty("PACKAGE", packageId.getName());
+ getProject().setProperty("PACKAGE_GUID", packageId.getGuid());
+ getProject().setProperty("PACKAGE_VERSION", packageId.getVersion());
+ getProject().setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
+
+ //
+ // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, MODULE_TYPE
+ // MODULE_DIR, MODULE_RELATIVE_DIR
+ //
+ getProject().setProperty("MODULE", moduleId.getName());
+ String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();
+ if (baseName == null) {
+ getProject().setProperty("BASE_NAME", moduleId.getName());
+ }
else {
- if (fp.getFfsNode() != null) {
- root.appendChild(fp.getFfsNode());
+ getProject().setProperty("BASE_NAME", baseName);
+ }
+ getProject().setProperty("GUID", moduleId.getGuid());
+ getProject().setProperty("FILE_GUID", moduleId.getGuid());
+ getProject().setProperty("VERSION", moduleId.getVersion());
+ getProject().setProperty("MODULE_TYPE", moduleId.getModuleType());
+ getProject().setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/"));
+
+ //
+ // SUBSYSTEM
+ //
+ String[][] subsystemMap = { { "BASE", "EFI_BOOT_SERVICE_DRIVER"},
+ { "SEC", "EFI_BOOT_SERVICE_DRIVER" },
+ { "PEI_CORE", "EFI_BOOT_SERVICE_DRIVER" },
+ { "PEIM", "EFI_BOOT_SERVICE_DRIVER" },
+ { "DXE_CORE", "EFI_BOOT_SERVICE_DRIVER" },
+ { "DXE_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
+ { "DXE_RUNTIME_DRIVER", "EFI_RUNTIME_DRIVER" },
+ { "DXE_SAL_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
+ { "DXE_SMM_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
+ { "TOOL", "EFI_BOOT_SERVICE_DRIVER" },
+ { "UEFI_DRIVER", "EFI_BOOT_SERVICE_DRIVER" },
+ { "UEFI_APPLICATION", "EFI_APPLICATION" },
+ { "USER_DEFINED", "EFI_BOOT_SERVICE_DRIVER"} };
+
+ String subsystem = "EFI_BOOT_SERVICE_DRIVER";
+ for (int i = 0; i < subsystemMap.length; i++) {
+ if (moduleId.getModuleType().equalsIgnoreCase(subsystemMap[i][0])) {
+ subsystem = subsystemMap[i][1];
+ break ;
}
}
- }
-
- /**
- Get file name from node. If some wrong, return string with zero length.
-
- @param node Filename node of MSA/MBD or specified in each Section
- @return File name
- **/
- private String getFilename(Node node) {
- String path = null;
- String filename = "${MODULE_DIR}" + File.separatorChar;
- String str = "";
- try {
- FilenameDocument file = (FilenameDocument) XmlObject.Factory.parse(node);
- str = file.getFilename().getStringValue().trim();
- path = file.getFilename().getPath();
- } catch (Exception e) {
- str = "";
- }
- if (path != null) {
- filename += path + File.separatorChar + str;
- } else {
- filename += str;
- }
- return getProject().replaceProperties(filename);
- }
-
- /**
- Get file type from node. If some wrong or not specified, return
- null.
-
- @param node Filename node of MSA/MBD or specified in each Section
- @return File type
- **/
- private String getFiletype(Node node) {
- String str = null;
- try {
- FilenameDocument file = (FilenameDocument) XmlObject.Factory.parse(node);
- str = file.getFilename().getFileType();
- } catch (Exception e) {
- str = null;
- }
- return str;
- }
-
- /**
- Return all source files but AutoGen.c.
-
- @return source files Node array
- **/
- public Node[] getSourceFiles() {
- XmlObject[] files = SurfaceAreaQuery.getSourceFiles(arch);
- if (files == null) {
- return new Node[0];
+ getProject().setProperty("SUBSYSTEM", subsystem);
+
+ //
+ // ENTRYPOINT
+ //
+ if (arch.equalsIgnoreCase("EBC")) {
+ getProject().setProperty("ENTRYPOINT", "EfiStart");
}
- Vector vector = new Vector();
- for (int i = 0; i < files.length; i++) {
- vector.addElement(files[i].getDomNode());
+ else {
+ getProject().setProperty("ENTRYPOINT", "_ModuleEntryPoint");
}
+
//
- // To be consider sourcefiles from Sections
+ // LIBS, OBJECTS, SDB_FILES
//
- return vector.toArray(new Node[vector.size()]);
- }
-
- /**
- Get current module's base name.
-
- @return base name
- **/
- public String getBaseName() {
- return baseName;
- }
-
- /**
- Set MBD surface area file. For ANT use.
-
- @param mbdFilename Surface Area file
- **/
- public void setMbdFilename(File mbdFilename) {
- this.mbdFilename = mbdFilename;
- }
-
- /**
- Set MSA surface area file. For ANT use.
-
- @param msaFilename Surface Area file
- **/
- public void setMsaFilename(File msaFilename) {
- this.msaFilename = msaFilename;
+ getProject().setProperty("OBJECTS", "");
+ getProject().setProperty("SDB_FILES", "");
+ getProject().setProperty("LIBS", "");
}
- /**
- Compile flags setup.
-
-
Take command CC and arch IA32 for example,
- Those flags are from ToolChainFactory:
-
-
IA32_CC
-
IA32_CC_STD_FLAGS
-
IA32_CC_GLOBAL_FLAGS
-
IA32_CC_GLOBAL_ADD_FLAGS
-
IA32_CC_GLOBAL_SUB_FLAGS
-
- Those flags can user-define:
-
-
IA32_CC_PROJ_FLAGS
-
IA32_CC_PROJ_ADD_FLAGS
-
IA32_CC_PROJ_SUB_FLAGS
-
CC_PROJ_FLAGS
-
CC_PROJ_ADD_FLAGS
-
CC_PROJ_SUB_FLAGS
-
CC_FLAGS
-
IA32_CC_FLAGS
-
-
-
The final flags is composed of STD, GLOBAL and PROJ. If CC_FLAGS or
- IA32_CC_FLAGS is specified, STD, GLOBAL and PROJ will not affect.
-
- Note that the ToolChainFactory executes only once
- during whole build process.
- **/
- private void flagsSetup() {
- Project project = getProject();
- //
- // If ToolChain has been set up before, do nothing.
- //
- ToolChainFactory toolChainFactory = new ToolChainFactory(project);
- toolChainFactory.setupToolChain();
-
- String[] cmd = ToolChainFactory.commandType;
- Set addSet = new HashSet(40);
- Set subSet = new HashSet(40);
- for (int i = 0; i < cmd.length; i++) {
- String str = ToolChainFactory.getValue(arch + "_" + cmd[i]);
+ private void getCompilerFlags(String target, String toolchain, FpdModuleIdentification fpdModuleId) throws EdkException {
+ String[] cmd = GlobalData.getToolChainInfo().getCommands();
+ for ( int m = 0; m < cmd.length; m++) {
//
- // Command line path+command name
+ // Set cmd, like CC, DLINK
//
- if (str != null) {
- project.setProperty(cmd[i], str);
- }
- //
- // ARCH_CMD_STD_FLAGS
- //
- str = ToolChainFactory.getValue(arch + "_" + cmd[i] + "_STD_FLAGS");
- if (str != null) {
- putFlagsToSet(addSet, str);
- project.setProperty(cmd[i] + "_STD_FLAGS", str);
- }
- //
- // ARCH_CMD_GLOBAL_FLAGS
- //
- str = ToolChainFactory.getValue(arch + "_" + cmd[i] + "_GLOBAL_FLAGS");
- if (str != null) {
- putFlagsToSet(addSet, str);
- }
- //
- // ARCH_CMD_GLOBAL_ADD_FLAGS
- //
- str = ToolChainFactory.getValue(arch + "_" + cmd[i] + "_GLOBAL_ADD_FLAGS");
- if (str != null) {
- putFlagsToSet(addSet, str);
- }
- //
- // ARCH_CMD_GLOBAL_SUB_FLAGS
- //
- str = ToolChainFactory.getValue(arch + "_" + cmd[i] + "_GLOBAL_SUB_FLAGS");
- if (str != null) {
- putFlagsToSet(subSet, str);
- }
+ String[] key = new String[]{target, toolchain, fpdModuleId.getArch(), cmd[m], null};
+ key[4] = "PATH";
+ String cmdPath = GlobalData.getCommandSetting(key, fpdModuleId);
+ key[4] = "NAME";
+ String cmdName = GlobalData.getCommandSetting(key, fpdModuleId);
+ File cmdFile = new File(cmdPath + File.separatorChar + cmdName);
+// GlobalData.log.info("PATH: " + cmdFile.getPath());
+ getProject().setProperty(cmd[m], cmdFile.getPath().replaceAll("(\\\\)", "/"));
+
//
- // ARCH_CMD_PROJ_FLAGS
+ // set CC_FLAGS
//
- str = project.getProperty(arch + "_" + cmd[i] + "_PROJ_FLAGS");
- if (str != null) {
- putFlagsToSet(addSet, str);
- }
+ key[4] = "FLAGS";
+ String cmdFlags = GlobalData.getCommandSetting(key, fpdModuleId);
+// GlobalData.log.info("Flags: " + cmdFlags);
+ Set addset = new LinkedHashSet();
+ Set subset = new LinkedHashSet();
+ putFlagsToSet(addset, cmdFlags);
+ getProject().setProperty(cmd[m] + "_FLAGS", getProject().replaceProperties(getFlags(addset, subset)));
+
//
- // ARCH_CMD_PROG_FLAGS
+ // Set CC_EXT
//
- str = project.getProperty(arch + "_" + cmd[i] + "_PROJ_ADD_FLAGS");
- if (str != null) {
- putFlagsToSet(addSet, str);
+ key[4] = "EXT";
+ String extName = GlobalData.getCommandSetting(key, fpdModuleId);
+// GlobalData.log.info("Ext: " + extName);
+ if ( extName != null && ! extName.equalsIgnoreCase("")) {
+ getProject().setProperty(cmd[m] + "_EXT", extName);
}
- //
- // ARCH_CMD_PROG_FLAGS
- //
- str = project.getProperty(arch + "_" + cmd[i] + "_PROJ_SUB_FLAGS");
- if (str != null) {
- putFlagsToSet(subSet, str);
+ else {
+ getProject().setProperty(cmd[m] + "_EXT", "");
}
+
//
- // CMD_PROJ_FLAGS
+ // set CC_FAMILY
//
- str = project.getProperty(cmd[i] + "_PROJ_FLAGS");
- if (str != null) {
- putFlagsToSet(addSet, str);
+ key[4] = "FAMILY";
+ String toolChainFamily = GlobalData.getCommandSetting(key, fpdModuleId);
+// GlobalData.log.info("FAMILY: " + toolChainFamily);
+ if (toolChainFamily != null) {
+ getProject().setProperty(cmd[m] + "_FAMILY", toolChainFamily);
}
+
//
- // CMD_PROG_FLAGS
+ // set CC_SPATH
//
- str = project.getProperty(cmd[i] + "_PROJ_ADD_FLAGS");
- if (str != null) {
- putFlagsToSet(addSet, str);
+ key[4] = "SPATH";
+ String spath = GlobalData.getCommandSetting(key, fpdModuleId);
+// GlobalData.log.info("SPATH: " + spath);
+ if (spath != null) {
+ getProject().setProperty(cmd[m] + "_SPATH", spath.replaceAll("(\\\\)", "/"));
}
- //
- // CMD_PROG_FLAGS
- //
- str = project.getProperty(cmd[i] + "_PROJ_SUB_FLAGS");
- if (str != null) {
- putFlagsToSet(subSet, str);
+ else {
+ getProject().setProperty(cmd[m] + "_SPATH", "");
}
+
//
- // If IA32_CC_FLAGS or IA32_LIB_FLAGS .. has defined in BuildOptions
+ // set CC_DPATH
//
- if ((str = project.getProperty(arch + "_" + cmd[i] + "_FLAGS")) != null) {
- project.setProperty(cmd[i] + "_FLAGS", getRawFlags(addSet, subSet));
- addSet.clear();
- subSet.clear();
- putFlagsToSet(addSet, project.replaceProperties(str));
- project.setProperty(cmd[i] + "_FLAGS", project.replaceProperties(getFlags(addSet, subSet)));
- addSet.clear();
- subSet.clear();
+ key[4] = "DPATH";
+ String dpath = GlobalData.getCommandSetting(key, fpdModuleId);
+// GlobalData.log.info("DPATH: " + dpath);
+ if (dpath != null) {
+ getProject().setProperty(cmd[m] + "_DPATH", dpath.replaceAll("(\\\\)", "/"));
}
- //
- // If CC_FLAGS or LIB_FLAGS .. has defined in BuildOptions
- //
- else if ((str = project.getProperty(cmd[i] + "_FLAGS")) != null) {
- project.setProperty(cmd[i] + "_FLAGS", getRawFlags(addSet, subSet));
- addSet.clear();
- subSet.clear();
- putFlagsToSet(addSet, project.replaceProperties(str));
- project.setProperty(cmd[i] + "_FLAGS", project.replaceProperties(getFlags(addSet, subSet)));
- addSet.clear();
- subSet.clear();
- } else {
- project.setProperty(cmd[i] + "_FLAGS", getFlags(addSet, subSet));
- addSet.clear();
- subSet.clear();
+ else {
+ getProject().setProperty(cmd[m] + "_DPATH", "");
}
}
- project.setProperty("C_FLAGS", project.getProperty("CC_FLAGS"));
+ }
+
+ public void setMsaFile(File msaFile) {
+ this.msaFile = msaFile;
}
/**
- Initialize some properties will be used in current module build, including
- user-defined option from Option of BuildOptions in
- surface area.
+ Method is for ANT to initialize MSA file.
+
+ @param msaFilename MSA file name
**/
- private void updateParameters() {
- getProject().setProperty("OBJECTS", "");
- getProject().setProperty("SDB_FILES", "");
- getProject().setProperty("BASE_NAME", baseName);
- if (map.get("MsaHeader") != null) {
- guid = SurfaceAreaQuery.getModuleGuid();//header.getGuid().getStringValue();
- componentType = SurfaceAreaQuery.getComponentType();//header.getComponentType().toString();
- if (!componentType.equalsIgnoreCase("LIBRARY")) {
- flag = GlobalData.MSA_AND_MBD;
- } else {
- flag = GlobalData.LIBMSA_AND_LIBMBD;
- }
- }
+ public void setMsaFile(String msaFilename) {
+ String moduleDir = getProject().getProperty("MODULE_DIR");
- else if (map.get("MsaLibHeader") != null) {
- flag = GlobalData.LIBMSA_AND_LIBMBD;
- MsaLibHeaderDocument.MsaLibHeader header = ((MsaLibHeaderDocument) map.get("MsaLibHeader"))
- .getMsaLibHeader();
- guid = header.getGuid().getStringValue();
- componentType = header.getComponentType().toString();
+ //
+ // If is Single Module Build, then use the Base Dir defined in build.xml
+ //
+ if (moduleDir == null) {
+ moduleDir = getProject().getBaseDir().getPath();
}
+ msaFile = new File(moduleDir + File.separatorChar + msaFilename);
+ }
+
+ public void addConfiguredModuleItem(ModuleItem moduleItem) {
+ PackageIdentification packageId = new PackageIdentification(moduleItem.getPackageGuid(), moduleItem.getPackageVersion());
+ ModuleIdentification moduleId = new ModuleIdentification(moduleItem.getModuleGuid(), moduleItem.getModuleVersion());
+ moduleId.setPackage(packageId);
+ this.moduleId = moduleId;
+ }
+
+ /**
+ Add a property.
+
+ @param p property
+ **/
+ public void addProperty(Property p) {
+ properties.addElement(p);
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ private void applyBuild(String buildTarget, String buildTagname, FpdModuleIdentification fpdModuleId) throws EdkException{
+ //
+ // AutoGen
+ //
+// AutoGen autogen = new AutoGen(getProject().getProperty("DEST_DIR_DEBUG"), fpdModuleId);
+// autogen.genAutogen();
+
- if (componentType != null) {
- getProject().setProperty("COMPONENT_TYPE", componentType);
+ //
+ // Get compiler flags
+ //
+ getCompilerFlags(buildTarget, buildTagname, fpdModuleId);
+
+ //
+ // Prepare LIBS
+ //
+ ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch());
+ String propertyLibs = "";
+ for (int i = 0; i < libinstances.length; i++) {
+ propertyLibs += " " + getProject().getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib";
}
-
- if (guid != null) {
- getProject().setProperty("FILE_GUID", guid);
+ getProject().setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));
+
+ //
+ // if it is CUSTOM_BUILD
+ // then call the exist BaseName_build.xml directly.
+ //
+ if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
+ GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
+ Ant ant = new Ant();
+ ant.setProject(getProject());
+ ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml");
+ ant.setInheritAll(true);
+ ant.init();
+ ant.execute();
+ return ;
}
+
//
- // Get all options and set to properties
+ // Generate ${BASE_NAME}_build.xml
+ // TBD
//
- String[][] options = SurfaceAreaQuery.getOptions(arch);
- for (int i = 0; i < options.length; i++) {
- if (options[i][0] != null && options[i][1] != null) {
- getProject().setProperty(options[i][0], getProject().replaceProperties(options[i][1]));
- }
+ String ffsKeyword = SurfaceAreaQuery.getModuleFfsKeyword();
+ ModuleBuildFileGenerator fileGenerator = new ModuleBuildFileGenerator(getProject(), ffsKeyword, fpdModuleId);
+ String buildFilename = getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml";
+ fileGenerator.genBuildFile(buildFilename);
+
+ //
+ // Ant call ${BASE_NAME}_build.xml
+ //
+ Ant ant = new Ant();
+ ant.setProject(getProject());
+ ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
+ ant.setInheritAll(true);
+ ant.init();
+ ant.execute();
+ }
+
+ private void applyClean(FpdModuleIdentification fpdModuleId){
+ //
+ // if it is CUSTOM_BUILD
+ // then call the exist BaseName_build.xml directly.
+ //
+ if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
+ GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
+ Ant ant = new Ant();
+ ant.setProject(getProject());
+ ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml");
+ ant.setTarget("clean");
+ ant.setInheritAll(true);
+ ant.init();
+ ant.execute();
+ return ;
}
-
- buildType = getProject().getProperty("BUILD_TYPE");
- if (buildType == null) {
- buildType = componentType;
+
+ Ant ant = new Ant();
+ ant.setProject(getProject());
+ ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
+ ant.setTarget("clean");
+ ant.setInheritAll(true);
+ ant.init();
+ ant.execute();
+
+ //
+ // Delete current module's DEST_DIR_OUTPUT
+ // TBD
+ }
+
+ private void applyCleanall(FpdModuleIdentification fpdModuleId){
+ //
+ // if it is CUSTOM_BUILD
+ // then call the exist BaseName_build.xml directly.
+ //
+ if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
+ GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
+ Ant ant = new Ant();
+ ant.setProject(getProject());
+ ant.setAntfile(getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml");
+ ant.setTarget("cleanall");
+ ant.setInheritAll(true);
+ ant.init();
+ ant.execute();
+ return ;
}
-
+
+ Ant ant = new Ant();
+ ant.setProject(getProject());
+ ant.setAntfile(getProject().getProperty("DEST_DIR_OUTPUT") + File.separatorChar + moduleId.getName() + "_build.xml");
+ ant.setTarget("cleanall");
+ ant.setInheritAll(true);
+ ant.init();
+ ant.execute();
+
+ //
+ // Delete current module's DEST_DIR_OUTPUT
+ // TBD
}
+
+
+
/**
Separate the string and instore in set.
@@ -1130,13 +658,15 @@ public class GenBuildTask extends Task {
@param str string to separate
**/
private void putFlagsToSet(Set set, String str) {
+ if (str == null || str.length() == 0) {
+ return;
+ }
+
Pattern myPattern = Pattern.compile("[^\\\\]?(\".*?[^\\\\]\")[ \t,]+");
Matcher matcher = myPattern.matcher(str + " ");
while (matcher.find()) {
String item = str.substring(matcher.start(1), matcher.end(1));
- if (!set.contains(item)) {
- set.add(item);
- }
+ set.add(item);
}
}
@@ -1152,7 +682,7 @@ public class GenBuildTask extends Task {
add.removeAll(sub);
Iterator iter = add.iterator();
while (iter.hasNext()) {
- String str = getProject().replaceProperties((String) iter.next());
+ String str = (String) iter.next();
result += str.substring(1, str.length() - 1) + " ";
}
return result;
@@ -1174,23 +704,55 @@ public class GenBuildTask extends Task {
@return flags with original format
**/
private String getRawFlags(Set add, Set sub) {
- String result = "";
+ String result = null;
add.removeAll(sub);
Iterator iter = add.iterator();
while (iter.hasNext()) {
- String str = getProject().replaceProperties((String) iter.next());
+ String str = (String) iter.next();
result += "\"" + str.substring(1, str.length() - 1) + "\", ";
}
return result;
}
- /**
- Set base name. For ANT use.
-
- @param baseName Base name
- **/
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
+ private String parseOptionString(String optionString, Set addSet, Set subSet) {
+ boolean overrideOption = false;
+ Pattern pattern = Pattern.compile("ADD\\.\\[(.+)\\]");
+ Matcher matcher = pattern.matcher(optionString);
+
+ while (matcher.find()) {
+ overrideOption = true;
+ String addOption = optionString.substring(matcher.start(1), matcher.end(1)).trim();
+ putFlagsToSet(addSet, addOption);
+
+ }
+ pattern = Pattern.compile("SUB\\.\\[(.+)\\]");
+ matcher = pattern.matcher(optionString);
+
+ while (matcher.find()) {
+ overrideOption = true;
+ String subOption = optionString.substring(matcher.start(1), matcher.end(1)).trim();
+ putFlagsToSet(subSet, subOption);
+ }
+
+ if (overrideOption == true) {
+ return null;
+ }
+
+ return optionString;
+ }
+
+ private void pushProperties() {
+ backupPropertiesStack.push(getProject().getProperties());
+ }
+
+ private void popProperties() {
+ Hashtable backupProperties = backupPropertiesStack.pop();
+ Set keys = backupProperties.keySet();
+ Iterator iter = keys.iterator();
+ while (iter.hasNext()) {
+ String item = (String)iter.next();
+ getProject().setProperty(item, (String)backupProperties.get(item));
+ }
+ }
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java
new file mode 100644
index 0000000000..4c6843e6b2
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/ModuleBuildFileGenerator.java
@@ -0,0 +1,591 @@
+/** @file
+
+ 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.
+ **/
+package org.tianocore.build;
+
+import java.io.File;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.tianocore.build.fpd.FpdParserTask;
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.id.FpdModuleIdentification;
+import org.tianocore.build.id.ModuleIdentification;
+import org.tianocore.build.id.PackageIdentification;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class ModuleBuildFileGenerator {
+
+ ///
+ /// Pass: TARGET, TOOLCHAIN, ARCH
+ /// PACKAGE, PACKAGE_GUID, PACKAGE_VERSION
+ ///
+ String[] inheritProperties = {"ARCH", "MODULE_GUID", "MODULE_VERSION", "PLATFORM", "PACKAGE_GUID", "PACKAGE_VERSION"};
+
+ ///
+ /// The information at the header of build.xml.
+ ///
+ private String info = "DO NOT EDIT \n"
+ + "File auto-generated by build utility\n"
+ + "\n"
+ + "Abstract:\n"
+ + "Auto-generated ANT build file for building of EFI Modules/Platforms\n";
+
+ private FpdModuleIdentification fpdModuleId;
+
+ private Project project;
+
+ private String ffsKeyword;
+
+ public ModuleBuildFileGenerator(Project project, String ffsKeyword, FpdModuleIdentification fpdModuleId) {
+ this.project = project;
+ this.fpdModuleId = fpdModuleId;
+ this.ffsKeyword = ffsKeyword;
+ }
+
+ /**
+ The whole BaseName_build.xml is composed of seven part.
+
+
ANT properties;
+
Dependent module (dependent library instances in most case);
+
Source files;
+
Sections if module is not library;
+
Output (different for library module and driver module);
+
Clean;
+
Clean all.
+
+
+ @throws BuildException
+ Error throws during BaseName_build.xml generating.
+ **/
+ public void genBuildFile(String buildFilename) throws BuildException {
+ FfsProcess fp = new FfsProcess();
+ DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder dombuilder = domfac.newDocumentBuilder();
+ Document document = dombuilder.newDocument();
+ Comment rootComment = document.createComment(info);
+
+ //
+ // create root element and its attributes
+ //
+ Element root = document.createElement("project");
+ root.setAttribute("name", fpdModuleId.getModule().getName());
+ root.setAttribute("default", "all");
+ root.setAttribute("basedir", ".");
+
+ //
+ // element for External ANT tasks
+ //
+ root.appendChild(document.createComment("Apply external ANT tasks"));
+ Element ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "frameworktasks.tasks");
+ root.appendChild(ele);
+ ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "cpptasks.tasks");
+ root.appendChild(ele);
+ ele = document.createElement("typedef");
+ ele.setAttribute("resource", "cpptasks.types");
+ root.appendChild(ele);
+ ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "net/sf/antcontrib/antlib.xml");
+ root.appendChild(ele);
+
+ //
+ // Generate the default target,
+ // which depends on init, sections and output target
+ //
+ root.appendChild(document.createComment("Default target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "all");
+ ele.setAttribute("depends", "libraries, sourcefiles, sections, output");
+ root.appendChild(ele);
+
+ //
+ // compile all source files
+ //
+ root.appendChild(document.createComment("Compile all dependency Library instances."));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "libraries");
+
+ //
+ // Parse all sourfiles but files specified in sections
+ //
+ applyLibraryInstance(document, ele);
+ root.appendChild(ele);
+
+ //
+ // compile all source files
+ //
+ root.appendChild(document.createComment("sourcefiles target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "sourcefiles");
+
+ //
+ // Parse all sourfiles but files specified in sections
+ //
+ applyCompileElement(document, ele);
+ root.appendChild(ele);
+
+ //
+ // generate the init target
+ // main purpose is create all nessary pathes
+ // generate the sections target
+ //
+ root.appendChild(document.createComment("sections target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "sections");
+ applySectionsElement(document, ele, fp);
+ root.appendChild(ele);
+
+ //
+ // generate the output target
+ //
+ root.appendChild(document.createComment("output target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "output");
+ applyOutputElement(document, ele, fp);
+ root.appendChild(ele);
+
+
+ //
+ // generate the clean target
+ //
+ root.appendChild(document.createComment("clean target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "clean");
+ applyCleanElement(document, ele);
+ root.appendChild(ele);
+
+ //
+ // generate the Clean All target
+ //
+ root.appendChild(document.createComment("Clean All target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "cleanall");
+ applyDeepcleanElement(document, ele);
+ root.appendChild(ele);
+
+ //
+ // add the root element to the document
+ //
+ document.appendChild(rootComment);
+ document.appendChild(root);
+ //
+ // Prepare the DOM document for writing
+ //
+ Source source = new DOMSource(document);
+
+ //
+ // Prepare the output file
+ //
+ File file = new File(buildFilename);
+
+ //
+ // generate all directory path
+ //
+ (new File(file.getParent())).mkdirs();
+ Result result = new StreamResult(file);
+
+ //
+ // Write the DOM document to the file
+ //
+ Transformer xformer = TransformerFactory.newInstance().newTransformer();
+ xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+ xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ xformer.transform(source, result);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new BuildException("Module [" + fpdModuleId.getModule().getName() + "] generating build file failed.\n" + ex.getMessage());
+ }
+ }
+
+ /**
+ Generate the clean elements for BaseName_build.xml.
+
+ @param document current BaseName_build.xml XML document
+ @param root Root element for current
+ **/
+ private void applyCleanElement(Document document, Node root) {
+ ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch());
+ for (int i = 0; i < libinstances.length; i++) {
+ //
+ // Put package file path to module identification
+ //
+ PackageIdentification packageId = libinstances[i].getPackage();
+
+ //
+ // Generate ANT script to clean
+ //
+ Element ele = document.createElement("GenBuild");
+ ele.setAttribute("type", "clean");
+
+ //
+ // Prepare pass down information
+ //
+ Map passDownMap = new LinkedHashMap();
+ for (int j = 0; j < inheritProperties.length; j ++){
+ passDownMap.put(inheritProperties[j], "${" + inheritProperties[j] + "}");
+ }
+ passDownMap.put("MODULE_GUID", libinstances[i].getGuid());
+ passDownMap.put("MODULE_VERSION", libinstances[i].getVersion());
+
+ passDownMap.put("PACKAGE_GUID", packageId.getGuid());
+ passDownMap.put("PACKAGE_VERSION", packageId.getVersion());
+
+ for (int j = 0; j < inheritProperties.length; j ++){
+ Element property = document.createElement("property");
+ property.setAttribute("name", inheritProperties[j]);
+ property.setAttribute("value", passDownMap.get(inheritProperties[j]));
+ ele.appendChild(property);
+ }
+
+ root.appendChild(ele);
+ }
+ //
+ //
+ //
+ //
+ //
+ Element deleteEle = document.createElement("delete");
+ deleteEle.setAttribute("includeemptydirs", "true");
+ Element filesetEle = document.createElement("fileset");
+ filesetEle.setAttribute("dir", "${DEST_DIR_OUTPUT}");
+ filesetEle.setAttribute("includes", "**/*");
+ filesetEle.setAttribute("excludes", "*.xml");
+ deleteEle.appendChild(filesetEle);
+ root.appendChild(deleteEle);
+ }
+
+ /**
+ Generate the cleanall elements for BaseName_build.xml.
+
+ @param document current BaseName_build.xml XML document
+ @param root Root element for current
+ **/
+ private void applyDeepcleanElement(Document document, Node root) {
+ ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch());
+ for (int i = 0; i < libinstances.length; i++) {
+ //
+ // Put package file path to module identification
+ //
+ PackageIdentification packageId = libinstances[i].getPackage();
+
+ //
+ // Generate ANT script to clean
+ //
+ Element ele = document.createElement("GenBuild");
+ ele.setAttribute("type", "cleanall");
+
+ //
+ // Prepare pass down information
+ //
+ Map passDownMap = new LinkedHashMap();
+ for (int j = 0; j < inheritProperties.length; j ++){
+ passDownMap.put(inheritProperties[j], "${" + inheritProperties[j] + "}");
+ }
+
+ passDownMap.put("MODULE_GUID", libinstances[i].getGuid());
+ passDownMap.put("MODULE_VERSION", libinstances[i].getVersion());
+
+ passDownMap.put("PACKAGE_GUID", packageId.getGuid());
+ passDownMap.put("PACKAGE_VERSION", packageId.getVersion());
+
+ for (int j = 0; j < inheritProperties.length; j ++){
+ Element property = document.createElement("property");
+ property.setAttribute("name", inheritProperties[j]);
+ property.setAttribute("value", passDownMap.get(inheritProperties[j]));
+ ele.appendChild(property);
+ }
+
+ root.appendChild(ele);
+ }
+ //
+ //
+ //
+ //
+ //
+ Element deleteEle = document.createElement("delete");
+ deleteEle.setAttribute("includeemptydirs", "true");
+ Element filesetEle = document.createElement("fileset");
+ filesetEle.setAttribute("dir", "${DEST_DIR_OUTPUT}");
+ filesetEle.setAttribute("includes", "**/*");
+ filesetEle.setAttribute("excludes", "*.xml");
+ deleteEle.appendChild(filesetEle);
+ root.appendChild(deleteEle);
+
+ //
+ //
+ //
+ //
+ //
+ deleteEle = document.createElement("delete");
+ deleteEle.setAttribute("includeemptydirs", "true");
+ filesetEle = document.createElement("fileset");
+ filesetEle.setAttribute("dir", "${DEST_DIR_DEBUG}");
+ filesetEle.setAttribute("includes", "**/*");
+ deleteEle.appendChild(filesetEle);
+ root.appendChild(deleteEle);
+ }
+
+ /**
+ Generate the dependent library instances elements for BaseName_build.xml.
+
+ @param document current BaseName_build.xml XML document
+ @param root Root element for current
+ **/
+ private void applyLibraryInstance(Document document, Node root) {
+ ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch());
+// String propertyLibs = "";
+ for (int i = 0; i < libinstances.length; i++) {
+ //
+ // Put package file path to module identification
+ //
+ PackageIdentification packageId = libinstances[i].getPackage();
+
+ //
+ // Generate ANT script to build library instances
+ //
+ Element ele = document.createElement("GenBuild");
+ ele.setAttribute("type", "build");
+// ele.setAttribute("inheritAll", "false");
+
+ //
+ // Prepare pass down information
+ //
+ Map passDownMap = new LinkedHashMap();
+ for (int j = 0; j < inheritProperties.length; j ++){
+ passDownMap.put(inheritProperties[j], "${" + inheritProperties[j] + "}");
+ }
+
+ passDownMap.put("MODULE_GUID", libinstances[i].getGuid());
+ passDownMap.put("MODULE_VERSION", libinstances[i].getVersion());
+
+ passDownMap.put("PACKAGE_GUID", packageId.getGuid());
+ passDownMap.put("PACKAGE_VERSION", packageId.getVersion());
+
+ for (int j = 0; j < inheritProperties.length; j ++){
+ Element property = document.createElement("property");
+ property.setAttribute("name", inheritProperties[j]);
+ property.setAttribute("value", passDownMap.get(inheritProperties[j]));
+ ele.appendChild(property);
+ }
+
+ root.appendChild(ele);
+// propertyLibs += " " + project.getProperty("BIN_DIR") + File.separatorChar + libinstances[i].getName() + ".lib";
+ }
+// project.setProperty("LIBS", propertyLibs.replaceAll("(\\\\)", "/"));
+ }
+
+ /**
+ Generate the build source files elements for BaseName_build.xml.
+
+ @param document current BaseName_build.xml XML document
+ @param root Root element for current
+ **/
+ private void applyCompileElement(Document document, Node root) {
+ //
+ // Prepare the includes: PackageDependencies and Output debug direactory
+ //
+ Set includes = new LinkedHashSet();
+
+ //
+ // WORKSPACE
+ //
+ includes.add("${WORKSPACE_DIR}");
+
+ //
+ // Module iteself
+ //
+ includes.add("${MODULE_DIR}");
+ includes.add("${MODULE_DIR}" + File.separatorChar + "${ARCH}");
+
+ //
+ // Packages in PackageDenpendencies
+ //
+ PackageIdentification[] packageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch());
+ for (int i = 0; i < packageDependencies.length; i++) {
+ GlobalData.refreshPackageIdentification(packageDependencies[i]);
+ File packageFile = packageDependencies[i].getSpdFile();
+ includes.add(packageFile.getParent() + File.separatorChar + "Include");
+ includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + "${ARCH}");
+ }
+
+ //
+ // All Dependency Library Instance's PackageDependencies
+ //
+ ModuleIdentification[] libinstances = SurfaceAreaQuery.getLibraryInstance(fpdModuleId.getArch());
+ for (int i = 0; i < libinstances.length; i++) {
+ SurfaceAreaQuery.push(GlobalData.getDoc(libinstances[i], fpdModuleId.getArch()));
+ PackageIdentification[] libraryPackageDependencies = SurfaceAreaQuery.getDependencePkg(fpdModuleId.getArch());
+ for (int j = 0; j < libraryPackageDependencies.length; j++) {
+ GlobalData.refreshPackageIdentification(libraryPackageDependencies[j]);
+ File packageFile = libraryPackageDependencies[j].getSpdFile();
+ includes.add(packageFile.getParent() + File.separatorChar + "Include");
+ includes.add(packageFile.getParent() + File.separatorChar + "Include" + File.separatorChar + "${ARCH}");
+ }
+ SurfaceAreaQuery.pop();
+ }
+
+
+ //
+ // The package which the module belongs to
+ // TBD
+ includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include");
+ includes.add(fpdModuleId.getModule().getPackage().getPackageDir() + File.separatorChar + "Include" + File.separatorChar + "${ARCH}");
+
+ //
+ // Debug files output directory
+ //
+ includes.add("${DEST_DIR_DEBUG}");
+
+ //
+ // sourceFiles[][0] is FileType, [][1] is File name relative to Module_Dir
+ //
+ String[][] sourceFiles = SurfaceAreaQuery.getSourceFiles(fpdModuleId.getArch());
+
+ FileProcess fileProcess = new FileProcess();
+ fileProcess.init(project, includes, document);
+
+ String moduleDir = project.getProperty("MODULE_DIR");
+ //
+ // Parse all Unicode files
+ //
+ for (int i = 0; i < sourceFiles.length; i++) {
+ //
+ // Go through all source files. Add MODULE_DIR to preffix
+ //
+ File sourceFile = new File(moduleDir + File.separatorChar + sourceFiles[i][1]);
+ sourceFiles[i][1] = sourceFile.getPath();
+ String filetype = sourceFiles[i][0];
+ if (filetype != null) {
+ fileProcess.parseFile(sourceFiles[i][1], filetype, root, true);
+ } else {
+ fileProcess.parseFile(sourceFiles[i][1], root, true);
+ }
+ }
+
+ //
+ // If exist Unicode file
+ //
+ if (fileProcess.isUnicodeExist()) {
+ Element ele = document.createElement("Build_Unicode_Database");
+ ele.setAttribute("FILEPATH", ".");
+ ele.setAttribute("FILENAME", "${BASE_NAME}");
+ String[] includePaths = includes.toArray(new String[includes.size()]);
+ Element includesEle = document.createElement("EXTRA.INC");
+ for (int i = 0; i < includePaths.length; i++) {
+ Element includeEle = document.createElement("includepath");
+ includeEle.setAttribute("path", includePaths[i]);
+ includesEle.appendChild(includeEle);
+ }
+ ele.appendChild(includesEle);
+ root.appendChild(ele);
+ }
+
+ //
+ // Parse AutoGen.c & AutoGen.h
+ //
+ if ( ! fpdModuleId.getModule().getName().equalsIgnoreCase("Shell")) {
+ fileProcess.parseFile(project.getProperty("DEST_DIR_DEBUG") + File.separatorChar + "AutoGen.c", root, false);
+ }
+
+ //
+ // Parse all source files but Unicode files
+ //
+ for (int i = 0; i < sourceFiles.length; i++) {
+ String filetype = sourceFiles[i][0];
+ if (filetype != null) {
+ fileProcess.parseFile(sourceFiles[i][1], filetype, root, false);
+ } else {
+ fileProcess.parseFile(sourceFiles[i][1], root, false);
+ }
+ }
+
+ //
+ // Initialize SOURCE_FILES for dependcy check use
+ //
+ String str = "";
+ for (int i = 0; i < sourceFiles.length; i++) {
+ str += " " + sourceFiles[i][1];
+ }
+ project.setProperty("SOURCE_FILES", str.replaceAll("(\\\\)", "/"));
+ }
+
+ /**
+ Generate the section elements for BaseName_build.xml. Library module will
+ skip this process.
+
+ @param document current BaseName_build.xml XML document
+ @param root Root element for current
+ **/
+ private void applySectionsElement(Document document, Node root, FfsProcess fp) {
+ if (fpdModuleId.getModule().isLibrary()) {
+ return ;
+ }
+ if (fp.initSections(ffsKeyword, project, fpdModuleId)) {
+ String targetFilename = fpdModuleId.getModule().getGuid() + "-" + fpdModuleId.getModule().getName() + FpdParserTask.getSuffix(fpdModuleId.getModule().getModuleType());
+ String[] list = fp.getGenSectionElements(document, "${BASE_NAME}", fpdModuleId.getModule().getGuid(), targetFilename);
+
+ for (int i = 0; i < list.length; i++) {
+ Element ele = document.createElement(list[i]);
+ ele.setAttribute("FILEPATH", ".");
+ ele.setAttribute("FILENAME", "${BASE_NAME}");
+ root.appendChild(ele);
+ }
+ }
+ }
+
+ /**
+ Generate the output elements for BaseName_build.xml. If module is library,
+ call the LIB command, else call the GenFfs command.
+
+ @param document current BaseName_build.xml XML document
+ @param root Root element for current
+ **/
+ private void applyOutputElement(Document document, Node root, FfsProcess fp) {
+ if (fpdModuleId.getModule().isLibrary()) {
+ //
+ // call Lib command
+ //
+ Element cc = document.createElement("Build_Library");
+ cc.setAttribute("FILENAME", fpdModuleId.getModule().getName());
+ root.appendChild(cc);
+ }
+ //
+ // if it is a module but library
+ //
+ else {
+ if (fp.getFfsNode() != null) {
+ root.appendChild(fp.getFfsNode());
+ }
+ }
+ }
+
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetup.java b/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetup.java
new file mode 100644
index 0000000000..6a53fa6dbb
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetup.java
@@ -0,0 +1,271 @@
+package org.tianocore.build;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.build.fpd.FpdParserTask;
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.OutputManager;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.id.FpdModuleIdentification;
+import org.tianocore.build.id.ModuleIdentification;
+import org.tianocore.build.id.PackageIdentification;
+import org.tianocore.build.id.PlatformIdentification;
+
+public class OutputDirSetup extends Task {
+ ///
+ /// Module surface area file.
+ ///
+ File msaFile;
+
+ ///
+ /// Module's Identification.
+ ///
+ private ModuleIdentification moduleId;
+
+ ///
+ /// Module's component type, such as SEC, LIBRARY, BS_DRIVER and so on.
+ ///
+ private String componentType;
+
+// private ToolChainFactory toolChainFactory;
+
+ /**
+ Public construct method. It is necessary for ANT task.
+ **/
+ public OutputDirSetup() {
+ }
+
+ public void execute() throws BuildException {
+ //
+ // Global Data initialization
+ //
+// GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db",
+// getProject().getProperty("WORKSPACE_DIR"));
+
+ //
+ // Parse MSA and get the basic information
+ // Including BaseName, GUID, Version, ComponentType and SupportedArchs
+ //
+ Map doc = GlobalData.getNativeMsa(msaFile);
+
+ SurfaceAreaQuery.setDoc(doc);
+
+ //
+ // String[]: {BaseName, ModuleType, ComponentType, Guid, Version}
+ //
+ moduleId = SurfaceAreaQuery.getMsaHeader();
+ // REMOVE!!! TBD
+ componentType = "APPLICATION";
+
+ //
+ // Judge whether it is single module build or not
+ //
+ if (getProject().getProperty("PLATFORM") == null) {
+ //
+ // Single Module build
+ //
+ prepareSingleModuleBuild();
+ }
+ else {
+ //
+ // Platform build
+ //
+ String platformName = getProject().getProperty("PLATFORM");
+ PlatformIdentification platformId = GlobalData.getPlatform(platformName);
+ getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
+
+ String packageName = getProject().getProperty("PACKAGE");
+ String packageGuid = getProject().getProperty("PACKAGE_GUID");
+ String packageVersion = getProject().getProperty("PACKAGE_VERSION");
+ PackageIdentification packageId = new PackageIdentification(packageName, packageGuid, packageVersion);
+ moduleId.setPackage(packageId);
+ }
+
+ //
+ // Tools Definition file parse
+ //
+ parseToolsDefinitionFile();
+
+ //
+ // For Every TOOLCHAIN, TARGET, ARCH
+ //
+// String[] targetList = GlobalData.getTargets();
+// for (int i = 0; i < targetList.length; i ++){
+// //
+// // Prepare for target related common properties
+// // TARGET
+// //
+// getProject().setProperty("TARGET", targetList[i]);
+// String[] toolchainList = GlobalData.getToolChains();
+// for(int j = 0; j < toolchainList.length; j ++){
+// //
+// // Prepare for toolchain related common properties
+// // TOOLCHAIN
+// //
+// getProject().setProperty("TOOLCHAIN", toolchainList[j]);
+// //
+// // If single module : intersection MSA supported ARCHs and tools def!!
+// // else, get arch from pass down
+// //
+// String[] archList = GlobalData.getArchs();
+// for (int k = 0; k < archList.length; k++) {
+//
+// FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, archList[k]);
+//
+// SurfaceAreaQuery.setDoc(GlobalData.getDoc(fpdModuleId));
+//
+// //
+// // Prepare for all other common properties
+// // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
+// // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, COMPONENT_TYPE
+// // MODULE_DIR, MODULE_RELATIVE_DIR
+// // SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH
+// // LIBS, OBJECTS, SDB_FILES
+// //
+// getProject().setProperty("ARCH", archList[k]);
+// setModuleCommonProperties();
+//
+// //
+// // String[0] is build mode. String[1] is user-defined output dir.
+// //
+// String buildMode = SurfaceAreaQuery.getFpdIntermediateDirectories();
+// String userDefinedOutputDir = SurfaceAreaQuery.getFpdOutputDirectory();
+//
+// //
+// // OutputManage prepare for
+// // BIN_DIR, DEST_DIR_DEBUG, DEST_DIR_OUTPUT, BUILD_DIR, FV_DIR
+// //
+// OutputManager.getInstance().update(getProject(), userDefinedOutputDir, buildMode);
+//
+// }
+// }
+// }
+
+ }
+
+ private void prepareSingleModuleBuild(){
+ //
+ // Find out the package which the module belongs to
+ // TBD: Enhance it!!!!
+ //
+ PackageIdentification packageId = GlobalData.getPackageForModule(moduleId);
+
+ moduleId.setPackage(packageId);
+
+ //
+ // Read ACTIVE_PLATFORM's FPD file (Call FpdParserTask's method)
+ //
+ String activePlatformName = getProject().getProperty("env.ACTIVE_PLATFORM");
+
+ PlatformIdentification platformId = GlobalData.getPlatform(activePlatformName);
+
+ //
+ // Read FPD file
+ //
+ FpdParserTask fpdParser = new FpdParserTask();
+ fpdParser.parseFpdFile(platformId.getFpdFile());
+
+ //
+ // Prepare for Platform related common properties
+ // PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
+ //
+ getProject().setProperty("PLATFORM", activePlatformName);
+ getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
+ }
+
+
+
+ /**
+
+ **/
+ private void setModuleCommonProperties() {
+ //
+ // Prepare for all other common properties
+ // PACKAGE, PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
+ //
+ PackageIdentification packageId = moduleId.getPackage();
+ getProject().setProperty("PACKAGE", packageId.getName());
+ getProject().setProperty("PACKAGE_GUID", packageId.getGuid());
+ getProject().setProperty("PACKAGE_VERSION", packageId.getVersion());
+ GlobalData.log.info("" + packageId);
+ getProject().setProperty("PACKAGE_DIR", packageId.getPackageDir().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("PACKAGE_RELATIVE_DIR", packageId.getPackageRelativeDir().replaceAll("(\\\\)", "/"));
+
+ //
+ // MODULE or BASE_NAME, GUID or FILE_GUID, VERSION, COMPONENT_TYPE
+ // MODULE_DIR, MODULE_RELATIVE_DIR
+ //
+ getProject().setProperty("MODULE", moduleId.getName());
+ getProject().setProperty("BASE_NAME", moduleId.getName());
+ getProject().setProperty("GUID", moduleId.getGuid());
+ getProject().setProperty("FILE_GUID", moduleId.getGuid());
+ getProject().setProperty("VERSION", moduleId.getVersion());
+ getProject().setProperty("COMPONENT_TYPE", componentType);
+ getProject().setProperty("MODULE_DIR", moduleId.getMsaFile().getParent().replaceAll("(\\\\)", "/"));
+ getProject().setProperty("MODULE_RELATIVE_DIR", moduleId.getModuleRelativePath().replaceAll("(\\\\)", "/"));
+ }
+
+
+ /**
+ Method is for ANT use to initialize MSA file.
+
+ @param msaFilename MSA file name
+ **/
+ public void setMsaFile(String msaFilename) {
+ String moduleDir = getProject().getProperty("MODULE_DIR");
+ if (moduleDir == null) {
+ moduleDir = getProject().getBaseDir().getPath();
+ }
+ msaFile = new File(moduleDir + File.separatorChar + msaFilename);
+ }
+
+ /**
+ Compile flags setup.
+
+
Take command CC and arch IA32 for example,
+ Those flags are from ToolChainFactory:
+
+
IA32_CC
+
IA32_CC_STD_FLAGS
+
IA32_CC_GLOBAL_FLAGS
+
IA32_CC_GLOBAL_ADD_FLAGS
+
IA32_CC_GLOBAL_SUB_FLAGS
+
+ Those flags can user-define:
+
+
IA32_CC_PROJ_FLAGS
+
IA32_CC_PROJ_ADD_FLAGS
+
IA32_CC_PROJ_SUB_FLAGS
+
CC_PROJ_FLAGS
+
CC_PROJ_ADD_FLAGS
+
CC_PROJ_SUB_FLAGS
+
CC_FLAGS
+
IA32_CC_FLAGS
+
+
+
The final flags is composed of STD, GLOBAL and PROJ. If CC_FLAGS or
+ IA32_CC_FLAGS is specified, STD, GLOBAL and PROJ will not affect.
+
+ Note that the ToolChainFactory executes only once
+ during whole build process.
+ **/
+ private void parseToolsDefinitionFile() {
+ //
+ // If ToolChain has been set up before, do nothing.
+ // CONF dir + tools definition file name
+ //
+ String confDir = GlobalData.getWorkspacePath() + File.separatorChar + "Tools" + File.separatorChar + "Conf";
+ String toolsDefFilename = "tools_def.txt";
+ if (getProject().getProperty("env.TOOLS_DEF") != null) {
+ toolsDefFilename = getProject().getProperty("env.TOOLS_DEF");
+ }
+// toolChainFactory = new ToolChainFactory(confDir, toolsDefFilename);
+// toolChainFactory.setupToolChain();
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetupTask.java b/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetupTask.java
deleted file mode 100644
index c2b7cc997b..0000000000
--- a/Tools/Source/GenBuild/org/tianocore/build/OutputDirSetupTask.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/** @file
-
- This file is an ANT task OutputDirSetupTask.
-
- This task main purpose is to setup some necessary properties for Package,
- Platform or Module clean.
-
-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.
-**/
-package org.tianocore.build;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.xmlbeans.XmlObject;
-
-import org.tianocore.build.global.GlobalData;
-import org.tianocore.build.global.OutputManager;
-import org.tianocore.build.global.SurfaceAreaQuery;
-import org.tianocore.build.toolchain.ToolChainFactory;
-
-/**
- OutputDirSetupTask is an ANT task that can be used in ANT build
- system. The main function of this task is to initialize some basic information
- for Package|Platform|Module clean or cleanall usage.
-
-
Note that all this task doing is part of GenBuildTask.
-
- @since GenBuild 1.0
- @see org.tianocore.build.GenBuildTask
-**/
-public class OutputDirSetupTask extends Task {
-
- ///
- /// Module surface area file.
- ///
- File msaFilename;
-
- ///
- /// Module build description file.
- ///
- File mbdFilename;
-
- ///
- /// Module surface area information after overrided.
- ///
- public Map map = new HashMap();
-
- ///
- /// Module's base name.
- ///
- private String baseName;
-
- /**
- Public construct method. It is necessary for ANT task.
- **/
- public OutputDirSetupTask () {
- }
-
- /**
- ANT task's entry point, will be called after init(). The main steps is described
- as following:
-
-
Judge current build mode (MODULE | PACKAGE | PLATFORM). This step will execute
- only once in whole build process;
-
Initialize global information (Framework DB, SPD files and all MSA files
- listed in SPD). This step will execute only once in whole build process;
-
Restore some important ANT property. If current build is single module
- build, here will set many default values;
-
Get the current module's overridded surface area information from
- global data;
-
Set up the output directories, including BIN_DIR, DEST_DIR_OUTPUT and
- DEST_DIR_DEBUG;
-
-
- @throws BuildException
- From module build, exception from module surface area invalid.
- **/
- public void execute() throws BuildException {
- System.out.println("Deleting module [" + baseName + "] start.");
- OutputManager.update(getProject());
- GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db", getProject()
- .getProperty("WORKSPACE_DIR"));
- recallFixedProperties();
- map = GlobalData.getDoc(baseName);
- //
- // Initialize SurfaceAreaQuery
- //
- SurfaceAreaQuery.setDoc(map);
- //
- // Setup Output Management
- //
- String[] outdir = SurfaceAreaQuery.getOutputDirectory();
- OutputManager.update(getProject(), outdir[1], outdir[0]);
- }
-
- /**
- Get current module's base name.
-
- @return base name
- **/
- public String getBaseName() {
- return baseName;
- }
-
- /**
- Set base name. For ANT use.
-
- @param baseName Base name
- **/
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
- /**
- Set MBD surface area file. For ANT use.
-
- @param mbdFilename Surface Area file
- **/
- public void setMbdFilename(File mbdFilename) {
- this.mbdFilename = mbdFilename;
- }
-
- /**
- Set MSA surface area file. For ANT use.
-
- @param msaFilename Surface Area file
- **/
- public void setMsaFilename(File msaFilename) {
- this.msaFilename = msaFilename;
- }
-
- /**
- Restore some important ANT property. If current build is single module
- build, here will set many default values.
-
-
If current build is single module build, then the default ARCH
- is IA32. Also set up the properties PACKAGE,
- PACKAGE_DIR, TARGET and MODULE_DIR
-
-
Note that for package build, package name is stored in PLATFORM
- and package directory is stored in PLATFORM_DIR.
-
- @see org.tianocore.build.global.OutputManager
- **/
- private void recallFixedProperties(){
- //
- // If build is for module build
- //
- if (getProject().getProperty("PACKAGE_DIR") == null) {
- ToolChainFactory toolChainFactory = new ToolChainFactory(getProject());
- toolChainFactory.setupToolChain();
- //
- // PACKAGE PACKAGE_DIR ARCH (Default) COMMON_FILE BUILD_MACRO
- //
- if (getProject().getProperty("ARCH") == null){
- getProject().setProperty("ARCH", "IA32");
- }
- String packageName = GlobalData.getPackageNameForModule(baseName);
- getProject().setProperty("PACKAGE", packageName);
- String packageDir = GlobalData.getPackagePath(packageName);
- getProject().setProperty("PACKAGE_DIR", getProject().getProperty("WORKSPACE_DIR") + File.separatorChar + packageDir);
- getProject().setProperty("TARGET", toolChainFactory.getCurrentTarget());
- getProject().setProperty("MODULE_DIR", getProject().replaceProperties(getProject().getProperty("MODULE_DIR")));
- }
- if (OutputManager.PLATFORM != null) {
- getProject().setProperty("PLATFORM", OutputManager.PLATFORM);
- }
- if (OutputManager.PLATFORM_DIR != null) {
- getProject().setProperty("PLATFORM_DIR", OutputManager.PLATFORM_DIR);
- }
- }
-}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
index 1b9c5a0e4a..95875544b3 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutoGen.java
@@ -20,12 +20,14 @@ package org.tianocore.build.autogen;
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;
import org.tianocore.GuidsDocument;
import org.tianocore.LibraryClassDocument.LibraryClass;
import org.tianocore.PPIsDocument;
import org.tianocore.ProtocolsDocument;
-import org.tianocore.build.pcd.action.PCDAutoGenAction;
-
+//import org.tianocore.build.pcd.action.PCDAutoGenAction;
+import org.tianocore.build.exception.*;
import org.apache.tools.ant.BuildException;
import org.apache.xmlbeans.XmlObject;
@@ -33,78 +35,86 @@ import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Set;
/**
- This class is to generate Autogen.h and Autogen.c according to module surface
- area or library surface area.
-**/
+ * This class is to generate Autogen.h and Autogen.c according to module surface
+ * area or library surface area.
+ */
public class AutoGen {
- ///
- /// The output path of Autogen.h and Autogen.c
- ///
+ // /
+ // / The output path of Autogen.h and Autogen.c
+ // /
private String outputPath;
- ///
- /// The base name of module or library.
- ///
- private String baseName;
+ // /
+ // / The base name of module or library.
+ // /
+ private ModuleIdentification moduleId;
- ///
- /// The build architecture
- ///
+ // /
+ // / The build architecture
+ // /
private String arch;
- ///
- /// PcdAutogen instance which is used to manage how to generate the PCD
- /// information.
- ///
- private PCDAutoGenAction myPcdAutogen;
-
- ///
- /// The protocl list which records in module or library surface area and
- /// it's dependence on library instance surface area.
- ///
- private List mProtocolList = new ArrayList();
-
- ///
- /// The Ppi list which recorded in module or library surface area and its
- /// dependency on library instance surface area.
- ///
- private List mPpiList = new ArrayList();
-
- ///
- /// The Guid list which recoreded in module or library surface are and it's
- /// dependence on library instance surface area.
- ///
- private List mGuidList = new ArrayList();
+ // /
+ // / PcdAutogen instance which is used to manage how to generate the PCD
+ // / information.
+ // /
+// private PCDAutoGenAction myPcdAutogen;
+
+ // /
+ // / The protocl list which records in module or library surface area and
+ // / it's dependence on library instance surface area.
+ // /
+ private Set mProtocolList = new HashSet();
+
+ // /
+ // / The Ppi list which recorded in module or library surface area and its
+ // / dependency on library instance surface area.
+ // /
+ private Set mPpiList = new HashSet();
+
+ // /
+ // / The Guid list which recoreded in module or library surface are and it's
+ // / dependence on library instance surface area.
+ // /
+ private Set mGuidList = new HashSet();
/**
- Construct function
-
- This function mainly initialize some member variable.
-
- @param outputPath Output path of AutoGen file.
- @param baseName Module base name.
- @param arch Target architecture.
- **/
- public AutoGen(String outputPath, String baseName, String arch) {
+ * Construct function
+ *
+ * This function mainly initialize some member variable.
+ *
+ * @param outputPath
+ * Output path of AutoGen file.
+ * @param baseName
+ * Module base name.
+ * @param arch
+ * Target architecture.
+ */
+ public AutoGen(String outputPath, ModuleIdentification moduleId, String arch) {
this.outputPath = outputPath;
- this.baseName = baseName;
+ this.moduleId = moduleId;
this.arch = arch;
}
/**
- saveFile function
-
- This function save the content in stringBuffer to file.
-
- @param fileName The name of file.
- @param fileBuffer The content of AutoGen file in buffer.
- @return "true" successful, "false" failed.
- **/
+ * saveFile function
+ *
+ * This function save the content in stringBuffer to file.
+ *
+ * @param fileName
+ * The name of file.
+ * @param fileBuffer
+ * The content of AutoGen file in buffer.
+ * @return "true" successful, "false" failed.
+ */
private boolean saveFile(String fileName, StringBuffer fileBuffer) {
try {
File autoGenH = new File(fileName);
@@ -136,13 +146,14 @@ public class AutoGen {
}
/**
- genAutogen function
-
- This function call libGenAutoGen or moduleGenAutogen function, which
- dependence on generate library autogen or module autogen.
-
- @throws BuildException Failed to creat AutoGen.c & AutoGen.h.
- **/
+ * genAutogen function
+ *
+ * This function call libGenAutoGen or moduleGenAutogen function, which
+ * dependence on generate library autogen or module autogen.
+ *
+ * @throws BuildException
+ * Failed to creat AutoGen.c & AutoGen.h.
+ */
public void genAutogen() throws BuildException {
try {
//
@@ -155,8 +166,7 @@ public class AutoGen {
// Check current is library or not, then call the corresponding
// function.
//
- if (SurfaceAreaQuery.getComponentType().equalsIgnoreCase(
- CommonDefinition.LibraryStr)) {
+ if (this.moduleId.isLibrary()) {
libGenAutogen();
} else {
moduleGenAutogen();
@@ -169,13 +179,14 @@ public class AutoGen {
}
}
- /**
- moduleGenAutogen function
-
- This function generates AutoGen.c & AutoGen.h for module.
-
- @throws BuildException Faile to create module AutoGen.c & AutoGen.h.
- **/
+ /**
+ * moduleGenAutogen function
+ *
+ * This function generates AutoGen.c & AutoGen.h for module.
+ *
+ * @throws BuildException
+ * Faile to create module AutoGen.c & AutoGen.h.
+ */
void moduleGenAutogen() throws BuildException {
try {
@@ -189,13 +200,13 @@ public class AutoGen {
}
/**
- libGenAutogen function
-
- This function generates AutoGen.c & AutoGen.h for library.
-
- @throws BuildException
- Faile to create library AutoGen.c & AutoGen.h
- **/
+ * libGenAutogen function
+ *
+ * This function generates AutoGen.c & AutoGen.h for library.
+ *
+ * @throws BuildException
+ * Faile to create library AutoGen.c & AutoGen.h
+ */
void libGenAutogen() throws BuildException {
try {
libGenAutogenC();
@@ -208,38 +219,42 @@ public class AutoGen {
}
/**
- moduleGenAutogenH
-
- This function generates AutoGen.h for module.
-
- @throws BuildException
- Failed to generate AutoGen.h.
- **/
- void moduleGenAutogenH() throws BuildException {
-
- List libClassIncludeH;
- String moduleType;
- List headerFileList;
+ * moduleGenAutogenH
+ *
+ * This function generates AutoGen.h for module.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.h.
+ */
+ void moduleGenAutogenH() throws AutoGenException {
+ Set libClassIncludeH;
+ String moduleType;
+ // List headerFileList;
+ Set headerFileList;
+ Iterator item;
StringBuffer fileBuffer = new StringBuffer(8192);
-
+
//
- // Write Autogen.h header notation
+ // Write Autogen.h header notation
//
fileBuffer.append(CommonDefinition.autogenHNotation);
-
+
//
- // Add #ifndef ${BaseName}_AUTOGENH
- // #def ${BseeName}_AUTOGENH
+ // Add #ifndef ${BaseName}_AUTOGENH
+ // #def ${BseeName}_AUTOGENH
//
- fileBuffer.append("#ifndef " + this.baseName.toUpperCase() + "_AUTOGENH\r\n");
- fileBuffer.append("#define " + this.baseName.toUpperCase() + "_AUTOGENH\r\n\r\n");
-
+ fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n");
+ fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n\r\n");
+
//
// Write the specification version and release version at the begine
// of autogen.h file.
// Note: the specification version and release version should
- // be got from module surface area instead of hard code by it's moduleType.
+ // be got from module surface area instead of hard code by it's
+ // moduleType.
//
moduleType = SurfaceAreaQuery.getModuleType();
switch (CommonDefinition.getModuleType(moduleType)) {
@@ -267,7 +282,7 @@ public class AutoGen {
}
//
- // Add "extern int __make_me_compile_correctly;" at begin of
+ // Add "extern int __make_me_compile_correctly;" at begin of
// AutoGen.h.
//
fileBuffer.append(CommonDefinition.autoGenHbegin);
@@ -275,49 +290,53 @@ public class AutoGen {
//
// Write consumed package's mdouleInfo related .h file to autogen.h
//
- List consumedPkgList = SurfaceAreaQuery
- .getIncludePackageName(this.arch);
- if (consumedPkgList != null) {
- headerFileList = IncludesToAutogenH(consumedPkgList, moduleType);
- for (int i = 0; i < headerFileList.size(); i++) {
- fileBuffer.append(headerFileList.get(i));
+// PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery
+// .getDependencePkg(this.arch);
+ PackageIdentification[] consumedPkgIdList = SurfaceAreaQuery.getDependencePkg(null);
+ if (consumedPkgIdList != null) {
+ headerFileList = depPkgToAutogenH(consumedPkgIdList, moduleType);
+ item = headerFileList.iterator();
+ while (item.hasNext()){
+ fileBuffer.append(item.next().toString());
}
}
//
// Write library class's related *.h file to autogen.h.
//
- LibraryClass[] libClassList = SurfaceAreaQuery
- .getLibraryClassArray(CommonDefinition.AlwaysConsumed);
+ String[] libClassList = SurfaceAreaQuery
+ .getLibraryClasses(CommonDefinition.AlwaysConsumed);
if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
- for (int i = 0; i < libClassIncludeH.size(); i++) {
- fileBuffer.append(libClassIncludeH.get(i));
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()){
+ fileBuffer.append(item.next().toString());
}
}
libClassList = SurfaceAreaQuery
- .getLibraryClassArray(CommonDefinition.AlwaysProduced);
+ .getLibraryClasses(CommonDefinition.AlwaysProduced);
if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
- for (int i = 0; i < libClassIncludeH.size(); i++) {
- fileBuffer.append(libClassIncludeH.get(i));
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()){
+ fileBuffer.append(item.next().toString());
}
}
fileBuffer.append("\r\n");
-
+
//
// Write PCD autogen information to AutoGen.h.
//
- if (this.myPcdAutogen != null) {
- fileBuffer.append(this.myPcdAutogen.OutputH());
- }
+// if (this.myPcdAutogen != null) {
+// fileBuffer.append(this.myPcdAutogen.OutputH());
+// }
//
// Append the #endif at AutoGen.h
//
fileBuffer.append("#endif\r\n");
-
+
//
// Save string buffer content in AutoGen.h.
//
@@ -325,32 +344,40 @@ public class AutoGen {
throw new BuildException("Failed to generate AutoGen.h !!!");
}
}
-
+
/**
- moduleGenAutogenC
-
- This function generates AutoGen.c for module.
-
- @throws BuildException
- Failed to generate AutoGen.c.
- **/
- void moduleGenAutogenC() throws BuildException {
+ * moduleGenAutogenC
+ *
+ * This function generates AutoGen.c for module.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.c.
+ */
+ void moduleGenAutogenC() throws AutoGenException {
StringBuffer fileBuffer = new StringBuffer(8192);
//
- // Write Autogen.c header notation
+ // Write Autogen.c header notation
//
fileBuffer.append(CommonDefinition.autogenCNotation);
-
+
//
// Write #include at beginning of AutoGen.c
//
fileBuffer.append(CommonDefinition.includeAutogenH);
-
+
+ //
+ // Get the native MSA file infomation. Since before call autogen,
+ // the MSA native information were overrided. So before
+ // process it should be set the DOC as the Native MSA info.
+ //
+ Map doc = GlobalData.getNativeMsa(this.moduleId);
+ SurfaceAreaQuery.push(doc);
//
- // Write DriverBinding/ComponentName/DriverConfiguration/DriverDialog
+ // Write DriverBinding/ComponentName/DriverConfiguration/DriverDialog
// to AutoGen.c
//
+
ExternsDriverBindingToAutoGenC(fileBuffer);
//
@@ -367,21 +394,29 @@ public class AutoGen {
EntryPointToAutoGen(entryPointList, fileBuffer);
}
+ //
+ // Restore the DOC which include the FPD module info.
+ //
+ SurfaceAreaQuery.pop();
+
//
// Write Guid to autogen.c
//
- String guid = SurfaceAreaQuery.getModuleGuid();
+ String guid = CommonDefinition.formatGuidName(SurfaceAreaQuery.getModuleGuid());
+
fileBuffer
.append("GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = {");
if (guid == null) {
- throw new BuildException("Guid value must set!\n");
+ throw new AutoGenException("Guid value must set!\n");
}
//
// Formate Guid as ANSI c form.Example:
- // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0}}
+ // {0xd2b2b828, 0x826, 0x48a7,{0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24,
+ // 0xf0}}
//
- fileBuffer.append(Spd.formatGuidName(guid));
+
+ fileBuffer.append(guid);
fileBuffer.append("};\r\n");
//
@@ -403,116 +438,119 @@ public class AutoGen {
// Call pcd autogen. PCDAutoGenAction tool only need module name and
// isPcdEmulatedDriver as parameter. Library inherits PCD and module's
// PCD information has been collected in FPDParser task by
- // CollectPCDAction.
+ // CollectPCDAction.
// Note : when PCD image tool ready,
// isPCDEmulatedDriver parameter will be removed.
//
- try {
- this.myPcdAutogen = new PCDAutoGenAction(baseName,
- null,
- null,
- null,
- this.arch,
- null,
- false,
- SurfaceAreaQuery.getModulePcdEntryNameArray());
- this.myPcdAutogen.execute();
- } catch (Exception e) {
- throw new BuildException("PCD Autogen for module failed:" + e.getMessage());
- }
-
- if (this.myPcdAutogen != null) {
- fileBuffer.append(this.myPcdAutogen.OutputC());
- }
+// try {
+// this.myPcdAutogen = new PCDAutoGenAction(moduleId.getName(),
+// moduleId.getName().equalsIgnoreCase("PcdEmulatorPeim"));
+// this.myPcdAutogen.execute();
+// } catch (Exception e) {
+// throw new BuildException("PCD Autogen failed:" + e.getMessage());
+// }
+//
+// if (this.myPcdAutogen != null) {
+// fileBuffer.append(this.myPcdAutogen.OutputC());
+// }
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
throw new BuildException("Failed to generate AutoGen.c !!!");
}
}
-
+
/**
- libGenAutogenH
-
- This function generates AutoGen.h for library.
-
- @throws BuildException
- Failed to generate AutoGen.c.
- **/
- void libGenAutogenH() throws BuildException {
-
- List libClassIncludeH;
+ * libGenAutogenH
+ *
+ * This function generates AutoGen.h for library.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.c.
+ */
+ void libGenAutogenH() throws AutoGenException {
+
+ Set libClassIncludeH;
String moduleType;
- List headerFileList;
+ Set headerFileList;
+ Iterator item;
StringBuffer fileBuffer = new StringBuffer(10240);
//
- // Write Autogen.h header notation
+ // Write Autogen.h header notation
//
fileBuffer.append(CommonDefinition.autogenHNotation);
-
+
//
- // Add #ifndef ${BaseName}_AUTOGENH
- // #def ${BseeName}_AUTOGENH
+ // Add #ifndef ${BaseName}_AUTOGENH
+ // #def ${BseeName}_AUTOGENH
//
- fileBuffer.append("#ifndef " + this.baseName.toUpperCase() + "_AUTOGENH\r\n");
- fileBuffer.append("#define " + this.baseName.toUpperCase() + "_AUTOGENH\r\n\r\n");
-
+ fileBuffer.append("#ifndef " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n");
+ fileBuffer.append("#define " + this.moduleId.getName().toUpperCase()
+ + "_AUTOGENH\r\n\r\n");
+
//
- // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
+ // Write EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION
// to autogen.h file.
// Note: the specification version and release version should
// be get from module surface area instead of hard code.
//
fileBuffer.append(CommonDefinition.autoGenHbegin);
- fileBuffer.append(CommonDefinition.autoGenHLine1);
- fileBuffer.append(CommonDefinition.autoGenHLine2);
+ String[] specList = SurfaceAreaQuery.getExternSpecificaiton();
+ for (int i = 0; i < specList.length; i++){
+ fileBuffer.append(CommonDefinition.marcDefineStr + specList[i] + "\r\n");
+ }
+// fileBuffer.append(CommonDefinition.autoGenHLine1);
+// fileBuffer.append(CommonDefinition.autoGenHLine2);
//
// Write consumed package's mdouleInfo related *.h file to autogen.h.
//
moduleType = SurfaceAreaQuery.getModuleType();
- List cosumedPkglist = SurfaceAreaQuery
- .getIncludePackageName(this.arch);
- headerFileList = IncludesToAutogenH(cosumedPkglist, moduleType);
- for (int i = 0; i < headerFileList.size(); i++) {
- fileBuffer.append(headerFileList.get(i));
+ PackageIdentification[] cosumedPkglist = SurfaceAreaQuery
+ .getDependencePkg(this.arch);
+ headerFileList = depPkgToAutogenH(cosumedPkglist, moduleType);
+ item = headerFileList.iterator();
+ while (item.hasNext()){
+ fileBuffer.append(item.next().toString());
}
-
//
// Write library class's related *.h file to autogen.h
//
- LibraryClass[] libClassList = SurfaceAreaQuery
- .getLibraryClassArray(CommonDefinition.AlwaysConsumed);
+ String[] libClassList = SurfaceAreaQuery
+ .getLibraryClasses(CommonDefinition.AlwaysConsumed);
if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
- for (int i = 0; i < libClassIncludeH.size(); i++) {
- fileBuffer.append(libClassIncludeH.get(i));
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()){
+ fileBuffer.append(item.next().toString());
}
}
libClassList = SurfaceAreaQuery
- .getLibraryClassArray(CommonDefinition.AlwaysProduced);
+ .getLibraryClasses(CommonDefinition.AlwaysProduced);
if (libClassList != null) {
libClassIncludeH = LibraryClassToAutogenH(libClassList);
- for (int i = 0; i < libClassIncludeH.size(); i++) {
- fileBuffer.append(libClassIncludeH.get(i));
+ item = libClassIncludeH.iterator();
+ while (item.hasNext()){
+ fileBuffer.append(item.next().toString());
}
}
fileBuffer.append("\r\n");
-
+
//
// Write PCD information to library AutoGen.h.
//
- if (this.myPcdAutogen != null) {
- fileBuffer.append(this.myPcdAutogen.OutputH());
- }
+// if (this.myPcdAutogen != null) {
+// fileBuffer.append(this.myPcdAutogen.OutputH());
+// }
//
// Append the #endif at AutoGen.h
//
fileBuffer.append("#endif\r\n");
-
+
//
// Save content of string buffer to AutoGen.h file.
//
@@ -522,21 +560,21 @@ public class AutoGen {
}
/**
- libGenAutogenC
-
- This function generates AutoGen.h for library.
-
- @throws BuildException
- Failed to generate AutoGen.c.
- **/
+ * libGenAutogenC
+ *
+ * This function generates AutoGen.h for library.
+ *
+ * @throws BuildException
+ * Failed to generate AutoGen.c.
+ */
void libGenAutogenC() throws BuildException {
StringBuffer fileBuffer = new StringBuffer(10240);
//
- // Write Autogen.c header notation
+ // Write Autogen.c header notation
//
fileBuffer.append(CommonDefinition.autogenCNotation);
-
+
fileBuffer.append(CommonDefinition.autoGenCLine1);
fileBuffer.append("\r\n");
@@ -544,27 +582,22 @@ public class AutoGen {
// Call pcd autogen. PCDAutoGenAction tool only need module name and
// isPcdEmulatedDriver as parameter. Library inherit PCD and module's
// PCD information has been collected in FPDParser task by
- // CollectPCDAction.
+ // CollectPCDAction.
// Note : when PCD image tool ready,
// isPCDEmulatedDriver parameter will be removed.
//
try {
- this.myPcdAutogen = new PCDAutoGenAction(baseName,
- null,
- null,
- null,
- this.arch,
- null,
- true,
- SurfaceAreaQuery.getModulePcdEntryNameArray());
- this.myPcdAutogen.execute();
+// this.myPcdAutogen = new PCDAutoGenAction(this.moduleId.getName(),
+// this.moduleId.getName().equalsIgnoreCase("PcdEmulatorPeim"));
+// this.myPcdAutogen.execute();
+// this.myPcdAutogen = new PCDAutoGenAction(this.moduleId,);
} catch (Exception e) {
- throw new BuildException("Pcd Autogen for library failed! " + e.getMessage());
+ throw new BuildException(e.getMessage());
}
- if (this.myPcdAutogen != null) {
- fileBuffer.append(this.myPcdAutogen.OutputC());
- }
+// if (this.myPcdAutogen != null) {
+// fileBuffer.append(this.myPcdAutogen.OutputC());
+// }
if (!saveFile(outputPath + File.separatorChar + "AutoGen.c", fileBuffer)) {
throw new BuildException("Failed to generate AutoGen.c !!!");
@@ -572,78 +605,97 @@ public class AutoGen {
}
/**
- LibraryClassToAutogenH
-
- This function returns *.h files declared by library classes which are
- consumed or produced by current build module or library.
-
- @param libClassList List of library class which consumed or produce
- by current build module or library.
- @return includeStrList List of *.h file.
- **/
- List LibraryClassToAutogenH(LibraryClass[] libClassList) {
- List includStrList = new ArrayList();
- String includerName;
+ * LibraryClassToAutogenH
+ *
+ * This function returns *.h files declared by library classes which are
+ * consumed or produced by current build module or library.
+ *
+ * @param libClassList
+ * List of library class which consumed or produce by current
+ * build module or library.
+ * @return includeStrList List of *.h file.
+ */
+ Set LibraryClassToAutogenH(String[] libClassList) throws AutoGenException{
+ Set includStrList = new HashSet();
+ String includerName[];
String str = "";
-
+
//
- // Get include file from GlobalData's SPDTable according to
+ // Get include file from GlobalData's SPDTable according to
// library class name.
//
+
for (int i = 0; i < libClassList.length; i++) {
- includerName = GlobalData.getLibClassIncluder(getStringValue((XmlObject)libClassList[i]));
- if (includerName != null) {
- str = CommonDefinition.include + " " + "<";
- str = str + includerName + ">\r\n";
- includStrList.add(str);
- includerName = null;
+ includerName = GlobalData.getLibraryClassHeaderFiles(
+ SurfaceAreaQuery.getDependencePkg(this.arch),
+ libClassList[i]);
+ if (includerName == null){
+ throw new AutoGenException("Can not find library class [" + libClassList[i] + "] declaration in every packages. ");
+ }
+ for (int j = 0; j < includerName.length; j++) {
+ String includeNameStr = includerName[j];
+ if (includeNameStr != null) {
+ str = CommonDefinition.include + " " + "<";
+ str = str + includeNameStr + ">\r\n";
+ includStrList.add(str);
+ includeNameStr = null;
+ }
}
}
return includStrList;
}
/**
- IncludesToAutogenH
-
- This function add include file in AutoGen.h file.
- @param packageNameList List of module depended package.
- @param moduleType Module type.
- @return
- **/
- List IncludesToAutogenH(List packageNameList,
- String moduleType) {
-
- List includeStrList = new ArrayList();
- String packageName = "";
+ * IncludesToAutogenH
+ *
+ * This function add include file in AutoGen.h file.
+ *
+ * @param packageNameList
+ * List of module depended package.
+ * @param moduleType
+ * Module type.
+ * @return
+ */
+ Set depPkgToAutogenH(PackageIdentification[] packageNameList,
+ String moduleType) throws AutoGenException{
+
+ Set includeStrList = new HashSet();
+ String pkgHeader;
String includeStr = "";
//
// Get include file from moduleInfo file
//
- for (int i = 0; i < packageNameList.size(); i++) {
- packageName = packageNameList.get(i);
- includeStr = GlobalData.getModuleInfoByPackageName(packageName,
- moduleType);
- includeStrList.add(includeStr);
+ for (int i = 0; i < packageNameList.length; i++){
+// pkgHeader = GlobalData.getPackageHeaderFiles(packageNameList[i], moduleType);
+// if (pkgHeader == null){
+// throw new AutoGenException("Can not find package [" + packageNameList[i] + "] declaration in every packages. ");
+// }else if (!pkgHeader.equalsIgnoreCase("")){
+// includeStr = CommonDefinition.include + "<" + pkgHeader + ">\r\n";
+// includeStrList.add(includeStr);
+// }
}
+
return includeStrList;
}
/**
- EntryPointToAutoGen
-
- This function convert & information
- in mas to AutoGen.c
-
- @param entryPointList List of entry point.
- @param fileBuffer String buffer fo AutoGen.c.
- @throws Exception
- **/
+ * EntryPointToAutoGen
+ *
+ * This function convert &
+ * information in mas to AutoGen.c
+ *
+ * @param entryPointList
+ * List of entry point.
+ * @param fileBuffer
+ * String buffer fo AutoGen.c.
+ * @throws Exception
+ */
void EntryPointToAutoGen(String[] entryPointList, StringBuffer fileBuffer)
throws BuildException {
String typeStr = SurfaceAreaQuery.getModuleType();
-
+
//
// The parameters and return value of entryPoint is difference
// for difference module type.
@@ -833,23 +885,7 @@ public class AutoGen {
//
entryPointList = SurfaceAreaQuery.getModuleUnloadImageArray();
entryPointCount = 0;
- if (entryPointList != null) {
- for (int i = 0; i < entryPointList.length; i++) {
- if (!entryPointList[i].equals("")) {
- fileBuffer.append("EFI_STATUS\r\n");
- fileBuffer.append("EFIAPI\r\n");
- fileBuffer.append(entryPointList[i]);
- fileBuffer.append(" (\r\n");
- fileBuffer
- .append(" EFI_HANDLE ImageHandle\r\n");
- fileBuffer.append(" );\r\n");
- entryPointCount++;
- } else {
- break;
- }
- }
- }
-
+
fileBuffer
.append("GLOBAL_REMOVE_IF_UNREFERENCED const UINT8 _gDriverUnloadImageCount = ");
fileBuffer.append(Integer.toString(entryPointCount));
@@ -1078,198 +1114,170 @@ public class AutoGen {
}
/**
- PpiGuidToAutogenc
-
- This function gets GUIDs from SPD file accrodeing to information and
- write those GUIDs to AutoGen.c.
-
- @param fileBuffer String Buffer for Autogen.c file.
- @throws BuildException Guid must set value!
- **/
- void PpiGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {
+ * PpiGuidToAutogenc
+ *
+ * This function gets GUIDs from SPD file accrodeing to information
+ * and write those GUIDs to AutoGen.c.
+ *
+ * @param fileBuffer
+ * String Buffer for Autogen.c file.
+ * @throws BuildException
+ * Guid must set value!
+ */
+ void PpiGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
String[] cNameGuid = null;
- boolean isEqual = false;
-
- PPIsDocument.PPIs.Ppi[] ppiList = SurfaceAreaQuery.getPpiArray(null);
- if (ppiList != null) {
- for (int i = 0; i < ppiList.length; i++) {
- isEqual = false;
- String ppiName = getStringValue((XmlObject)ppiList[i]);
- for (int j = 0; j < this.mPpiList.size(); j++) {
- if (this.mPpiList.get(j).equalsIgnoreCase(ppiName)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mPpiList.add(ppiName);
- }
- }
+
+ //
+ // Get the all PPI adn PPI Notify from MSA file,
+ // then add those PPI ,and PPI Notify name to list.
+ //
+ String[] ppiList = SurfaceAreaQuery.getPpiArray(null);
+ for (int i = 0; i < ppiList.length; i++) {
+ this.mPpiList.add(ppiList[i]);
}
- PPIsDocument.PPIs.PpiNotify[] ppiNotifyList = SurfaceAreaQuery
- .getPpiNotifyArray(null);
- if (ppiNotifyList != null) {
- for (int i = 0; i < ppiNotifyList.length; i++) {
- isEqual = false;
- String ppiNotifyName = getStringValue((XmlObject)ppiNotifyList[i]);
- for (int j = 0; j < this.mPpiList.size(); j++) {
- if (this.mPpiList.get(j).equalsIgnoreCase(ppiNotifyName)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mPpiList.add(ppiNotifyName);
- }
- }
+ String[] ppiNotifyList = SurfaceAreaQuery.getPpiNotifyArray(null);
+ for (int i = 0; i < ppiNotifyList.length; i++) {
+ this.mPpiList.add(ppiNotifyList[i]);
}
- for (int i = 0; i < this.mPpiList.size(); i++) {
- if (this.mPpiList.get(i) != null) {
- cNameGuid = GlobalData.getPpiInfoGuid(this.mPpiList.get(i));
- if (cNameGuid != null) {
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
- fileBuffer.append(cNameGuid[0]);
- fileBuffer.append(" = { ");
- fileBuffer.append(cNameGuid[1]);
- fileBuffer.append(" } ;");
- }
+ //
+ // Find CNAME and GUID from dependence SPD file and write to Autogen.c
+ //
+ Iterator ppiIterator = this.mPpiList.iterator();
+ String ppiKeyWord = null;
+ while (ppiIterator.hasNext()) {
+ ppiKeyWord = ppiIterator.next().toString();
+ cNameGuid = GlobalData
+ .getPpiGuid(SurfaceAreaQuery.getDependencePkg(this.arch),
+ ppiKeyWord);
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(cNameGuid[1]);
+ fileBuffer.append(" } ;");
} else {
- throw new BuildException("Guid must set value!");
+ //
+ // If can't find Ppi GUID declaration in every package
+ //
+ throw new AutoGenException("Can not find Ppi GUID [" + ppiKeyWord + "] declaration in every packages. ");
}
}
}
/**
- ProtocolGuidToAutogenc
-
- This function gets GUIDs from SPD file accrodeing to
- information and write those GUIDs to AutoGen.c.
-
- @param fileBuffer String Buffer for Autogen.c file.
- @throws BuildException Protocol name must set.
- **/
+ * ProtocolGuidToAutogenc
+ *
+ * This function gets GUIDs from SPD file accrodeing to
+ * information and write those GUIDs to AutoGen.c.
+ *
+ * @param fileBuffer
+ * String Buffer for Autogen.c file.
+ * @throws BuildException
+ * Protocol name must set.
+ */
void ProtocolGuidToAutogenC(StringBuffer fileBuffer) throws BuildException {
String[] cNameGuid = null;
- boolean isEqual = false;
-
- ProtocolsDocument.Protocols.Protocol[] protocolList = SurfaceAreaQuery
- .getProtocolArray(null);
- if (protocolList != null) {
- for (int i = 0; i < protocolList.length; i++) {
- isEqual = false;
- String protocolName = getStringValue((XmlObject)protocolList[i]);
- for (int j = 0; j < this.mProtocolList.size(); j++) {
- if (this.mProtocolList.get(j).equalsIgnoreCase(protocolName)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mProtocolList.add(protocolName);
- }
- }
+ String[] protocolList = SurfaceAreaQuery.getProtocolArray(this.arch);
+
+ //
+ // Add result to Autogen global list.
+ //
+ for (int i = 0; i < protocolList.length; i++) {
+ this.mProtocolList.add(protocolList[i]);
}
- ProtocolsDocument.Protocols.ProtocolNotify[] protocolNotifyList = SurfaceAreaQuery
- .getProtocolNotifyArray(null);
- if (protocolNotifyList != null) {
- for (int i = 0; i < protocolNotifyList.length; i++) {
- isEqual = false;
- String protocolNotifyName = getStringValue((XmlObject)protocolNotifyList[i]);
- for (int j = 0; j < this.mProtocolList.size(); j++) {
- if (this.mProtocolList.get(j).equalsIgnoreCase(protocolNotifyName)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mProtocolList.add(protocolNotifyName);
+ String[] protocolNotifyList = SurfaceAreaQuery
+ .getProtocolNotifyArray(this.arch);
- }
- }
+ for (int i = 0; i < protocolNotifyList.length; i++) {
+ this.mProtocolList.add(protocolNotifyList[i]);
}
- if (this.mProtocolList.size() > 0) {
- for (int i = 0; i < this.mProtocolList.size(); i++) {
- if (this.mProtocolList.get(i) != null) {
- cNameGuid = GlobalData
- .getProtocolInfoGuid(this.mProtocolList.get(i));
- if (cNameGuid != null) {
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
- fileBuffer.append(cNameGuid[0]);
- fileBuffer.append(" = { ");
- fileBuffer.append(cNameGuid[1]);
- fileBuffer.append(" } ;");
- }
- } else {
- throw new BuildException("Protocol name must set!");
- }
+
+ //
+ // Get the NAME and GUID from dependence SPD and write to Autogen.c
+ //
+ Iterator protocolIterator = this.mPpiList.iterator();
+ String protocolKeyWord = null;
+ while (protocolIterator.hasNext()) {
+ protocolKeyWord = protocolIterator.next().toString();
+ cNameGuid = GlobalData.getProtocolGuid(SurfaceAreaQuery
+ .getDependencePkg(this.arch), protocolKeyWord);
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(cNameGuid[1]);
+ fileBuffer.append(" } ;");
+ } else {
+ //
+ // If can't find protocol GUID declaration in every package
+ //
+ throw new BuildException("Can not find protocol Guid [" + cNameGuid + "] declaration in every packages. ");
}
}
}
/**
- GuidGuidToAutogenc
-
- This function gets GUIDs from SPD file accrodeing to information
- and write those GUIDs to AutoGen.c.
-
- @param fileBuffer String Buffer for Autogen.c file.
-
- **/
- void GuidGuidToAutogenC(StringBuffer fileBuffer) {
+ * GuidGuidToAutogenc
+ *
+ * This function gets GUIDs from SPD file accrodeing to information
+ * and write those GUIDs to AutoGen.c.
+ *
+ * @param fileBuffer
+ * String Buffer for Autogen.c file.
+ *
+ */
+ void GuidGuidToAutogenC(StringBuffer fileBuffer) throws AutoGenException {
String[] cNameGuid = null;
- boolean isEqual = false;
- GuidsDocument.Guids.GuidEntry[] guidList = SurfaceAreaQuery
- .getGuidEntryArray(null);
-
- if (guidList != null) {
- for (int i = 0; i < guidList.length; i++) {
- for (int j = 0; j < this.mGuidList.size(); j++) {
- isEqual = false;
- if (this.mGuidList.get(j).getCName().equalsIgnoreCase(
- guidList[i].getCName().toString())) {
- isEqual = true;
- break;
- }
- }
- if (!isEqual) {
- this.mGuidList.add(guidList[i]);
+ String guidKeyWord = null;
- }
+ String[] guidList = SurfaceAreaQuery.getGuidEntryArray(this.arch);
- }
+ for (int i = 0; i < guidList.length; i++) {
+ this.mGuidList.add(guidList[i]);
}
- for (int i = 0; i < this.mGuidList.size(); i++) {
- if (this.mGuidList.get(i).getCName() != null) {
- cNameGuid = GlobalData.getGuidInfoGuid(this.mGuidList.get(i)
- .getCName());
- if (cNameGuid != null) {
- fileBuffer
- .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
- fileBuffer.append(cNameGuid[0]);
- fileBuffer.append(" = { ");
- fileBuffer.append(cNameGuid[1]);
- fileBuffer.append("} ;");
- }
+ Iterator guidIterator = this.mGuidList.iterator();
+ while (guidIterator.hasNext()) {
+ guidKeyWord = guidIterator.next().toString();
+ cNameGuid = GlobalData.getGuid(SurfaceAreaQuery
+ .getDependencePkg(this.arch), guidKeyWord);
+
+ if (cNameGuid != null) {
+ fileBuffer
+ .append("\r\nGLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID ");
+ fileBuffer.append(cNameGuid[0]);
+ fileBuffer.append(" = { ");
+ fileBuffer.append(cNameGuid[1]);
+ fileBuffer.append("} ;");
+ }else {
+ //
+ // If can't find GUID declaration in every package
+ //
+ throw new AutoGenException("Can not find Guid [" + guidKeyWord + "] declaration in every packages. ");
}
+
}
}
/**
- LibInstanceToAutogenC
-
- This function adds dependent library instance to autogen.c,which includeing
- library's constructor, destructor, and library dependent ppi, protocol, guid,
- pcd information.
-
- @param fileBuffer String buffer for AutoGen.c
- @throws BuildException
- **/
+ * LibInstanceToAutogenC
+ *
+ * This function adds dependent library instance to autogen.c,which
+ * includeing library's constructor, destructor, and library dependent ppi,
+ * protocol, guid, pcd information.
+ *
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws BuildException
+ */
void LibInstanceToAutogenC(StringBuffer fileBuffer) throws BuildException {
int index;
- boolean isEqual = false;
String moduleType = SurfaceAreaQuery.getModuleType();
List libConstructList = new ArrayList();
@@ -1277,144 +1285,83 @@ public class AutoGen {
String libConstructName = null;
String libDestructName = null;
- List libraryList = SurfaceAreaQuery.getLibraryInstance(
- this.arch, CommonDefinition.AlwaysConsumed);
+ ModuleIdentification[] libraryIdList = SurfaceAreaQuery.getLibraryInstance(this.arch);
try {
- if (libraryList != null) {
+ if (libraryIdList != null) {
//
// Reorder library instance sequence.
//
- AutogenLibOrder libOrder = new AutogenLibOrder(libraryList);
- List orderList = libOrder.orderLibInstance();
-
+ AutogenLibOrder libOrder = new AutogenLibOrder(libraryIdList, this.arch);
+ List orderList = libOrder.orderLibInstance();
+
if (orderList != null) {
//
// Process library instance one by one.
//
for (int i = 0; i < orderList.size(); i++) {
-
+
//
// Get library instance basename.
//
- String libInstanceName = orderList.get(i).toString();
-
+ ModuleIdentification libInstanceId = orderList.get(i);
+
//
// Get override map
//
Map libDoc = GlobalData
- .getDoc(libInstanceName);
+ .getDoc(libInstanceId, this.arch);
SurfaceAreaQuery.push(libDoc);
-
+
//
// Get , , list of this library
// instance.
//
- PPIsDocument.PPIs.Ppi[] ppiList = SurfaceAreaQuery
+ String[] ppiList = SurfaceAreaQuery
.getPpiArray(null);
- PPIsDocument.PPIs.PpiNotify[] ppiNotifyList = SurfaceAreaQuery
+ String[] ppiNotifyList = SurfaceAreaQuery
.getPpiNotifyArray(null);
- ProtocolsDocument.Protocols.Protocol[] protocolList = SurfaceAreaQuery
+ String[] protocolList = SurfaceAreaQuery
.getProtocolArray(null);
- ProtocolsDocument.Protocols.ProtocolNotify[] protocolNotifyList = SurfaceAreaQuery
+ String[] protocolNotifyList = SurfaceAreaQuery
.getProtocolNotifyArray(null);
- GuidsDocument.Guids.GuidEntry[] guidList = SurfaceAreaQuery
+ String[] guidList = SurfaceAreaQuery
.getGuidEntryArray(null);
//
- // Add those ppi, protocol, guid in global ppi, protocol, guid
+ // Add those ppi, protocol, guid in global ppi,
+ // protocol, guid
// list.
//
- if (ppiList != null) {
- for (index = 0; index < ppiList.length; index++) {
- isEqual = false;
- String name = getStringValue((XmlObject)ppiList[index]);
- for (int j = 0; j < this.mPpiList.size(); j++) {
- if (this.mPpiList.get(j).equalsIgnoreCase(name)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mPpiList.add(name);
- }
- }
+ for (index = 0; index < ppiList.length; index++) {
+ this.mPpiList.add(ppiList[index]);
}
- if (ppiNotifyList != null) {
- for (index = 0; index < ppiNotifyList.length; index++) {
- isEqual = false;
- String name = getStringValue((XmlObject)ppiNotifyList[index]);
- for (int j = 0; j < this.mPpiList.size(); j++) {
- if (this.mPpiList.get(j).equalsIgnoreCase(name)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mPpiList.add(name);
- }
- }
+
+ for (index = 0; index < ppiNotifyList.length; index++) {
+ this.mPpiList.add(ppiNotifyList[index]);
}
- if (protocolList != null) {
- for (index = 0; index < protocolList.length; index++) {
- isEqual = false;
- String name = getStringValue((XmlObject)protocolList[index]);
- for (int j = 0; j < this.mProtocolList.size(); j++) {
- if (this.mProtocolList.get(j).equalsIgnoreCase(name)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mProtocolList.add(name);
- }
- }
+
+ for (index = 0; index < protocolList.length; index++) {
+ this.mProtocolList.add(protocolList[index]);
}
- if (protocolNotifyList != null) {
- for (index = 0; index < protocolNotifyList.length; index++) {
- isEqual = false;
- String name = getStringValue((XmlObject)protocolNotifyList[index]);
- for (int j = 0; j < this.mProtocolList.size(); j++) {
- if (this.mProtocolList.get(j).equalsIgnoreCase(name)) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mProtocolList.add(name);
- }
- }
+
+ for (index = 0; index < protocolNotifyList.length; index++) {
+ this.mProtocolList.add(protocolNotifyList[index]);
}
- if (guidList != null) {
- for (index = 0; index < guidList.length; index++) {
- isEqual = false;
- for (int j = 0; j < this.mGuidList.size(); j++) {
- if (this.mGuidList.get(j).getCName()
- .equalsIgnoreCase(
- guidList[index].getCName())) {
- isEqual = true;
- }
- }
- if (!isEqual) {
- this.mGuidList.add(guidList[index]);
- }
- }
+
+ for (index = 0; index < guidList.length; index++) {
+ this.mGuidList.add(guidList[index]);
}
//
// If not yet parse this library instance's constructor
// element,parse it.
//
- if (!GlobalData.isHaveLibInstance(libInstanceName)) {
- libConstructName = SurfaceAreaQuery
+ libConstructName = SurfaceAreaQuery
.getLibConstructorName();
- libDestructName = SurfaceAreaQuery
+ libDestructName = SurfaceAreaQuery
.getLibDestructorName();
- GlobalData.setLibInstanceInfo(libInstanceName,
- libConstructName, libDestructName);
- } else {
- libConstructName = GlobalData
- .getLibInstanceConstructor(libInstanceName);
- libDestructName = GlobalData
- .getLibInstanceDestructor(libInstanceName);
- }
SurfaceAreaQuery.pop();
//
// Add dependent library instance constructor function.
@@ -1440,8 +1387,7 @@ public class AutoGen {
//
// Add library destructor to AutoGen.c
//
- LibDestructorToAutogenC(libDestructList, moduleType,
- fileBuffer/* autogenC */);
+ LibDestructorToAutogenC(libDestructList, moduleType, fileBuffer/* autogenC */);
}
} catch (Exception e) {
@@ -1449,24 +1395,26 @@ public class AutoGen {
}
}
-
/**
- LibConstructorToAutogenc
-
- This function writes library constructor list to AutoGen.c. The library
- constructor's parameter and return value depend on module type.
-
- @param libInstanceList List of library construct name.
- @param moduleType Module type.
- @param fileBuffer String buffer for AutoGen.c
- @throws Exception
- **/
+ * LibConstructorToAutogenc
+ *
+ * This function writes library constructor list to AutoGen.c. The library
+ * constructor's parameter and return value depend on module type.
+ *
+ * @param libInstanceList
+ * List of library construct name.
+ * @param moduleType
+ * Module type.
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws Exception
+ */
void LibConstructorToAutogenC(List libInstanceList,
String moduleType, StringBuffer fileBuffer) throws Exception {
boolean isFirst = true;
//
- // The library constructor's parameter and return value depend on
+ // The library constructor's parameter and return value depend on
// module type.
//
for (int i = 0; i < libInstanceList.size(); i++) {
@@ -1577,16 +1525,19 @@ public class AutoGen {
}
/**
- LibDestructorToAutogenc
-
- This function writes library destructor list to AutoGen.c. The library
- destructor's parameter and return value depend on module type.
-
- @param libInstanceList List of library destructor name.
- @param moduleType Module type.
- @param fileBuffer String buffer for AutoGen.c
- @throws Exception
- **/
+ * LibDestructorToAutogenc
+ *
+ * This function writes library destructor list to AutoGen.c. The library
+ * destructor's parameter and return value depend on module type.
+ *
+ * @param libInstanceList
+ * List of library destructor name.
+ * @param moduleType
+ * Module type.
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws Exception
+ */
void LibDestructorToAutogenC(List libInstanceList,
String moduleType, StringBuffer fileBuffer) throws Exception {
boolean isFirst = true;
@@ -1666,12 +1617,13 @@ public class AutoGen {
}
/**
- ExternsDriverBindingToAutoGenC
-
- This function is to write DRIVER_BINDING, COMPONENT_NAME,
- DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
-
- @param fileBuffer String buffer for AutoGen.c
+ * ExternsDriverBindingToAutoGenC
+ *
+ * This function is to write DRIVER_BINDING, COMPONENT_NAME,
+ * DRIVER_CONFIGURATION, DRIVER_DIAGNOSTIC in AutoGen.c.
+ *
+ * @param fileBuffer
+ * String buffer for AutoGen.c
*/
void ExternsDriverBindingToAutoGenC(StringBuffer fileBuffer)
throws BuildException {
@@ -1681,12 +1633,12 @@ public class AutoGen {
// under should be same. 1. DRIVER_BINDING 2. COMPONENT_NAME
// 3.DRIVER_CONFIGURATION 4. DRIVER_DIAGNOSTIC
//
-
+
String[] drvBindList = SurfaceAreaQuery.getDriverBindingArray();
-
+
//
// If component name protocol,component configuration protocol,
- // component diagnostic protocol is not null or empty, check
+ // component diagnostic protocol is not null or empty, check
// if every one have the same number of the driver binding protocol.
//
if (drvBindList == null || drvBindList.length == 0) {
@@ -1819,14 +1771,15 @@ public class AutoGen {
}
/**
- ExternCallBackToAutoGenC
-
- This function adds and
- infomation to AutoGen.c
-
- @param fileBuffer String buffer for AutoGen.c
- @throws BuildException
- **/
+ * ExternCallBackToAutoGenC
+ *
+ * This function adds and
+ * infomation to AutoGen.c
+ *
+ * @param fileBuffer
+ * String buffer for AutoGen.c
+ * @throws BuildException
+ */
void ExternCallBackToAutoGenC(StringBuffer fileBuffer)
throws BuildException {
String[] setVirtualList = SurfaceAreaQuery
@@ -2003,7 +1956,4 @@ public class AutoGen {
}
- private String getStringValue(XmlObject xmlDoc) {
- return xmlDoc.getDomNode().getFirstChild().getNodeValue();
- }
-}
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java
index 50668b096b..f08fec70e7 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/AutogenLibOrder.java
@@ -20,11 +20,13 @@ import java.util.ArrayList;
import java.util.HashMap;
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;
+import org.tianocore.build.id.ModuleIdentification;
/**
This class This class is to reorder library instance sequence according to
@@ -34,18 +36,18 @@ public class AutogenLibOrder {
///
/// The map of library class and its library instance.
///
- private Map libClassMap = new HashMap();
+ private Map libClassMap = new HashMap();
///
- /// The map of library instance and its implemet instance.
+ /// The map of library instance and its implemet libraryClass.
///
- private Map libInstanceMap = new HashMap();
+ private Map libInstanceMap = new HashMap();
///
/// List of library instance. It is String[3] list, String[0] is libraryName,
/// String[1] is libraryConstructor name, String[2] is libDestructor name.
///
- private List libInstanceList = new ArrayList();
+ private List libInstanceList = new ArrayList();
/**
Constructor function
@@ -55,40 +57,37 @@ public class AutogenLibOrder {
@param libraryList List of the library instance.
@throws Exception
**/
- AutogenLibOrder(List libraryList) throws Exception {
- String[] libInstance = new String[3];
- LibraryClass[] libClassDeclList = null;
- LibraryClass[] libClassConsmList = null;
+ AutogenLibOrder(ModuleIdentification[] libraryList, String arch) throws Exception {
+ LibraryInstanceNode libInstanceNode;
+ String[] libClassDeclList = null;
+ String[] libClassConsmList = null;
- for (int i = 0; i < libraryList.size(); i++) {
+ for (int i = 0; i < libraryList.length; i++) {
//
// Add libraryInstance in to libInstanceList.
- //
- libInstance[0] = libraryList.get(i);
- Map libDoc = GlobalData.getDoc(libInstance[0]);
+ //
+ Map libDoc = GlobalData.getDoc(libraryList[i], arch);
SurfaceAreaQuery.push(libDoc);
- libInstance[1] = SurfaceAreaQuery.getLibConstructorName();
- libInstance[2] = SurfaceAreaQuery.getLibDestructorName();
- libInstanceList.add(libInstance.clone());
+ libInstanceNode = new LibraryInstanceNode (libraryList[i],SurfaceAreaQuery.getLibConstructorName(), SurfaceAreaQuery.getLibDestructorName());
+ libInstanceList.add(libInstanceNode);
//
// Add library instance and consumed library class list to
// libInstanceMap.
//
libClassConsmList = SurfaceAreaQuery
- .getLibraryClassArray(CommonDefinition.AlwaysConsumed);
+ .getLibraryClasses(CommonDefinition.AlwaysConsumed);
if (libClassConsmList != null) {
String[] classStr = new String[libClassConsmList.length];
for (int k = 0; k < libClassConsmList.length; k++) {
- //classStr[k] = libClassConsmList[k].getStringValue();
- classStr[k] = getStringValue((XmlObject)libClassConsmList[k]);
+ classStr[k] = libClassConsmList[k];
}
- if (this.libInstanceMap.containsKey(libInstance[0])) {
+ if (this.libInstanceMap.containsKey(libraryList[i])) {
throw new Exception(
- libInstance[0]
+ libraryList[i].getName()
+ "this library instance is already exist, please check you library instance list!");
} else {
- this.libInstanceMap.put(libInstance[0], classStr);
+ this.libInstanceMap.put(libraryList[i], classStr);
}
}
@@ -96,20 +95,17 @@ public class AutogenLibOrder {
// Add library class and library instance map.
//
libClassDeclList = SurfaceAreaQuery
- .getLibraryClassArray(CommonDefinition.AlwaysProduced);
+ .getLibraryClasses(CommonDefinition.AlwaysProduced);
if (libClassDeclList != null) {
for (int j = 0; j < libClassDeclList.length; j++) {
- //if (this.libClassMap.containsKey(libClassDeclList[j]
- // .getStringValue())) {
- String libClassName = getStringValue((XmlObject)libClassDeclList[j]);
- if (this.libClassMap.containsKey(libClassName)) {
- System.out.println(libClassName
+ if (this.libClassMap.containsKey(libClassDeclList[j])) {
+ System.out.println(libClassDeclList[j]
+ " class is already implement by "
- + this.libClassMap.get(libClassName));
+ + this.libClassMap.get(libClassDeclList[j]));
throw new Exception(libClassDeclList
+ " is already have library instance!");
} else {
- this.libClassMap.put(libClassName, libInstance[0]);
+ this.libClassMap.put(libClassDeclList[j], libraryList[i]);
}
}
}
@@ -149,15 +145,15 @@ public class AutogenLibOrder {
@return List which content the ordered library instance.
**/
- List orderLibInstance() {
- List orderList = new ArrayList();
+ List orderLibInstance() {
+ List orderList = new ArrayList();
//
// Stack of node which track the library instance name ant its visiting
// flag.
//
List stackList = new ArrayList();
int stackSize = 0;
- String libInstance = null;
+ ModuleIdentification libInstanceId = null;
if (libInstanceList.size() < 0) {
return null;
}
@@ -169,11 +165,11 @@ public class AutogenLibOrder {
//
// If library instance is already in the order list skip it.
//
- if (isInLibInstance(orderList, libInstanceList.get(i)[0])) {
+ if (isInLibInstance(orderList, libInstanceList.get(i).libId)) {
continue;
}
- Node node = new Node(libInstanceList.get(i)[0], false);
+ Node node = new Node(libInstanceList.get(i).libId, false);
//
// Use stack to reorder library instance.
// Push node to stack.
@@ -187,8 +183,8 @@ public class AutogenLibOrder {
//
if (stackList.get(stackSize).isVisit) {
if (!isInLibInstance(orderList,
- stackList.get(stackSize).nodeName)) {
- orderList.add(stackList.get(stackSize).nodeName);
+ stackList.get(stackSize).nodeId)) {
+ orderList.add(stackList.get(stackSize).nodeId);
stackList.remove(stackSize);
}
@@ -198,15 +194,15 @@ public class AutogenLibOrder {
//
stackList.get(stackList.size() - 1).isVisit = true;
String[] libClassList = this.libInstanceMap.get(stackList
- .get(stackSize).nodeName);
+ .get(stackSize).nodeId);
//
// Push the node dependence library instance to the stack.
//
if (libClassList != null) {
for (int j = 0; j < libClassList.length; j++) {
- libInstance = this.libClassMap.get(libClassList[j]);
- if (libInstance != null
- && !isInLibInstance(orderList, libInstance)) {
+ libInstanceId = this.libClassMap.get(libClassList[j]);
+ if (libInstanceId != null
+ && !isInLibInstance(orderList, libInstanceId)) {
//
// If and only if the currently library instance
// is not in stack and it have constructor or
@@ -214,7 +210,7 @@ public class AutogenLibOrder {
// instacne in stack.
//
if (!isInStackList(stackList, this.libClassMap
- .get(libClassList[j])) && isHaveConsDestructor(libInstance)) {
+ .get(libClassList[j])) && isHaveConsDestructor(libInstanceId)) {
stackList.add(new Node(this.libClassMap
.get(libClassList[j]), false));
}
@@ -237,9 +233,10 @@ public class AutogenLibOrder {
@return "true" the library instance in list |
"false" the library instance is not in list.
**/
- private boolean isInLibInstance(List list, String instanceName) {
+ private boolean isInLibInstance(List list, ModuleIdentification instanceId) {
for (int i = 0; i < list.size(); i++) {
- if (instanceName.equalsIgnoreCase(list.get(i).toString())) {
+
+ if (instanceId.equals(list.get(i))) {
return true;
}
}
@@ -256,9 +253,9 @@ public class AutogenLibOrder {
@return "true" if node have in stack |
"false" if node don't in stack.
**/
- private boolean isInStackList(List list, String nodeName) {
+ private boolean isInStackList(List list, ModuleIdentification instanceId) {
for (int i = 0; i < list.size(); i++) {
- if (nodeName.equalsIgnoreCase(list.get(i).nodeName)) {
+ if (instanceId.equals(list.get(i).nodeId)) {
return true;
}
}
@@ -276,20 +273,16 @@ public class AutogenLibOrder {
"false" if library don't have constructor
and desconstructor.
**/
- private boolean isHaveConsDestructor (String libName){
+ private boolean isHaveConsDestructor (ModuleIdentification libNode){
for (int i = 0; i < libInstanceList.size(); i++){
- if (libInstanceList.get(i)[0].equalsIgnoreCase(libName)){
- if (libInstanceList.get(i)[1] != null || libInstanceList.get(i)[2] != null){
+ if (libInstanceList.get(i).libId.equals(libNode)){
+ if (libInstanceList.get(i).constructorName != null || libInstanceList.get(i).deconstructorName != null){
return true;
}
}
}
return false;
}
-
- private String getStringValue(XmlObject xmlDoc) {
- return xmlDoc.getDomNode().getFirstChild().getNodeValue();
- }
}
/**
@@ -299,12 +292,29 @@ public class AutogenLibOrder {
**/
class Node {
- String nodeName;
+ ModuleIdentification nodeId;
boolean isVisit;
- Node(String name, boolean isVisit) {
- this.nodeName = name;
+ Node(ModuleIdentification nodeId, boolean isVisit) {
+ this.nodeId = nodeId;
this.isVisit = false;
}
-}
\ No newline at end of file
+}
+/**
+ LibraryInstance Node
+
+ This class is used to store LibrayInstance and it's deconstructor and constructor
+**/
+
+class LibraryInstanceNode {
+ ModuleIdentification libId;
+ String deconstructorName;
+ String constructorName;
+
+ LibraryInstanceNode (ModuleIdentification libId, String deconstructor, String constructor){
+ this.libId = libId;
+ this.deconstructorName = deconstructor;
+ this.constructorName = constructor;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
index 2da1c6b6f5..f449cb3a7c 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/autogen/CommonDefinition.java
@@ -44,6 +44,7 @@ public class CommonDefinition {
public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n";
public final static String includeAutogenH = "#include \r\n" ;
+ public final static String marcDefineStr = "#define ";
public final static String gEfi = "gEfi";
public final static String protocolGuid = "ProtocolGuid";
@@ -148,10 +149,10 @@ public class CommonDefinition {
new MyEnum("PEI_CORE", ModuleTypePeiCore),
new MyEnum("PEIM", ModuleTypePeim),
new MyEnum("DXE_CORE", ModuleTypeDxeCore),
- new MyEnum("DXE_DRIVER", ModuleTypeDxeDriver),
+ new MyEnum("DXE_DRIVER", ModuleTypeDxeRuntimeDriver),
new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),
- new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),
+ new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
@@ -254,29 +255,64 @@ public class CommonDefinition {
}
return false;
}
+
+ /**
+ * formateGuidName
+ *
+ * This function is to formate GUID to ANSI c form.
+ *
+ * @param guidNameCon
+ * String of GUID.
+ * @return Formated GUID.
+ */
+ public static String formatGuidName(String guidNameConv) {
+ String[] strList;
+ String guid = "";
+ int index = 0;
+ if (guidNameConv
+ .matches("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}")) {
+ strList = guidNameConv.split("-");
+ guid = "0x" + strList[0] + ", ";
+ guid = guid + "0x" + strList[1] + ", ";
+ guid = guid + "0x" + strList[2] + ", ";
+ guid = guid + "{";
+ guid = guid + "0x" + strList[3].substring(0, 2) + ", ";
+ guid = guid + "0x" + strList[3].substring(2, 4);
- static public boolean isPeiPhaseComponent (int componentType) {
- if (ComponentTypePe32Peim == componentType
- || ComponentTypePicPeim == componentType
- || ComponentTypeCombinedPeimDriver == componentType
- || ComponentTypePeiCore == componentType) {
- return true;
- }
- return false;
- }
+ while (index < strList[4].length()) {
+ guid = guid + ", ";
+ guid = guid + "0x" + strList[4].substring(index, index + 2);
+ index = index + 2;
+ }
+ guid = guid + "}";
+ return guid;
+ } else if (guidNameConv
+ .matches("0x[a-fA-F0-9]{1,8},( )*0x[a-fA-F0-9]{1,4},( )*0x[a-fA-F0-9]{1,4}(,( )*\\{)?(,?( )*0x[a-fA-F0-9]{1,2}){8}( )*(\\})?")) {
+ strList = guidNameConv.split(",");
- static public boolean isPe32PeimComponent (int componentType) {
- if (ComponentTypePe32Peim == componentType) {
- return true;
- }
- return false;
- }
+ //
+ // chang Microsoft specific form to ANSI c form
+ //
+ for (int i = 0; i < 3; i++) {
+ guid = guid + strList[i] + ",";
+ }
+ guid = guid + "{";
- static public boolean isBsDriverComponent (int componentType) {
- if (ComponentTypeBsDriver == componentType) {
- return true;
- }
- return false;
- }
-
-}
+ for (int i = 3; i < strList.length; i++) {
+ if (i == strList.length - 1) {
+ guid = guid + strList[i];
+ } else {
+ guid = guid + strList[i] + ",";
+ }
+ }
+ guid = guid + "}";
+ return guid;
+ } else {
+ System.out
+ .println("Check GUID Value, it don't conform to the schema!!!");
+ return "0";
+
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/AutoGenException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/AutoGenException.java
new file mode 100644
index 0000000000..0faf6c7113
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/AutoGenException.java
@@ -0,0 +1,39 @@
+/** @file
+ AutoGenException class.
+
+ The class handle the exception throwed by entity class.
+
+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.
+
+**/
+package org.tianocore.build.exception;
+
+
+/**
+ The class handle the exception throwed by entity class.
+**/
+public class AutoGenException extends GenBuildException {
+ //static final long serialVersionUID = -8034897190740066939L;
+ /**
+ Constructure function
+
+ @param expStr exception message string.
+ **/
+ public AutoGenException(String expStr) {
+ super("[AutoGenException]:" + expStr);
+ }
+
+ public AutoGenException() {
+ super();
+ }
+ public AutoGenException(Exception e, String messsge){
+ super(e, messsge);
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/EdkException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/EdkException.java
new file mode 100644
index 0000000000..8be839bb48
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/EdkException.java
@@ -0,0 +1,36 @@
+/** @file
+ EntityException class.
+
+ The class handle the exception throwed by entity class.
+
+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.
+
+**/
+package org.tianocore.build.exception;
+
+/**
+ The class handle the exception throwed by entity class.
+**/
+public class EdkException extends Exception {
+ //static final long serialVersionUID = -8034897190740066939L;
+ /**
+ Constructure function
+
+ @param expStr exception message string.
+ **/
+ public EdkException(String expStr) {
+ super("[EdkException]:" + expStr);
+ }
+
+ public EdkException() {
+ super();
+ }
+}
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java
new file mode 100644
index 0000000000..ac75ca8f9d
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/GenBuildException.java
@@ -0,0 +1,40 @@
+/** @file
+ GenBuildException class.
+
+ The class handle the exception throwed by entity class.
+
+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.
+
+**/
+package org.tianocore.build.exception;
+
+import org.tianocore.build.exception.EdkException;
+
+/**
+ The class handle the exception throwed by entity class.
+**/
+public class GenBuildException extends EdkException {
+ //static final long serialVersionUID = -8034897190740066939L;
+ /**
+ Constructure function
+
+ @param expStr exception message string.
+ **/
+ public GenBuildException(String expStr) {
+ super("[GenBuildException]:" + expStr);
+ }
+
+ public GenBuildException() {
+ super();
+ }
+ public GenBuildException(Exception e, String message){
+// super(e, message);
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java
new file mode 100644
index 0000000000..49d5543e11
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/PcdAutogenException.java
@@ -0,0 +1,35 @@
+/** @file
+ AutoGenException class.
+
+ The class handle the exception throwed by entity class.
+
+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.
+
+**/
+package org.tianocore.build.exception;
+
+/**
+ The class handle the exception throwed by entity class.
+**/
+public class PcdAutogenException extends AutoGenException {
+ //static final long serialVersionUID = -8034897190740066939L;
+ /**
+ Constructure function
+
+ @param expStr exception message string.
+ **/
+ public PcdAutogenException(String expStr) {
+ super("[PcdAutogenException]:" + expStr);
+ }
+
+ public PcdAutogenException() {
+ super();
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java
new file mode 100644
index 0000000000..3ab2fcf448
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/TianoToolsException.java
@@ -0,0 +1,41 @@
+/** @file
+ TianoToolsException class.
+
+ The class handle the exception throwed by entity class.
+
+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.
+
+**/
+package org.tianocore.build.exception;
+
+import org.tianocore.build.exception.EdkException;
+
+/**
+ The class handle the exception throwed by entity class.
+**/
+public class TianoToolsException extends EdkException {
+ //static final long serialVersionUID = -8034897190740066939L;
+ /**
+ Constructure function
+
+ @param expStr exception message string.
+ **/
+ public TianoToolsException(String expStr) {
+ super("[TianoToolsException]:" + expStr);
+ }
+
+ public TianoToolsException() {
+ super();
+ }
+
+ public TianoToolsException (Exception e, String message){
+// super(e, message);
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/exception/XmlParseException.java b/Tools/Source/GenBuild/org/tianocore/build/exception/XmlParseException.java
new file mode 100644
index 0000000000..afa92f4598
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/exception/XmlParseException.java
@@ -0,0 +1,35 @@
+/** @file
+ XmlParseException class.
+
+ The class handle the exception throwed by entity class.
+
+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.
+
+**/
+package org.tianocore.build.exception;
+
+/**
+ The class handle the exception throwed by entity class.
+**/
+public class XmlParseException extends GenBuildException {
+ //static final long serialVersionUID = -8034897190740066939L;
+ /**
+ Constructure function
+
+ @param expStr exception message string.
+ **/
+ public XmlParseException(String expStr) {
+ super("[XmlParseException]:" + expStr);
+ }
+
+ public XmlParseException() {
+ super();
+ }
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdModuleIdentification.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdModuleIdentification.java
deleted file mode 100644
index 261cf58a35..0000000000
--- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdModuleIdentification.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/** @file
- Java class FpdModuleIdentification is used to present a module identification
- from BaseName, GUID, Version, PackageName, and ARCH.
-
-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.
-**/
-package org.tianocore.build.fpd;
-
-/**
- This class is used to identify a module with BaseName, GUID, Version, PackageName
- and ARCH.
-
- @since GenBuild 1.0
- **/
-public class FpdModuleIdentification {
-
- private String arch;
-
- private String fvBinding;
-
- private String baseName;
-
- private String packageName;
-
- private String guid;
-
- private String version;
-
- private String sequence;
-
- /**
-
- @param baseName the base name of the module
- @param guid the GUID of the module
- @param arch the ARCH of the module
- **/
- public FpdModuleIdentification(String baseName, String guid, String arch){
- this.baseName = baseName;
- this.guid = guid;
- this.arch = arch;
- }
-
- /**
- Override java.lang.Object#equals.
-
-
Currently, use BaseName and ARCH to identify a module. It will enhance
- in the next version.
-
- @see java.lang.Object#equals(java.lang.Object)
- **/
- public boolean equals(Object obj) {
- if (obj instanceof FpdModuleIdentification) {
- FpdModuleIdentification moduleIdObj = (FpdModuleIdentification)obj;
- if ( baseName.equalsIgnoreCase(moduleIdObj.baseName) && arch.equalsIgnoreCase(moduleIdObj.arch)) {
- return true;
- }
- // TBD
- return false;
- }
- else {
- return super.equals(obj);
- }
- }
-
- public void setArch(String arch) {
- this.arch = arch;
- }
-
- public void setFvBinding(String fvBinding) {
- this.fvBinding = fvBinding;
- }
-
- public void setSequence(String sequence) {
- this.sequence = sequence;
- }
-
- public String toString(){
- return arch + ":" + guid + "_" + baseName;
- }
-
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
- public String getArch() {
- return arch;
- }
-
- public String getBaseName() {
- return baseName;
- }
-
- public String getFvBinding() {
- return fvBinding;
- }
-
- public String getGuid() {
- return guid;
- }
-
- public String getPackageName() {
- return packageName;
- }
-
- public String getSequence() {
- return sequence;
- }
-
- public String getVersion() {
- return version;
- }
-}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
index 21197b5c62..59bb47faa4 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
@@ -1,18 +1,18 @@
/** @file
- This file is ANT task FpdParserTask.
+ 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.
+ 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
-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.
-**/
+ 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.
+ **/
package org.tianocore.build.fpd;
import java.io.BufferedWriter;
@@ -25,67 +25,67 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
+import java.util.TreeMap;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
import org.apache.xmlbeans.XmlObject;
-import org.w3c.dom.Comment;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.tianocore.build.exception.EdkException;
import org.tianocore.build.global.GlobalData;
import org.tianocore.build.global.OutputManager;
-import org.tianocore.build.global.OverrideProcess;
import org.tianocore.build.global.SurfaceAreaQuery;
-import org.tianocore.build.pcd.action.CollectPCDAction;
-import org.tianocore.build.pcd.action.ActionMessage;
-import org.tianocore.BuildOptionsDocument;
-import org.tianocore.FrameworkPlatformDescriptionDocument;
-import org.tianocore.ModuleSADocument;
-
+import org.tianocore.build.id.FpdModuleIdentification;
+import org.tianocore.build.id.ModuleIdentification;
+import org.tianocore.build.id.PlatformIdentification;
+import org.tianocore.build.toolchain.ToolChainAttribute;
+import org.tianocore.build.toolchain.ToolChainElement;
+import org.tianocore.build.toolchain.ToolChainMap;
/**
- FpdParserTask is an ANT task. The main function is parsing FPD
- XML file and generating its ANT build script for Platform or Package.
+ FpdParserTask is an ANT task. The main function is parsing Framework
+ Platform Descritpion (FPD) XML file and generating its ANT build script for
+ corresponding platform.
+
+
The task sets global properties PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
+ and BUILD_DIR.
-
The usage is (take NT32 Platform for example):
+
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.
+
+
FpdParserTask task stores all FPD information to GlobalData. And parse
+ tools definition file to set up compiler options for different Target and
+ different ToolChainTag.
+
+
The method parseFpdFile is also prepared for single module build.
+
+ @param moduleType module type
+ @return
+ @throws BuildException
+ If module type is null
**/
- public void addProperty(Property p) {
- properties.addElement(p);
- }
+ public static String getSuffix(String moduleType) throws BuildException {
+ if (moduleType == null) {
+ throw new BuildException("Module type is not specified.");
+ }
- /**
- Get FPD file name.
-
- @return FPD file name.
- **/
- public File getFpdFilename() {
- return fpdFilename;
+ 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" } };
+
+ for (int i = 0; i < suffix.length; i++) {
+ if (suffix[i][0].equalsIgnoreCase(moduleType)) {
+ return suffix[i][1];
+ }
+ }
+ //
+ // Default is '.FFS'
+ //
+ return ".FFS";
}
-
/**
- Set FPD file name.
-
- @param fpdFilename FPD file name
- **/
- public void setFpdFilename(File fpdFilename) {
- this.fpdFilename = fpdFilename;
+ Add a property.
+
+ @param p property
+ **/
+ public void addProperty(Property p) {
+ properties.addElement(p);
}
- public File getGuiddatabase() {
- return guiddatabase;
+ public void setPlatformName(String platformName) {
+ this.platformName = platformName;
}
- public void setGuiddatabase(File guiddatabase) {
- this.guiddatabase = guiddatabase;
+ public void setFpdFile(File fpdFile) {
+ this.fpdFile = fpdFile;
}
- public void collectPCDInformation() {
- String exceptionString = null;
- CollectPCDAction collectAction = new CollectPCDAction ();
- //
- // Collect all PCD information from FPD to MSA, and get help information from SPD.
- // These all information will be stored into memory database for future usage such
- // as autogen.
- //
- try {
- collectAction.perform (getProject().getProperty("WORKSPACE_DIR"),
- fpdFilename.getPath(),
- ActionMessage.MAX_MESSAGE_LEVEL
- );
- } catch (Exception exp) {
- exceptionString = exp.getMessage();
- if (exceptionString == null) {
- exceptionString = "[Internal Error]Pcd tools catch a internel errors, Please report this bug into TianoCore or send email to Wang, scott or Lu, ken!";
- }
- throw new BuildException (String.format("Fail to do PCD preprocess from FPD file: %s", exceptionString));
- }
+ public void setType(String type) {
+ this.type = type;
}
+
+
}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java
new file mode 100644
index 0000000000..b41ea211d2
--- /dev/null
+++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/PlatformBuildFileGenerator.java
@@ -0,0 +1,479 @@
+/** @file
+
+ 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.
+ **/
+package org.tianocore.build.fpd;
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.tianocore.build.global.GlobalData;
+import org.tianocore.build.global.SurfaceAreaQuery;
+import org.tianocore.build.id.FpdModuleIdentification;
+import org.tianocore.build.id.ModuleIdentification;
+import org.w3c.dom.Comment;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+
+public class PlatformBuildFileGenerator {
+
+ private String platformName;
+
+ ///
+ /// Mapping from modules identification to out put file name
+ ///
+ private Map outfiles;
+
+ ///
+ /// Mapping from FV name to its modules
+ ///
+ private Map> fvs;
+
+ ///
+ /// Mapping from sequence number to FV names
+ ///
+ private Map> sequences;
+
+ private boolean isUnified = true;
+
+ private Project project;
+
+ private String info = "DO NOT EDIT \n"
+ + "File auto-generated by build utility\n"
+ + "\n"
+ + "Abstract:\n"
+ + "Auto-generated ANT build file for building of EFI Modules/Platforms\n";
+
+ public PlatformBuildFileGenerator(Project project, Map outfiles, Map> fvs, Map> sequences, boolean isUnified){
+ this.project = project;
+ this.outfiles = outfiles;
+ this.fvs = fvs;
+ this.sequences = sequences;
+ this.isUnified = isUnified;
+ this.platformName = project.getProperty("PLATFORM");
+ }
+
+ /**
+ Generate build.out.xml file.
+
+ @throws BuildException
+ build.out.xml XML document create error
+ **/
+ public void genBuildFile() throws BuildException {
+ DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
+ try {
+ DocumentBuilder dombuilder = domfac.newDocumentBuilder();
+ Document document = dombuilder.newDocument();
+ Comment rootComment = document.createComment(info);
+ //
+ // create root element and its attributes
+ //
+ Element root = document.createElement("project");
+ root.setAttribute("name", project.getProperty("PLATFORM"));
+ root.setAttribute("default", "all");
+ root.setAttribute("basedir", ".");
+
+ //
+ // element for External ANT tasks
+ //
+ root.appendChild(document.createComment("Apply external ANT tasks"));
+ Element ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "GenBuild.tasks");
+ root.appendChild(ele);
+
+ ele = document.createElement("taskdef");
+ ele.setAttribute("resource", "frameworktasks.tasks");
+ root.appendChild(ele);
+
+ ele = document.createElement("property");
+ ele.setAttribute("environment", "env");
+ root.appendChild(ele);
+
+ Set sequenceKeys = sequences.keySet();
+ Iterator sequenceIter = sequenceKeys.iterator();
+ String dependsStr = "";
+ while (sequenceIter.hasNext()) {
+ String num = (String)sequenceIter.next();
+ if (dependsStr.length() > 0) {
+ dependsStr += " , ";
+ }
+ dependsStr += "modules" + num + ", fvs" + num;
+ }
+
+ //
+ // Default Target
+ //
+ root.appendChild(document.createComment("Default target"));
+ ele = document.createElement("target");
+ ele.setAttribute("name", "all");
+ ele.setAttribute("depends", dependsStr + ", userextensions");
+ root.appendChild(ele);
+
+ //
+ // Modules and Fvs Target
+ //
+ sequenceIter = sequenceKeys.iterator();
+ while (sequenceIter.hasNext()) {
+ String num = (String)sequenceIter.next();
+ applyModules(document, root, num);
+ applyFvs(document, root, num);
+ }
+
+ //
+ // Clean Target
+ //
+ applyClean(document, root);
+
+ //
+ // Deep Clean Target
+ //
+ applyCleanall(document, root);
+
+ //
+ // User Extension
+ //
+ applyUserExtensions(document, root);
+
+ document.appendChild(rootComment);
+ document.appendChild(root);
+ //
+ // Prepare the DOM document for writing
+ //
+ Source source = new DOMSource(document);
+ //
+ // Prepare the output file
+ //
+ File file = new File(project.getProperty("PLATFORM_DIR") + File.separatorChar + platformName + "_build.xml");
+ //
+ // generate all directory path
+ //
+ (new File(file.getParent())).mkdirs();
+ Result result = new StreamResult(file);
+ //
+ // Write the DOM document to the file
+ //
+ Transformer xformer = TransformerFactory.newInstance().newTransformer();
+ xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
+ xformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ xformer.transform(source, result);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ throw new BuildException("Generate " + platformName + "_build.xml failed. \n" + ex.getMessage());
+ }
+ }
+ private void applyModules(Document document, Node root, String num) {
+ root.appendChild(document.createComment("Modules target"));
+ Element ele = document.createElement("target");
+ ele.setAttribute("name", "modules" + num);
+
+ Set fvNameSet = sequences.get(num);
+
+ Iterator fvNameIter = fvNameSet.iterator();
+ while (fvNameIter.hasNext()) {
+ String fvName = (String)fvNameIter.next();
+ Set set = fvs.get(fvName);
+ Iterator iter = set.iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();
+ ModuleIdentification moduleId = fpdModuleId.getModule();
+ Element moduleEle = document.createElement("GenBuild");
+ moduleEle.setAttribute("type", "build");
+ //
+ // Inherit Properties.
+ //{"ARCH", "PACKAGE", "PACKAGE_GUID", "PACKAGE_VERSION", "MODULE_DIR"}
+ //
+
+ //
+ // ARCH
+ //
+ Element property = document.createElement("property");
+ property.setAttribute("name", "ARCH");
+ property.setAttribute("value", fpdModuleId.getArch());
+ moduleEle.appendChild(property);
+
+ //
+ // MODULE_GUID
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "MODULE_GUID");
+ property.setAttribute("value", moduleId.getGuid());
+ moduleEle.appendChild(property);
+
+ //
+ // MODULE_VERSION
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "MODULE_VERSION");
+ property.setAttribute("value", moduleId.getVersion());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE_GUID
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_GUID");
+ property.setAttribute("value", moduleId.getPackage().getGuid());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE_VERSION
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_VERSION");
+ property.setAttribute("value", moduleId.getPackage().getVersion());
+ moduleEle.appendChild(property);
+
+ ele.appendChild(moduleEle);
+ }
+ }
+ root.appendChild(ele);
+ }
+
+ private void applyFvs(Document document, Node root, String num) {
+ Set fvNameSet = sequences.get(num);
+ //
+ // FVS Target
+ //
+ root.appendChild(document.createComment("FVs target"));
+ Element ele = document.createElement("target");
+ ele.setAttribute("name", "fvs" + num);
+
+ //
+ // For every Target and ToolChain
+ //
+ String[] targetList = GlobalData.getToolChainInfo().getTargets();
+ for (int i = 0; i < targetList.length; i++){
+ String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
+ for(int j = 0; j < toolchainList.length; j++){
+ String fvOutputDir = project.getProperty("BUILD_DIR") + File.separatorChar
+ + targetList[i] + File.separatorChar
+ + toolchainList[i] + File.separatorChar + "FV";
+ String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();
+ for (int k = 0; k < validFv.length; k++) {
+ if (fvNameSet.contains(validFv[k]) || ! isListInSequence(validFv[k])) {
+ String inputFile = fvOutputDir + "" + File.separatorChar + validFv[k].toUpperCase() + ".inf";
+ Element fvEle = document.createElement("genfvimage");
+ fvEle.setAttribute("infFile", inputFile);
+ fvEle.setAttribute("outputDir", fvOutputDir);
+ ele.appendChild(fvEle);
+ }
+ }
+ }
+ }
+ root.appendChild(ele);
+ }
+
+ private void applyClean(Document document, Node root) {
+ //
+ // Clean Target
+ //
+ root.appendChild(document.createComment("Clean target"));
+ Element ele = document.createElement("target");
+ ele.setAttribute("name", "clean");
+
+ if (isUnified) {
+ Element cleanEle = document.createElement("delete");
+ cleanEle.setAttribute("includeemptydirs", "true");
+ Element filesetEle = document.createElement("fileset");
+ filesetEle.setAttribute("dir", project.getProperty("BUILD_DIR"));
+ filesetEle.setAttribute("includes", "**\\OUTPUT\\**");
+ cleanEle.appendChild(filesetEle);
+ ele.appendChild(cleanEle);
+ } else {
+ Set set = outfiles.keySet();
+ Iterator iter = set.iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();
+ ModuleIdentification moduleId = fpdModuleId.getModule();
+
+ Element ifEle = document.createElement("if");
+ Element availableEle = document.createElement("available");
+ availableEle.setAttribute("file", moduleId.getMsaFile().getParent() + File.separatorChar
+ + "build.xml");
+ ifEle.appendChild(availableEle);
+ Element elseEle = document.createElement("then");
+
+ Element moduleEle = document.createElement("ant");
+ moduleEle.setAttribute("antfile", moduleId.getMsaFile().getParent() + File.separatorChar
+ + "build.xml");
+ moduleEle.setAttribute("target", "clean");
+ //
+ // Inherit Properties.
+ //{"ARCH", "PACKAGE", "PACKAGE_GUID", "PACKAGE_VERSION", "MODULE_DIR"}
+ //
+
+ //
+ // ARCH
+ //
+ Element property = document.createElement("property");
+ property.setAttribute("name", "ARCH");
+ property.setAttribute("value", fpdModuleId.getArch());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE");
+ property.setAttribute("value", moduleId.getPackage().getName());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE_GUID
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_GUID");
+ property.setAttribute("value", moduleId.getPackage().getGuid());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE_VERSION
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_VERSION");
+ property.setAttribute("value", moduleId.getPackage().getVersion());
+ moduleEle.appendChild(property);
+
+ //
+ // MODULE_DIR
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "MODULE_DIR");
+ property.setAttribute("value", moduleId.getMsaFile().getParent());
+ moduleEle.appendChild(property);
+ elseEle.appendChild(moduleEle);
+ ifEle.appendChild(elseEle);
+ ele.appendChild(ifEle);
+ }
+ }
+ root.appendChild(ele);
+ }
+
+ private void applyCleanall(Document document, Node root) {
+ //
+ // Deep Clean Target
+ //
+ root.appendChild(document.createComment("Clean All target"));
+ Element ele = document.createElement("target");
+ ele.setAttribute("name", "cleanall");
+
+ if (isUnified) {
+ Element cleanAllEle = document.createElement("delete");
+ cleanAllEle.setAttribute("dir", project.getProperty("BUILD_DIR"));
+ ele.appendChild(cleanAllEle);
+ } else {
+ Set set = outfiles.keySet();
+ Iterator iter = set.iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();
+ ModuleIdentification moduleId = fpdModuleId.getModule();
+
+ Element ifEle = document.createElement("if");
+ Element availableEle = document.createElement("available");
+ availableEle.setAttribute("file", moduleId.getMsaFile().getParent() + File.separatorChar
+ + "build.xml");
+ ifEle.appendChild(availableEle);
+ Element elseEle = document.createElement("then");
+
+ Element moduleEle = document.createElement("ant");
+ moduleEle.setAttribute("antfile", moduleId.getMsaFile().getParent() + File.separatorChar
+ + "build.xml");
+ moduleEle.setAttribute("target", "cleanall");
+ //
+ // Inherit Properties.
+ //{"ARCH", "PACKAGE", "PACKAGE_GUID", "PACKAGE_VERSION", "MODULE_DIR"}
+ //
+
+ //
+ // ARCH
+ //
+ Element property = document.createElement("property");
+ property.setAttribute("name", "ARCH");
+ property.setAttribute("value", fpdModuleId.getArch());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE");
+ property.setAttribute("value", moduleId.getPackage().getName());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE_GUID
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_GUID");
+ property.setAttribute("value", moduleId.getPackage().getGuid());
+ moduleEle.appendChild(property);
+
+ //
+ // PACKAGE_VERSION
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "PACKAGE_VERSION");
+ property.setAttribute("value", moduleId.getPackage().getVersion());
+ moduleEle.appendChild(property);
+
+ //
+ // MODULE_DIR
+ //
+ property = document.createElement("property");
+ property.setAttribute("name", "MODULE_DIR");
+ property.setAttribute("value", moduleId.getMsaFile().getParent());
+ moduleEle.appendChild(property);
+ elseEle.appendChild(moduleEle);
+ ifEle.appendChild(elseEle);
+ ele.appendChild(ifEle);
+ }
+ }
+ root.appendChild(ele);
+ }
+
+ private void applyUserExtensions(Document document, Node root) {
+ //
+ // User Extensions
+ //
+ root.appendChild(document.createComment("User Extensions"));
+ Element ele = document.createElement("target");
+ ele.setAttribute("name", "userextensions");
+
+ root.appendChild(ele);
+ }
+
+
+ private boolean isListInSequence(String fvName) {
+ Set numbers = sequences.keySet();
+ Iterator iter = numbers.iterator();
+ while (iter.hasNext()) {
+ Set fvNameSet = sequences.get(iter.next());
+ if (fvNameSet.contains(fvName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
index 97096f6b4f..99cccc364c 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
@@ -16,29 +16,34 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
package org.tianocore.build.global;
+import org.apache.tools.ant.BuildException;
+import org.apache.xmlbeans.XmlObject;
+import org.tianocore.DbPathAndFilename;
+import org.tianocore.FrameworkDatabaseDocument;
+import org.tianocore.ModuleSurfaceAreaDocument;
+import org.tianocore.ModuleSurfaceAreaDocument.ModuleSurfaceArea;
+import org.tianocore.build.exception.EdkException;
+import org.tianocore.build.id.FpdModuleIdentification;
+import org.tianocore.build.id.ModuleIdentification;
+import org.tianocore.build.id.PackageIdentification;
+import org.tianocore.build.id.PlatformIdentification;
+import org.tianocore.build.toolchain.ToolChainAttribute;
+import org.tianocore.build.toolchain.ToolChainConfig;
+import org.tianocore.build.toolchain.ToolChainElement;
+import org.tianocore.build.toolchain.ToolChainInfo;
+import org.tianocore.build.toolchain.ToolChainKey;
+import org.tianocore.build.toolchain.ToolChainMap;
+//import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
+//import org.tianocore.logger.EdkLog;
+
import java.io.File;
-import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.xmlbeans.XmlObject;
-import org.tianocore.FilenameDocument;
-import org.tianocore.FilenameDocument.Filename;
-import org.tianocore.FrameworkDatabaseDocument;
-import org.tianocore.MsaFilesDocument;
-import org.tianocore.MsaFilesDocument.MsaFiles.MsaFile;
-import org.tianocore.MsaHeaderDocument.MsaHeader;
-import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;
-import org.tianocore.PackageListDocument;
-import org.tianocore.PackageSurfaceAreaDocument;
-import org.tianocore.build.autogen.CommonDefinition;
-import org.tianocore.build.fpd.FpdParserTask;
-import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
+import java.util.logging.Logger;
/**
GlobalData provide initializing, instoring, querying and update global data.
@@ -46,408 +51,321 @@ import org.tianocore.build.pcd.entity.MemoryDatabaseManager;
PCD and so on.
Note that all global information are initialized incrementally. All data will
- parse and record only it is necessary during build time.
+ parse and record only of necessary during build time.
@since GenBuild 1.0
**/
public class GlobalData {
- ///
- /// means no surface area information for module
- ///
- public static final int NO_SA = 0;
-
- ///
- /// means only MSA
- ///
- public static final int ONLY_MSA = 1;
-
- ///
- /// means only Library MSA
- ///
- public static final int ONLY_LIBMSA = 2;
-
- ///
- /// means both MSA and MBD
- ///
- public static final int MSA_AND_MBD = 3;
-
- ///
- /// means both Library MSA and Library MBD
- ///
- public static final int LIBMSA_AND_LIBMBD = 4;
-
- ///
- /// Be used to ensure Global data will be initialized only once.
- ///
- public static boolean globalFlag = false;
-
+ public static Logger log = Logger.getAnonymousLogger();
+
///
/// Record current WORKSPACE Directory
///
private static String workspaceDir = "";
-
+
///
- /// Two columns: Package Name (Key), Package Path(ralative to WORKSPACE)
+ /// Be used to ensure Global data will be initialized only once.
///
- private static final Map packageInfo = new HashMap();
-
+ private static boolean globalFlag = false;
+
///
- /// spdTable
- /// Key: Package Name, Value: SPD detail info
+ /// Framework Database information: package list and platform list
///
- private static final Map spdTable = new HashMap();
+ private static Set packageList = new HashSet();
- ///
- /// Three columns:
- /// 1. Module Name | BaseName (Key)
- /// 2. Module Path + Msa file name (relative to Package)
- /// 3. Package Name (This module belong to which package)
- ///
- private static final Map moduleInfo = new HashMap();
+ private static Set platformList = new HashSet();
///
- /// List all libraries for current build module
- /// Key: Library BaseName, Value: output library path+name
+ /// Every detail SPD informations: Module list, Library class definition,
+ /// Package header file, GUID/PPI/Protocol definitions
///
- private static final Map libraries = new HashMap();
+ private static final Map spdTable = new HashMap();
///
- /// Store every module's relative library instances BaseName
- /// Key: Module BaseName, Value: All library instances module depends on.
+ /// Build informations are divided into three parts:
+ /// 1. From MSA 2. From FPD 3. From FPD' ModuleSA
///
- private static final Map > moduleLibraryMap = new HashMap >();
+ private static Map> nativeMsa = new HashMap>();
- ///
- /// Key: Module BaseName, Value: original MSA info
- ///
- private static final Map > nativeMsa = new HashMap >();
+ private static Map> fpdModuleSA= new HashMap>();
- ///
- /// Key: Module BaseName, Value: original MBD info
- ///
- private static final Map > nativeMbd = new HashMap >();
+ private static XmlObject fpdBuildOptions;
+ private static XmlObject fpdDynamicPcds;
+
///
- /// Two columns: Module Name or Base Name as Key
- /// Value is a HashMap with overridden data from MSA/MBD or/and Platform
+ /// Parsed modules list
///
- private static final Map > parsedModules = new HashMap >();
-
+ private static Map> parsedModules = new HashMap>();
+
///
- /// List all built Module; Value is Module BaseName + Arch. TBD
+ /// built modules list with ARCH, TARGET, TOOLCHAIN
///
- private static final Set builtModules = new HashSet();
-
+ private static Set builtModules = new HashSet();
+
///
- /// Library instance information table which recored the library and it's
- /// constructor and distructor function
+ /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.
///
- private static final Map libInstanceInfo = new HashMap();
+// private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();
///
- /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.
+ /// build target + tool chain family/tag name + arch + command types + command options
///
- private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();
-
- /**
- Query the module's absolute path with module base name.
-
- @param moduleName the base name of the module
- @return the absolute module path
- **/
- public synchronized static String getModulePath(String moduleName) {
- String[] info = moduleInfo.get(moduleName);
- String packagePath = (String) packageInfo.get(info[1]);
- File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);
- return convertFile.getParent();
- }
-
- /**
- Query the module's absolute MSA file path with module base name.
-
- @param moduleName the base name of the module
- @return the absolute MSA file name
- @throws BuildException
- Base name is not registered in any SPD files
- **/
- private synchronized static String getMsaFilename(String moduleName) throws BuildException {
- String[] info = moduleInfo.get(moduleName);
- if (info == null) {
- throw new BuildException("Module base name [" + moduleName + "] can't found in all SPD.");
- }
- String packagePath = (String) packageInfo.get(info[1]);
- File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);
- return convertFile.getPath();
- }
+ ///
+ /// Tool Chain Data
+ /// toolsDef - build tool program information
+ /// fpdBuildOption - all modules's build options for tool tag or tool chain families
+ /// moduleSaBuildOption - build options for a specific module
+ ///
+ private static ToolChainConfig toolsDef;
- /**
- Query the module's absolute MBD file path with module base name.
-
- @param moduleName the base name of the module
- @return the absolute MBD file name
- @throws BuildException
- Base name is not registered in any SPD files
- **/
- private synchronized static String getMbdFilename(String moduleName) throws BuildException {
- String[] info = moduleInfo.get(moduleName);
- if (info == null) {
- throw new BuildException("Info: Module base name [" + moduleName + "] can't found in all SPD.");
- }
- String packagePath = (String) packageInfo.get(info[1]);
- File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);
- return convertFile.getPath().substring(0, convertFile.getPath().length() - 4) + ".mbd";
- }
+ private static ToolChainInfo toolChainInfo;
+ private static ToolChainInfo toolChainEnvInfo;
+ private static ToolChainInfo toolChainPlatformInfo;
- /**
- Get the current WORKSPACE Directory.
- @return current workspace directory
- **/
- public synchronized static String getWorkspacePath() {
- return workspaceDir;
- }
+ private static ToolChainMap platformToolChainOption;
+ private static ToolChainMap platformToolChainFamilyOption;
- /**
- Query package relative path to WORKSPACE_DIR with package name.
-
- @param packageName the name of the package
- @return the path relative to WORKSPACE_DIR
- **/
- public synchronized static String getPackagePath(String packageName) {
- return (String) packageInfo.get(packageName);
- }
+ private static Map moduleToolChainOption = new HashMap();
+ private static Map moduleToolChainFamilyOption = new HashMap();
- /**
- Query package (which the module belongs to) relative path to WORSPACE_DIR.
-
- @param moduleName the base name of the module
- @return the relative path to WORKSPACE_DIR of the package which the module belongs to
- **/
- public synchronized static String getPackagePathForModule(String moduleName) {
- String[] info = moduleInfo.get(moduleName);
- String packagePath = (String) packageInfo.get(info[1]);
- return packagePath;
- }
+// private static final MemoryDatabasseManager pcdDbManager = new MemoryDatabaseManager();
- /**
- Query the package name which the module belongs to with the module's base name.
- @param moduleName the base name of the module
- @return the package name which the module belongs to
- **/
- public synchronized static String getPackageNameForModule(String moduleName) {
- return moduleInfo.get(moduleName)[1];
- }
/**
Parse framework database (DB) and all SPD files listed in DB to initialize
the environment for next build. This method will only be executed only once
in the whole build process.
-
+
@param workspaceDatabaseFile the file name of framework database
@param workspaceDir current workspace directory path
@throws BuildException
- Framework Dababase or SPD or MSA file is not valid
+ Framework Dababase or SPD or MSA file is not valid
**/
- public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir) throws BuildException {
+ public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir, String toolsDefFilename) throws BuildException {
+ //
+ // ensure this method will be revoked only once
+ //
if (globalFlag) {
return;
}
globalFlag = true;
- GlobalData.workspaceDir = workspaceDir;
+
+ //
+ // Backup workspace directory. It will be used by other method
+ //
+ GlobalData.workspaceDir = workspaceDir.replaceAll("(\\\\)", "/");
+
+ //
+ // Parse tools definition file
+ //
+ //
+ // If ToolChain has been set up before, do nothing.
+ // CONF dir + tools definition file name
+ //
+ String confDir = GlobalData.workspaceDir + File.separatorChar + "Tools" + File.separatorChar + "Conf";
+ File toolsDefFile = new File(confDir + File.separatorChar + toolsDefFilename);
+ System.out.println("Using file [" + toolsDefFile.getPath() + "] as tools definition file. ");
+ toolsDef = new ToolChainConfig(toolsDefFile);
+
+ //
+ // Parse Framework Database
+ //
File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile);
try {
FrameworkDatabaseDocument db = (FrameworkDatabaseDocument) XmlObject.Factory.parse(dbFile);
- List packages = db.getFrameworkDatabase().getPackageList()
- .getPackageList();
- Iterator iter = packages.iterator();
- while (iter.hasNext()) {
- PackageListDocument.PackageList.Package packageItem = (PackageListDocument.PackageList.Package) iter
- .next();
- String name = packageItem.getPackageNameArray(0).getStringValue();
- String path = packageItem.getPathArray(0).getStringValue();
- packageInfo.put(name, path);
- File spdFile = new File(workspaceDir + File.separatorChar + path + File.separatorChar + name + ".spd");
- initPackageInfo(spdFile.getPath(), name);
- //
- // SPD Parse.
- //
- PackageSurfaceAreaDocument spdDoc = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdFile);
- Spd spd = new Spd(spdDoc, path);
- spdTable.put(name, spd);
-
+ //
+ // validate FrameworkDatabaseFile
+ //
+ if (! db.validate()) {
+ throw new BuildException("Framework Database file [" + dbFile.getPath() + "] is invalid.");
}
- } catch (Exception e) {
- throw new BuildException("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage());
- }
- }
-
- /**
- Parse every MSA files, get base name from MSA Header. And record those
- values to ModuleInfo.
-
- @param packageFilename the file name of the package
- @param packageName the name of the package
- @throws BuildException
- SPD or MSA file is not valid
- **/
- private synchronized static void initPackageInfo(String packageFilename, String packageName) throws BuildException {
- File packageFile = new File(packageFilename);
- try {
- PackageSurfaceAreaDocument spd = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(packageFile);
- List msaFilenameList;
-
- List msasList = spd.getPackageSurfaceArea().getMsaFiles()
- .getMsaFileList();
- if (msasList.size() == 0) {
- msaFilenameList = spd.getPackageSurfaceArea().getMsaFiles().getFilenameList();
- } else {
- msaFilenameList = new ArrayList(msasList.size());
- Iterator msasIter = msasList.iterator();
- while (msasIter.hasNext()) {
- MsaFilesDocument.MsaFiles.MsaFile msaFile = (MsaFilesDocument.MsaFiles.MsaFile)msasIter.next();
- msaFilenameList.add(msaFile.getFilename().getStringValue());
+ //
+ // Get package list
+ //
+ if (db.getFrameworkDatabase().getPackageList() != null ) {
+ List packages = db.getFrameworkDatabase().getPackageList().getFilenameList();
+ Iterator iter = packages.iterator();
+ while (iter.hasNext()) {
+ String fileName = iter.next().getStringValue();
+ Spd spd = new Spd(new File(workspaceDir + File.separatorChar + fileName));
+ packageList.add(spd.getPackageId());
+ spdTable.put(spd.getPackageId(), spd);
}
}
- Iterator msaFilenameIter = msaFilenameList.iterator();
- while (msaFilenameIter.hasNext()) {
- String filename = (String)msaFilenameIter.next();
- File msaFile = new File(workspaceDir + File.separatorChar + GlobalData.getPackagePath(packageName)
- + File.separatorChar + filename);
- SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
- Map map = surfaceAreaParser.parseFile(msaFile);
- String baseName = "";
- XmlObject header = null;
- if ((header = map.get("MsaHeader")) != null) {
- if (((MsaHeader) header).isSetBaseName()) {
- baseName = ((MsaHeader) header).getBaseName().getStringValue();
- } else {
- baseName = ((MsaHeader) header).getModuleName();
+ //
+ // Get platform list
+ //
+ if (db.getFrameworkDatabase().getPlatformList() != null) {
+ List platforms = db.getFrameworkDatabase().getPlatformList().getFilenameList();
+ Iterator iter = platforms.iterator();
+ while (iter.hasNext()) {
+ String fileName = iter.next().getStringValue();
+ File fpdFile = new File(workspaceDir + File.separatorChar + fileName);
+ if ( ! fpdFile.exists() ) {
+ throw new BuildException("Platform file [" + fpdFile.getPath() + "] not exists. ");
}
- } else if ((header = map.get("MsaLibHeader")) != null) {
- baseName = ((MsaLibHeader) header).getBaseName().getStringValue();
- } else {
- continue;
+ XmlObject fpdDoc = XmlObject.Factory.parse(fpdFile);
+ //
+ // Verify FPD file, if is invalid, throw Exception
+ //
+ if (! fpdDoc.validate()) {
+ throw new BuildException("Framework Platform Surface Area file [" + fpdFile.getPath() + "] is invalid. ");
+ }
+ //
+ // We can change Map to XmlObject
+ //
+ //
+ // TBD check SPD or FPD is existed in FS
+ //
+ Map fpdDocMap = new HashMap();
+ fpdDocMap.put("PlatformSurfaceArea", fpdDoc);
+ SurfaceAreaQuery.setDoc(fpdDocMap);
+ PlatformIdentification platformId = SurfaceAreaQuery.getFpdHeader();
+ platformId.setFpdFile(fpdFile);
+ platformList.add(platformId);
}
- nativeMsa.put(baseName, map);
- String[] info = { filename, packageName };
- moduleInfo.put(baseName, info);
}
} catch (Exception e) {
- throw new BuildException("Parse package description file [" + packageFile.getPath() + "] Error.\n"
- + e.getMessage());
+ e.printStackTrace();
+ throw new BuildException("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage());
}
}
-
- /**
- Query the libraries which the module depends on.
- @param moduleName the base name of the module
- @return the libraries which the module depends on
- **/
- public synchronized static String[] getModuleLibrary(String moduleName, String arch) {
- Set set = moduleLibraryMap.get(moduleName + "-" + arch);
- return set.toArray(new String[set.size()]);
- }
-
/**
- Register module's library list which it depends on for later use.
+ Get the current WORKSPACE Directory.
- @param moduleName the base name of the module
- @param libraryList the libraries which the module depends on
+ @return current workspace directory
**/
- public synchronized static void addModuleLibrary(String moduleName, String arch, Set libraryList) {
- moduleLibraryMap.put(moduleName + "-" + arch, libraryList);
+ public synchronized static String getWorkspacePath() {
+ return workspaceDir;
}
- /**
- Query the library absolute file name with library name.
-
- @param library the base name of the library
- @return the library absolute file name
- **/
- public synchronized static String getLibrary(String library, String arch) {
- return libraries.get(library + "-" + arch);
- }
/**
- Register library absolute file name for later use.
-
- @param library the base name of the library
- @param resultPath the library absolute file name
- **/
- public synchronized static void addLibrary(String library, String arch, String resultPath) {
- libraries.put(library + "-" + arch, resultPath);
+ Get the MSA file name with absolute path
+ */
+ public synchronized static File getMsaFile(ModuleIdentification moduleId) throws BuildException {
+ File msaFile = null;
+ //
+ // TBD. Do only when package is null.
+ //
+ Iterator iter = packageList.iterator();
+ while (iter.hasNext()) {
+ PackageIdentification packageId = (PackageIdentification)iter.next();
+ Spd spd = spdTable.get(packageId);
+ msaFile = spd.getModuleFile(moduleId);
+ if (msaFile != null ) {
+ break ;
+ }
+ }
+ if (msaFile == null){
+ throw new BuildException("Can't find Module [" + moduleId.getName() + "] in all packages. ");
+ }
+ else {
+ return msaFile;
+ }
}
+ public synchronized static PackageIdentification getPackageForModule(ModuleIdentification moduleId) {
+ //
+ // If package already defined in module
+ //
+ if (moduleId.getPackage() != null) {
+ return moduleId.getPackage();
+ }
+
+ PackageIdentification packageId = null;
+ Iterator iter = packageList.iterator();
+ while (iter.hasNext()) {
+ packageId = (PackageIdentification)iter.next();
+ moduleId.setPackage(packageId);
+ Spd spd = spdTable.get(packageId);
+ if (spd.getModuleFile(moduleId) != null ) {
+ break ;
+ }
+ }
+ if (packageId == null){
+ throw new BuildException("Can't find Module [" + moduleId.getName() + "] in all packages. ");
+ }
+ else {
+ return packageId;
+ }
+ }
+
/**
- Whether the module with ARCH has built in the previous build.
-
- @param moduleName the base name of the module
- @param arch current build ARCH
- @return true if the module has built in previous, otherwise return false
+ Difference between build and parse: ToolChain and Target
**/
- public synchronized static boolean isModuleBuilt(String moduleName, String arch) {
- return builtModules.contains(moduleName + "-" + arch);
+ public synchronized static boolean isModuleBuilt(FpdModuleIdentification moduleId) {
+ return builtModules.contains(moduleId);
}
-
- /**
- Register the module with ARCH has built.
- @param moduleName the base name of the module
- @param arch current build ARCH
- **/
- public synchronized static void registerBuiltModule(String moduleName, String arch) {
- builtModules.add(moduleName + "-" + arch);
+ public synchronized static void registerBuiltModule(FpdModuleIdentification fpdModuleId) {
+ builtModules.add(fpdModuleId);
}
- /**
- Whether the module's surface area has parsed in the previous build.
-
- @param moduleName the base name of the module
- @return true if the module's surface area has parsed in previous, otherwise
- return false
- **/
- public synchronized static boolean isModuleParsed(String moduleName) {
- return parsedModules.containsKey(moduleName);
+
+ public synchronized static void registerFpdModuleSA(FpdModuleIdentification fpdModuleId, Map doc) {
+ Map result = new HashMap();
+ Set keySet = doc.keySet();
+ Iterator iter = keySet.iterator();
+ while (iter.hasNext()){
+ String key = (String)iter.next();
+ XmlObject item = cloneXmlObject(doc.get(key), true);
+ result.put(key, item);
+ }
+ fpdModuleSA.put(fpdModuleId, result);
}
-
+
/**
Query overrided module surface area information. If current is Package
or Platform build, also include the information from FPD file.
Note that surface area parsing is incremental. That means the method will
- only to parse the MSA and MBD files when never parsed before.
+ only parse the MSA and MBD files if necessary.
@param moduleName the base name of the module
@return the overrided module surface area information
@throws BuildException
MSA or MBD is not valid
**/
- public synchronized static Map getDoc(String moduleName) throws BuildException {
- if (parsedModules.containsKey(moduleName)) {
- return parsedModules.get(moduleName);
- }
- Map msaMap = getNativeMsa(moduleName);
- Map mbdMap = getNativeMbd(moduleName);
- OverrideProcess op = new OverrideProcess();
- Map map = op.override(mbdMap, msaMap);
+ public synchronized static Map getDoc(FpdModuleIdentification fpdModuleId) throws BuildException {
+ if (parsedModules.containsKey(fpdModuleId)) {
+ return parsedModules.get(fpdModuleId);
+ }
+ Map doc = new HashMap();
+ ModuleIdentification moduleId = fpdModuleId.getModule();
//
- // IF IT IS A PALTFORM BUILD, OVERRIDE FROM PLATFORM
+ // First part: get the MSA files info
//
- if (FpdParserTask.platformBuildOptions != null) {
- Map platformMap = new HashMap();
- platformMap.put("BuildOptions", FpdParserTask.platformBuildOptions);
- Map overrideMap = op.override(platformMap, OverrideProcess.deal(map));
- GlobalData.registerModule(moduleName, overrideMap);
- return overrideMap;
- } else {
- parsedModules.put(moduleName, map);
- return map;
+ doc = getNativeMsa(moduleId);
+
+ //
+ // Second part: put build options
+ //
+ doc.put("BuildOptions", fpdBuildOptions);
+
+ //
+ // Third part: get Module info from FPD, such as Library instances, PCDs
+ //
+ if (fpdModuleSA.containsKey(fpdModuleId)){
+ //
+ // merge module info in FPD to final Doc
+ // For Library Module, do nothing here
+ //
+ doc.putAll(fpdModuleSA.get(fpdModuleId));
}
+ parsedModules.put(fpdModuleId, doc);
+ return doc;
}
+ public synchronized static Map getDoc(ModuleIdentification moduleId, String arch) throws BuildException {
+ FpdModuleIdentification fpdModuleId = new FpdModuleIdentification(moduleId, arch);
+ return getDoc(fpdModuleId);
+ }
/**
Query the native MSA information with module base name.
@@ -459,200 +377,425 @@ public class GlobalData {
@throws BuildException
MSA file is not valid
**/
- public synchronized static Map getNativeMsa(String moduleName) throws BuildException {
- if (nativeMsa.containsKey(moduleName)) {
- return nativeMsa.get(moduleName);
- }
- String msaFilename = getMsaFilename(moduleName);
- File msaFile = new File(msaFilename);
- if (!msaFile.exists()) {
- throw new BuildException("Info: Surface Area file [" + msaFile.getPath() + "] can't found.");
- }
- SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
- Map map = surfaceAreaParser.parseFile(msaFile);
- nativeMsa.put(moduleName, map);
+ public synchronized static Map getNativeMsa(ModuleIdentification moduleId) throws BuildException {
+ if (nativeMsa.containsKey(moduleId)) {
+ return nativeMsa.get(moduleId);
+ }
+ File msaFile = getMsaFile(moduleId);
+ Map msaMap = getNativeMsa(msaFile);
+ nativeMsa.put(moduleId, msaMap);
+ return msaMap;
+ }
+
+ public synchronized static Map getNativeMsa(File msaFile) throws BuildException {
+ if (! msaFile.exists()) {
+ throw new BuildException("Surface Area file [" + msaFile.getPath() + "] can't found.");
+ }
+ try {
+ ModuleSurfaceAreaDocument doc = (ModuleSurfaceAreaDocument)XmlObject.Factory.parse(msaFile);
+ //
+ // Validate File if they accord with XML Schema
+ //
+ if ( ! doc.validate()){
+ throw new BuildException("Module Surface Area file [" + msaFile.getPath() + "] is invalid.");
+ }
+ //
+ // parse MSA file
+ //
+ ModuleSurfaceArea msa= doc.getModuleSurfaceArea();
+ Map msaMap = new HashMap();
+ msaMap.put("MsaHeader", cloneXmlObject(msa.getMsaHeader(), true));
+ msaMap.put("ModuleDefinitions", cloneXmlObject(msa.getModuleDefinitions(), true));
+ msaMap.put("LibraryClassDefinitions", cloneXmlObject(msa.getLibraryClassDefinitions(), true));
+ msaMap.put("SourceFiles", cloneXmlObject(msa.getSourceFiles(), true));
+ msaMap.put("PackageDependencies", cloneXmlObject(msa.getPackageDependencies(), true));
+ msaMap.put("Protocols", cloneXmlObject(msa.getProtocols(), true));
+ msaMap.put("PPIs", cloneXmlObject(msa.getPPIs(), true));
+ msaMap.put("Guids", cloneXmlObject(msa.getGuids(), true));
+ msaMap.put("Externs", cloneXmlObject(msa.getExterns(), true));
+ return msaMap;
+ }
+ catch (Exception ex){
+ throw new BuildException(ex.getMessage());
+ }
+ }
+
+ public static Map getFpdBuildOptions() {
+ Map map = new HashMap();
+ map.put("BuildOptions", fpdBuildOptions);
return map;
}
- /**
- Query the native MBD information with module base name.
-
-
Note that MBD parsing is incremental. That means the method will
- only to parse the MBD files when never parsed before.
+ public static void setFpdBuildOptions(XmlObject fpdBuildOptions) {
+ GlobalData.fpdBuildOptions = cloneXmlObject(fpdBuildOptions, true);
+ }
+
+ public static XmlObject getFpdDynamicPcds() {
+ return fpdDynamicPcds;
+ }
+
+ public static void setFpdDynamicPcds(XmlObject fpdDynamicPcds) {
+ GlobalData.fpdDynamicPcds = fpdDynamicPcds;
+ }
+
+ //////////////////////////////////////////////
+ //////////////////////////////////////////////
- @param moduleName the base name of the module
- @return the native MBD information
- @throws BuildException
- MBD file is not valid
- **/
- public synchronized static Map getNativeMbd(String moduleName) throws BuildException {
- if (nativeMbd.containsKey(moduleName)) {
- return nativeMbd.get(moduleName);
+ public static Set getModules(PackageIdentification packageId){
+ Spd spd = spdTable.get(packageId);
+ if (spd == null ) {
+ Set dummy = new HashSet();
+ return dummy;
}
- String mbdFilename = getMbdFilename(moduleName);
- File mbdFile = new File(mbdFilename);
- if (!mbdFile.exists()) {
- return null;
- //throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found.");
+ else {
+ return spd.getModules();
}
- SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
- Map map = surfaceAreaParser.parseFile(mbdFile);
- nativeMbd.put(moduleName, map);
- return map;
}
/**
- Register module overrided surface area information. If has existed, then update.
-
- @param moduleName the base name of the module
- @param map the overrided surface area information
- **/
- public synchronized static void registerModule(String moduleName, Map map) {
- parsedModules.put(moduleName, map);
+ * The header file path is relative to workspace dir
+ */
+ public static String[] getLibraryClassHeaderFiles(
+ PackageIdentification[] packages, String name)
+ throws BuildException {
+ if (packages == null) {
+ // throw Exception or not????
+ return new String[0];
+ }
+ String[] result = null;
+ for (int i = 0; i < packages.length; i++) {
+ Spd spd = spdTable.get(packages[i]);
+ //
+ // If find one package defined the library class
+ //
+ if ((result = spd.getLibClassIncluder(name)) != null) {
+ return result;
+ }
+ }
+ //
+ // If can't find library class declaration in every package
+ //
+ throw new BuildException("Can not find library class [" + name
+ + "] declaration in every packages. ");
}
/**
- *
- * @param protocolName
- * @return
+ * The header file path is relative to workspace dir
*/
- public synchronized static String[] getProtocolInfoGuid(String protocolName) {
- Set set = spdTable.keySet();
- Iterator iter = set.iterator();
- String[] cNameGuid = null;
-
- while (iter.hasNext()) {
- Spd spd = (Spd) spdTable.get(iter.next());
- cNameGuid = spd.getProtocolNameGuidArray(protocolName);
- if (cNameGuid != null) {
- break;
+ public static String getPackageHeaderFiles(PackageIdentification packages,
+ String moduleType) throws BuildException {
+ if (packages == null) {
+ return new String("");
+ }
+ Spd spd = spdTable.get(packages);
+ //
+ // If can't find package header file, skip it
+ //
+ String temp = null;
+ if (spd != null) {
+ if ((temp = spd.getPackageIncluder(moduleType)) != null) {
+ return temp;
+ } else {
+ temp = "";
+ return temp;
}
+ } else {
+ return null;
}
- return cNameGuid;
}
- public synchronized static String[] getPpiInfoGuid(String ppiName) {
- Set set = spdTable.keySet();
- Iterator iter = set.iterator();
- String[] cNameGuid = null;
-
- while (iter.hasNext()) {
- Spd spd = (Spd) spdTable.get(iter.next());
- cNameGuid = spd.getPpiCnameGuidArray(ppiName);
-
- if (cNameGuid != null) {
- break;
+ /**
+ * return two values: {cName, GuidValue}
+ */
+ public static String[] getGuid(PackageIdentification[] packages, String name)
+ throws BuildException {
+ if (packages == null) {
+ // throw Exception or not????
+ return new String[0];
+ }
+ String[] result = null;
+ for (int i = 0; i < packages.length; i++) {
+ Spd spd = spdTable.get(packages[i]);
+ //
+ // If find one package defined the GUID
+ //
+ if ((result = spd.getGuid(name)) != null) {
+ return result;
}
}
- return cNameGuid;
+ return null;
}
/**
- *
- * @param guidName
- * @return
+ * return two values: {cName, GuidValue}
*/
- public synchronized static String[] getGuidInfoGuid(String guidName) {
- String[] cNameGuid = null;
- Set set = spdTable.keySet();
- Iterator iter = set.iterator();
-
- while (iter.hasNext()) {
- Spd spd = (Spd) spdTable.get(iter.next());
- cNameGuid = spd.getGuidNameArray(guidName);
- if (cNameGuid != null) {
- break;
+ public static String[] getPpiGuid(PackageIdentification[] packages,
+ String name) throws BuildException {
+ if (packages == null) {
+ return new String[0];
+ }
+ String[] result = null;
+ for (int i = 0; i < packages.length; i++) {
+ Spd spd = spdTable.get(packages[i]);
+ //
+ // If find one package defined the Ppi GUID
+ //
+ if ((result = spd.getPpi(name)) != null) {
+ return result;
}
}
- return cNameGuid;
+ return null;
+
}
- public synchronized static String getLibClassIncluder(String libName) {
- String libIncluder = null;
- Set set = spdTable.keySet();
- Iterator iter = set.iterator();
+ /**
+ * return two values: {cName, GuidValue}
+ */
+ public static String[] getProtocolGuid(PackageIdentification[] packages,
+ String name) throws BuildException {
+ if (packages == null) {
+ return new String[0];
+ }
+ String[] result = null;
+ for (int i = 0; i < packages.length; i++) {
+ Spd spd = spdTable.get(packages[i]);
+ //
+ // If find one package defined the protocol GUID
+ //
+ if ((result = spd.getProtocol(name)) != null) {
+ return result;
+ }
+ }
+ return null;
- while (iter.hasNext()) {
- String packageName = (String) iter.next();
- Spd spd = (Spd) spdTable.get(packageName);
- libIncluder = spd.getLibClassIncluder(libName);
- String packagePath = spd.packagePath;
- if (packagePath != null) {
- packagePath = packagePath.replace('\\', File.separatorChar);
- packagePath = packagePath.replace('/', File.separatorChar);
- } else {
- packagePath = packageName;
+ }
+
+ /////////////////////////// Update!! Update!! Update!!
+// public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {
+// return pcdDbManager;
+// }
+ ///////////////////////////
+ public synchronized static PlatformIdentification getPlatform(String name) throws BuildException {
+ Iterator iter = platformList.iterator();
+ while(iter.hasNext()){
+ PlatformIdentification platformId = (PlatformIdentification)iter.next();
+ if (platformId.getName().equalsIgnoreCase(name)) {
+// GlobalData.log.info("Platform: " + platformId + platformId.getFpdFile());
+ return platformId;
}
- if (libIncluder != null) {
- libIncluder = libIncluder.replace('\\', File.separatorChar);
- libIncluder = libIncluder.replace('/', File.separatorChar);
- libIncluder = packageName + File.separatorChar + libIncluder;
- break;
+ }
+ throw new BuildException("Can't find platform [" + name + "] in current workspace. ");
+ }
+
+ public synchronized static PackageIdentification refreshPackageIdentification(PackageIdentification packageId) throws BuildException {
+ Iterator iter = packageList.iterator();
+ while(iter.hasNext()){
+ PackageIdentification packageItem = (PackageIdentification)iter.next();
+ if (packageItem.equals(packageId)) {
+ packageId.setName(packageItem.getName());
+ packageId.setSpdFile(packageItem.getSpdFile());
+ return packageId;
}
}
- return libIncluder;
+ throw new BuildException("Can't find package GUID value " + packageId.getGuid() + " under current workspace. ");
+ }
+
+ public synchronized static ModuleIdentification refreshModuleIdentification(ModuleIdentification moduleId) throws BuildException {
+// System.out.println("1");
+// System.out.println("##" + moduleId.getGuid());
+ PackageIdentification packageId = getPackageForModule(moduleId);
+// System.out.println("" + packageId.getGuid());
+ moduleId.setPackage(packageId);
+ Spd spd = spdTable.get(packageId);
+ if (spd == null) {
+ throw new BuildException("Can't find package GUID value " + packageId.getGuid() + " under current workspace. ");
+ }
+ Set modules = spd.getModules();
+ Iterator iter = modules.iterator();
+ while (iter.hasNext()) {
+ ModuleIdentification item = iter.next();
+ if (item.equals(moduleId)) {
+ moduleId.setName(item.getName());
+ moduleId.setModuleType(item.getModuleType());
+ moduleId.setMsaFile(item.getMsaFile());
+ return moduleId;
+ }
+ }
+ throw new BuildException("Can't find module GUID value " + moduleId.getGuid() + " in " + packageId + " under current workspace. ");
+ }
+
+ public synchronized static Set getPackageList(){
+ return packageList;
+ }
+ ///// remove!!
+ private static XmlObject cloneXmlObject(XmlObject object, boolean deep) throws BuildException {
+ if ( object == null) {
+ return null;
+ }
+ XmlObject result = null;
+ try {
+ result = XmlObject.Factory.parse(object.getDomNode()
+ .cloneNode(deep));
+ } catch (Exception ex) {
+ throw new BuildException(ex.getMessage());
+ }
+ return result;
}
- public synchronized static String getModuleInfoByPackageName(String packageName, String moduleType) {
- Spd spd;
- String includeFile = null;
- String includeStr = "";
- String cleanPath = "";
-
- spd = (Spd) spdTable.get(packageName);
- includeFile = spd.getModuleTypeIncluder(moduleType);
- if (includeFile != null) {
- includeFile = includeFile.replace('\\', File.separatorChar);
- includeFile = includeFile.replace('/', File.separatorChar);
- includeStr = CommonDefinition.include + " <" + includeStr;
- cleanPath = spd.packagePath;
- cleanPath = cleanPath.replace('\\', File.separatorChar);
- cleanPath = cleanPath.replace('/', File.separatorChar);
+ ////// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
- if (cleanPath.charAt(spd.packagePath.length() - 1) != File.separatorChar) {
- cleanPath = cleanPath + File.separatorChar;
+ public static ToolChainInfo getToolChainInfo() {
+// GlobalData.log.info(toolsDef.getConfigInfo() + "" + toolChainEnvInfo + toolChainPlatformInfo);
+ if (toolChainInfo == null) {
+ toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);
+ if (toolChainPlatformInfo != null) {
+ toolChainInfo = toolChainInfo.intersection(toolChainPlatformInfo);
}
- includeStr = includeStr + cleanPath;
- includeStr = includeStr + includeFile;
- includeStr = includeStr + ">\r\n";
+ toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());
+ toolChainInfo.normalize();
+ GlobalData.log.info(toolChainInfo + "");
}
+ return toolChainInfo;
+ }
+
+
- return includeStr;
+ public static void setPlatformToolChainFamilyOption(ToolChainMap map) {
+ platformToolChainFamilyOption = map;
}
- public synchronized static void setLibInstanceInfo(String libName, String libConstructor, String libDesturctor) {
- String[] libConsDes = new String[2];
- libConsDes[0] = libConstructor;
- libConsDes[1] = libDesturctor;
+ public static void setPlatformToolChainOption(ToolChainMap map) {
+ platformToolChainOption = map;
+ }
- libInstanceInfo.put(libName, libConsDes);
+ public static void addModuleToolChainOption(FpdModuleIdentification fpdModuleId,
+ ToolChainMap toolChainOption) {
+ moduleToolChainOption.put(fpdModuleId, toolChainOption);
}
- public synchronized static boolean isHaveLibInstance(String libName) {
- return libInstanceInfo.containsKey(libName);
+ public static void addModuleToolChainFamilyOption(FpdModuleIdentification fpdModuleId,
+ ToolChainMap toolChainOption) {
+ moduleToolChainFamilyOption.put(fpdModuleId, toolChainOption);
}
- public synchronized static String getLibInstanceConstructor(String libName) {
- String[] libInstanceValue;
- libInstanceValue = libInstanceInfo.get(libName);
- if (libInstanceValue != null) {
- return libInstanceValue[0];
- } else {
- return null;
+ public static String getCommandSetting(String[] commandDescription, FpdModuleIdentification fpdModuleId) throws EdkException {
+ ToolChainKey toolChainKey = new ToolChainKey(commandDescription);
+ ToolChainMap toolChainConfig = toolsDef.getConfig();
+ String setting = null;
+
+ if (!commandDescription[ToolChainElement.ATTRIBUTE.value].equals(ToolChainAttribute.FLAGS.toString())) {
+ setting = toolChainConfig.get(toolChainKey);
+ if (setting == null) {
+ setting = "";
+ }
+ return setting;
}
- }
- public synchronized static String getLibInstanceDestructor(String libName) {
- String[] libInstanceValue;
- libInstanceValue = libInstanceInfo.get(libName);
- if (libInstanceValue != null) {
- return libInstanceValue[1];
- } else {
- return null;
+ //
+ // get module specific options, if any
+ //
+ // tool tag first
+ ToolChainMap option = moduleToolChainOption.get(fpdModuleId);
+ ToolChainKey toolChainFamilyKey = null;
+
+ if ((option == null) || (option != null && (setting = option.get(toolChainKey)) == null)) {
+ //
+ // then tool chain family
+ //
+ toolChainFamilyKey = new ToolChainKey(commandDescription);
+ toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), ToolChainElement.ATTRIBUTE.value);
+ String family = toolChainConfig.get(toolChainFamilyKey);
+ toolChainFamilyKey.setKey(family, ToolChainElement.TOOLCHAIN.value);
+ toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);
+
+ option = moduleToolChainFamilyOption.get(fpdModuleId);
+ if (option != null) {
+ setting = option.get(toolChainFamilyKey);
+ }
}
- }
- public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {
- return pcdDbManager;
+ //
+ // get platform options, if any
+ //
+ if (setting == null) {
+ // tool tag first
+ if (platformToolChainOption == null || (setting = platformToolChainOption.get(toolChainKey)) == null) {
+ // then tool chain family
+ if (toolChainFamilyKey == null) {
+ toolChainFamilyKey = new ToolChainKey(commandDescription);
+ toolChainFamilyKey.setKey(ToolChainAttribute.FAMILY.toString(), ToolChainElement.ATTRIBUTE.value);
+ String family = toolChainConfig.get(toolChainFamilyKey);
+ toolChainFamilyKey.setKey(family, ToolChainElement.TOOLCHAIN.value);
+ toolChainFamilyKey.setKey(ToolChainAttribute.FLAGS.toString(), ToolChainElement.ATTRIBUTE.value);
+ }
+
+ setting = platformToolChainFamilyOption.get(toolChainFamilyKey);
+ }
+ }
+
+ if (setting == null) {
+ setting = "";
+ }
+
+ return setting;
+ }
+
+ public static void setToolChainEnvInfo(ToolChainInfo envInfo) {
+ toolChainEnvInfo = envInfo;
+ }
+ public static void setToolChainPlatformInfo(ToolChainInfo platformInfo) {
+ toolChainPlatformInfo = platformInfo;
}
+
+ //
+ // for PCD
+ //
+// public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {
+// return pcdDbManager;
+// }
+
+ //
+ // For PCD
+ //
+ /**
+ *
+ * @param guidName
+ * @return
+ */
+// public synchronized static String[] getGuidInfoGuid(String guidName) {
+// String[] cNameGuid = null;
+// Set set = spdTable.keySet();
+// Iterator iter = set.iterator();
+//
+// while (iter.hasNext()) {
+// Spd spd = (Spd) spdTable.get(iter.next());
+// cNameGuid = spd.getGuidNameArray(guidName);
+// if (cNameGuid != null) {
+// break;
+// }
+// }
+// return cNameGuid;
+// }
+
+ //
+ // For PCD
+ //
+// public synchronized static Map getFpdModuleSaXmlObject(
+// String xmlObjectName) {
+// Set fpdModuleSASet = fpdModuleSA.keySet();
+// Iterator item = fpdModuleSASet.iterator();
+//
+// Map SAPcdBuildDef = new HashMap();
+// Map SANode = new HashMap();
+// FpdModuleIdentification moduleId;
+// while (item.hasNext()) {
+// moduleId = (FpdModuleIdentification) item.next();
+// SANode = fpdModuleSA.get(item.next());
+// SAPcdBuildDef.put(moduleId,
+// (PcdBuildDefinitionDocument.PcdBuildDefinition) SANode
+// .get(xmlObjectName));
+// }
+// return SAPcdBuildDef;
+// }
}
+
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalShare.java b/Tools/Source/GenBuild/org/tianocore/build/global/GlobalShare.java
deleted file mode 100644
index 5912127a10..0000000000
--- a/Tools/Source/GenBuild/org/tianocore/build/global/GlobalShare.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*++
-
- 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.
-
- Module Name:
- ShareObject.java
-
- Abstract:
-
- --*/
-package org.tianocore.build.global;
-
-import java.util.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.types.DataType;
-
-public class GlobalShare extends DataType implements DynamicConfigurator {
- private static final HashMap objStorage = new HashMap();
-
- private DataObjectOp op;
-
- private String objName;
-
- private Object objInst;
-
- private String objClassPackage = "org.tianocore";
-
- public GlobalShare () {
-
- }
-
- public GlobalShare (String objName) {
- this.objName = objName;
- this.objInst = objStorage.get(this.objName);
- }
-
- public GlobalShare (String objName, Object obj) {
- this.objName = objName;
- this.objInst = obj;
- objStorage.put(this.objName, this.objInst);
- }
-
- public Object createDynamicElement(String name) throws BuildException {
- String className = objClassPackage + "." + name;
- log("GlobalShare.createDynamicElement(" + name + ")",
- Project.MSG_VERBOSE);
- try {
- objInst = Class.forName(className).newInstance();
- } catch (ClassNotFoundException e) {
- throw new BuildException("class name is not found");
- } catch (InstantiationException e) {
- throw new BuildException("the class cannnot be instantiated");
- } catch (IllegalAccessException e) {
- throw new BuildException("cannot access the class");
- }
-
- return objInst;
- }
-
- public void setDynamicAttribute(String name, String value)
- throws BuildException {
- log("name = " + name + " value = " + value, Project.MSG_VERBOSE);
- throw new BuildException();
- }
-
- public void setName(String name) {
- this.objName = name;
- if (this.op != null) {
- issueOperation();
- }
- }
-
- public String getName() {
- return this.objName;
- }
-
- public void setPackage(String name) {
- log("ShareObject.setPackage(" + name + ")", Project.MSG_VERBOSE);
- this.objClassPackage = name;
- }
-
- public String getPackage() {
- return this.objClassPackage;
- }
-
- public void setOperation(String opName) {
- log("ShareObject.setOperation(" + opName + ")", Project.MSG_VERBOSE);
- this.op = DataObjectOp.formString(opName);
-
- if (this.objName != null) {
- issueOperation();
- }
- }
-
- public String getOperation() {
- return this.op.toString();
- }
-
- public void issueOperation() {
- if (this.op == DataObjectOp.ADD) {
-
- log("ShareObject: adding ... " + this.objName, Project.MSG_VERBOSE);
- objStorage.put(this.objName, this.objInst);
-
- } else if (this.op == DataObjectOp.GET) {
-
- log("ShareObject: fetching ... " + this.objName,
- Project.MSG_VERBOSE);
- objInst = objStorage.get(objName);
-
- } else if (this.op == DataObjectOp.DEL) {
-
- log("ShareObject: removing ... " + this.objName,
- Project.MSG_VERBOSE);
- objInst = objStorage.remove(objName);
-
- } else {
- throw new BuildException("not supported operation");
- }
- }
-
- public Object get() {
- return this.objInst;
- }
-
- public static int getObjectNum() {
- return objStorage.size();
- }
-
- public static Object add(String objName, Object obj) {
- return objStorage.put(objName, obj);
- }
-
- public static Object retrieve(String objName) {
- return objStorage.get(objName);
- }
-
- public static Object remove(String objName) {
- return objStorage.remove(objName);
- }
-
- public static void empty() {
- objStorage.clear();
- }
-}
-
-class DataObjectOp {
- private static final HashMap opMap = new HashMap();
-
- private final String opName;
-
- private DataObjectOp (String name) {
- this.opName = name;
- opMap.put(this.opName, this);
- }
-
- public String toString() {
- return opName;
- }
-
- public static DataObjectOp formString(String opName) {
- return opMap.get(opName);
- }
-
- public static final DataObjectOp ADD = new DataObjectOp("ADD");
-
- public static final DataObjectOp GET = new DataObjectOp("GET");
-
- public static final DataObjectOp DEL = new DataObjectOp("DEL");
-}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/LibBuildFileGenerator.java b/Tools/Source/GenBuild/org/tianocore/build/global/LibBuildFileGenerator.java
deleted file mode 100644
index 4d7e870587..0000000000
--- a/Tools/Source/GenBuild/org/tianocore/build/global/LibBuildFileGenerator.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/** @file
- This file is an ANT task.
-
- LibBuildFileGenerator task is used to generate module's build.xml file.
-
-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.
-
-**/
-package org.tianocore.build.global;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.xmlbeans.XmlObject;
-import org.tianocore.MsaHeaderDocument.MsaHeader;
-import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-/**
- This class LibBuildFileGenerator is an ANT task to generate
- build.xml for each module. Here are two usages.
-
-
-
- For one module (bf is LibBuildFileGenerator task name):
-
-
- @since GenBuild 1.0
-**/
-public class LibBuildFileGenerator extends Task {
-
- private File buildFile;
-
- private boolean recursive = false;
-
- private String license = " Copyright (c) 2006, Intel Corporation \n"
- + "All rights reserved. This program and the accompanying materials \n"
- + "are licensed and made available under the terms and conditions of the BSD License \n"
- + "which accompanies this distribution. The full text of the license may be found at \n"
- + "http://opensource.org/licenses/bsd-license.php \n"
- + "\n"
- + "THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN \"AS IS\" BASIS, \n"
- + "WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.";
-
- private String base_name;
-
- private String module_relative_path;
-
- private File base_file = new File(".");
-
- /**
- Public construct method. It is necessary for ANT task.
- **/
- public LibBuildFileGenerator () {
- }
-
- /**
- ANT task's entry point, will be called after init().
-
- @throws BuildException
- buildFile do not specify while recursive set to false
- **/
- public void execute() throws BuildException {
- if(recursive){
- searchMsa(new File("."));
- }
- else {
- Map map = new HashMap();
- String basename = buildFile.getName();
- int k = basename.lastIndexOf('.');
- base_name = basename.substring(0, k);
- map.put(base_name, buildFile);
- genBuildFile(map);
- }
- }
-
- /**
- Recursivly find all MSA files and record all modules.
-
- @param path Package path
- **/
- private void searchMsa(File path){
- File[] files = path.listFiles();
- Vector vec = new Vector();
- for(int i=0; i < files.length; i ++){
- if (files[i].isFile()){
- if(files[i].getName().endsWith(".msa")){
- System.out.println("#" + files[i].getPath());
- vec.add(files[i]);
- }
- }
- }
- Map mapBasename = new HashMap();
- if (vec.size() > 0){
- base_name = null;
- for ( int j = 0 ; j < vec.size(); j++){
- if ( vec.size() > 1){
- System.out.println("##" + vec.get(0));
- }
- File f = (File)vec.get(j);
- SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();
- Map map = surfaceAreaParser.parseFile(f);
- String baseName = "";
- XmlObject header = null;
- if ( (header = map.get("MsaHeader")) != null ){
- baseName = ((MsaHeader)header).getBaseName().getStringValue();
- }
- else if ( (header = map.get("MsaLibHeader")) != null){
- baseName = ((MsaLibHeader)header).getBaseName().getStringValue();
- } else {
- continue ;
- }
- if ( base_name == null || base_name.length() > baseName.length()){
- base_name = baseName;
- buildFile = f;
- try {
- module_relative_path = buildFile.getParent().substring(base_file.getPath().length() + 1);
- }
- catch(Exception e){
- module_relative_path = ".";
- }
- }
- mapBasename.put(baseName, f);
- }
- genBuildFile(mapBasename);
- }
-
- for(int i=0; i < files.length; i ++){
- if (files[i].isDirectory()){
- searchMsa(files[i]);
- }
- }
- }
-
- /**
- Generate build.xml.
-
- @param map All base name under one module directory
- **/
- private void genBuildFile(Map map) {
- DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();
- try {
- DocumentBuilder dombuilder = domfac.newDocumentBuilder();
- Document document = dombuilder.newDocument();
- //
- // create root element and its attributes
- //
- document.appendChild(document.createComment(license));
- Element root = document.createElement("project");
- root.setAttribute("default", base_name);
- root.setAttribute("basedir", ".");
- //
- // element for External ANT tasks
- //
- root.appendChild(document.createComment("Apply external ANT tasks"));
- Element ele = document.createElement("taskdef");
- ele.setAttribute("resource", "GenBuild.tasks");
- root.appendChild(ele);
- //
- //
- //
- ele = document.createElement("taskdef");
- ele.setAttribute("resource", "net/sf/antcontrib/antlib.xml");
- root.appendChild(ele);
-
- ele = document.createElement("property");
- ele.setAttribute("environment", "env");
- root.appendChild(ele);
-
- ele = document.createElement("property");
- ele.setAttribute("name", "WORKSPACE_DIR");
- ele.setAttribute("value", "${env.WORKSPACE}");
- root.appendChild(ele);
-
- ele = document.createElement("import");
- ele.setAttribute("file", "${WORKSPACE_DIR}"+File.separatorChar+"Tools"+File.separatorChar+"Conf"+File.separatorChar+"BuildMacro.xml");
- root.appendChild(ele);
-
- root.appendChild(document.createComment("MODULE_RELATIVE PATH is relative to PACKAGE_DIR"));
- ele = document.createElement("property");
- ele.setAttribute("name", "MODULE_RELATIVE_PATH");
- ele.setAttribute("value", module_relative_path);
- root.appendChild(ele);
-
- ele = document.createElement("property");
- ele.setAttribute("name", "MODULE_DIR");
- ele.setAttribute("value", "${PACKAGE_DIR}" + File.separatorChar + "${MODULE_RELATIVE_PATH}");
- root.appendChild(ele);
-
- ele = document.createElement("property");
- ele.setAttribute("name", "COMMON_FILE");
- ele.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar + "Tools"
- + File.separatorChar + "Conf" + File.separatorChar + "Common.xml");
- root.appendChild(ele);
-
- //
- // generate the buildfmd target
- //
- Set set = map.keySet();
- Iterator iter = set.iterator();
- while (iter.hasNext()){
- String bName = (String)iter.next();
- File msaFile = (File)map.get(bName);
- String msaFilename = "${MODULE_DIR}" + File.separatorChar + msaFile.getName();
- String mbdFilename = msaFilename.substring(0 , msaFilename.length() - 4) + ".mbd";
- ele = document.createElement("target");
- ele.setAttribute("name", bName);
- Element target = document.createElement("GenBuild");
- target.setAttribute("msaFilename", msaFilename);
- target.setAttribute("mbdFilename", mbdFilename);
- target.setAttribute("baseName", bName);
- ele.appendChild(target);
- root.appendChild(ele);
- }
-
- root.appendChild(ele);
- //
- // Default clean
- //
- ele = document.createElement("target");
- ele.setAttribute("name", "clean");
- ele.setAttribute("depends", base_name + "_clean");
- root.appendChild(ele);
- //
- // Default Clean ALl
- //
- ele = document.createElement("target");
- ele.setAttribute("name", "cleanall");
- ele.setAttribute("depends", base_name + "_cleanall");
- root.appendChild(ele);
- //
- // Every clean target for each BaseName
- //
- set = map.keySet();
- iter = set.iterator();
- while (iter.hasNext()){
- String bName = (String)iter.next();
- File msaFile = (File)map.get(bName);
- String msaFilename = "${MODULE_DIR}" + File.separatorChar + msaFile.getName();
- String mbdFilename = msaFilename.substring(0 , msaFilename.length() - 4) + ".mbd";
-
- ele = document.createElement("target");
- ele.setAttribute("name", bName + "_clean");
- //
- // Output Dir
- //
- Element target = document.createElement("OutputDirSetup");
- target.setAttribute("msaFilename", msaFilename);
- target.setAttribute("mbdFilename", mbdFilename);
- target.setAttribute("baseName", bName);
- ele.appendChild(target);
- //
- // Call BaseName_build.xml clean
- //
- Element ifEle = document.createElement("if");
- Element availableEle = document.createElement("available");
- availableEle.setAttribute("file", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
- ifEle.appendChild(availableEle);
- Element elseEle = document.createElement("then");
-
- Element moduleEle = document.createElement("ant");
- moduleEle.setAttribute("antfile", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
- moduleEle.setAttribute("target", "clean");
-
- elseEle.appendChild(moduleEle);
- ifEle.appendChild(elseEle);
- ele.appendChild(ifEle);
- //
- // just delete
- //
- Element clean = document.createElement("delete");
- clean.setAttribute("dir", "${DEST_DIR_OUTPUT}");
- clean.setAttribute("excludes", "*.xml");
- ele.appendChild(clean);
-
- root.appendChild(ele);
- }
- //
- // Every Clean ALl target for each BaseName
- //
- set = map.keySet();
- iter = set.iterator();
- while (iter.hasNext()){
- String bName = (String)iter.next();
- File msaFile = (File)map.get(bName);
- String msaFilename = "${MODULE_DIR}" + File.separatorChar + msaFile.getName();
- String mbdFilename = msaFilename.substring(0 , msaFilename.length() - 4) + ".mbd";
-
- ele = document.createElement("target");
- ele.setAttribute("name", bName + "_cleanall");
- //
- // Output Dir
- //
- Element target = document.createElement("OutputDirSetup");
- target.setAttribute("msaFilename", msaFilename);
- target.setAttribute("mbdFilename", mbdFilename);
- target.setAttribute("baseName", bName);
- ele.appendChild(target);
- //
- // Call BaseName_build.xml clean
- //
- Element ifEle = document.createElement("if");
- Element availableEle = document.createElement("available");
- availableEle.setAttribute("file", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
- ifEle.appendChild(availableEle);
- Element elseEle = document.createElement("then");
-
- Element moduleEle = document.createElement("ant");
- moduleEle.setAttribute("antfile", "${DEST_DIR_OUTPUT}" + File.separatorChar + bName + "_build.xml");
- moduleEle.setAttribute("target", "cleanall");
-
- elseEle.appendChild(moduleEle);
- ifEle.appendChild(elseEle);
- ele.appendChild(ifEle);
- //
- // just delete
- //
- Element clean = document.createElement("delete");
- clean.setAttribute("dir", "${DEST_DIR_OUTPUT}");
- ele.appendChild(clean);
-
- clean = document.createElement("delete");
- clean.setAttribute("dir", "${DEST_DIR_DEBUG}");
- ele.appendChild(clean);
-
- clean = document.createElement("delete");
- Element fileset = document.createElement("fileset");
- fileset.setAttribute("dir", "${BIN_DIR}");
- fileset.setAttribute("includes", "**" + bName + "*");
- clean.appendChild(fileset);
- ele.appendChild(clean);
-
- root.appendChild(ele);
- }
- document.appendChild(root);
- //
- // Prepare the DOM document for writing
- //
- Source source = new DOMSource(document);
- //
- // Prepare the output file
- //
- String filename = buildFile.getParent() + File.separatorChar + "build.xml";
- File file = new File(getProject().replaceProperties(filename));
- //
- // generate all directory path
- //
- Result result = new StreamResult(file);
- //
- // Write the DOM document to the file
- //
- Transformer xformer = TransformerFactory.newInstance()
- .newTransformer();
- xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
- xformer.setOutputProperty(OutputKeys.INDENT, "yes");
- xformer.transform(source, result);
- } catch (Exception ex) {
- System.out.println("##" + ex);
- }
- }
-
-
- public File getBuildFile() {
- return buildFile;
- }
-
- public void setBuildFile(File buildFile) {
- this.buildFile = buildFile;
- }
-
- public boolean isRecursive() {
- return recursive;
- }
-
- public void setRecursive(boolean recursive) {
- this.recursive = recursive;
- }
-}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/ModuleIdentification.java b/Tools/Source/GenBuild/org/tianocore/build/global/ModuleIdentification.java
deleted file mode 100644
index 74311d4541..0000000000
--- a/Tools/Source/GenBuild/org/tianocore/build/global/ModuleIdentification.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package org.tianocore.build.global;
-
-public class ModuleIdentification {
-
- private String baseName;
-
- private String packageName;
-
- private String guid;
-
- private String version;
-
- public ModuleIdentification(String baseName, String packageName, String guid, String version){
- this.baseName = baseName;
- this.packageName = packageName;
- this.guid = guid;
- this.version = version;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof ModuleIdentification) {
- ModuleIdentification moduleIdObj = (ModuleIdentification)obj;
- if ( baseName.equalsIgnoreCase(moduleIdObj.baseName)) {
- return true;
- }
- // TBD
- return false;
- }
- else {
- return super.equals(obj);
- }
- }
-
- public String toString(){
- return packageName + ":" + guid + "_" + baseName + "_" + version;
- }
-
- public void setBaseName(String baseName) {
- this.baseName = baseName;
- }
-
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- public void setPackageName(String packageName) {
- this.packageName = packageName;
- }
-
- public void setVersion(String version) {
- this.version = version;
- }
-
-
-}
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java b/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java
index 01e24e653f..773fe3e949 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/global/OutputManager.java
@@ -19,158 +19,180 @@ import java.io.File;
/**
OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
- DEST_DIR_DEBUG) according to BUILD_MODE.
+ DEST_DIR_DEBUG).
@since GenBuild 1.0
**/
public class OutputManager {
-
- ///
- /// Single Module build
- ///
- public static final String MODULE_BUILD = "MODULE";
-
- ///
- /// Package build
- ///
- public static final String PACKAGE_BUILD = "PACKAGE";
///
- /// Platform build
+ /// means intermediate files will put under Module's dir
///
- public static final String PLATFORM_BUILD = "PLATFORM";
-
- public static String buildMode = MODULE_BUILD;
+ private String MODULE = "MODULE";
///
- /// For Package build, PLATFORM represent PACKAGE
+ /// mean intermediate files will put under a unify dir
///
- public static String PLATFORM;
+ private String UNIFIED = "UNIFIED";
- ///
- /// For Platform build, PLATFORM_DIR represent PACKAGE_DIR
- ///
- public static String PLATFORM_DIR;
- ///
- /// means intermediate files will put under Module's dir
- ///
- public static final String MODULE = "MODULE";
+ private String userdir;
+ private String type;
///
- /// mean intermediate files will put under a unify dir
+ /// Singleton Design Pattern
///
- public static final String UNIFIED = "UNIFIED";
+ private static OutputManager object;
- ///
- /// Flag to ensure the function update will be called only one in the whole build.
- ///
- private static boolean flag = true;
+ public synchronized static OutputManager getInstance() {
+ if ( object == null ) {
+ object = new OutputManager();
+ }
+ return object;
+ }
+
+ public void setup(String userdir, String type) {
+ this.userdir = userdir;
+ this.type = type;
+ }
/**
- If BUILD_MODE is PLATFORM or PACKAGE, record PLATFORM and PLARFORM_DIR.
- Reminder that for PACKAGE build, here set value PACKAGE to PLATFORM and
- PACKAGE_DIR to PLARFORM_DIR, and also update the ant properties.
+ Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:
+
+
Divide all output files into two types: one is final files, such as FFS
+ file for driver module while LIB file for library module; another is
+ intermediate files, such AutoGen.c, OBJ files, Section files and so on.
+
+
In FPD, OutputDirectory element is used to specify where to put the output
+ files to. There are two mode (MODULE | UNIFIED). MODULE mode means that all
+ output files will put to the module directory while UNIFIED mode means that
+ all output files will put together. Default is UNIFIED mode.
+
+
BUILD_DIR is the base directory for current module build. By default,
+ BUILD_DIR is PLATFORM_DIR/Build in UNIFIED mode while is MODULE_DIR/Build
+ in MODULE mode. Of course, user can customize BUILD_DIR. If user-defined
+ BUILD_DIR is relative path, then look as related to WORKSPACE_DIR.
-
Note that this function will be called only once in the whole build.
+
Then, BIN_DIR is BUILD_DIR/TARGET/TOOLCHAIN/ARCH;
+
+
FV_DIR is BUILD_DIR/TARGET/TOOLCHAIN/FV;
+
+
DEST_DIR_DEBUG | DEST_DIR_OUTPUT is:
+ BIN_DIR/PACKAGE_RELATIVE_DIR/MODULE_RELATIVE_DIR/DEBUG | OUTPUT
+
@param project current ANT build Project
+ @param userdir user-defined directory
+ @param type the module build type (MODULE or UNIFIED)
**/
- public synchronized static void update(Project project) {
- if (flag){
- flag = false;
- String str = project.getProperty("BUILD_MODE");
- if (str != null){
- if (str.equals(PLATFORM_BUILD)) {
- buildMode = PLATFORM_BUILD;
- PLATFORM = project.getProperty("PLATFORM");
- PLATFORM_DIR = project.getProperty("PLATFORM_DIR");
- }
- else if (str.equals(PACKAGE_BUILD)) {
- buildMode = PACKAGE_BUILD;
- PLATFORM = project.getProperty("PACKAGE");
- PLATFORM_DIR = project.getProperty("PACKAGE_DIR");
- project.setProperty("PLATFORM", PLATFORM);
- project.setProperty("PLATFORM_DIR", PLATFORM_DIR);
- }
+ public void update(Project project) {
+// GlobalData.log.info("" + userdir + ":" + type);
+ //
+ // Default mode is UNIFIED.
+ //
+ if (type != null && type.equalsIgnoreCase(MODULE)) {
+ type = MODULE;
+ }
+ else {
+ type = UNIFIED;
+ }
+
+ //
+ // default BUILD_DIR value
+ //
+ String buildDir;
+ if(type.equals(MODULE)){
+ buildDir = project.getProperty("MODULE_DIR") + File.separatorChar + "Build";
+ }
+ else {
+ buildDir = project.getProperty("PLATFORM_DIR") + File.separatorChar + "Build";
+ }
+
+ //
+ // If user define BUILD_DIR
+ //
+ if (userdir != null && ! userdir.equals("")) {
+ File buildFile = new File(userdir);
+ if (buildFile.isAbsolute()){
+ buildDir = userdir;
+ }
+ //
+ // If path is not absolute, then look as related to WORKSPACE_DIR
+ //
+ else {
+ buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir;
}
}
- }
-
- /**
- Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:
-
-
- Those three variables are defined as following
- DEST_DIR_OUTPUT (intermediate files)
- DEST_DIR_DEBUG (intermediate debug files)
- BIN_DIR (final files)
- Output Dir (MODULE or UNIFIED):
- For Module build:
- All intermediate files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}/DEBUG|OUTPUT
- All final files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}
+ //
+ // Define BIN_DIR and FV_DIR
+ //
+ String binDir = buildDir + File.separatorChar + project.getProperty("TARGET")
+ + File.separatorChar + project.getProperty("TOOLCHAIN")
+ + File.separatorChar + project.getProperty("ARCH") ;
- For Platform build:
- If specified with MODULE
- Intermediate files->${MODULE_DIR}/Build/${PLATFORM}/${TARGET}/${ARCH}/DEBUG|OUTPUT
- Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
+ String fvDir = buildDir + File.separatorChar + project.getProperty("TARGET")
+ + File.separatorChar + project.getProperty("TOOLCHAIN")
+ + File.separatorChar + "FV";
- Else if specified with UNIFIED
- Intermediate files->${PLARFORM_DIR}/Build/${TARGET}/${ARCH}/${PACKAGE}/${SOURCE_RELATIVE_PATH}/DEBUG|OUTPUT
- Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
+ //
+ // Define DEST_DIR_OUTPUT and DEST_DIR_DEBUG
+ //
+ String destDir = binDir + File.separatorChar + project.getProperty("PACKAGE_RELATIVE_DIR")
+ + File.separatorChar + project.getProperty("MODULE_RELATIVE_DIR");
- For Package build:
- If specified with MODULE
- Intermediate files->${MODULE_DIR}/Build/${PACKAGE}/${TARGET}/${ARCH}/DEBUG|OUTPUT
- Final files -> ${PACKAGE_DIR}/Build/${TARGET}/${ARCH}
+ //
+ // Set properties
+ //
+ project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
+ project.setProperty("FV_DIR", fvDir.replaceAll("(\\\\)", "/"));
+ project.setProperty("BIN_DIR", binDir.replaceAll("(\\\\)", "/"));
+ project.setProperty("DEST_DIR_DEBUG", (destDir + File.separatorChar + "DEBUG").replaceAll("(\\\\)", "/"));
+ project.setProperty("DEST_DIR_OUTPUT", (destDir + File.separatorChar + "OUTPUT").replaceAll("(\\\\)", "/"));
- Else if specified with UNIFIED
- Intermediate files->${PACKAGE_DIR}/Build/${TARGET}/${ARCH}/${PACKAGE}/${SOURCE_RELATIVE_PATH}/DEBUG|OUTPUT
- Final files -> ${PACKAGE_DIR}/Build/${TARGET}/${ARCH}
-
-
- @param project current ANT build Project
- @param userdir user-defined directory
- @param type the module build type (MODULE or UNIFIED)
- **/
- public synchronized static void update(Project project, String userdir, String type) {
- //
- // userdir TBD
- //
- if( type == null || ! type.equals(MODULE)){
- type = UNIFIED;
- }
- if (buildMode.equals(MODULE_BUILD)){
- project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${MODULE_DIR}"
- + File.separatorChar + "Build" + File.separatorChar + "${TARGET}"
- + File.separatorChar + "${ARCH}" + File.separatorChar + "OUTPUT"));
- project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "DEBUG"));
- project.setProperty("BIN_DIR", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
- }
- else if (buildMode.equals(PLATFORM_BUILD)) {
- if (type.equals(MODULE)) {
- project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "OUTPUT"));
- project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "DEBUG"));
- project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
- }
- else if (type.equals(UNIFIED)){
- project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "OUTPUT"));
- project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "DEBUG"));
- project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
- }
- }
- else if (buildMode.equals(PACKAGE_BUILD)) {
- if (type.equals(MODULE)) {
- project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "OUTPUT"));
- project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${PLATFORM}" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "DEBUG"));
- project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
- }
- else if (type.equals(UNIFIED)){
- project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "OUTPUT"));
- project.setProperty("DEST_DIR_DEBUG", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}" + File.separatorChar + "${PACKAGE}" + File.separatorChar + "${MODULE_RELATIVE_PATH}" + File.separatorChar + "DEBUG"));
- project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
- }
- }
+ //
+ // Create all directory if necessary
+ //
+ (new File(buildDir)).mkdirs();
+ (new File(fvDir)).mkdirs();
+ (new File(binDir)).mkdirs();
+ (new File(destDir + File.separatorChar + "DEBUG")).mkdirs();
+ (new File(destDir + File.separatorChar + "OUTPUT")).mkdirs();
}
-}
+
+ public boolean prepareBuildDir(Project project){
+ boolean isUnified = true;
+
+ if (type.equalsIgnoreCase("MODULE")) {
+ isUnified = false;
+ }
+
+ String buildDir = project.getProperty("PLATFORM_DIR") + File.separatorChar + "Build";
+ //
+ // If user define BUILD_DIR
+ //
+ if (userdir != null && ! userdir.equals("")) {
+ File buildFile = new File(userdir);
+ if (buildFile.isAbsolute()){
+ buildDir = userdir;
+ }
+ //
+ // If path is not absolute, then look as related to WORKSPACE_DIR
+ //
+ else {
+ buildDir = GlobalData.getWorkspacePath() + File.separatorChar + userdir;
+ }
+ }
+ //
+ // Set to property
+ //
+ project.setProperty("BUILD_DIR", buildDir.replaceAll("(\\\\)", "/"));
+
+ //
+ // Create all directory if necessary
+ //
+ (new File(buildDir)).mkdirs();
+ return isUnified;
+ }
+
+}
\ No newline at end of file
diff --git a/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java b/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java
deleted file mode 100644
index 60f430f458..0000000000
--- a/Tools/Source/GenBuild/org/tianocore/build/global/OverrideProcess.java
+++ /dev/null
@@ -1,361 +0,0 @@
-/** @file
- OverrideProcess class.
-
- OverrideProcess class is used to override surface area information.
-
-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.
-
-**/
-package org.tianocore.build.global;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.namespace.QName;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.xmlbeans.XmlCursor;
-import org.apache.xmlbeans.XmlObject;
-import org.tianocore.BootModesDocument;
-import org.tianocore.BuildOptionsDocument;
-import org.tianocore.DataHubsDocument;
-import org.tianocore.EventsDocument;
-import org.tianocore.ExternsDocument;
-import org.tianocore.FormsetsDocument;
-import org.tianocore.GuidsDocument;
-import org.tianocore.HobsDocument;
-import org.tianocore.IncludesDocument;
-import org.tianocore.LibrariesDocument;
-import org.tianocore.LibraryClassDefinitionsDocument;
-import org.tianocore.MsaHeaderDocument;
-import org.tianocore.MsaLibHeaderDocument;
-import org.tianocore.PcdCodedDocument;
-import org.tianocore.PPIsDocument;
-import org.tianocore.ProtocolsDocument;
-import org.tianocore.SourceFilesDocument;
-import org.tianocore.SystemTablesDocument;
-import org.tianocore.VariablesDocument;
-import org.tianocore.PackageDependenciesDocument;
-
-/**
- This class is used to override surface area information. For example, MBD can
- overried MSA, Platform can override all information of the module.
-
-
Override will take effect if two element satisfy one of following two condition:
-
-
Element name and its attribute OverrideID equal each other.
-
Element is defined as exclusive which mean such element can be
- only appeared in the surface area.
-
-
-
For example, here OutputDirectory element is exclusive: