Change to new XML Schema.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@687 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
9c39e21476
commit
a29c47e01d
@ -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.
|
|
||||||
<p>Current, prepare the dependent Library instance list for <code>LIBS</code></p>
|
|
||||||
|
|
||||||
@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 <code>LIBS</code> 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);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,6 +26,10 @@ import org.apache.tools.ant.BuildException;
|
|||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.apache.xmlbeans.XmlCursor;
|
import org.apache.xmlbeans.XmlCursor;
|
||||||
import org.apache.xmlbeans.XmlObject;
|
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.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.NamedNodeMap;
|
||||||
@ -61,6 +65,8 @@ public class FfsProcess {
|
|||||||
///
|
///
|
||||||
private Node ffs;
|
private Node ffs;
|
||||||
|
|
||||||
|
private BuildOptionsDocument.BuildOptions.Ffs ffsXmlObject;
|
||||||
|
|
||||||
///
|
///
|
||||||
/// ANT script to call GenFfs
|
/// ANT script to call GenFfs
|
||||||
///
|
///
|
||||||
@ -131,10 +137,30 @@ public class FfsProcess {
|
|||||||
@throws BuildException
|
@throws BuildException
|
||||||
If specified COMMON_FILE XML file is not valide.
|
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
|
// if module specify sections itself, it's okay
|
||||||
@ -194,22 +220,30 @@ public class FfsProcess {
|
|||||||
**/
|
**/
|
||||||
public String[] getGenSectionElements(Document document, String basename, String guid, String targetFilename) {
|
public String[] getGenSectionElements(Document document, String basename, String guid, String targetFilename) {
|
||||||
this.basename = basename;
|
this.basename = basename;
|
||||||
if (ffs == null) {
|
if (ffs == null && ffsXmlObject == null) {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
Vector<String> sectionList = new Vector<String>();
|
Vector<String> sectionList = new Vector<String>();
|
||||||
XmlCursor cursor = null;
|
XmlCursor cursor = null;
|
||||||
try {
|
try {
|
||||||
|
if (ffsXmlObject == null) {
|
||||||
cursor = XmlObject.Factory.parse(ffs).newCursor();
|
cursor = XmlObject.Factory.parse(ffs).newCursor();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cursor = ffsXmlObject.newCursor();
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
int mode = MODE_NONE;
|
int mode = MODE_NONE;
|
||||||
Element root = document.createElement("genffsfile");
|
Element root = document.createElement("genffsfile");
|
||||||
root.setAttribute("outputDir", "${BIN_DIR}");
|
root.setAttribute("outputDir", "${BIN_DIR}");
|
||||||
|
root.setAttribute("moduleType", "${MODULE_TYPE}");
|
||||||
root.setAttribute("BaseName", basename);
|
root.setAttribute("BaseName", basename);
|
||||||
root.setAttribute("fileGuid", guid);
|
root.setAttribute("fileGuid", guid);
|
||||||
|
if (ffsXmlObject == null) {
|
||||||
cursor.toFirstChild();
|
cursor.toFirstChild();
|
||||||
|
}
|
||||||
if (cursor.toFirstChild()) {
|
if (cursor.toFirstChild()) {
|
||||||
do {
|
do {
|
||||||
if (cursor.getName().getLocalPart().equalsIgnoreCase("Attribute")) {
|
if (cursor.getName().getLocalPart().equalsIgnoreCase("Attribute")) {
|
||||||
@ -315,7 +349,7 @@ public class FfsProcess {
|
|||||||
// outputPath = "${DEST_DIR_OUTPUT}">
|
// outputPath = "${DEST_DIR_OUTPUT}">
|
||||||
//
|
//
|
||||||
ele = doc.createElement("tool");
|
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");
|
+ File.separatorChar + "GenCRC32Section");
|
||||||
ele.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");
|
ele.setAttribute("outputPath", "${DEST_DIR_OUTPUT}");
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@ package org.tianocore.build;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Project;
|
import org.apache.tools.ant.Project;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
@ -29,17 +30,24 @@ import org.w3c.dom.Node;
|
|||||||
by its extension. Following is the current supported extensions. </p>
|
by its extension. Following is the current supported extensions. </p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
.c | C_Code
|
Source File Suffix File Type Description
|
||||||
.asm | Assembly
|
.h CHeader C header file
|
||||||
.s | IPF_Assembly_Code
|
.c CCode C source file
|
||||||
.h | Header
|
.inc ASMHeader Assembly header file
|
||||||
.lib | Static_Library
|
.asm ASM Assembly source file, usually for IA32 and X64 Arch and MSFT tool chain
|
||||||
.i | IPF_PP_Code
|
.S ASM Assembly source file, usually for IPF Arch
|
||||||
.vfr | Vfr
|
.s ASM Assembly source file, usually for IA32 and X64 Arch and GCC tool chain
|
||||||
.uni | Unicode
|
.uni UNI Unicode file
|
||||||
.dxs | Dependency_File
|
.vfr VFR Visual Forms Representation File
|
||||||
.bmp | Graphics
|
.fv FV Firmware Volume
|
||||||
.efi | EFI
|
.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
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
@since GenBuild 1.0
|
@since GenBuild 1.0
|
||||||
@ -48,13 +56,25 @@ public class FileProcess {
|
|||||||
///
|
///
|
||||||
/// The mapping information about source suffix, result suffix, file type.
|
/// The mapping information about source suffix, result suffix, file type.
|
||||||
///
|
///
|
||||||
public final String[][] fileTypes = { { ".c", ".obj", "C_Code" }, { ".asm", ".obj", "Assembly" },
|
public final String[][] fileTypes = { {".h", "", "CHeader" },
|
||||||
{ ".s", ".obj", "IPF_Assembly_Code" }, { ".h", "", "Header" },
|
{".c", "", "CCode" },
|
||||||
{ ".lib", "", "Static_Library" }, { ".src", ".c", "" },
|
{".inc", "", "ASMHeader" },
|
||||||
{ ".i", ".obj", "IPF_PP_Code" }, { ".vfr", ".obj", "Vfr" },
|
{".asm", "", "ASM" },
|
||||||
{ ".uni", "", "Unicode" }, { ".dxs", "", "Dependency_File" },
|
{".S", "", "ASM" },
|
||||||
{ ".bmp", "", "Graphics" }, { ".efi", "", "EFI" } };
|
{".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.
|
/// Current ANT context.
|
||||||
///
|
///
|
||||||
@ -65,11 +85,6 @@ public class FileProcess {
|
|||||||
///
|
///
|
||||||
private Set<String> includes;
|
private Set<String> includes;
|
||||||
|
|
||||||
///
|
|
||||||
/// Current source files.
|
|
||||||
///
|
|
||||||
private Set<String> sourceFiles;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Xml Document.
|
/// Xml Document.
|
||||||
///
|
///
|
||||||
@ -93,11 +108,10 @@ public class FileProcess {
|
|||||||
@param sourceFiles Modules source files
|
@param sourceFiles Modules source files
|
||||||
@param document XML document
|
@param document XML document
|
||||||
**/
|
**/
|
||||||
public void init(Project project, Set<String> includes, Set<String> sourceFiles, Document document) {
|
public void init(Project project, Set<String> includes, Document document) {
|
||||||
this.document = document;
|
this.document = document;
|
||||||
this.includes = includes;
|
this.includes = includes;
|
||||||
this.project = project;
|
this.project = project;
|
||||||
this.sourceFiles = sourceFiles;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -140,16 +154,16 @@ public class FileProcess {
|
|||||||
@param filename Source file name
|
@param filename Source file name
|
||||||
@param root Root node
|
@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;
|
boolean flag = false;
|
||||||
for (int i = 0; i < fileTypes.length; i++) {
|
for (int i = 0; i < fileTypes.length; i++) {
|
||||||
if (filename.toLowerCase().endsWith(fileTypes[i][0])) {
|
if (filename.endsWith(fileTypes[i][0])) {
|
||||||
flag = true;
|
flag = true;
|
||||||
parseFile(filename, fileTypes[i][2], root);
|
parseFile(filename, fileTypes[i][2], root);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!flag) {
|
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) {
|
public synchronized void parseFile(String filename, String filetype, Node root) {
|
||||||
if (unicodeFirst) {
|
if (unicodeFirst) {
|
||||||
if ( ! filetype.equalsIgnoreCase("Unicode")){
|
if ( ! filetype.equalsIgnoreCase("UNI")){
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
unicodeExist= true;
|
unicodeExist= true;
|
||||||
} else {
|
} else {
|
||||||
if (filetype.equalsIgnoreCase("Unicode")){
|
if (filetype.equalsIgnoreCase("UNI")){
|
||||||
return ;
|
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;
|
return;
|
||||||
}
|
}
|
||||||
if (filetype.equalsIgnoreCase("IPF_PP_Code")) {
|
|
||||||
|
//
|
||||||
|
// If file is pre-processor file, skip it
|
||||||
|
//
|
||||||
|
if (filetype.equalsIgnoreCase("PPCode")) {
|
||||||
return;
|
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");
|
String module_path = project.getProperty("MODULE_DIR");
|
||||||
File moduleFile = new File(module_path);
|
File moduleFile = new File(module_path);
|
||||||
File sourceFile = new File(filename);
|
File sourceFile = new File(filename);
|
||||||
|
|
||||||
|
//
|
||||||
// If source file is AutoGen.c, then Filepath is .
|
// 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")) {
|
if (sourceFile.getPath().endsWith("AutoGen.c")) {
|
||||||
sourceFilepath = ".";
|
sourceFilepath = ".";
|
||||||
sourceFilename = "AutoGen";
|
sourceFilename = "AutoGen";
|
||||||
|
sourceFileext = ".c";
|
||||||
filetype = "AUTOGEN";
|
filetype = "AUTOGEN";
|
||||||
} else {
|
} else {
|
||||||
// sourceFile.
|
// sourceFile.
|
||||||
@ -206,12 +247,14 @@ public class FileProcess {
|
|||||||
index = str.lastIndexOf('.');
|
index = str.lastIndexOf('.');
|
||||||
if (index > 0) {
|
if (index > 0) {
|
||||||
sourceFilename = str.substring(0, index);
|
sourceFilename = str.substring(0, index);
|
||||||
|
sourceFileext = str.substring(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// <Build_filetype FILEPATH="" FILENAME="" />
|
// <Build_filetype FILEPATH="" FILENAME="" />
|
||||||
Element ele = document.createElement("Build_" + filetype);
|
Element ele = document.createElement("Build_" + filetype);
|
||||||
ele.setAttribute("FILEPATH", sourceFilepath);
|
ele.setAttribute("FILEPATH", sourceFilepath);
|
||||||
ele.setAttribute("FILENAME", sourceFilename);
|
ele.setAttribute("FILENAME", sourceFilename);
|
||||||
|
ele.setAttribute("FILEEXT", sourceFileext.substring(1));
|
||||||
String[] includePaths = includes.toArray(new String[includes.size()]);
|
String[] includePaths = includes.toArray(new String[includes.size()]);
|
||||||
Element includesEle = document.createElement("EXTRA.INC");
|
Element includesEle = document.createElement("EXTRA.INC");
|
||||||
for (int i = 0; i < includePaths.length; i++) {
|
for (int i = 0; i < includePaths.length; i++) {
|
||||||
|
@ -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<File> buildFiles = new LinkedHashSet<File>();
|
||||||
|
|
||||||
|
private Set<File> fpdFiles = new LinkedHashSet<File>();
|
||||||
|
|
||||||
|
private Set<File> msaFiles = new LinkedHashSet<File>();
|
||||||
|
|
||||||
|
///
|
||||||
|
/// 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<String, String> sysProperties = System.getenv();
|
||||||
|
Set<String> keys = sysProperties.keySet();
|
||||||
|
Iterator<String> 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<File> iter = fpdFiles.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
allFiles[index] = iter.next();
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
iter = msaFiles.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
allFiles[index] = iter.next();
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
System.out.println("Find " + allFiles.length + " FPD and MSA files: ");
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -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 <em>build.xml</em>.
|
||||||
|
///
|
||||||
|
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.
|
||||||
|
<ul>
|
||||||
|
<li> ANT properties; </li>
|
||||||
|
<li> Dependent module (dependent library instances in most case); </li>
|
||||||
|
<li> Source files; </li>
|
||||||
|
<li> Sections if module is not library; </li>
|
||||||
|
<li> Output (different for library module and driver module); </li>
|
||||||
|
<li> Clean; </li>
|
||||||
|
<li> Clean all. </li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
@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<String, String> passDownMap = new LinkedHashMap<String, String>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// <delete includeemptydirs="true">
|
||||||
|
// <fileset dir="${DEST_DIR_OUTPUT}" includes="" excludes="" />
|
||||||
|
// </delete>
|
||||||
|
//
|
||||||
|
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<String, String> passDownMap = new LinkedHashMap<String, String>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// <delete includeemptydirs="true">
|
||||||
|
// <fileset dir="${DEST_DIR_OUTPUT}" includes="" excludes="" />
|
||||||
|
// </delete>
|
||||||
|
//
|
||||||
|
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);
|
||||||
|
|
||||||
|
//
|
||||||
|
// <delete includeemptydirs="true">
|
||||||
|
// <fileset dir="${DEST_DIR_DEBUG}" includes="" />
|
||||||
|
// </delete>
|
||||||
|
//
|
||||||
|
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<String, String> passDownMap = new LinkedHashMap<String, String>();
|
||||||
|
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<String> includes = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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 <em>LIB</em> command, else call the <em>GenFfs</em> 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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
271
Tools/Source/GenBuild/org/tianocore/build/OutputDirSetup.java
Normal file
271
Tools/Source/GenBuild/org/tianocore/build/OutputDirSetup.java
Normal file
@ -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<String, XmlObject> 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.
|
||||||
|
|
||||||
|
<p> Take command <code>CC</code> and arch <code>IA32</code> for example,
|
||||||
|
Those flags are from <code>ToolChainFactory</code>: </p>
|
||||||
|
<ul>
|
||||||
|
<li> IA32_CC </li>
|
||||||
|
<li> IA32_CC_STD_FLAGS </li>
|
||||||
|
<li> IA32_CC_GLOBAL_FLAGS </li>
|
||||||
|
<li> IA32_CC_GLOBAL_ADD_FLAGS </li>
|
||||||
|
<li> IA32_CC_GLOBAL_SUB_FLAGS </li>
|
||||||
|
</ul>
|
||||||
|
Those flags can user-define:
|
||||||
|
<ul>
|
||||||
|
<li> IA32_CC_PROJ_FLAGS </li>
|
||||||
|
<li> IA32_CC_PROJ_ADD_FLAGS </li>
|
||||||
|
<li> IA32_CC_PROJ_SUB_FLAGS </li>
|
||||||
|
<li> CC_PROJ_FLAGS </li>
|
||||||
|
<li> CC_PROJ_ADD_FLAGS </li>
|
||||||
|
<li> CC_PROJ_SUB_FLAGS </li>
|
||||||
|
<li> CC_FLAGS </li>
|
||||||
|
<li> IA32_CC_FLAGS </li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<p> 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. </p>
|
||||||
|
|
||||||
|
Note that the <code>ToolChainFactory</code> 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();
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
|
||||||
|
|
||||||
/**
|
|
||||||
<code>OutputDirSetupTask</code> 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.
|
|
||||||
|
|
||||||
<p>Here is an example: </p>
|
|
||||||
<pre>
|
|
||||||
<OutputDirSetup baseName="HelloWorld"
|
|
||||||
mbdFilename="${MODULE_DIR}\HelloWorld.mbd"
|
|
||||||
msaFilename="${MODULE_DIR}\HelloWorld.msa" />
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Note that all this task doing is part of GenBuildTask. </p>
|
|
||||||
|
|
||||||
@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<String, XmlObject> map = new HashMap<String, XmlObject>();
|
|
||||||
|
|
||||||
///
|
|
||||||
/// 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:
|
|
||||||
<ul>
|
|
||||||
<li> Judge current build mode (MODULE | PACKAGE | PLATFORM). This step will execute
|
|
||||||
only once in whole build process; </li>
|
|
||||||
<li> Initialize global information (Framework DB, SPD files and all MSA files
|
|
||||||
listed in SPD). This step will execute only once in whole build process; </li>
|
|
||||||
<li> Restore some important ANT property. If current build is single module
|
|
||||||
build, here will set many default values; </li>
|
|
||||||
<li> Get the current module's overridded surface area information from
|
|
||||||
global data; </li>
|
|
||||||
<li> Set up the output directories, including BIN_DIR, DEST_DIR_OUTPUT and
|
|
||||||
DEST_DIR_DEBUG; </li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@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.
|
|
||||||
|
|
||||||
<p> If current build is single module build, then the default <code>ARCH</code>
|
|
||||||
is <code>IA32</code>. Also set up the properties <code>PACKAGE</code>,
|
|
||||||
<code>PACKAGE_DIR</code>, <code>TARGET</code> and <code>MODULE_DIR</code></p>
|
|
||||||
|
|
||||||
<p> Note that for package build, package name is stored in <code>PLATFORM</code>
|
|
||||||
and package directory is stored in <code>PLATFORM_DIR</code>. </p>
|
|
||||||
|
|
||||||
@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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -20,11 +20,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.xmlbeans.XmlObject;
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.tianocore.LibraryClassDocument.LibraryClass;
|
import org.tianocore.LibraryClassDocument.LibraryClass;
|
||||||
|
|
||||||
import org.tianocore.build.global.GlobalData;
|
import org.tianocore.build.global.GlobalData;
|
||||||
import org.tianocore.build.global.SurfaceAreaQuery;
|
import org.tianocore.build.global.SurfaceAreaQuery;
|
||||||
|
import org.tianocore.build.id.ModuleIdentification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class This class is to reorder library instance sequence according to
|
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.
|
/// The map of library class and its library instance.
|
||||||
///
|
///
|
||||||
private Map<String, String> libClassMap = new HashMap<String, String>();
|
private Map<String, ModuleIdentification> libClassMap = new HashMap<String, ModuleIdentification>();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// The map of library instance and its implemet instance.
|
/// The map of library instance and its implemet libraryClass.
|
||||||
///
|
///
|
||||||
private Map<String, String[]> libInstanceMap = new HashMap<String, String[]>();
|
private Map<ModuleIdentification, String[]> libInstanceMap = new HashMap<ModuleIdentification, String[]>();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// List of library instance. It is String[3] list, String[0] is libraryName,
|
/// List of library instance. It is String[3] list, String[0] is libraryName,
|
||||||
/// String[1] is libraryConstructor name, String[2] is libDestructor name.
|
/// String[1] is libraryConstructor name, String[2] is libDestructor name.
|
||||||
///
|
///
|
||||||
private List<String[]> libInstanceList = new ArrayList<String[]>();
|
private List<LibraryInstanceNode> libInstanceList = new ArrayList<LibraryInstanceNode>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor function
|
Constructor function
|
||||||
@ -55,40 +57,37 @@ public class AutogenLibOrder {
|
|||||||
@param libraryList List of the library instance.
|
@param libraryList List of the library instance.
|
||||||
@throws Exception
|
@throws Exception
|
||||||
**/
|
**/
|
||||||
AutogenLibOrder(List<String> libraryList) throws Exception {
|
AutogenLibOrder(ModuleIdentification[] libraryList, String arch) throws Exception {
|
||||||
String[] libInstance = new String[3];
|
LibraryInstanceNode libInstanceNode;
|
||||||
LibraryClass[] libClassDeclList = null;
|
String[] libClassDeclList = null;
|
||||||
LibraryClass[] libClassConsmList = 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.
|
// Add libraryInstance in to libInstanceList.
|
||||||
//
|
//
|
||||||
libInstance[0] = libraryList.get(i);
|
Map<String, XmlObject> libDoc = GlobalData.getDoc(libraryList[i], arch);
|
||||||
Map<String, XmlObject> libDoc = GlobalData.getDoc(libInstance[0]);
|
|
||||||
SurfaceAreaQuery.push(libDoc);
|
SurfaceAreaQuery.push(libDoc);
|
||||||
libInstance[1] = SurfaceAreaQuery.getLibConstructorName();
|
libInstanceNode = new LibraryInstanceNode (libraryList[i],SurfaceAreaQuery.getLibConstructorName(), SurfaceAreaQuery.getLibDestructorName());
|
||||||
libInstance[2] = SurfaceAreaQuery.getLibDestructorName();
|
libInstanceList.add(libInstanceNode);
|
||||||
libInstanceList.add(libInstance.clone());
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Add library instance and consumed library class list to
|
// Add library instance and consumed library class list to
|
||||||
// libInstanceMap.
|
// libInstanceMap.
|
||||||
//
|
//
|
||||||
libClassConsmList = SurfaceAreaQuery
|
libClassConsmList = SurfaceAreaQuery
|
||||||
.getLibraryClassArray(CommonDefinition.AlwaysConsumed);
|
.getLibraryClasses(CommonDefinition.AlwaysConsumed);
|
||||||
if (libClassConsmList != null) {
|
if (libClassConsmList != null) {
|
||||||
String[] classStr = new String[libClassConsmList.length];
|
String[] classStr = new String[libClassConsmList.length];
|
||||||
for (int k = 0; k < libClassConsmList.length; k++) {
|
for (int k = 0; k < libClassConsmList.length; k++) {
|
||||||
//classStr[k] = libClassConsmList[k].getStringValue();
|
classStr[k] = libClassConsmList[k];
|
||||||
classStr[k] = getStringValue((XmlObject)libClassConsmList[k]);
|
|
||||||
}
|
}
|
||||||
if (this.libInstanceMap.containsKey(libInstance[0])) {
|
if (this.libInstanceMap.containsKey(libraryList[i])) {
|
||||||
throw new Exception(
|
throw new Exception(
|
||||||
libInstance[0]
|
libraryList[i].getName()
|
||||||
+ "this library instance is already exist, please check you library instance list!");
|
+ "this library instance is already exist, please check you library instance list!");
|
||||||
} else {
|
} 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.
|
// Add library class and library instance map.
|
||||||
//
|
//
|
||||||
libClassDeclList = SurfaceAreaQuery
|
libClassDeclList = SurfaceAreaQuery
|
||||||
.getLibraryClassArray(CommonDefinition.AlwaysProduced);
|
.getLibraryClasses(CommonDefinition.AlwaysProduced);
|
||||||
if (libClassDeclList != null) {
|
if (libClassDeclList != null) {
|
||||||
for (int j = 0; j < libClassDeclList.length; j++) {
|
for (int j = 0; j < libClassDeclList.length; j++) {
|
||||||
//if (this.libClassMap.containsKey(libClassDeclList[j]
|
if (this.libClassMap.containsKey(libClassDeclList[j])) {
|
||||||
// .getStringValue())) {
|
System.out.println(libClassDeclList[j]
|
||||||
String libClassName = getStringValue((XmlObject)libClassDeclList[j]);
|
|
||||||
if (this.libClassMap.containsKey(libClassName)) {
|
|
||||||
System.out.println(libClassName
|
|
||||||
+ " class is already implement by "
|
+ " class is already implement by "
|
||||||
+ this.libClassMap.get(libClassName));
|
+ this.libClassMap.get(libClassDeclList[j]));
|
||||||
throw new Exception(libClassDeclList
|
throw new Exception(libClassDeclList
|
||||||
+ " is already have library instance!");
|
+ " is already have library instance!");
|
||||||
} else {
|
} 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.
|
@return List which content the ordered library instance.
|
||||||
**/
|
**/
|
||||||
List orderLibInstance() {
|
List<ModuleIdentification> orderLibInstance() {
|
||||||
List<String> orderList = new ArrayList<String>();
|
List<ModuleIdentification> orderList = new ArrayList<ModuleIdentification>();
|
||||||
//
|
//
|
||||||
// Stack of node which track the library instance name ant its visiting
|
// Stack of node which track the library instance name ant its visiting
|
||||||
// flag.
|
// flag.
|
||||||
//
|
//
|
||||||
List<Node> stackList = new ArrayList<Node>();
|
List<Node> stackList = new ArrayList<Node>();
|
||||||
int stackSize = 0;
|
int stackSize = 0;
|
||||||
String libInstance = null;
|
ModuleIdentification libInstanceId = null;
|
||||||
if (libInstanceList.size() < 0) {
|
if (libInstanceList.size() < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -169,11 +165,11 @@ public class AutogenLibOrder {
|
|||||||
//
|
//
|
||||||
// If library instance is already in the order list skip it.
|
// 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;
|
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.
|
// Use stack to reorder library instance.
|
||||||
// Push node to stack.
|
// Push node to stack.
|
||||||
@ -187,8 +183,8 @@ public class AutogenLibOrder {
|
|||||||
//
|
//
|
||||||
if (stackList.get(stackSize).isVisit) {
|
if (stackList.get(stackSize).isVisit) {
|
||||||
if (!isInLibInstance(orderList,
|
if (!isInLibInstance(orderList,
|
||||||
stackList.get(stackSize).nodeName)) {
|
stackList.get(stackSize).nodeId)) {
|
||||||
orderList.add(stackList.get(stackSize).nodeName);
|
orderList.add(stackList.get(stackSize).nodeId);
|
||||||
stackList.remove(stackSize);
|
stackList.remove(stackSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,15 +194,15 @@ public class AutogenLibOrder {
|
|||||||
//
|
//
|
||||||
stackList.get(stackList.size() - 1).isVisit = true;
|
stackList.get(stackList.size() - 1).isVisit = true;
|
||||||
String[] libClassList = this.libInstanceMap.get(stackList
|
String[] libClassList = this.libInstanceMap.get(stackList
|
||||||
.get(stackSize).nodeName);
|
.get(stackSize).nodeId);
|
||||||
//
|
//
|
||||||
// Push the node dependence library instance to the stack.
|
// Push the node dependence library instance to the stack.
|
||||||
//
|
//
|
||||||
if (libClassList != null) {
|
if (libClassList != null) {
|
||||||
for (int j = 0; j < libClassList.length; j++) {
|
for (int j = 0; j < libClassList.length; j++) {
|
||||||
libInstance = this.libClassMap.get(libClassList[j]);
|
libInstanceId = this.libClassMap.get(libClassList[j]);
|
||||||
if (libInstance != null
|
if (libInstanceId != null
|
||||||
&& !isInLibInstance(orderList, libInstance)) {
|
&& !isInLibInstance(orderList, libInstanceId)) {
|
||||||
//
|
//
|
||||||
// If and only if the currently library instance
|
// If and only if the currently library instance
|
||||||
// is not in stack and it have constructor or
|
// is not in stack and it have constructor or
|
||||||
@ -214,7 +210,7 @@ public class AutogenLibOrder {
|
|||||||
// instacne in stack.
|
// instacne in stack.
|
||||||
//
|
//
|
||||||
if (!isInStackList(stackList, this.libClassMap
|
if (!isInStackList(stackList, this.libClassMap
|
||||||
.get(libClassList[j])) && isHaveConsDestructor(libInstance)) {
|
.get(libClassList[j])) && isHaveConsDestructor(libInstanceId)) {
|
||||||
stackList.add(new Node(this.libClassMap
|
stackList.add(new Node(this.libClassMap
|
||||||
.get(libClassList[j]), false));
|
.get(libClassList[j]), false));
|
||||||
}
|
}
|
||||||
@ -237,9 +233,10 @@ public class AutogenLibOrder {
|
|||||||
@return "true" the library instance in list |
|
@return "true" the library instance in list |
|
||||||
"false" the library instance is not in list.
|
"false" the library instance is not in list.
|
||||||
**/
|
**/
|
||||||
private boolean isInLibInstance(List list, String instanceName) {
|
private boolean isInLibInstance(List<ModuleIdentification> list, ModuleIdentification instanceId) {
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
if (instanceName.equalsIgnoreCase(list.get(i).toString())) {
|
|
||||||
|
if (instanceId.equals(list.get(i))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -256,9 +253,9 @@ public class AutogenLibOrder {
|
|||||||
@return "true" if node have in stack |
|
@return "true" if node have in stack |
|
||||||
"false" if node don't in stack.
|
"false" if node don't in stack.
|
||||||
**/
|
**/
|
||||||
private boolean isInStackList(List<Node> list, String nodeName) {
|
private boolean isInStackList(List<Node> list, ModuleIdentification instanceId) {
|
||||||
for (int i = 0; i < list.size(); i++) {
|
for (int i = 0; i < list.size(); i++) {
|
||||||
if (nodeName.equalsIgnoreCase(list.get(i).nodeName)) {
|
if (instanceId.equals(list.get(i).nodeId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,20 +273,16 @@ public class AutogenLibOrder {
|
|||||||
"false" if library don't have constructor
|
"false" if library don't have constructor
|
||||||
and desconstructor.
|
and desconstructor.
|
||||||
**/
|
**/
|
||||||
private boolean isHaveConsDestructor (String libName){
|
private boolean isHaveConsDestructor (ModuleIdentification libNode){
|
||||||
for (int i = 0; i < libInstanceList.size(); i++){
|
for (int i = 0; i < libInstanceList.size(); i++){
|
||||||
if (libInstanceList.get(i)[0].equalsIgnoreCase(libName)){
|
if (libInstanceList.get(i).libId.equals(libNode)){
|
||||||
if (libInstanceList.get(i)[1] != null || libInstanceList.get(i)[2] != null){
|
if (libInstanceList.get(i).constructorName != null || libInstanceList.get(i).deconstructorName != null){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getStringValue(XmlObject xmlDoc) {
|
|
||||||
return xmlDoc.getDomNode().getFirstChild().getNodeValue();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -299,12 +292,29 @@ public class AutogenLibOrder {
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
class Node {
|
class Node {
|
||||||
String nodeName;
|
ModuleIdentification nodeId;
|
||||||
|
|
||||||
boolean isVisit;
|
boolean isVisit;
|
||||||
|
|
||||||
Node(String name, boolean isVisit) {
|
Node(ModuleIdentification nodeId, boolean isVisit) {
|
||||||
this.nodeName = name;
|
this.nodeId = nodeId;
|
||||||
this.isVisit = false;
|
this.isVisit = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -44,6 +44,7 @@ public class CommonDefinition {
|
|||||||
public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n";
|
public final static String autoGenHReleaseDefault = "#define EDK_RELEASE_VERSION 0x00000000\r\n";
|
||||||
|
|
||||||
public final static String includeAutogenH = "#include <AutoGen.h>\r\n" ;
|
public final static String includeAutogenH = "#include <AutoGen.h>\r\n" ;
|
||||||
|
public final static String marcDefineStr = "#define ";
|
||||||
|
|
||||||
public final static String gEfi = "gEfi";
|
public final static String gEfi = "gEfi";
|
||||||
public final static String protocolGuid = "ProtocolGuid";
|
public final static String protocolGuid = "ProtocolGuid";
|
||||||
@ -148,10 +149,10 @@ public class CommonDefinition {
|
|||||||
new MyEnum("PEI_CORE", ModuleTypePeiCore),
|
new MyEnum("PEI_CORE", ModuleTypePeiCore),
|
||||||
new MyEnum("PEIM", ModuleTypePeim),
|
new MyEnum("PEIM", ModuleTypePeim),
|
||||||
new MyEnum("DXE_CORE", ModuleTypeDxeCore),
|
new MyEnum("DXE_CORE", ModuleTypeDxeCore),
|
||||||
new MyEnum("DXE_DRIVER", ModuleTypeDxeDriver),
|
new MyEnum("DXE_DRIVER", ModuleTypeDxeRuntimeDriver),
|
||||||
new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),
|
new MyEnum("DXE_RUNTIME_DRIVER", ModuleTypeDxeRuntimeDriver),
|
||||||
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
|
|
||||||
new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),
|
new MyEnum("DXE_SAL_DRIVER", ModuleTypeDxeSalDriver),
|
||||||
|
new MyEnum("DXE_SMM_DRIVER", ModuleTypeDxeSmmDriver),
|
||||||
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
|
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
|
||||||
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
|
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication) };
|
||||||
|
|
||||||
@ -255,28 +256,63 @@ public class CommonDefinition {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static public boolean isPeiPhaseComponent (int componentType) {
|
/**
|
||||||
if (ComponentTypePe32Peim == componentType
|
* formateGuidName
|
||||||
|| ComponentTypePicPeim == componentType
|
*
|
||||||
|| ComponentTypeCombinedPeimDriver == componentType
|
* This function is to formate GUID to ANSI c form.
|
||||||
|| ComponentTypePeiCore == componentType) {
|
*
|
||||||
return true;
|
* @param guidNameCon
|
||||||
}
|
* String of GUID.
|
||||||
return false;
|
* @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 isPe32PeimComponent (int componentType) {
|
while (index < strList[4].length()) {
|
||||||
if (ComponentTypePe32Peim == componentType) {
|
guid = guid + ", ";
|
||||||
return true;
|
guid = guid + "0x" + strList[4].substring(index, index + 2);
|
||||||
}
|
index = index + 2;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
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(",");
|
||||||
|
|
||||||
|
//
|
||||||
|
// chang Microsoft specific form to ANSI c form
|
||||||
|
//
|
||||||
|
for (int i = 0; i < 3; i++) {
|
||||||
|
guid = guid + strList[i] + ",";
|
||||||
|
}
|
||||||
|
guid = guid + "{";
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
static public boolean isBsDriverComponent (int componentType) {
|
|
||||||
if (ComponentTypeBsDriver == componentType) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
@ -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();
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -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<FpdModuleIdentification, String> outfiles;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Mapping from FV name to its modules
|
||||||
|
///
|
||||||
|
private Map<String, Set<FpdModuleIdentification>> fvs;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Mapping from sequence number to FV names
|
||||||
|
///
|
||||||
|
private Map<String, Set<String>> 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<FpdModuleIdentification, String> outfiles, Map<String, Set<FpdModuleIdentification>> fvs, Map<String, Set<String>> 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<String> 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<String> fvNameSet = sequences.get(num);
|
||||||
|
|
||||||
|
Iterator fvNameIter = fvNameSet.iterator();
|
||||||
|
while (fvNameIter.hasNext()) {
|
||||||
|
String fvName = (String)fvNameIter.next();
|
||||||
|
Set<FpdModuleIdentification> 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<String> 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<String> numbers = sequences.keySet();
|
||||||
|
Iterator<String> iter = numbers.iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
Set<String> fvNameSet = sequences.get(iter.next());
|
||||||
|
if (fvNameSet.contains(fvName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@ -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<String, Object> objStorage = new HashMap<String, Object>();
|
|
||||||
|
|
||||||
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<String, DataObjectOp> opMap = new HashMap<String, DataObjectOp>();
|
|
||||||
|
|
||||||
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");
|
|
||||||
}
|
|
@ -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 <code>LibBuildFileGenerator</code> is an ANT task to generate
|
|
||||||
build.xml for each module. Here are two usages.
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
For one module (<b>bf</b> is LibBuildFileGenerator task name):
|
|
||||||
<pre>
|
|
||||||
<bf buildFile="Application\HelloWorld\HelloWorld.msa" />
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
For one package:
|
|
||||||
<pre>
|
|
||||||
<bf recursive="true" />
|
|
||||||
</pre>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@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<String,File> map = new HashMap<String,File>();
|
|
||||||
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<File> vec = new Vector<File>();
|
|
||||||
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<String,File> mapBasename = new HashMap<String,File>();
|
|
||||||
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<String, XmlObject> 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);
|
|
||||||
//
|
|
||||||
// <taskdef resource="net/sf/antcontrib/antlib.xml" />
|
|
||||||
//
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -19,158 +19,180 @@ import java.io.File;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
OutputManager class is used to setup output directories (BIN_DIR, DEST_DIR_OUTPUT,
|
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
|
@since GenBuild 1.0
|
||||||
**/
|
**/
|
||||||
public class OutputManager {
|
public class OutputManager {
|
||||||
|
|
||||||
///
|
|
||||||
/// Single Module build
|
|
||||||
///
|
|
||||||
public static final String MODULE_BUILD = "MODULE";
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Package build
|
|
||||||
///
|
|
||||||
public static final String PACKAGE_BUILD = "PACKAGE";
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Platform build
|
|
||||||
///
|
|
||||||
public static final String PLATFORM_BUILD = "PLATFORM";
|
|
||||||
|
|
||||||
public static String buildMode = MODULE_BUILD;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// For Package build, PLATFORM represent PACKAGE
|
|
||||||
///
|
|
||||||
public static String PLATFORM;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// For Platform build, PLATFORM_DIR represent PACKAGE_DIR
|
|
||||||
///
|
|
||||||
public static String PLATFORM_DIR;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// means intermediate files will put under Module's dir
|
/// means intermediate files will put under Module's dir
|
||||||
///
|
///
|
||||||
public static final String MODULE = "MODULE";
|
private String MODULE = "MODULE";
|
||||||
|
|
||||||
///
|
///
|
||||||
/// mean intermediate files will put under a unify dir
|
/// mean intermediate files will put under a unify dir
|
||||||
///
|
///
|
||||||
public static final String UNIFIED = "UNIFIED";
|
private String UNIFIED = "UNIFIED";
|
||||||
|
|
||||||
|
|
||||||
|
private String userdir;
|
||||||
|
|
||||||
|
private String type;
|
||||||
///
|
///
|
||||||
/// Flag to ensure the function <code>update</code> will be called only one in the whole build.
|
/// Singleton Design Pattern
|
||||||
///
|
///
|
||||||
private static boolean flag = true;
|
private static OutputManager object;
|
||||||
|
|
||||||
/**
|
public synchronized static OutputManager getInstance() {
|
||||||
If BUILD_MODE is PLATFORM or PACKAGE, record PLATFORM and PLARFORM_DIR.
|
if ( object == null ) {
|
||||||
Reminder that for PACKAGE build, here set value PACKAGE to PLATFORM and
|
object = new OutputManager();
|
||||||
PACKAGE_DIR to PLARFORM_DIR, and also update the ant properties.
|
}
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
<p>Note that this function will be called only once in the whole build.</p>
|
public void setup(String userdir, String type) {
|
||||||
|
this.userdir = userdir;
|
||||||
@param project current ANT build Project
|
this.type = type;
|
||||||
**/
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:
|
Setup BIN_DIR, DEST_DIR_OUTPUT and DEST_DIR_OUTPUT, following are the rules:
|
||||||
|
|
||||||
<pre>
|
<p>Divide all output files into two types: one is final files, such as FFS
|
||||||
Those three variables are defined as following
|
file for driver module while LIB file for library module; another is
|
||||||
DEST_DIR_OUTPUT (intermediate files)
|
intermediate files, such AutoGen.c, OBJ files, Section files and so on.
|
||||||
DEST_DIR_DEBUG (intermediate debug files)
|
|
||||||
BIN_DIR (final files)
|
|
||||||
|
|
||||||
Output Dir (MODULE or UNIFIED):
|
<p>In FPD, OutputDirectory element is used to specify where to put the output
|
||||||
For <b>Module</b> build:
|
files to. There are two mode (MODULE | UNIFIED). MODULE mode means that all
|
||||||
All intermediate files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}/DEBUG|OUTPUT
|
output files will put to the module directory while UNIFIED mode means that
|
||||||
All final files are at ${MODULE_DIR}/Build/${TARGET}/${ARCH}
|
all output files will put together. Default is UNIFIED mode.
|
||||||
|
|
||||||
For <b>Platform</b> build:
|
<p>BUILD_DIR is the base directory for current module build. By default,
|
||||||
If specified with MODULE
|
BUILD_DIR is PLATFORM_DIR/Build in UNIFIED mode while is MODULE_DIR/Build
|
||||||
Intermediate files->${MODULE_DIR}/Build/${PLATFORM}/${TARGET}/${ARCH}/DEBUG|OUTPUT
|
in MODULE mode. Of course, user can customize BUILD_DIR. If user-defined
|
||||||
Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
|
BUILD_DIR is relative path, then look as related to WORKSPACE_DIR.
|
||||||
|
|
||||||
Else if specified with UNIFIED
|
<p>Then, BIN_DIR is BUILD_DIR/TARGET/TOOLCHAIN/ARCH;
|
||||||
Intermediate files->${PLARFORM_DIR}/Build/${TARGET}/${ARCH}/${PACKAGE}/${SOURCE_RELATIVE_PATH}/DEBUG|OUTPUT
|
|
||||||
Final files -> ${PLARFORM_DIR}/Build/${TARGET}/${ARCH}
|
|
||||||
|
|
||||||
For <b>Package</b> build:
|
<p>FV_DIR is BUILD_DIR/TARGET/TOOLCHAIN/FV;
|
||||||
If specified with MODULE
|
|
||||||
Intermediate files->${MODULE_DIR}/Build/${PACKAGE}/${TARGET}/${ARCH}/DEBUG|OUTPUT
|
<p>DEST_DIR_DEBUG | DEST_DIR_OUTPUT is:
|
||||||
Final files -> ${PACKAGE_DIR}/Build/${TARGET}/${ARCH}
|
BIN_DIR/PACKAGE_RELATIVE_DIR/MODULE_RELATIVE_DIR/DEBUG | OUTPUT
|
||||||
|
|
||||||
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}
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
@param project current ANT build Project
|
@param project current ANT build Project
|
||||||
@param userdir user-defined directory
|
@param userdir user-defined directory
|
||||||
@param type the module build type (MODULE or UNIFIED)
|
@param type the module build type (MODULE or UNIFIED)
|
||||||
**/
|
**/
|
||||||
public synchronized static void update(Project project, String userdir, String type) {
|
public void update(Project project) {
|
||||||
|
// GlobalData.log.info("" + userdir + ":" + type);
|
||||||
//
|
//
|
||||||
// userdir TBD
|
// Default mode is UNIFIED.
|
||||||
//
|
//
|
||||||
if( type == null || ! type.equals(MODULE)){
|
if (type != null && type.equalsIgnoreCase(MODULE)) {
|
||||||
|
type = MODULE;
|
||||||
|
}
|
||||||
|
else {
|
||||||
type = UNIFIED;
|
type = UNIFIED;
|
||||||
}
|
}
|
||||||
if (buildMode.equals(MODULE_BUILD)){
|
|
||||||
project.setProperty("DEST_DIR_OUTPUT", project.replaceProperties("${MODULE_DIR}"
|
//
|
||||||
+ File.separatorChar + "Build" + File.separatorChar + "${TARGET}"
|
// default BUILD_DIR value
|
||||||
+ 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"));
|
String buildDir;
|
||||||
project.setProperty("BIN_DIR", project.replaceProperties("${MODULE_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
|
if(type.equals(MODULE)){
|
||||||
|
buildDir = project.getProperty("MODULE_DIR") + File.separatorChar + "Build";
|
||||||
}
|
}
|
||||||
else if (buildMode.equals(PLATFORM_BUILD)) {
|
else {
|
||||||
if (type.equals(MODULE)) {
|
buildDir = project.getProperty("PLATFORM_DIR") + File.separatorChar + "Build";
|
||||||
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"));
|
// If user define BUILD_DIR
|
||||||
project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
|
//
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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"));
|
// Define BIN_DIR and FV_DIR
|
||||||
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}"));
|
String binDir = buildDir + File.separatorChar + project.getProperty("TARGET")
|
||||||
|
+ File.separatorChar + project.getProperty("TOOLCHAIN")
|
||||||
|
+ File.separatorChar + project.getProperty("ARCH") ;
|
||||||
|
|
||||||
|
String fvDir = buildDir + File.separatorChar + project.getProperty("TARGET")
|
||||||
|
+ File.separatorChar + project.getProperty("TOOLCHAIN")
|
||||||
|
+ File.separatorChar + "FV";
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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");
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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("(\\\\)", "/"));
|
||||||
|
|
||||||
|
//
|
||||||
|
// 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();
|
||||||
}
|
}
|
||||||
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"));
|
public boolean prepareBuildDir(Project project){
|
||||||
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"));
|
boolean isUnified = true;
|
||||||
project.setProperty("BIN_DIR", project.replaceProperties("${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "${TARGET}" + File.separatorChar + "${ARCH}"));
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -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.
|
|
||||||
|
|
||||||
<p>Override will take effect if two element satisfy one of following two condition: </p>
|
|
||||||
<ul>
|
|
||||||
<li>Element name and its attribute OverrideID equal each other. </li>
|
|
||||||
<li>Element is defined as exclusive which mean such element can be
|
|
||||||
only appeared in the surface area. </li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>For example, here OutputDirectory element is exclusive: </p>
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
Low priority Xml Document fragment:
|
|
||||||
<Libraries>
|
|
||||||
<Arch ArchType="IA32">
|
|
||||||
<Library OverrideID="8888">EdkPeCoffLoaderLib</Library>
|
|
||||||
<Library OverrideID="8888">BasePeCoffLib</Library>
|
|
||||||
</Arch>
|
|
||||||
</Libraries>
|
|
||||||
<BuildOptions>
|
|
||||||
<OutputDirectory IntermediateDirectories="MODULE"/>
|
|
||||||
<Option>CC_FLAGS = "/NOLOGO", "/C"</Option>
|
|
||||||
<BuildOptions>
|
|
||||||
|
|
||||||
High priority Xml Document fragment:
|
|
||||||
<Libraries>
|
|
||||||
<Arch ArchType="IA32">
|
|
||||||
<Library OverrideID="8888">Nt32PeCoffLoaderLib</Library>
|
|
||||||
</Arch>
|
|
||||||
</Libraries>
|
|
||||||
<BuildOptions>
|
|
||||||
<OutputDirectory IntermediateDirectories="UNIFIED"/>
|
|
||||||
<Option>LIB_FLAGS = "/NOLOGO"</Option>
|
|
||||||
<BuildOptions>
|
|
||||||
|
|
||||||
The result is:
|
|
||||||
<Libraries>
|
|
||||||
<Arch ArchType="IA32">
|
|
||||||
<Library OverrideID="8888">Nt32PeCoffLoaderLib</Library>
|
|
||||||
</Arch>
|
|
||||||
</Libraries>
|
|
||||||
<BuildOptions>
|
|
||||||
<OutputDirectory IntermediateDirectories="UNIFIED"/>
|
|
||||||
<Option>CC_FLAGS = "/NOLOGO", "/C"</Option>
|
|
||||||
<Option>LIB_FLAGS = "/NOLOGO"</Option>
|
|
||||||
<BuildOptions>
|
|
||||||
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
<p>Note that using XmlBeans to walk through the whole XML document tree.</p>
|
|
||||||
|
|
||||||
@since GenBuild 1.0
|
|
||||||
@see org.apache.xmlbeans.XmlBeans
|
|
||||||
**/
|
|
||||||
public class OverrideProcess {
|
|
||||||
|
|
||||||
///
|
|
||||||
/// URI, the namespace of current XML schema
|
|
||||||
///
|
|
||||||
public static String prefix = "http://www.TianoCore.org/2006/Edk2.0";
|
|
||||||
|
|
||||||
///
|
|
||||||
/// list of top elements of surface area
|
|
||||||
///
|
|
||||||
public static String[] topElements = { "LibraryClassDefinitions",
|
|
||||||
"SourceFiles", "Includes", "PackageDependencies", "Libraries", "Protocols",
|
|
||||||
"Events", "Hobs", "PPIs", "Variables", "BootModes",
|
|
||||||
"SystemTables", "DataHubs", "Formsets", "Guids", "Externs",
|
|
||||||
"PcdCoded", "BuildOptions" };
|
|
||||||
|
|
||||||
///
|
|
||||||
/// list of exclusive elements
|
|
||||||
///
|
|
||||||
public static String[] exclusiveElements = {"OutputDirectory"};
|
|
||||||
|
|
||||||
/**
|
|
||||||
Recursively find out all elements specified with OverrideId attribute
|
|
||||||
and exclusive elements in current XML object.
|
|
||||||
|
|
||||||
@param o curent parsing XML object
|
|
||||||
@param map Map to list elements specified OverrideID attribute
|
|
||||||
@param execlusiveMap Map to list exclusive elements appeared in current XMl object
|
|
||||||
@param level the depth in XML document tree
|
|
||||||
**/
|
|
||||||
private void listOverrideID(XmlObject o, Map<String,Object> map, Map<String,Object> execlusiveMap, int level) {
|
|
||||||
XmlCursor cursor = o.newCursor();
|
|
||||||
String name = cursor.getName().getLocalPart();
|
|
||||||
for (int i = 0 ; i < exclusiveElements.length; i++){
|
|
||||||
if (name.equalsIgnoreCase(exclusiveElements[i])){
|
|
||||||
execlusiveMap.put(exclusiveElements[i], cursor.getObject());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String overrideID = cursor.getAttributeText(new QName("OverrideID"));
|
|
||||||
if (overrideID != null) {
|
|
||||||
map.put(name + ":" + overrideID, cursor.getObject());
|
|
||||||
}
|
|
||||||
if (cursor.toFirstChild()) {
|
|
||||||
do {
|
|
||||||
listOverrideID(cursor.getObject(), map, execlusiveMap, level + 1);
|
|
||||||
} while (cursor.toNextSibling());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
This function is used to prepare for overriding with changing data.
|
|
||||||
|
|
||||||
@param map original surface area information
|
|
||||||
@return after normalize surface area information
|
|
||||||
**/
|
|
||||||
public synchronized static Map<String, XmlObject> deal(Map<String, XmlObject> map) {
|
|
||||||
Map<String, XmlObject> newMap = new HashMap<String, XmlObject>();
|
|
||||||
if (map.get("MsaHeader") != null) {
|
|
||||||
newMap.put("MsaHeader", ((MsaHeaderDocument) map.get("MsaHeader"))
|
|
||||||
.getMsaHeader());
|
|
||||||
}
|
|
||||||
if (map.get("MsaLibHeader") != null) {
|
|
||||||
newMap.put("MsaLibHeader", ((MsaLibHeaderDocument) map
|
|
||||||
.get("MsaLibHeader")).getMsaLibHeader());
|
|
||||||
}
|
|
||||||
if (map.get("LibraryClassDefinitions") != null) {
|
|
||||||
newMap.put("LibraryClassDefinitions",
|
|
||||||
((LibraryClassDefinitionsDocument) map
|
|
||||||
.get("LibraryClassDefinitions"))
|
|
||||||
.getLibraryClassDefinitions());
|
|
||||||
}
|
|
||||||
if (map.get("SourceFiles") != null) {
|
|
||||||
newMap.put("SourceFiles", ((SourceFilesDocument) map
|
|
||||||
.get("SourceFiles")).getSourceFiles());
|
|
||||||
}
|
|
||||||
if (map.get("Includes") != null) {
|
|
||||||
newMap.put("Includes", ((IncludesDocument) map.get("Includes"))
|
|
||||||
.getIncludes());
|
|
||||||
}
|
|
||||||
if (map.get("PackageDependencies") != null) {
|
|
||||||
newMap.put("PackageDependencies", ((PackageDependenciesDocument) map.get("PackageDependencies"))
|
|
||||||
.getPackageDependencies());
|
|
||||||
}
|
|
||||||
if (map.get("Libraries") != null) {
|
|
||||||
newMap.put("Libraries", ((LibrariesDocument) map.get("Libraries"))
|
|
||||||
.getLibraries());
|
|
||||||
}
|
|
||||||
if (map.get("Protocols") != null) {
|
|
||||||
newMap.put("Protocols", ((ProtocolsDocument) map.get("Protocols"))
|
|
||||||
.getProtocols());
|
|
||||||
}
|
|
||||||
if (map.get("Events") != null) {
|
|
||||||
newMap.put("Events", ((EventsDocument) map.get("Events"))
|
|
||||||
.getEvents());
|
|
||||||
}
|
|
||||||
if (map.get("Hobs") != null) {
|
|
||||||
newMap.put("Hobs", ((HobsDocument) map.get("Hobs")).getHobs());
|
|
||||||
}
|
|
||||||
if (map.get("PPIs") != null) {
|
|
||||||
newMap.put("PPIs", ((PPIsDocument) map.get("PPIs")).getPPIs());
|
|
||||||
}
|
|
||||||
if (map.get("Variables") != null) {
|
|
||||||
newMap.put("Variables", ((VariablesDocument) map.get("Variables"))
|
|
||||||
.getVariables());
|
|
||||||
}
|
|
||||||
if (map.get("BootModes") != null) {
|
|
||||||
newMap.put("BootModes", ((BootModesDocument) map.get("BootModes"))
|
|
||||||
.getBootModes());
|
|
||||||
}
|
|
||||||
if (map.get("SystemTables") != null) {
|
|
||||||
newMap.put("SystemTables", ((SystemTablesDocument) map
|
|
||||||
.get("SystemTables")).getSystemTables());
|
|
||||||
}
|
|
||||||
if (map.get("DataHubs") != null) {
|
|
||||||
newMap.put("DataHubs", ((DataHubsDocument) map.get("DataHubs"))
|
|
||||||
.getDataHubs());
|
|
||||||
}
|
|
||||||
if (map.get("Formsets") != null) {
|
|
||||||
newMap.put("Formsets", ((FormsetsDocument) map.get("Formsets"))
|
|
||||||
.getFormsets());
|
|
||||||
}
|
|
||||||
if (map.get("Guids") != null) {
|
|
||||||
newMap.put("Guids", ((GuidsDocument) map.get("Guids")).getGuids());
|
|
||||||
}
|
|
||||||
if (map.get("Externs") != null) {
|
|
||||||
newMap.put("Externs", ((ExternsDocument) map.get("Externs"))
|
|
||||||
.getExterns());
|
|
||||||
}
|
|
||||||
if (map.get("PcdCoded") != null) {
|
|
||||||
newMap.put("PcdCoded", ((PcdCodedDocument) map.get("PcdCoded")).getPcdCoded());
|
|
||||||
}
|
|
||||||
if (map.get("BuildOptions") != null) {
|
|
||||||
newMap.put("BuildOptions", ((BuildOptionsDocument) map
|
|
||||||
.get("BuildOptions")).getBuildOptions());
|
|
||||||
}
|
|
||||||
return newMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Recursively remove all subelement in Xml Object l (with low priority)
|
|
||||||
based on OverrideID or exclusive elements.
|
|
||||||
|
|
||||||
@param l the XML object to process
|
|
||||||
@param map list of elements with OverrideID in high priority XML object
|
|
||||||
@param execusiveMap list of exclusive elements in high priority XML object
|
|
||||||
**/
|
|
||||||
private void cut(XmlCursor l, Map map, Map execusiveMap) {
|
|
||||||
String name = l.getName().getLocalPart();
|
|
||||||
if (execusiveMap.containsKey(name)){
|
|
||||||
l.removeXml();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String overrideID = l.getAttributeText(new QName("OverrideID"));
|
|
||||||
if (overrideID != null) {
|
|
||||||
if (map.containsKey(name + ":" + overrideID)) {
|
|
||||||
l.removeXml();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (l.toFirstChild()) {
|
|
||||||
do {
|
|
||||||
cut(l, map, execusiveMap);
|
|
||||||
} while (l.toNextSibling());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private XmlObject cloneXmlObject(XmlObject object, boolean deep) throws BuildException {
|
|
||||||
XmlObject result = null;
|
|
||||||
try {
|
|
||||||
result = XmlObject.Factory.parse(object.getDomNode()
|
|
||||||
.cloneNode(deep));
|
|
||||||
} catch (Exception ex) {
|
|
||||||
throw new BuildException(ex.getMessage());
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Process every item list in h and l.
|
|
||||||
|
|
||||||
@param h surface area info with high priority
|
|
||||||
@param l surface area info with low priority
|
|
||||||
@return surface area after override
|
|
||||||
**/
|
|
||||||
public Map<String, XmlObject> override(Map<String, XmlObject> h,
|
|
||||||
Map<String, XmlObject> l) {
|
|
||||||
Map<String, XmlObject> result = new HashMap<String, XmlObject>();
|
|
||||||
result.put("MsaHeader", override(l.get("MsaHeader"), null));
|
|
||||||
result.put("MsaLibHeader", override(l.get("MsaLibHeader"), null));
|
|
||||||
for (int i = 0; i < topElements.length; i++) {
|
|
||||||
if (h != null) {
|
|
||||||
result.put(topElements[i], override(h.get(topElements[i]), l.get(topElements[i])));
|
|
||||||
} else {
|
|
||||||
result.put(topElements[i], override(l.get(topElements[i]), null));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Recursively override two Xml Objects.
|
|
||||||
|
|
||||||
@param h Xml Object info with high priority
|
|
||||||
@param l Xml Object info with low priority
|
|
||||||
@return Xml Object after area
|
|
||||||
**/
|
|
||||||
public XmlObject override(XmlObject h, XmlObject l) {
|
|
||||||
if (l == null && h == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (h == null) {
|
|
||||||
return cloneXmlObject(l, true);
|
|
||||||
}
|
|
||||||
if (l == null) {
|
|
||||||
return cloneXmlObject(h, true);
|
|
||||||
}
|
|
||||||
XmlCursor hc = h.newCursor();
|
|
||||||
if (h.getClass() != l.getClass()) {
|
|
||||||
System.out.println("Error: Two XmlObject does not with compliant format.");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (!hc.toFirstChild()) {
|
|
||||||
return cloneXmlObject(l, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
XmlCursor result = cloneXmlObject(h, true).newCursor();
|
|
||||||
XmlCursor lcursor = cloneXmlObject(l, true).newCursor();
|
|
||||||
result.push();
|
|
||||||
result.toNextToken();
|
|
||||||
result.insertNamespace("", prefix);
|
|
||||||
result.toFirstChild();
|
|
||||||
//
|
|
||||||
// found out all element specified a OverrideID
|
|
||||||
//
|
|
||||||
Map<String,Object> hmap = new HashMap<String,Object>();
|
|
||||||
Map<String,Object> execlusiveMap = new HashMap<String,Object>();
|
|
||||||
listOverrideID(h, hmap, execlusiveMap, 0);
|
|
||||||
lcursor.toNextToken();
|
|
||||||
lcursor.push();
|
|
||||||
//
|
|
||||||
// for every direct subelement of l, cut all element satisfied with
|
|
||||||
// override rule
|
|
||||||
//
|
|
||||||
if (lcursor.toFirstChild()) {
|
|
||||||
do {
|
|
||||||
cut(lcursor, hmap, execlusiveMap);
|
|
||||||
} while (lcursor.toNextSibling());
|
|
||||||
}
|
|
||||||
lcursor.pop();
|
|
||||||
if (lcursor.toFirstChild()) {
|
|
||||||
do {
|
|
||||||
lcursor.copyXml(result);
|
|
||||||
result.insertChars("\n");
|
|
||||||
} while (lcursor.toNextSibling());
|
|
||||||
}
|
|
||||||
result.pop();
|
|
||||||
return result.getObject();
|
|
||||||
}
|
|
||||||
}
|
|
@ -14,40 +14,35 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
package org.tianocore.build.global;
|
package org.tianocore.build.global;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.tianocore.GuidDeclarationsDocument.GuidDeclarations;
|
import java.io.File;
|
||||||
import org.tianocore.IncludeHeaderDocument.IncludeHeader;
|
import java.util.HashMap;
|
||||||
import org.tianocore.LibraryClassDeclarationDocument.LibraryClassDeclaration;
|
import java.util.Iterator;
|
||||||
import org.tianocore.LibraryClassDeclarationsDocument.LibraryClassDeclarations;
|
import java.util.Map;
|
||||||
import org.tianocore.PackageHeadersDocument.PackageHeaders;
|
import java.util.Set;
|
||||||
import org.tianocore.PackageSurfaceAreaDocument;
|
|
||||||
import org.tianocore.PackageSurfaceAreaDocument.PackageSurfaceArea;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.tianocore.PpiDeclarationsDocument.PpiDeclarations;
|
import org.apache.xmlbeans.XmlObject;
|
||||||
import org.tianocore.PpiDeclarationsDocument.PpiDeclarations.Entry;
|
import org.tianocore.build.id.ModuleIdentification;
|
||||||
import org.tianocore.ProtocolDeclarationsDocument.ProtocolDeclarations;
|
import org.tianocore.build.id.PackageIdentification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
This class is to generate a global table for the content of spd file.
|
This class is to generate a global table for the content of spd file.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
public class Spd {
|
public class Spd {
|
||||||
///
|
///
|
||||||
/// Map of module name and package it belongs to.
|
|
||||||
/// Key : Module BaseName
|
|
||||||
/// Value: Relative Path to Package
|
|
||||||
///
|
///
|
||||||
Map<String, String[]> msaInfo = new HashMap<String, String[]>();
|
///
|
||||||
|
Map<ModuleIdentification, File> msaInfo = new HashMap<ModuleIdentification, File>();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Map of module info.
|
/// Map of module info.
|
||||||
/// Key : moduletype
|
/// Key : moduletype
|
||||||
/// Value: moduletype related include file
|
/// Value: moduletype related include file
|
||||||
///
|
///
|
||||||
Map<String, String> moduleInfo = new HashMap<String, String>();
|
Map<String, String> packageHeaderInfo = new HashMap<String, String>();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Map of PPI info.
|
/// Map of PPI info.
|
||||||
@ -70,271 +65,185 @@ public class Spd {
|
|||||||
///
|
///
|
||||||
Map<String, String[]> guidInfo = new HashMap<String, String[]>();
|
Map<String, String[]> guidInfo = new HashMap<String, String[]>();
|
||||||
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Map of library class and its exposed header file.
|
/// Map of library class and its exposed header file.
|
||||||
/// Key : library class name
|
/// Key : library class name
|
||||||
/// value : library class corresponding header file
|
/// value : library class corresponding header file
|
||||||
///
|
///
|
||||||
Map<String, String> libClassHeaderList = new HashMap<String, String>();
|
Map<String, String[]> libClassHeaderList = new HashMap<String, String[]>();
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Package path.
|
/// Package path.
|
||||||
///
|
///
|
||||||
String packagePath = null;
|
PackageIdentification packageId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor function
|
Constructor function
|
||||||
|
|
||||||
This function mainly initialize some member variables.
|
This function mainly initialize some member variables.
|
||||||
|
|
||||||
@param spdDoc Handle of spd document.
|
|
||||||
@param spdPath Path of spd file.
|
|
||||||
**/
|
**/
|
||||||
Spd (PackageSurfaceAreaDocument spdDoc, String spdPath) {
|
Spd(File packageFile) throws BuildException {
|
||||||
|
//
|
||||||
PackageSurfaceArea spd = spdDoc.getPackageSurfaceArea();
|
// If specified package file not exists
|
||||||
this.packagePath = spdPath;
|
//
|
||||||
|
if ( ! packageFile.exists()) {
|
||||||
GuidDeclarations spdGuidInfo = spd.getGuidDeclarations();
|
throw new BuildException("Package file [" + packageFile.getPath() + "] not exists. ");
|
||||||
genGuidInfoList(spdGuidInfo);
|
|
||||||
|
|
||||||
PpiDeclarations spdPpiInfo = spd.getPpiDeclarations();
|
|
||||||
genPpiInfoList(spdPpiInfo);
|
|
||||||
|
|
||||||
ProtocolDeclarations spdProtocolInfo = spd.getProtocolDeclarations();
|
|
||||||
genProtocolInfoList(spdProtocolInfo);
|
|
||||||
|
|
||||||
LibraryClassDeclarations spdLibClassDeclare = spd
|
|
||||||
.getLibraryClassDeclarations();
|
|
||||||
genLibClassDeclare(spdLibClassDeclare);
|
|
||||||
|
|
||||||
PackageHeaders spdPackageHeaderInfo = spd.getPackageHeaders();
|
|
||||||
genModuleInfoList(spdPackageHeaderInfo);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
genModuleInfoList
|
|
||||||
|
|
||||||
This function is to generate Module info map.
|
|
||||||
|
|
||||||
@param packageHeader The information of packageHeader which descripted
|
|
||||||
in spd file.
|
|
||||||
**/
|
|
||||||
public void genModuleInfoList(PackageHeaders packageHeader) {
|
|
||||||
|
|
||||||
if (packageHeader != null) {
|
|
||||||
List<IncludeHeader> headerList = packageHeader.getIncludeHeaderList();
|
|
||||||
IncludeHeader header;
|
|
||||||
|
|
||||||
for (int i = 0; i < headerList.size(); i++) {
|
|
||||||
header = (IncludeHeader)headerList.get(i);
|
|
||||||
try {
|
try {
|
||||||
this.moduleInfo.put(header.getModuleType().toString(), header.getStringValue());
|
XmlObject spdDoc = XmlObject.Factory.parse(packageFile);
|
||||||
} catch (Exception e) {
|
//
|
||||||
System.out.print("can't find ModuleHeaders ModuleType & includeHeader!\n");
|
// Verify SPD file, if is invalid, throw Exception
|
||||||
|
//
|
||||||
|
if (! spdDoc.validate()) {
|
||||||
|
throw new BuildException("Package Surface Area file [" + packageFile.getPath() + "] is invalid. ");
|
||||||
|
}
|
||||||
|
// We can change Map to XmlObject
|
||||||
|
Map<String, XmlObject> spdDocMap = new HashMap<String, XmlObject>();
|
||||||
|
spdDocMap.put("PackageSurfaceArea", spdDoc);
|
||||||
|
SurfaceAreaQuery.setDoc(spdDocMap);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
packageId = SurfaceAreaQuery.getSpdHeader();
|
||||||
|
packageId.setSpdFile(packageFile);
|
||||||
|
|
||||||
|
//
|
||||||
|
// initialize Msa Files
|
||||||
|
// MSA file is absolute file path
|
||||||
|
//
|
||||||
|
String[] msaFilenames = SurfaceAreaQuery.getSpdMsaFile();
|
||||||
|
for (int i = 0; i < msaFilenames.length; i++){
|
||||||
|
File msaFile = new File(packageId.getPackageDir() + File.separatorChar + msaFilenames[i]);
|
||||||
|
Map<String, XmlObject> msaDoc = GlobalData.getNativeMsa( msaFile );
|
||||||
|
SurfaceAreaQuery.push(msaDoc);
|
||||||
|
ModuleIdentification moduleId = SurfaceAreaQuery.getMsaHeader();
|
||||||
|
SurfaceAreaQuery.pop();
|
||||||
|
moduleId.setPackage(packageId);
|
||||||
|
moduleId.setMsaFile(msaFile);
|
||||||
|
if (msaInfo.containsKey(moduleId)) {
|
||||||
|
throw new BuildException("Find two modules with the same GUID and Version in " + packageId + ". They are [" + msaInfo.get(moduleId) + "] and [" + msaFile + "] ");
|
||||||
|
}
|
||||||
|
msaInfo.put(moduleId, msaFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// initialize Package header files
|
||||||
|
//
|
||||||
|
Map<String, String> packageHeaders = SurfaceAreaQuery.getSpdPackageHeaderFiles();
|
||||||
|
Set keys = packageHeaders.keySet();
|
||||||
|
Iterator iter = keys.iterator();
|
||||||
|
while (iter.hasNext()){
|
||||||
|
String moduleType = (String)iter.next();
|
||||||
|
String header = packageId.getPackageRelativeDir() + File.separatorChar + packageHeaders.get(moduleType);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Change path seperator to system-dependent path separator
|
||||||
|
//
|
||||||
|
File file = new File (header);
|
||||||
|
header = file.getParent();
|
||||||
|
packageHeaderInfo.put(moduleType, header);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// initialize Guid Info
|
||||||
|
//
|
||||||
|
guidInfo.putAll(SurfaceAreaQuery.getSpdGuid());
|
||||||
|
|
||||||
|
//
|
||||||
|
// initialize PPI info
|
||||||
|
//
|
||||||
|
ppiInfo.putAll(SurfaceAreaQuery.getSpdPpi());
|
||||||
|
|
||||||
|
//
|
||||||
|
// initialize Protocol info
|
||||||
|
//
|
||||||
|
protocolInfo.putAll(SurfaceAreaQuery.getSpdProtocol());
|
||||||
|
|
||||||
|
//
|
||||||
|
// initialize library class declaration
|
||||||
|
//
|
||||||
|
Map<String, String[]> libraryClassHeaders = SurfaceAreaQuery.getSpdLibraryClasses();
|
||||||
|
keys = libraryClassHeaders.keySet();
|
||||||
|
iter = keys.iterator();
|
||||||
|
while (iter.hasNext()){
|
||||||
|
String libraryClassName = (String)iter.next();
|
||||||
|
String[] headerFiles = libraryClassHeaders.get(libraryClassName);
|
||||||
|
for (int i = 0; i < headerFiles.length; i++){
|
||||||
|
headerFiles[i] = packageId.getPackageRelativeDir() + File.separatorChar + headerFiles[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Change path separator to system system-dependent path separator.
|
||||||
|
//
|
||||||
|
File file = new File (headerFiles[i]);
|
||||||
|
headerFiles[i] = file.getPath();
|
||||||
|
}
|
||||||
|
libClassHeaderList.put(libraryClassName, headerFiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.setStackTrace(e.getStackTrace());
|
||||||
|
throw new BuildException("Parse package description file [" + packageId.getSpdFile() + "] Error.\n"
|
||||||
|
+ e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PackageIdentification getPackageId() {
|
||||||
|
return packageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getModuleFile(ModuleIdentification moduleId) {
|
||||||
|
return msaInfo.get(moduleId);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ModuleIdentification> getModules(){
|
||||||
|
return msaInfo.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
genPpiInfoList
|
return two value {CName, Guid}. If not found, return null.
|
||||||
|
|
||||||
This function is to generate Ppi info map.
|
|
||||||
|
|
||||||
@param ppiInfo The information of PpiDeclarations which descripted
|
|
||||||
in spd file.
|
|
||||||
**/
|
**/
|
||||||
public void genPpiInfoList(PpiDeclarations ppiInfo) {
|
public String[] getPpi(String ppiName) {
|
||||||
String[] cNameGuid = new String[2];
|
return ppiInfo.get(ppiName);
|
||||||
String guidString;
|
|
||||||
|
|
||||||
if (ppiInfo != null) {
|
|
||||||
List<PpiDeclarations.Entry> ppiEntryList = ppiInfo.getEntryList();
|
|
||||||
PpiDeclarations.Entry ppiEntry;
|
|
||||||
|
|
||||||
for (int i = 0; i < ppiEntryList.size(); i++) {
|
|
||||||
ppiEntry = (PpiDeclarations.Entry)ppiEntryList.get(i);
|
|
||||||
try {
|
|
||||||
if (ppiEntry.isSetGuidValue()) {
|
|
||||||
guidString = ppiEntry.getGuidValue();
|
|
||||||
} else {
|
|
||||||
guidString = ppiEntry.getGuid().getStringValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
cNameGuid[0] = ppiEntry.getCName();
|
|
||||||
cNameGuid[1] = formatGuidName(guidString);
|
|
||||||
this.ppiInfo.put(ppiEntry.getName(), new String[] { cNameGuid[0], cNameGuid[1] });
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.print("can't find GuidDeclarations C_Name & Guid!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
genProtocolInfoList
|
return two value {CName, Guid}. If not found, return null.
|
||||||
|
|
||||||
This function is to generate Protocol info map.
|
|
||||||
|
|
||||||
@param proInfo The information of ProtocolDeclarations which
|
|
||||||
descripted in spd file.
|
|
||||||
**/
|
**/
|
||||||
public void genProtocolInfoList(ProtocolDeclarations proInfo) {
|
public String[] getProtocol(String protocolName) {
|
||||||
String[] cNameGuid = new String[2];
|
return protocolInfo.get(protocolName);
|
||||||
String guidString;
|
|
||||||
|
|
||||||
if (proInfo != null) {
|
|
||||||
List<ProtocolDeclarations.Entry> protocolEntryList = proInfo.getEntryList();
|
|
||||||
ProtocolDeclarations.Entry protocolEntry;
|
|
||||||
for (int i = 0; i < protocolEntryList.size(); i++) {
|
|
||||||
protocolEntry = (ProtocolDeclarations.Entry)protocolEntryList.get(i);
|
|
||||||
try {
|
|
||||||
if (protocolEntry.isSetGuidValue()) {
|
|
||||||
guidString = protocolEntry.getGuidValue();
|
|
||||||
} else {
|
|
||||||
guidString = protocolEntry.getGuid().getStringValue();
|
|
||||||
}
|
|
||||||
cNameGuid[0] = protocolEntry.getCName();
|
|
||||||
cNameGuid[1] = formatGuidName(guidString);
|
|
||||||
|
|
||||||
String temp = new String(protocolEntry.getName());
|
|
||||||
this.protocolInfo.put(temp, new String[] { cNameGuid[0], cNameGuid[1] });
|
|
||||||
} catch (Exception e) {
|
|
||||||
System.out.print("can't find ProtocolDeclarations C_Name & Guid!\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
genGuidInfoList
|
return two value {CName, Guid}. If not found, return null.
|
||||||
|
|
||||||
This function is to generate GUID inf map.
|
|
||||||
|
|
||||||
@param guidInfo The information of GuidDeclarations which descripted
|
|
||||||
in spd file.
|
|
||||||
|
|
||||||
**/
|
**/
|
||||||
public void genGuidInfoList(GuidDeclarations guidInfo) {
|
public String[] getGuid(String guidName) {
|
||||||
String[] cNameGuid = new String[2];
|
return guidInfo.get(guidName);
|
||||||
String guidString;
|
|
||||||
|
|
||||||
if (guidInfo != null) {
|
|
||||||
|
|
||||||
List<GuidDeclarations.Entry> guidEntryList = guidInfo.getEntryList();
|
|
||||||
GuidDeclarations.Entry guidEntry;
|
|
||||||
for (int i = 0; i < guidEntryList.size(); i++) {
|
|
||||||
guidEntry = (GuidDeclarations.Entry)guidEntryList.get(i);
|
|
||||||
if (guidEntry.isSetGuidValue()) {
|
|
||||||
guidString = guidEntry.getGuidValue();
|
|
||||||
} else {
|
|
||||||
guidString = guidEntry.getGuid().getStringValue();
|
|
||||||
}
|
|
||||||
|
|
||||||
cNameGuid[0] = guidEntry.getCName();
|
|
||||||
cNameGuid[1] = formatGuidName(guidString);
|
|
||||||
this.guidInfo.put(guidEntry.getName(), new String[] {cNameGuid[0], cNameGuid[1] });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
genLibClassDeclare
|
getLibClassInclude
|
||||||
|
|
||||||
This function is to generate the libClassHeader list.
|
This function is to get the library exposed header file name according
|
||||||
|
library class name.
|
||||||
|
|
||||||
@param libClassDeclares The information of LibraryClassDeclarations which
|
@param libName Name of library class
|
||||||
descripted in spd file.
|
@return Name of header file
|
||||||
**/
|
**/
|
||||||
public void genLibClassDeclare(LibraryClassDeclarations libClassDeclares) {
|
String[] getLibClassIncluder(String libName) {
|
||||||
if (libClassDeclares != null && libClassDeclares.getLibraryClassDeclarationList() != null) {
|
return libClassHeaderList.get(libName);
|
||||||
if (libClassDeclares.getLibraryClassDeclarationList().size() > 0) {
|
|
||||||
List<LibraryClassDeclaration> libDeclareList = libClassDeclares.getLibraryClassDeclarationList();
|
|
||||||
for (int i = 0; i < libDeclareList.size(); i++) {
|
|
||||||
libClassHeaderList.put(libDeclareList.get(i).getLibraryClass()
|
|
||||||
.getStringValue(), libDeclareList.get(i)
|
|
||||||
.getIncludeHeader().getStringValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
getPpiGuid
|
getModuleTypeIncluder
|
||||||
|
|
||||||
This function is to get ppi GUID according ppi name.
|
This function is to get the header file name from module info map
|
||||||
|
according to module type.
|
||||||
|
|
||||||
@param ppiStr Name of ppi.
|
@param moduleType Module type.
|
||||||
@return PPi's GUID.
|
@return Name of header file.
|
||||||
**/
|
**/
|
||||||
public String getPpiGuid(String ppiStr) {
|
String getPackageIncluder(String moduleType) {
|
||||||
if (ppiInfo.get(ppiStr) != null) {
|
return packageHeaderInfo.get(moduleType);
|
||||||
return ppiInfo.get(ppiStr)[1];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
getPpiCnameGuidArray
|
|
||||||
|
|
||||||
This function is to get the ppi CName and it's GUID according to ppi name.
|
|
||||||
|
|
||||||
@param ppiName Name of ppi.
|
|
||||||
@return Ppi CName and it's GUID.
|
|
||||||
**/
|
|
||||||
public String[] getPpiCnameGuidArray(String ppiName) {
|
|
||||||
return this.ppiInfo.get(ppiName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
getProtocolGuid
|
|
||||||
|
|
||||||
This function is to get the protocol GUID according to protocol's name.
|
|
||||||
|
|
||||||
@param protocolStr Name of protocol.
|
|
||||||
@return Protocol's GUID.
|
|
||||||
**/
|
|
||||||
public String getProtocolGuid(String protocolStr) {
|
|
||||||
if (protocolInfo.get(protocolStr) != null) {
|
|
||||||
return this.protocolInfo.get(protocolStr)[0];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
getProtocolNameGuidArray
|
|
||||||
|
|
||||||
This function is to get the protocol's CName ant it's GUID according to
|
|
||||||
protocol's namej.
|
|
||||||
|
|
||||||
@param protocolName Name of protocl.
|
|
||||||
@return Protocol's CName and it's GUID.
|
|
||||||
**/
|
|
||||||
public String[] getProtocolNameGuidArray(String protocolName) {
|
|
||||||
return this.protocolInfo.get(protocolName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
getGUIDGuid
|
|
||||||
|
|
||||||
This function is to get the GUID according to GUID's name
|
|
||||||
|
|
||||||
@param guidStr Name of GUID
|
|
||||||
@return GUID.
|
|
||||||
**/
|
|
||||||
public String getGUIDGuid(String guidStr) {
|
|
||||||
if (guidInfo.get(guidStr) != null) {
|
|
||||||
return guidInfo.get(guidStr)[1];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -350,86 +259,4 @@ public class Spd {
|
|||||||
return this.guidInfo.get(guidName);
|
return this.guidInfo.get(guidName);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
getLibClassInclude
|
|
||||||
|
|
||||||
This function is to get the library exposed header file name according
|
|
||||||
library class name.
|
|
||||||
|
|
||||||
@param libName Name of library class
|
|
||||||
@return Name of header file
|
|
||||||
**/
|
|
||||||
String getLibClassIncluder(String libName) {
|
|
||||||
return libClassHeaderList.get(libName);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
getModuleTypeIncluder
|
|
||||||
|
|
||||||
This function is to get the header file name from module info map
|
|
||||||
according to module type.
|
|
||||||
|
|
||||||
@param moduleType Module type.
|
|
||||||
@return Name of header file.
|
|
||||||
**/
|
|
||||||
String getModuleTypeIncluder(String moduleType) {
|
|
||||||
return moduleInfo.get(moduleType);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
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);
|
|
||||||
|
|
||||||
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(",");
|
|
||||||
|
|
||||||
//
|
|
||||||
// chang Microsoft specific form to ANSI c form
|
|
||||||
//
|
|
||||||
for (int i = 0; i < 3; i++){
|
|
||||||
guid = guid + strList[i] + ",";
|
|
||||||
}
|
|
||||||
guid = guid + "{";
|
|
||||||
|
|
||||||
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";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,213 +0,0 @@
|
|||||||
/** @file
|
|
||||||
SurfaceAreaParser class.
|
|
||||||
|
|
||||||
SurfaceAreaParser class is used to parse module surface area include both
|
|
||||||
driver and library.
|
|
||||||
|
|
||||||
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.Map;
|
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
|
||||||
import org.apache.xmlbeans.XmlObject;
|
|
||||||
import org.tianocore.LibraryModuleBuildDescriptionDocument;
|
|
||||||
import org.tianocore.LibraryModuleSurfaceAreaDocument;
|
|
||||||
import org.tianocore.ModuleBuildDescriptionDocument;
|
|
||||||
import org.tianocore.ModuleSurfaceAreaDocument;
|
|
||||||
|
|
||||||
/**
|
|
||||||
This class is used to parse module surface area (MSA & MBD) include both
|
|
||||||
driver and library.
|
|
||||||
|
|
||||||
@since GenBuild 1.0
|
|
||||||
**/
|
|
||||||
public class SurfaceAreaParser {
|
|
||||||
|
|
||||||
/**
|
|
||||||
Using XmlBeans to parse and valid surface area file.
|
|
||||||
|
|
||||||
@param surfaceAreaFile the surface area file to parse
|
|
||||||
@return top level elements and its value mapping information
|
|
||||||
@throws BuildException
|
|
||||||
If surface area is not well-formed or invalid
|
|
||||||
**/
|
|
||||||
public Map<String, XmlObject> parseFile(File surfaceAreaFile) throws BuildException {
|
|
||||||
Map<String, XmlObject> map = new HashMap<String, XmlObject>();
|
|
||||||
try {
|
|
||||||
XmlObject sadoc = XmlObject.Factory.parse(surfaceAreaFile);
|
|
||||||
// Validate File if they obey XML Schema
|
|
||||||
|
|
||||||
if ( ! sadoc.validate()){
|
|
||||||
throw new BuildException("Surface Area file [" + surfaceAreaFile.getPath() + "] is invalid.");
|
|
||||||
}
|
|
||||||
if (sadoc instanceof ModuleSurfaceAreaDocument){
|
|
||||||
parseFile((ModuleSurfaceAreaDocument) sadoc, map);
|
|
||||||
}
|
|
||||||
else if(sadoc instanceof ModuleBuildDescriptionDocument){
|
|
||||||
parseFile((ModuleBuildDescriptionDocument) sadoc, map);
|
|
||||||
}
|
|
||||||
else if(sadoc instanceof LibraryModuleSurfaceAreaDocument){
|
|
||||||
parseFile((LibraryModuleSurfaceAreaDocument) sadoc, map);
|
|
||||||
}
|
|
||||||
else if(sadoc instanceof LibraryModuleBuildDescriptionDocument){
|
|
||||||
parseFile((LibraryModuleBuildDescriptionDocument) sadoc, map);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex){
|
|
||||||
throw new BuildException(ex.getMessage());
|
|
||||||
}
|
|
||||||
return map;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Parse MSA.
|
|
||||||
|
|
||||||
@param doc top level surface area XML document
|
|
||||||
@param msaMap the map to store the result
|
|
||||||
**/
|
|
||||||
private void parseFile(ModuleSurfaceAreaDocument doc, Map<String, XmlObject> msaMap) {
|
|
||||||
msaMap.put("MsaHeader", doc.getModuleSurfaceArea().getMsaHeader());
|
|
||||||
msaMap.put("LibraryClassDefinitions", doc.getModuleSurfaceArea()
|
|
||||||
.getLibraryClassDefinitions());
|
|
||||||
msaMap.put("SourceFiles", doc.getModuleSurfaceArea().getSourceFiles());
|
|
||||||
msaMap.put("Includes", doc.getModuleSurfaceArea().getIncludes());
|
|
||||||
msaMap.put("PackageDependencies", doc.getModuleSurfaceArea().getPackageDependencies());
|
|
||||||
msaMap.put("Protocols", doc.getModuleSurfaceArea().getProtocols());
|
|
||||||
|
|
||||||
msaMap.put("Events", doc.getModuleSurfaceArea().getEvents());
|
|
||||||
msaMap.put("Hobs", doc.getModuleSurfaceArea().getHobs());
|
|
||||||
msaMap.put("PPIs", doc.getModuleSurfaceArea().getPPIs());
|
|
||||||
msaMap.put("Variables", doc.getModuleSurfaceArea().getVariables());
|
|
||||||
msaMap.put("BootModes", doc.getModuleSurfaceArea().getBootModes());
|
|
||||||
|
|
||||||
msaMap.put("SystemTables", doc.getModuleSurfaceArea().getSystemTables());
|
|
||||||
msaMap.put("DataHubs", doc.getModuleSurfaceArea().getDataHubs());
|
|
||||||
msaMap.put("Formsets", doc.getModuleSurfaceArea().getFormsets());
|
|
||||||
msaMap.put("Guids", doc.getModuleSurfaceArea().getGuids());
|
|
||||||
msaMap.put("Externs", doc.getModuleSurfaceArea().getExterns());
|
|
||||||
|
|
||||||
msaMap.put("PcdCoded", doc.getModuleSurfaceArea().getPcdCoded());
|
|
||||||
msaMap.put("BuildOptions", doc.getModuleSurfaceArea().getBuildOptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Parse MBD.
|
|
||||||
|
|
||||||
@param doc top level surface area XML document
|
|
||||||
@param msaMap the map to store the result
|
|
||||||
**/
|
|
||||||
private void parseFile(ModuleBuildDescriptionDocument doc, Map<String, XmlObject> mbdMap) {
|
|
||||||
mbdMap.put("MbdHeader", doc.getModuleBuildDescription().getMbdHeader());
|
|
||||||
mbdMap.put("Libraries", doc.getModuleBuildDescription().getLibraries());
|
|
||||||
mbdMap.put("SourceFiles", doc.getModuleBuildDescription()
|
|
||||||
.getSourceFiles());
|
|
||||||
mbdMap.put("Includes", doc.getModuleBuildDescription().getIncludes());
|
|
||||||
mbdMap.put("Protocols", doc.getModuleBuildDescription().getProtocols());
|
|
||||||
|
|
||||||
mbdMap.put("Events", doc.getModuleBuildDescription().getEvents());
|
|
||||||
mbdMap.put("Hobs", doc.getModuleBuildDescription().getHobs());
|
|
||||||
mbdMap.put("PPIs", doc.getModuleBuildDescription().getPPIs());
|
|
||||||
mbdMap.put("Variables", doc.getModuleBuildDescription().getVariables());
|
|
||||||
mbdMap.put("BootModes", doc.getModuleBuildDescription().getBootModes());
|
|
||||||
|
|
||||||
mbdMap.put("SystemTables", doc.getModuleBuildDescription()
|
|
||||||
.getSystemTables());
|
|
||||||
mbdMap.put("DataHubs", doc.getModuleBuildDescription().getDataHubs());
|
|
||||||
mbdMap.put("Formsets", doc.getModuleBuildDescription().getFormsets());
|
|
||||||
mbdMap.put("Guids", doc.getModuleBuildDescription().getGuids());
|
|
||||||
mbdMap.put("Externs", doc.getModuleBuildDescription().getExterns());
|
|
||||||
|
|
||||||
mbdMap.put("BuildOptions", doc.getModuleBuildDescription()
|
|
||||||
.getBuildOptions());
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
Parse Library MSA.
|
|
||||||
|
|
||||||
@param doc top level surface area XML document
|
|
||||||
@param msaMap the map to store the result
|
|
||||||
**/
|
|
||||||
private void parseFile(LibraryModuleSurfaceAreaDocument doc, Map<String, XmlObject> msaMap) {
|
|
||||||
msaMap.put("MsaLibHeader", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getMsaLibHeader());
|
|
||||||
msaMap.put("LibraryClassDefinitions", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getLibraryClassDefinitions());
|
|
||||||
msaMap.put("SourceFiles", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getSourceFiles());
|
|
||||||
msaMap.put("Includes", doc.getLibraryModuleSurfaceArea().getIncludes());
|
|
||||||
msaMap.put("Protocols", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getProtocols());
|
|
||||||
|
|
||||||
msaMap.put("Events", doc.getLibraryModuleSurfaceArea().getEvents());
|
|
||||||
msaMap.put("Hobs", doc.getLibraryModuleSurfaceArea().getHobs());
|
|
||||||
msaMap.put("PPIs", doc.getLibraryModuleSurfaceArea().getPPIs());
|
|
||||||
msaMap.put("Variables", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getVariables());
|
|
||||||
msaMap.put("BootModes", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getBootModes());
|
|
||||||
|
|
||||||
msaMap.put("SystemTables", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getSystemTables());
|
|
||||||
msaMap.put("DataHubs", doc.getLibraryModuleSurfaceArea().getDataHubs());
|
|
||||||
msaMap.put("Formsets", doc.getLibraryModuleSurfaceArea().getFormsets());
|
|
||||||
msaMap.put("Guids", doc.getLibraryModuleSurfaceArea().getGuids());
|
|
||||||
msaMap.put("Externs", doc.getLibraryModuleSurfaceArea().getExterns());
|
|
||||||
|
|
||||||
msaMap.put("PcdCoded", doc.getLibraryModuleSurfaceArea().getPcdCoded());
|
|
||||||
msaMap.put("BuildOptions", doc.getLibraryModuleSurfaceArea()
|
|
||||||
.getBuildOptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Parse Library MBD.
|
|
||||||
|
|
||||||
@param doc top level surface area XML document
|
|
||||||
@param msaMap the map to store the result
|
|
||||||
**/
|
|
||||||
private void parseFile(LibraryModuleBuildDescriptionDocument doc, Map<String, XmlObject> mbdMap) {
|
|
||||||
mbdMap.put("MbdLibHeader", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getMbdLibHeader());
|
|
||||||
mbdMap.put("Libraries", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getLibraries());
|
|
||||||
mbdMap.put("SourceFiles", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getSourceFiles());
|
|
||||||
mbdMap.put("Includes", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getIncludes());
|
|
||||||
mbdMap.put("Protocols", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getProtocols());
|
|
||||||
|
|
||||||
mbdMap
|
|
||||||
.put("Events", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getEvents());
|
|
||||||
mbdMap.put("Hobs", doc.getLibraryModuleBuildDescription().getHobs());
|
|
||||||
mbdMap.put("PPIs", doc.getLibraryModuleBuildDescription().getPPIs());
|
|
||||||
mbdMap.put("Variables", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getVariables());
|
|
||||||
mbdMap.put("BootModes", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getBootModes());
|
|
||||||
|
|
||||||
mbdMap.put("SystemTables", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getSystemTables());
|
|
||||||
mbdMap.put("DataHubs", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getDataHubs());
|
|
||||||
mbdMap.put("Formsets", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getFormsets());
|
|
||||||
mbdMap.put("Guids", doc.getLibraryModuleBuildDescription().getGuids());
|
|
||||||
mbdMap.put("Externs", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getExterns());
|
|
||||||
|
|
||||||
mbdMap.put("BuildOptions", doc.getLibraryModuleBuildDescription()
|
|
||||||
.getBuildOptions());
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -11,7 +11,8 @@ http://opensource.org/licenses/bsd-license.php
|
|||||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||||
**/
|
**/
|
||||||
package org.tianocore.build.fpd;
|
package org.tianocore.build.id;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This class is used to identify a module with BaseName, GUID, Version, PackageName
|
This class is used to identify a module with BaseName, GUID, Version, PackageName
|
||||||
@ -23,30 +24,27 @@ public class FpdModuleIdentification {
|
|||||||
|
|
||||||
private String arch;
|
private String arch;
|
||||||
|
|
||||||
private String fvBinding;
|
private String fvBinding = "NULL"; // Optional
|
||||||
|
|
||||||
private String baseName;
|
private String sequence = "0"; // Optional
|
||||||
|
|
||||||
private String packageName;
|
private ModuleIdentification module;
|
||||||
|
|
||||||
private String guid;
|
private String target; // Optional
|
||||||
|
|
||||||
private String version;
|
private String toolchain; // Optional
|
||||||
|
|
||||||
private String sequence;
|
public FpdModuleIdentification(String arch, String fvBinding, String sequence, ModuleIdentification module){
|
||||||
|
|
||||||
/**
|
|
||||||
|
|
||||||
@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;
|
this.arch = arch;
|
||||||
|
this.fvBinding = fvBinding;
|
||||||
|
this.sequence = sequence;
|
||||||
|
this.module = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FpdModuleIdentification(ModuleIdentification module, String arch){
|
||||||
|
this.arch = arch;
|
||||||
|
this.module = module;
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
Override java.lang.Object#equals.
|
Override java.lang.Object#equals.
|
||||||
|
|
||||||
@ -58,21 +56,16 @@ public class FpdModuleIdentification {
|
|||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (obj instanceof FpdModuleIdentification) {
|
if (obj instanceof FpdModuleIdentification) {
|
||||||
FpdModuleIdentification moduleIdObj = (FpdModuleIdentification)obj;
|
FpdModuleIdentification moduleIdObj = (FpdModuleIdentification)obj;
|
||||||
if ( baseName.equalsIgnoreCase(moduleIdObj.baseName) && arch.equalsIgnoreCase(moduleIdObj.arch)) {
|
if ( module.equals(moduleIdObj.module) && arch.equalsIgnoreCase(moduleIdObj.arch)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// TBD
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return super.equals(obj);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArch(String arch) {
|
|
||||||
this.arch = arch;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFvBinding(String fvBinding) {
|
public void setFvBinding(String fvBinding) {
|
||||||
this.fvBinding = fvBinding;
|
this.fvBinding = fvBinding;
|
||||||
}
|
}
|
||||||
@ -82,50 +75,34 @@ public class FpdModuleIdentification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String toString(){
|
public String toString(){
|
||||||
return arch + ":" + guid + "_" + baseName;
|
return arch + ":" + module;
|
||||||
}
|
|
||||||
|
|
||||||
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() {
|
public String getFvBinding() {
|
||||||
return fvBinding;
|
return fvBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGuid() {
|
|
||||||
return guid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPackageName() {
|
|
||||||
return packageName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSequence() {
|
public String getSequence() {
|
||||||
return sequence;
|
return sequence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getVersion() {
|
public ModuleIdentification getModule() {
|
||||||
return version;
|
return module;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModule(ModuleIdentification module) {
|
||||||
|
this.module = module;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArch() {
|
||||||
|
return arch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArch(String arch) {
|
||||||
|
this.arch = arch;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode(){
|
||||||
|
return module.hashCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package org.tianocore.build.id;
|
||||||
|
|
||||||
|
import org.tianocore.build.global.GlobalData;
|
||||||
|
|
||||||
|
public class Identification {
|
||||||
|
|
||||||
|
String name;
|
||||||
|
|
||||||
|
String guid;
|
||||||
|
|
||||||
|
String version;
|
||||||
|
|
||||||
|
String type; // Optional
|
||||||
|
|
||||||
|
Identification(String name, String guid, String version){
|
||||||
|
this.name = name;
|
||||||
|
this.guid = guid;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
Identification(String guid, String version){
|
||||||
|
this.guid = guid;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof Identification) {
|
||||||
|
Identification id = (Identification)obj;
|
||||||
|
if ( guid.equalsIgnoreCase(id.guid)) {
|
||||||
|
if (version == null || id.version == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (version.equalsIgnoreCase(id.version)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return super.equals(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGuid(String guid) {
|
||||||
|
this.guid = guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVersion(String version) {
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGuid() {
|
||||||
|
return guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVersion() {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode(){
|
||||||
|
return guid.toLowerCase().hashCode();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,124 @@
|
|||||||
|
package org.tianocore.build.id;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.tianocore.build.global.GlobalData;
|
||||||
|
|
||||||
|
public class ModuleIdentification extends Identification {
|
||||||
|
|
||||||
|
private PackageIdentification packageId;
|
||||||
|
|
||||||
|
private File msaFile;
|
||||||
|
|
||||||
|
private String moduleType;
|
||||||
|
|
||||||
|
private boolean isLibrary = false;
|
||||||
|
|
||||||
|
public ModuleIdentification(String guid, String version){
|
||||||
|
super(guid, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModuleIdentification(String guid, String version, PackageIdentification packageId){
|
||||||
|
super(guid, version);
|
||||||
|
this.packageId = packageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModuleIdentification(String name, String guid, String version){
|
||||||
|
super(name, guid, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ModuleIdentification(String name, String guid, String version, PackageIdentification packageId){
|
||||||
|
super(name, guid, version);
|
||||||
|
this.packageId = packageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLibrary() {
|
||||||
|
return isLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLibrary(boolean isLibrary) {
|
||||||
|
this.isLibrary = isLibrary;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getMsaFile() {
|
||||||
|
prepareMsaFile();
|
||||||
|
return msaFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModuleRelativePath() {
|
||||||
|
prepareMsaFile();
|
||||||
|
if (msaFile.getParent().length() == packageId.getPackageDir().length()) {
|
||||||
|
return ".";
|
||||||
|
}
|
||||||
|
return msaFile.getParent().substring(packageId.getPackageDir().length() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepareMsaFile(){
|
||||||
|
if (msaFile == null) {
|
||||||
|
GlobalData.refreshModuleIdentification(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMsaFile(File msaFile) {
|
||||||
|
this.msaFile = msaFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj instanceof ModuleIdentification) {
|
||||||
|
ModuleIdentification id = (ModuleIdentification)obj;
|
||||||
|
if (guid.equalsIgnoreCase(id.getGuid()) && packageId.equals(id.getPackage())) {
|
||||||
|
if (version == null || id.version == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (version.trim().equalsIgnoreCase("") || id.version.trim().equalsIgnoreCase("")){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (version.equalsIgnoreCase(id.version)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return super.equals(obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
if (name == null) {
|
||||||
|
GlobalData.refreshModuleIdentification(this);
|
||||||
|
}
|
||||||
|
if (version == null || version.trim().equalsIgnoreCase("")) {
|
||||||
|
return "Module [" + name + "] in " + packageId;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "Module [" + name + " " + version + "] in " + packageId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPackage(PackageIdentification packageId) {
|
||||||
|
this.packageId = packageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackageIdentification getPackage() {
|
||||||
|
return packageId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModuleType() {
|
||||||
|
if (moduleType == null) {
|
||||||
|
GlobalData.refreshModuleIdentification(this);
|
||||||
|
}
|
||||||
|
return moduleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setModuleType(String moduleType) {
|
||||||
|
this.moduleType = moduleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
if (name == null) {
|
||||||
|
GlobalData.refreshModuleIdentification(this);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package org.tianocore.build.id;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.tianocore.build.global.GlobalData;
|
||||||
|
|
||||||
|
public class PackageIdentification extends Identification{
|
||||||
|
|
||||||
|
//
|
||||||
|
// It is optional
|
||||||
|
//
|
||||||
|
private File spdFile;
|
||||||
|
|
||||||
|
public PackageIdentification(String guid, String version){
|
||||||
|
super(guid, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackageIdentification(String name, String guid, String version){
|
||||||
|
super(name, guid, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackageIdentification(String name, String guid, String version, String spdFilename){
|
||||||
|
super(name, guid, version);
|
||||||
|
this.spdFile = new File(spdFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PackageIdentification(String name, String guid, String version, File spdFile){
|
||||||
|
super(name, guid, version);
|
||||||
|
this.spdFile = spdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSpdFile(File spdFile) {
|
||||||
|
this.spdFile = spdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getSpdFile() {
|
||||||
|
return spdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
if (name == null) {
|
||||||
|
GlobalData.refreshPackageIdentification(this);
|
||||||
|
}
|
||||||
|
if (version == null || version.trim().equalsIgnoreCase("")) {
|
||||||
|
return "package [" + name + "]";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "package [" + name + " " + version + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageDir(){
|
||||||
|
prepareSpdFile();
|
||||||
|
return spdFile.getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPackageRelativeDir(){
|
||||||
|
prepareSpdFile();
|
||||||
|
return spdFile.getParent().substring(GlobalData.getWorkspacePath().length() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void prepareSpdFile(){
|
||||||
|
if (spdFile == null) {
|
||||||
|
GlobalData.refreshPackageIdentification(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
if (name == null) {
|
||||||
|
GlobalData.refreshPackageIdentification(this);
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package org.tianocore.build.id;
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.tianocore.build.global.GlobalData;
|
||||||
|
|
||||||
|
public class PlatformIdentification extends Identification{
|
||||||
|
|
||||||
|
private File fpdFile;
|
||||||
|
|
||||||
|
public PlatformIdentification(String guid, String version){
|
||||||
|
super(guid, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlatformIdentification(String name, String guid, String version){
|
||||||
|
super(name, guid, version);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlatformIdentification(String name, String guid, String version, String fpdFilename){
|
||||||
|
super(name, guid, version);
|
||||||
|
this.fpdFile = new File(fpdFilename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlatformIdentification(String name, String guid, String version, File fpdFile){
|
||||||
|
super(name, guid, version);
|
||||||
|
this.fpdFile = fpdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString(){
|
||||||
|
return "Platform " + name + "["+guid+"]";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFpdFile(File fpdFile) {
|
||||||
|
this.fpdFile = fpdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getFpdFile() {
|
||||||
|
return fpdFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlatformRelativeDir(){
|
||||||
|
return fpdFile.getParent().substring(GlobalData.getWorkspacePath().length());
|
||||||
|
}
|
||||||
|
}
|
@ -14,16 +14,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
**/
|
**/
|
||||||
package org.tianocore.build.toolchain;
|
package org.tianocore.build.toolchain;
|
||||||
|
|
||||||
|
import org.tianocore.build.exception.EdkException;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.util.HashMap;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
@ -36,6 +33,7 @@ public class ConfigReader {
|
|||||||
|
|
||||||
private static String confPath = ".";
|
private static String confPath = ".";
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Public construct method.
|
Public construct method.
|
||||||
**/
|
**/
|
||||||
@ -48,7 +46,7 @@ public class ConfigReader {
|
|||||||
@param filename the config file name like "target.txt"
|
@param filename the config file name like "target.txt"
|
||||||
@return the variables defined in file
|
@return the variables defined in file
|
||||||
**/
|
**/
|
||||||
public static synchronized String[][] parse(String filename) {
|
public static synchronized String[][] parse(String filename) throws EdkException {
|
||||||
return parse(confPath, filename);
|
return parse(confPath, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,157 +60,77 @@ public class ConfigReader {
|
|||||||
@throws BuildException
|
@throws BuildException
|
||||||
Config file's format is not valid
|
Config file's format is not valid
|
||||||
**/
|
**/
|
||||||
public static synchronized String[][] parse(String confPath, String filename) throws BuildException {
|
public static synchronized String[][] parse(String confPath, String filename) throws EdkException {
|
||||||
|
//Map<String, String> map = new TreeMap<String,String>(comparator);
|
||||||
|
List<String> keyList = new ArrayList<String>(256);
|
||||||
|
List<String> valueList = new ArrayList<String>(256);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Map<String, String> map = new HashMap<String, String>(20);
|
|
||||||
File file = new File(confPath + File.separatorChar + filename);
|
File file = new File(confPath + File.separatorChar + filename);
|
||||||
FileReader reader = new FileReader(file);
|
FileReader reader = new FileReader(file);
|
||||||
BufferedReader in = new BufferedReader(reader);
|
BufferedReader in = new BufferedReader(reader);
|
||||||
String str;
|
String str;
|
||||||
|
|
||||||
while ((str = in.readLine()) != null) {
|
while ((str = in.readLine()) != null) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
//
|
//
|
||||||
// if str is empty line or comments (start with '#')
|
// if str is empty line, comments (start with '#'),
|
||||||
|
// without '=', or start with '='
|
||||||
//
|
//
|
||||||
if (str.equalsIgnoreCase("") || str.startsWith("#")) {
|
int index;
|
||||||
continue;
|
if (str.length() == 0 || str.startsWith("#") ||
|
||||||
}
|
(index = str.indexOf('=')) <= 0) {
|
||||||
//
|
|
||||||
// if str without '=' or start with '='
|
|
||||||
//
|
|
||||||
if (str.indexOf('=') <= 0) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
// look as line "A = B"
|
// look as line "A = B"
|
||||||
//
|
//
|
||||||
int index = str.indexOf('=');
|
keyList.add(str.substring(0, index).trim());
|
||||||
String key = str.substring(0, index).trim();
|
valueList.add(str.substring(index + 1).trim());
|
||||||
String value = str.substring(index + 1).trim();
|
|
||||||
//
|
|
||||||
// if key is existed, then update
|
|
||||||
//
|
|
||||||
if (map.containsKey(key)) {
|
|
||||||
map.remove(key);
|
|
||||||
}
|
}
|
||||||
map.put(key, value);
|
|
||||||
}
|
|
||||||
Set keyset = map.keySet();
|
|
||||||
Iterator iter = keyset.iterator();
|
|
||||||
String[][] result = new String[map.size()][2];
|
|
||||||
int i = 0;
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
String key = (String) iter.next();
|
|
||||||
result[i][0] = key;
|
|
||||||
result[i++][1] = (String) map.get(key);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new BuildException("Processor file [" + filename + "] error. \n" + e.getMessage());
|
throw new EdkException("Process file [" + filename + "] error. \n" + e.getMessage());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
String[][] definitions = new String[2][keyList.size()];
|
||||||
Parse global flags table. The format is like such(global flag name, value,
|
definitions[0] = (String[])keyList.toArray(definitions[0]);
|
||||||
vendor_arch_cmd, [add flags], [sub flags]):
|
definitions[1] = (String[])valueList.toArray(definitions[1]);
|
||||||
|
|
||||||
<pre>
|
return definitions;
|
||||||
# EFI_DEBUG
|
}
|
||||||
EFI_DEBUG YES MSFT_IA32_ASM ADD.["/Zi", "/DEBUG"]
|
|
||||||
EFI_DEBUG YES MSFT_IA32_CC ADD.["/Zi", "/Gm", "/D EFI_DEBUG"] SUB.["/nologo", "/WX"]
|
public static synchronized ToolChainMap parseToolChainConfig(File ConfigFile) throws EdkException {
|
||||||
EFI_DEBUG YES MSFT_IA32_LINK ADD.["/DEBUG"]
|
ToolChainMap map = new ToolChainMap();
|
||||||
EFI_DEBUG YES MSFT_NT32_CC ADD.["/DEBUG"]
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
@param confPath the file path of config file
|
|
||||||
@param filename the file name of config file
|
|
||||||
@return the value list
|
|
||||||
@throws BuildException
|
|
||||||
Config file is not valid
|
|
||||||
**/
|
|
||||||
public static synchronized String[][] parseTable(String confPath,
|
|
||||||
String filename) throws BuildException {
|
|
||||||
try {
|
try {
|
||||||
Vector<String[]> vector = new Vector<String[]>(20);
|
FileReader reader = new FileReader(ConfigFile);
|
||||||
File file = new File(confPath + File.separatorChar + filename);
|
|
||||||
FileReader reader = new FileReader(file);
|
|
||||||
BufferedReader in = new BufferedReader(reader);
|
BufferedReader in = new BufferedReader(reader);
|
||||||
String str;
|
String str;
|
||||||
|
|
||||||
while ((str = in.readLine()) != null) {
|
while ((str = in.readLine()) != null) {
|
||||||
str = str.trim();
|
str = str.trim();
|
||||||
//
|
//
|
||||||
// if str is empty line or comments (start with '#')
|
// if str is empty line, comments (start with '#'),
|
||||||
|
// without '=', or start with '='
|
||||||
//
|
//
|
||||||
if (str.equalsIgnoreCase("") || str.startsWith("#")) {
|
int index;
|
||||||
|
if (str.length() == 0 || str.startsWith("#") ||
|
||||||
|
(index = str.indexOf('=')) <= 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String[] item = new String[5];
|
//
|
||||||
for(int i=0; i < item.length; i++){
|
// look as line "A = B"
|
||||||
item[i] = "";
|
//
|
||||||
|
String key = str.substring(0, index).trim().toUpperCase();
|
||||||
|
String value = str.substring(index + 1).trim();
|
||||||
|
map.put(key, value);
|
||||||
}
|
}
|
||||||
//
|
} catch (Exception e) {
|
||||||
// EFI_DEBUG YES MSFT_IA32_ASM ADD.["/Zi", "/DEBUG"]
|
throw new EdkException("Process file [" + ConfigFile.getAbsolutePath() + "] error. \n" + e.getMessage());
|
||||||
// FLAGS: EFI_DEBUG
|
|
||||||
//
|
|
||||||
int index = str.indexOf(" ");
|
|
||||||
item[0] = str.substring(0, index);
|
|
||||||
str = str.substring(index + 1).trim();
|
|
||||||
//
|
|
||||||
// Setting: YES
|
|
||||||
//
|
|
||||||
index = str.indexOf(" ");
|
|
||||||
item[1] = str.substring(0, index);
|
|
||||||
str = str.substring(index + 1).trim();
|
|
||||||
//
|
|
||||||
// Vendor_Arch_Commandtype: MSFT_IA32_ASM
|
|
||||||
//
|
|
||||||
index = str.indexOf(" ");
|
|
||||||
item[2] = str.substring(0, index);
|
|
||||||
str = str.substring(index + 1).trim();
|
|
||||||
//
|
|
||||||
// Add or/and Sub
|
|
||||||
//
|
|
||||||
if (str.startsWith("ADD.")) {
|
|
||||||
index = str.indexOf("]");
|
|
||||||
if ( index > 0){
|
|
||||||
item[3] = str.substring(5, index);
|
|
||||||
str = str.substring(index + 1).trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(str.startsWith("SUB.")){
|
|
||||||
index = str.indexOf("]");
|
|
||||||
if ( index > 0){
|
|
||||||
item[4] = str.substring(5, index);
|
|
||||||
str = str.substring(index + 1).trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new BuildException("File [" + filename + "] never conform to Global Flags Table format.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (str.startsWith("ADD.")) {
|
return map;
|
||||||
index = str.indexOf("]");
|
|
||||||
if ( index > 0){
|
|
||||||
item[3] = str.substring(5, index);
|
|
||||||
str = str.substring(index + 1).trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(str.startsWith("SUB.")){
|
|
||||||
index = str.indexOf("]");
|
|
||||||
if ( index > 0){
|
|
||||||
item[4] = str.substring(5, index);
|
|
||||||
str = str.substring(index + 1).trim();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
vector.addElement(item);
|
|
||||||
}
|
|
||||||
String[][] result = new String[vector.size()][5];
|
|
||||||
for(int i=0; i < vector.size(); i++){
|
|
||||||
result[i] = (String[])vector.get(i);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new BuildException("Processor file [" + filename + "] error. \n" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package org.tianocore.build.toolchain;
|
||||||
|
/**
|
||||||
|
* TODO: Add class description
|
||||||
|
*
|
||||||
|
* @author jwang36
|
||||||
|
*/
|
||||||
|
public class ToolChainAttribute {
|
||||||
|
private static int nextValue = 0;
|
||||||
|
|
||||||
|
//"NAME", "PATH", "DPATH", "SPATH", "EXT", "FAMILY", "FLAGS"
|
||||||
|
public final static ToolChainAttribute NAME = new ToolChainAttribute("NAME");
|
||||||
|
public final static ToolChainAttribute PATH = new ToolChainAttribute("PATH");
|
||||||
|
public final static ToolChainAttribute DPATH = new ToolChainAttribute("DPATH");
|
||||||
|
public final static ToolChainAttribute SPATH = new ToolChainAttribute("SPATH");
|
||||||
|
public final static ToolChainAttribute EXT = new ToolChainAttribute("EXT");
|
||||||
|
public final static ToolChainAttribute FAMILY = new ToolChainAttribute("FAMILY");
|
||||||
|
public final static ToolChainAttribute FLAGS = new ToolChainAttribute("FLAGS");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
public final int value = nextValue++;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
|
private ToolChainAttribute(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,142 @@
|
|||||||
|
/** @file
|
||||||
|
ToolChainFactory class.
|
||||||
|
|
||||||
|
ToolChainFactory class parse all config files and get STD_FLAGS, GLOBAL_FLAGS,
|
||||||
|
and also command path + name.
|
||||||
|
|
||||||
|
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.toolchain;
|
||||||
|
|
||||||
|
import org.apache.tools.ant.BuildException;
|
||||||
|
import org.tianocore.build.exception.EdkException;
|
||||||
|
import org.tianocore.build.toolchain.ToolChainKey;
|
||||||
|
import org.tianocore.build.toolchain.ToolChainMap;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This class parse all config files and get STD_FLAGS, GLOBAL_FLAGS, and also
|
||||||
|
command path + name.
|
||||||
|
|
||||||
|
@since GenBuild 1.0
|
||||||
|
**/
|
||||||
|
public class ToolChainConfig {
|
||||||
|
///
|
||||||
|
/// list of attributes
|
||||||
|
///
|
||||||
|
private final static String[] attributes = {"NAME", "PATH", "DPATH", "SPATH", "EXT", "FAMILY", "FLAGS"};
|
||||||
|
///
|
||||||
|
/// elements which are used to define one type of tool
|
||||||
|
///
|
||||||
|
private final static String[] elements = {"TARGET", "TOOLCHAIN", "ARCH", "CMD", "ATTRIBUTE" };
|
||||||
|
|
||||||
|
///
|
||||||
|
/// tool chain definitions
|
||||||
|
///
|
||||||
|
private ToolChainMap config = null;
|
||||||
|
private ToolChainInfo info = new ToolChainInfo();
|
||||||
|
|
||||||
|
/**
|
||||||
|
Public construct method.
|
||||||
|
**/
|
||||||
|
public ToolChainConfig () {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Public construct method.
|
||||||
|
|
||||||
|
@param confPath the path of config files
|
||||||
|
@param toolChainTag TOOL_CHAIN name
|
||||||
|
**/
|
||||||
|
public ToolChainConfig (File toolChainFile) {
|
||||||
|
try {
|
||||||
|
config = ConfigReader.parseToolChainConfig(toolChainFile);
|
||||||
|
parseToolChainDefKey(config.keySet());
|
||||||
|
}
|
||||||
|
catch (EdkException ex) {
|
||||||
|
throw new BuildException(ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
///
|
||||||
|
///
|
||||||
|
public void parseToolChainDefKey (Set<ToolChainKey> toolChainDefKey) {
|
||||||
|
Iterator it = toolChainDefKey.iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ToolChainKey key = (ToolChainKey)it.next();
|
||||||
|
String[] keySet = key.getKeySet();
|
||||||
|
info.addTargets(keySet[0]);
|
||||||
|
info.addTagnames(keySet[1]);
|
||||||
|
info.addArchs(keySet[2]);
|
||||||
|
info.addCommands(keySet[1], keySet[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
public Set<String> getTargets() {
|
||||||
|
return info.getTargets();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getTagnames() {
|
||||||
|
return info.getTagnames();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getArchs() {
|
||||||
|
return info.getArchs();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getCommands() {
|
||||||
|
return info.getCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String key) {
|
||||||
|
return config.get(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(String[] keySet) {
|
||||||
|
return config.get(keySet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue(ToolChainKey key) {
|
||||||
|
return config.get(key);
|
||||||
|
}
|
||||||
|
**/
|
||||||
|
|
||||||
|
public ToolChainMap getConfig() {
|
||||||
|
return config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolChainInfo getConfigInfo() {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// override toString()
|
||||||
|
///
|
||||||
|
public String toString() {
|
||||||
|
StringBuffer ts = new StringBuffer(10240);
|
||||||
|
|
||||||
|
Iterator it = config.keySet().iterator();
|
||||||
|
while (it.hasNext()) {
|
||||||
|
ToolChainKey key = (ToolChainKey)it.next();
|
||||||
|
ts.append(key.toString() + " = ");
|
||||||
|
// ts.append(config.get(key) + "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ts.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package org.tianocore.build.toolchain;
|
||||||
|
/**
|
||||||
|
* TODO: Add class description
|
||||||
|
*
|
||||||
|
* @author jwang36
|
||||||
|
*/
|
||||||
|
public class ToolChainElement {
|
||||||
|
private static int nextValue = 0;
|
||||||
|
|
||||||
|
//"NAME", "PATH", "DPATH", "SPATH", "EXT", "FAMILY", "FLAGS"
|
||||||
|
public final static ToolChainElement TARGET = new ToolChainElement("TARGET");
|
||||||
|
public final static ToolChainElement TOOLCHAIN = new ToolChainElement("TOOLCHAIN");
|
||||||
|
public final static ToolChainElement ARCH = new ToolChainElement("ARCH");
|
||||||
|
public final static ToolChainElement TOOLCODE = new ToolChainElement("TOOLCODE");
|
||||||
|
public final static ToolChainElement ATTRIBUTE = new ToolChainElement("ATTRIBUTE");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
public final int value = nextValue++;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor
|
||||||
|
*/
|
||||||
|
private ToolChainElement(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,529 +0,0 @@
|
|||||||
/** @file
|
|
||||||
ToolChainFactory class.
|
|
||||||
|
|
||||||
ToolChainFactory class parse all config files and get STD_FLAGS, GLOBAL_FLAGS,
|
|
||||||
and also command path + name.
|
|
||||||
|
|
||||||
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.toolchain;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.StringTokenizer;
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
import org.apache.tools.ant.Project;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
This class parse all config files and get STD_FLAGS, GLOBAL_FLAGS, and also
|
|
||||||
command path + name.
|
|
||||||
|
|
||||||
@since GenBuild 1.0
|
|
||||||
**/
|
|
||||||
public class ToolChainFactory {
|
|
||||||
///
|
|
||||||
/// list of Arch: EBC, ARM, IA32, X64, IPF, PPC
|
|
||||||
///
|
|
||||||
public final static String[] arch = { "EBC", "ARM", "IA32", "X64", "IPF",
|
|
||||||
"PPC"};
|
|
||||||
|
|
||||||
///
|
|
||||||
/// list of OS: Linux, Windows
|
|
||||||
///
|
|
||||||
public final static String[] os = { "WINDOWS", "LINUX" };
|
|
||||||
|
|
||||||
///
|
|
||||||
/// list of Command Type: CC, LIB, LINK, ASL, ASM, ASMLINK, PP
|
|
||||||
///
|
|
||||||
public final static String[] commandType = { "CC", "LIB", "LINK", "ASL",
|
|
||||||
"ASM", "ASMLINK", "PP" };
|
|
||||||
|
|
||||||
///
|
|
||||||
/// default command name for every command
|
|
||||||
///
|
|
||||||
public final static String[][] defaultCmdName = { { "CC", "cl" },
|
|
||||||
{ "LIB", "lib" }, { "LINK", "link" }, { "ASL", "iasl" },
|
|
||||||
{ "ASM", "ml" }, { "ASMLINK", "link" }, { "PP", "cl" } };
|
|
||||||
|
|
||||||
private String confPath = ".";
|
|
||||||
|
|
||||||
private String toolChainName = "MSFT";
|
|
||||||
|
|
||||||
private String sTargetFilename = "target.txt";
|
|
||||||
|
|
||||||
private String sToolsdefFilename = "tools_def.txt";
|
|
||||||
|
|
||||||
private String sWorkspaceTarget = "WORKSPACE_TARGET";
|
|
||||||
|
|
||||||
private String sTargetArch = "TARGET_ARCH";
|
|
||||||
|
|
||||||
private HashMap<String,String[][]> filesMap = new HashMap<String,String[][]>();
|
|
||||||
|
|
||||||
private HashMap<String,String> globalFlagsMap = new HashMap<String,String>();
|
|
||||||
|
|
||||||
private String[][] globalFlagTable;
|
|
||||||
|
|
||||||
private String currentTarget = "RELEASE";
|
|
||||||
|
|
||||||
///
|
|
||||||
/// toolchain array list all results by parsing config files
|
|
||||||
///
|
|
||||||
public static String[][] toolchain = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
Public construct method.
|
|
||||||
**/
|
|
||||||
public ToolChainFactory () {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Public construct method.
|
|
||||||
|
|
||||||
@param project current ANT Project.
|
|
||||||
**/
|
|
||||||
public ToolChainFactory (Project project) {
|
|
||||||
this.confPath = project.replaceProperties("${WORKSPACE_DIR}" + File.separatorChar + "Tools" + File.separatorChar + "Conf");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Public construct method.
|
|
||||||
|
|
||||||
@param confPath the path of config files
|
|
||||||
@param toolChainName TOOL_CHAIN name
|
|
||||||
**/
|
|
||||||
public ToolChainFactory (String confPath, String toolChainName) {
|
|
||||||
this.confPath = confPath;
|
|
||||||
//
|
|
||||||
// If set tool used the set one, otherwise use default one.
|
|
||||||
// toolChain used to define open tools define txt file.
|
|
||||||
//
|
|
||||||
if (toolChainName != null && toolChainName.length() > 0){
|
|
||||||
this.toolChainName = toolChainName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Parse all config files, following are the detail steps:
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Parse target.txt file. This file define the current build TARGET
|
|
||||||
and supported ARCH list. </li>
|
|
||||||
<li>Parse tools_def.txt file. This file define every command name, path
|
|
||||||
and vendor. </li>
|
|
||||||
<li>For every supported ARCH and Command Type, find out STD_FLAGS,
|
|
||||||
GLOBAL_ADD_FLAGS, GLOBAL_SUB_FLAGS. </li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<p>Note that this method will be called only once during the whole build
|
|
||||||
process. </p>
|
|
||||||
**/
|
|
||||||
public void setupToolChain() {
|
|
||||||
if (toolchain != null) {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
Map<String, String> map = new HashMap<String, String>(40);
|
|
||||||
//
|
|
||||||
// parse target.txt
|
|
||||||
//
|
|
||||||
String[][] target = ConfigReader.parse(confPath, sTargetFilename);
|
|
||||||
//
|
|
||||||
// get workspace_target and initialize global flags setting
|
|
||||||
//
|
|
||||||
currentTarget = getValue(sWorkspaceTarget, target);
|
|
||||||
parseGlobalSetting(currentTarget);
|
|
||||||
String[] archList = getArchs(getValue(sTargetArch, target));
|
|
||||||
|
|
||||||
//
|
|
||||||
// If user write the ${toolChain}_Tools_Def.txt use this one,
|
|
||||||
// otherwise used "tools_def.txt" file.
|
|
||||||
//
|
|
||||||
File tempFile = new File (confPath + File.separator + toolChainName.toLowerCase() + "_tools_def.txt");
|
|
||||||
if (tempFile.exists()){
|
|
||||||
sToolsdefFilename = toolChainName.toLowerCase() + "_tools_def.txt";
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("Tools definition file is: " + sToolsdefFilename);
|
|
||||||
//
|
|
||||||
// parse tools_def.txt
|
|
||||||
//
|
|
||||||
String[][] tools_def = ConfigReader.parse(confPath, sToolsdefFilename);
|
|
||||||
//
|
|
||||||
// for each arch find all command's path&name and flags
|
|
||||||
//
|
|
||||||
for (int i = 0; i < archList.length; i++) {
|
|
||||||
for (int j = 0; j < commandType.length; j++) {
|
|
||||||
//
|
|
||||||
// Path & Name
|
|
||||||
//
|
|
||||||
map.put(archList[i] + "_" + commandType[j], getAbsoluteCmdPath(
|
|
||||||
archList[i], commandType[j], tools_def));
|
|
||||||
//
|
|
||||||
// Flags: CMD_STD_FLAGS + CMD_GLOBAL_FLAGS + CMD_PROJ_FLAGS
|
|
||||||
// ARCH_CMD_STD_FLAGS
|
|
||||||
//
|
|
||||||
map.put(archList[i] + "_" + commandType[j] + "_STD_FLAGS",
|
|
||||||
getStdFlags(archList[i], commandType[j],
|
|
||||||
tools_def));
|
|
||||||
//
|
|
||||||
// Flags:ARCH_CMD_VENDOR or ARCH_VENDOR
|
|
||||||
//
|
|
||||||
map.put(archList[i]+ "_"+commandType[j]+"_VENDOR", getVendorFlag(archList[i],
|
|
||||||
commandType[j], tools_def));
|
|
||||||
//
|
|
||||||
// ARCH_CMD_GLOBAL_FLAGS
|
|
||||||
//
|
|
||||||
String[] globalFlags = getGlobalFlags(archList[i], commandType[j],
|
|
||||||
tools_def);
|
|
||||||
map.put(archList[i] + "_" + commandType[j] + "_GLOBAL_ADD_FLAGS",
|
|
||||||
globalFlags[0]);
|
|
||||||
map.put(archList[i] + "_" + commandType[j] + "_GLOBAL_SUB_FLAGS",
|
|
||||||
globalFlags[1]);
|
|
||||||
//
|
|
||||||
// ARCH_CMD_GLOBAL_FLAGS, default is "".
|
|
||||||
//
|
|
||||||
map.put(archList[i] + "_" + commandType[j] + "_PROJ_FLAGS", "");
|
|
||||||
}
|
|
||||||
map.put(archList[i]+"_VENDOR", getVendorFlag(archList[i], null, tools_def));
|
|
||||||
}
|
|
||||||
Set keyset = map.keySet();
|
|
||||||
Iterator iter = keyset.iterator();
|
|
||||||
String[][] result = new String[map.size()][2];
|
|
||||||
int i = 0;
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
String key = (String) iter.next();
|
|
||||||
result[i][0] = key;
|
|
||||||
result[i++][1] = (String) map.get(key);
|
|
||||||
}
|
|
||||||
toolchain = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the standard flags (STD_FLAGS) for specified arch and command type.
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Find out Vendor that cmd Command Type with arch ARCH used. The
|
|
||||||
search sequence is ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT". Here
|
|
||||||
we suppose default Vendor is MSFT.</li>
|
|
||||||
<li>Search ${Vendor}_tools.txt file, and get the corrsponding flags.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@param arch the ARCH
|
|
||||||
@param cmd the command type
|
|
||||||
@param map detail flags information of tools_def.txt
|
|
||||||
@return the standard flags of arch ARCH and cmd Command Type
|
|
||||||
**/
|
|
||||||
private String getStdFlags(String arch, String cmd, String[][] map) {
|
|
||||||
//
|
|
||||||
// first is to find out its Vendor in map
|
|
||||||
// ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT"
|
|
||||||
// Here we suppose default Vendor is MSFT.
|
|
||||||
//
|
|
||||||
String vendor = "MSFT";
|
|
||||||
String str;
|
|
||||||
if ((str = getValue(arch + "_" + cmd + "_VENDOR", map)) != null) {
|
|
||||||
vendor = str;
|
|
||||||
} else if ((str = getValue(arch + "_VENDOR", map)) != null) {
|
|
||||||
vendor = str;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// change to low letter
|
|
||||||
//
|
|
||||||
vendor = vendor.toLowerCase();
|
|
||||||
//
|
|
||||||
// parse the corresponding file and get arch_cmd value
|
|
||||||
//
|
|
||||||
String filename = vendor + "_tools.txt";
|
|
||||||
String[][] flagsMap;
|
|
||||||
if (filesMap.containsKey(filename)) {
|
|
||||||
flagsMap = (String[][]) filesMap.get(filename);
|
|
||||||
} else {
|
|
||||||
//
|
|
||||||
// read file and store in filesMap
|
|
||||||
//
|
|
||||||
flagsMap = ConfigReader.parse(confPath, vendor + "_tools.txt");
|
|
||||||
filesMap.put(filename, flagsMap);
|
|
||||||
}
|
|
||||||
if ((str = getValue(arch + "_" + cmd, flagsMap)) != null) {
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get the global flags (GLOBAL_ADD_FLAGS & GLOBAL_SUB_FLAGS) for specified
|
|
||||||
arch and command type.
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Find out Vendor that cmd Command Type with arch ARCH used. The
|
|
||||||
search sequence is ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT". Here
|
|
||||||
we suppose default Vendor is MSFT.</li>
|
|
||||||
<li>Search efi_flags_table.txt file, and get the corrsponding flags.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
@param arch the ARCH
|
|
||||||
@param cmd the command type
|
|
||||||
@param map detail flags information of tools_def.txt
|
|
||||||
@return two values, first is GLOBAL_ADD_FLAGS and another value is
|
|
||||||
GLOBAL_SUB_FLAGS
|
|
||||||
**/
|
|
||||||
private String[] getGlobalFlags(String arch, String cmd, String[][] map) {
|
|
||||||
String addStr = "";
|
|
||||||
String subStr = "";
|
|
||||||
//
|
|
||||||
// first is to find out its Vendor in map
|
|
||||||
// ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT"
|
|
||||||
// Here we suppose default Vendor is MSFT.
|
|
||||||
//
|
|
||||||
String vendor = "MSFT";
|
|
||||||
String str;
|
|
||||||
if ((str = getValue(arch + "_" + cmd + "_VENDOR", map)) != null) {
|
|
||||||
vendor = str;
|
|
||||||
} else if ((str = getValue(arch + "_VENDOR", map)) != null) {
|
|
||||||
vendor = str;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// parse global flags table
|
|
||||||
//
|
|
||||||
if (globalFlagTable == null) {
|
|
||||||
globalFlagTable = ConfigReader.parseTable(confPath, "efi_flags_table.txt");
|
|
||||||
}
|
|
||||||
for (int i=0; i < globalFlagTable.length; i++){
|
|
||||||
String[] item = globalFlagTable[i];
|
|
||||||
if (item[2].equalsIgnoreCase(vendor + "_" + arch + "_" + cmd)){
|
|
||||||
//
|
|
||||||
// if item[0] == item[1] is existed in globalFlagsMap
|
|
||||||
//
|
|
||||||
if (globalFlagsMap.containsKey(item[0])){
|
|
||||||
if( item[1].equalsIgnoreCase((String)globalFlagsMap.get(item[0]))){
|
|
||||||
addStr += item[3] + " ";
|
|
||||||
subStr += item[4] + " ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return new String[]{addStr, subStr};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Find out command path and command name.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
Command path searching sequence in tools_def.txt file:
|
|
||||||
Path: ARCH_CMD_PATH -> ARCH_PATH -> Set to "".
|
|
||||||
|
|
||||||
Command name searching sequence in tools_def.txt file:
|
|
||||||
Name: ARCH_CMD_NAME -> CMD_NAME -> Default Value.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
@param arch the ARCH
|
|
||||||
@param cmd the Command Type
|
|
||||||
@param map detail flags information of tools_def.txt
|
|
||||||
@return the absolute command path and name
|
|
||||||
**/
|
|
||||||
private String getAbsoluteCmdPath(String arch, String cmd, String[][] map) {
|
|
||||||
String path = "";
|
|
||||||
String name = "";
|
|
||||||
String str;
|
|
||||||
//
|
|
||||||
// find Path
|
|
||||||
//
|
|
||||||
if ((str = getValue(arch + "_" + cmd + "_PATH", map)) != null) {
|
|
||||||
path = str;
|
|
||||||
} else if ((str = getValue(arch + "_PATH", map)) != null) {
|
|
||||||
path = str;
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// find Name
|
|
||||||
//
|
|
||||||
if ((str = getValue(arch + "_" + cmd + "_NAME", map)) != null) {
|
|
||||||
name = str;
|
|
||||||
} else if ((str = getValue(cmd + "_NAME", map)) != null) {
|
|
||||||
name = str;
|
|
||||||
} else {
|
|
||||||
name = getValue(cmd, defaultCmdName);
|
|
||||||
}
|
|
||||||
if (path.equalsIgnoreCase("")) {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
return path + File.separatorChar + name;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Find out all global flags value, such as EFI_DEBUG equal YES or NO. Here
|
|
||||||
are three type files: global_efi_flags.txt, ${TARGET}_efi_flags.txt,
|
|
||||||
my_efi_flags.txt. global_efi_flags.txt with the highest priority while
|
|
||||||
my_efi_flags.txt with the lowest priority.
|
|
||||||
|
|
||||||
<p>All global flags value will store in <code>globalFlagsMap</code> for
|
|
||||||
getGlobalFlags using. </p>
|
|
||||||
|
|
||||||
@param target current build TARGET value
|
|
||||||
**/
|
|
||||||
private void parseGlobalSetting(String target){
|
|
||||||
//
|
|
||||||
// parse global_efi_flags -> ${TARGET}_efi_flags -> my_efi_flags
|
|
||||||
// parse global_efi_flags
|
|
||||||
//
|
|
||||||
String[][] map = ConfigReader.parse(confPath, "global_efi_flags.txt");
|
|
||||||
for (int i = 0; i < map.length; i++){
|
|
||||||
if(globalFlagsMap.containsKey(map[i][0])){
|
|
||||||
globalFlagsMap.remove(map[i][0]);
|
|
||||||
}
|
|
||||||
globalFlagsMap.put(map[i][0], map[i][1]);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// parse ${TARGET}_efi_flags
|
|
||||||
//
|
|
||||||
map = ConfigReader.parse(confPath, target.toLowerCase() + "_efi_flags.txt");
|
|
||||||
for (int i = 0; i < map.length; i++){
|
|
||||||
if(globalFlagsMap.containsKey(map[i][0])){
|
|
||||||
globalFlagsMap.remove(map[i][0]);
|
|
||||||
}
|
|
||||||
globalFlagsMap.put(map[i][0], map[i][1]);
|
|
||||||
}
|
|
||||||
//
|
|
||||||
// parse my_efi_flags.txt
|
|
||||||
//
|
|
||||||
map = ConfigReader.parse(confPath, "my_efi_flags.txt");
|
|
||||||
for (int i = 0; i < map.length; i++){
|
|
||||||
if(globalFlagsMap.containsKey(map[i][0])){
|
|
||||||
globalFlagsMap.remove(map[i][0]);
|
|
||||||
}
|
|
||||||
globalFlagsMap.put(map[i][0], map[i][1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Find value with key from map. If not found, return null.
|
|
||||||
|
|
||||||
<p>Note that default is case-insensitive</p>
|
|
||||||
|
|
||||||
@param key key value
|
|
||||||
@param map mapping information
|
|
||||||
@return the related value of key
|
|
||||||
**/
|
|
||||||
private String getValue(String key, String[][] map) {
|
|
||||||
return getValue(key, map, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Find value with key from map. If not found, return null.
|
|
||||||
|
|
||||||
@param key key value
|
|
||||||
@param map mapping information
|
|
||||||
@param caseSensitive whether case sesitive or not
|
|
||||||
@return the related value of key
|
|
||||||
**/
|
|
||||||
private String getValue(String key, String[][] map, boolean caseSensitive) {
|
|
||||||
for (int i = 0; i < map.length; i++) {
|
|
||||||
if (caseSensitive) {
|
|
||||||
if (key.compareTo(map[i][0]) == 0) {
|
|
||||||
return map[i][1];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (key.compareToIgnoreCase(map[i][0]) == 0) {
|
|
||||||
return map[i][1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Find value with key from <code>toolchain</code>. If not found, return null.
|
|
||||||
|
|
||||||
@param key key value
|
|
||||||
@return the related value of key
|
|
||||||
**/
|
|
||||||
public static String getValue(String key){
|
|
||||||
for (int i = 0; i < toolchain.length; i++) {
|
|
||||||
if (key.compareToIgnoreCase(toolchain[i][0]) == 0) {
|
|
||||||
return toolchain[i][1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get Arch list from a string separated with comma.
|
|
||||||
|
|
||||||
<pre>
|
|
||||||
For example:
|
|
||||||
If the arch string is "IA32, X64, EBC".
|
|
||||||
Then the result is {"IA32", "X64", "EBC"}.
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
@param arch string separated with comma
|
|
||||||
@return Arch list
|
|
||||||
**/
|
|
||||||
public String[] getArchs(String arch) {
|
|
||||||
if (arch == null) {
|
|
||||||
return new String[0];
|
|
||||||
}
|
|
||||||
StringTokenizer st = new StringTokenizer(arch, " \t,");
|
|
||||||
String[] archs = new String[st.countTokens()];
|
|
||||||
int i = 0;
|
|
||||||
while (st.hasMoreTokens()) {
|
|
||||||
archs[i++] = st.nextToken().toUpperCase();
|
|
||||||
}
|
|
||||||
return archs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Get current target value.
|
|
||||||
|
|
||||||
@return current target value
|
|
||||||
**/
|
|
||||||
public String getCurrentTarget() {
|
|
||||||
return currentTarget;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Find out Vendor that cmd Command Type with arch ARCH used. The
|
|
||||||
search sequence is ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT". Here
|
|
||||||
we suppose default Vendor is MSFT.
|
|
||||||
|
|
||||||
@param arch the ARCH
|
|
||||||
@param cmd the Command Type
|
|
||||||
@param map detail flags information of tools_def.txt
|
|
||||||
@return the related vendor name
|
|
||||||
**/
|
|
||||||
public String getVendorFlag (String arch, String cmdType, String[][] map){
|
|
||||||
//
|
|
||||||
// ARCH_CMD_VENDOR -> ARCH_VENDOR -> "MSFT"
|
|
||||||
// Here we suppose default Vendor is MSFT.
|
|
||||||
//
|
|
||||||
String str;
|
|
||||||
String vendor = "";
|
|
||||||
if (cmdType != null){
|
|
||||||
if ((str = getValue(arch + "_" + cmdType + "_VENDOR", map)) != null) {
|
|
||||||
vendor = str;
|
|
||||||
}else {
|
|
||||||
vendor = "";
|
|
||||||
}
|
|
||||||
}else if (arch != null){
|
|
||||||
if ((str = getValue(arch + "_VENDOR", map)) != null) {
|
|
||||||
vendor = str;
|
|
||||||
}else {
|
|
||||||
vendor = "";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return vendor;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,219 @@
|
|||||||
|
package org.tianocore.build.toolchain;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class ToolChainInfo {
|
||||||
|
|
||||||
|
private Set<String> targets = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
private Set<String> tagnames = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
private Set<String> archs = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
private Set<String> commands = new LinkedHashSet<String>();
|
||||||
|
|
||||||
|
private Map<String, Set<String>> commandMap = new HashMap<String, Set<String>>();
|
||||||
|
|
||||||
|
public void addTargets(String targetList) {
|
||||||
|
//
|
||||||
|
// targetList some targets separated by space " "
|
||||||
|
//
|
||||||
|
if (targetList == null) {
|
||||||
|
targets.add("*");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
addTargets(targetList.split(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTargets(String[] targetArray) {
|
||||||
|
if (targetArray == null ) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < targetArray.length; i++) {
|
||||||
|
targets.add(targetArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTargets(Set<String> targetSet) {
|
||||||
|
targets.addAll(targetSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTagnames(String tagnameList) {
|
||||||
|
//
|
||||||
|
// tagnameList some tagnames separated by space " "
|
||||||
|
//
|
||||||
|
if (tagnameList == null) {
|
||||||
|
tagnames.add("*");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
addTagnames(tagnameList.split(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTagnames(String[] tagnameArray) {
|
||||||
|
if (tagnameArray == null ) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < tagnameArray.length; i++) {
|
||||||
|
tagnames.add(tagnameArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTagnames(Set<String> tagnameSet) {
|
||||||
|
tagnames.addAll(tagnameSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addArchs(String archList) {
|
||||||
|
//
|
||||||
|
// archList some archs separated by space " "
|
||||||
|
//
|
||||||
|
if (archList == null) {
|
||||||
|
archs.add("*");
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
addArchs(archList.split(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addArchs(String[] archArray) {
|
||||||
|
if (archArray == null ) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < archArray.length; i++) {
|
||||||
|
archs.add(archArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addArchs(Set<String> archSet) {
|
||||||
|
archs.addAll(archSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCommands(String toolChain, String commandList) {
|
||||||
|
//
|
||||||
|
// archList some archs separated by space " "
|
||||||
|
//
|
||||||
|
if (commandList == null || commandList.length() == 0) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
addCommands(commandList.split(" "));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCommands(String[] commandArray) {
|
||||||
|
if (commandArray == null ) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < commandArray.length; i++) {
|
||||||
|
commands.add(commandArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCommands(String toolChain, String[] commandArray) {
|
||||||
|
if (commandArray == null) {
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
Set<String> toolChainCommandSet = commandMap.get(toolChain);
|
||||||
|
if (toolChainCommandSet == null) {
|
||||||
|
toolChainCommandSet = new LinkedHashSet<String>();
|
||||||
|
commandMap.put(toolChain, toolChainCommandSet);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < commandArray.length; i++) {
|
||||||
|
commands.add(commandArray[i]);
|
||||||
|
toolChainCommandSet.add(commandArray[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCommands(String toolChain, Set<String> commandSet) {
|
||||||
|
if (commandSet == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Set<String> toolChainCommandSet = commandMap.get(toolChain);
|
||||||
|
if (toolChainCommandSet == null) {
|
||||||
|
toolChainCommandSet = new LinkedHashSet<String>();
|
||||||
|
commandMap.put(toolChain, toolChainCommandSet);
|
||||||
|
}
|
||||||
|
commands.addAll(commandSet);
|
||||||
|
toolChainCommandSet.addAll(commandSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolChainInfo union(ToolChainInfo info) {
|
||||||
|
ToolChainInfo result = new ToolChainInfo();
|
||||||
|
result.addTargets(union(this.targets, info.targets));
|
||||||
|
result.addTagnames(union(this.tagnames, info.tagnames));
|
||||||
|
result.addArchs(union(this.archs, info.archs));
|
||||||
|
//result.addCommands(union(this.getCommands(), info.getCommands()));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolChainInfo intersection(ToolChainInfo info) {
|
||||||
|
// System.out.println(this + "\n" + info);
|
||||||
|
ToolChainInfo result = new ToolChainInfo();
|
||||||
|
result.addTargets(intersection(this.targets, info.targets));
|
||||||
|
result.addTagnames(intersection(this.tagnames, info.tagnames));
|
||||||
|
result.addArchs(intersection(this.archs, info.archs));
|
||||||
|
// result.addCommands(union(this.commands, info.commands));
|
||||||
|
// System.out.println("result: " + result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<String> union(Set<String> set1, Set<String> set2) {
|
||||||
|
Set<String> result = new LinkedHashSet<String>();
|
||||||
|
result.addAll(set1);
|
||||||
|
result.addAll(set2);
|
||||||
|
result.remove("*");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Set<String> intersection(Set<String> set1, Set<String> set2) {
|
||||||
|
Set<String> result = new LinkedHashSet<String>();
|
||||||
|
boolean set1HasWildcard = set1.contains("*");
|
||||||
|
boolean set2HasWildcard = set2.contains("*");
|
||||||
|
|
||||||
|
if (set1HasWildcard && set2HasWildcard) {
|
||||||
|
result.addAll(set1);
|
||||||
|
result.addAll(set2);
|
||||||
|
} else if (set1HasWildcard) {
|
||||||
|
result.addAll(set2);
|
||||||
|
} else if (set2HasWildcard) {
|
||||||
|
result.addAll(set1);
|
||||||
|
} else {
|
||||||
|
result.addAll(set1);
|
||||||
|
result.retainAll(set2);
|
||||||
|
}
|
||||||
|
|
||||||
|
// result.remove("*");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getTargets() {
|
||||||
|
return (String[])targets.toArray(new String[targets.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getTagnames() {
|
||||||
|
return (String[])tagnames.toArray(new String[tagnames.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getArchs() {
|
||||||
|
return (String[])archs.toArray(new String[archs.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getCommands() {
|
||||||
|
return (String[])commands.toArray(new String[commands.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getCommands(String toolChain) {
|
||||||
|
return commandMap.get(toolChain);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return targets + "\n" + tagnames + "\n" + archs + "\n" + commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void normalize() {
|
||||||
|
targets.remove("*");
|
||||||
|
tagnames.remove("*");
|
||||||
|
archs.remove("*");
|
||||||
|
commands.remove("*");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,177 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
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:
|
||||||
|
ToolChainKey.java
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
package org.tianocore.build.toolchain;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
import org.tianocore.build.exception.EdkException;
|
||||||
|
|
||||||
|
public class ToolChainKey implements java.io.Serializable, Comparable<ToolChainKey> {
|
||||||
|
|
||||||
|
private String delimiter = "_";
|
||||||
|
|
||||||
|
public final static int keyLength = 5;
|
||||||
|
|
||||||
|
private String[] keySet = null;
|
||||||
|
|
||||||
|
private String keyString = null;
|
||||||
|
|
||||||
|
private int hashValue = 0;
|
||||||
|
|
||||||
|
public ToolChainKey(String keyString, String delimiter) throws Exception {
|
||||||
|
setKey(keyString, delimiter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolChainKey(String keyString) throws EdkException {
|
||||||
|
setKey(keyString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ToolChainKey(String[] keySet) throws EdkException {
|
||||||
|
setKey(keySet);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
if (hashValue != 0) {
|
||||||
|
return hashValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < keySet.length; ++i) {
|
||||||
|
char[] keyStringValue = new char[keySet[i].length()];
|
||||||
|
this.keySet[i].getChars(0, keyStringValue.length, keyStringValue, 0);
|
||||||
|
|
||||||
|
for (int j = 0; j < keyStringValue.length; ++j) {
|
||||||
|
hashValue = keyStringValue[j] + hashValue * 31;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return hashValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int compareTo(ToolChainKey dstKey) {
|
||||||
|
String[] dstKeySet = dstKey.getKeySet();
|
||||||
|
int result = 0;
|
||||||
|
for (int i = 0; i < this.keyLength; ++i) {
|
||||||
|
result = this.keySet[i].compareToIgnoreCase(dstKeySet[i]);
|
||||||
|
if (result != 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
ToolChainKey dstKey = (ToolChainKey)o;
|
||||||
|
String[] dstKeySet = dstKey.getKeySet();
|
||||||
|
|
||||||
|
if (this == dstKey) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dstKeySet.length != this.keyLength) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < this.keyLength; ++i) {
|
||||||
|
if (!this.keySet[i].equalsIgnoreCase(dstKeySet[i])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String[] keySet) throws EdkException {
|
||||||
|
if (keySet.length != this.keyLength) {
|
||||||
|
throw new EdkException("Invalid ToolChain key");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.keySet = new String[this.keyLength];
|
||||||
|
System.arraycopy(keySet, 0, this.keySet, 0, this.keyLength);
|
||||||
|
for (int i = 0; i < this.keyLength; ++i) {
|
||||||
|
if (this.keySet[i] == null || this.keySet[i].length() == 0) {
|
||||||
|
this.keySet[i] = "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.keyString = null;
|
||||||
|
this.hashValue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String keySetString, int index) throws EdkException {
|
||||||
|
if (index >= this.keyLength) {
|
||||||
|
throw new EdkException("Invalid ToolChain key index");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keySetString == null || keySetString.length() == 0) {
|
||||||
|
keySetString = "*";
|
||||||
|
}
|
||||||
|
this.keySet[index] = keySetString;
|
||||||
|
this.keyString = null;
|
||||||
|
this.hashValue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String keyString) throws EdkException {
|
||||||
|
this.keySet = keyString.split(this.delimiter);
|
||||||
|
|
||||||
|
if (this.keySet.length != this.keyLength) {
|
||||||
|
throw new EdkException("Invalid ToolChain key");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.keyString = keyString;
|
||||||
|
this.hashValue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setKey(String keyString, String delimiter) throws Exception {
|
||||||
|
this.keySet = keyString.split(delimiter);
|
||||||
|
|
||||||
|
if (this.keySet.length != this.keyLength) {
|
||||||
|
throw new Exception("Invalid ToolChain key");
|
||||||
|
}
|
||||||
|
|
||||||
|
this.keyString = keyString;
|
||||||
|
this.delimiter = delimiter;
|
||||||
|
this.hashValue = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getKeySet() {
|
||||||
|
return keySet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
if (this.keyString == null) {
|
||||||
|
StringBuffer keyStringBuf = new StringBuffer(64);
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
keyStringBuf.append(this.keySet[i++]);
|
||||||
|
for (; i < this.keyLength; ++i) {
|
||||||
|
keyStringBuf.append(this.delimiter);
|
||||||
|
keyStringBuf.append(this.keySet[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.keyString = keyStringBuf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.keyString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,165 @@
|
|||||||
|
/*++
|
||||||
|
|
||||||
|
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:
|
||||||
|
ToolChainMap.java
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
package org.tianocore.build.toolchain;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.tianocore.build.exception.EdkException;
|
||||||
|
|
||||||
|
public class ToolChainMap {
|
||||||
|
|
||||||
|
private int matchLevel = ToolChainKey.keyLength - 2;
|
||||||
|
|
||||||
|
private Map<ToolChainKey, String> map = null;
|
||||||
|
|
||||||
|
public ToolChainMap() {
|
||||||
|
//this.map = new TreeMap<ToolChainKey, String>();
|
||||||
|
this.map = new HashMap<ToolChainKey, String>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String put(String key, String delimiter, String value)throws EdkException {
|
||||||
|
ToolChainKey toolChainKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
toolChainKey = new ToolChainKey(key, delimiter);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
return (String)map.put(toolChainKey, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String put(String key, String value) throws EdkException {
|
||||||
|
ToolChainKey toolChainKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
toolChainKey = new ToolChainKey(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
return (String)map.put(toolChainKey, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String put(String[] key, String value) throws EdkException {
|
||||||
|
ToolChainKey toolChainKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
toolChainKey = new ToolChainKey(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
return (String)map.put(toolChainKey, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String put(ToolChainKey key, String value) {
|
||||||
|
return (String)map.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(String key) throws EdkException {
|
||||||
|
ToolChainKey toolChainKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
toolChainKey = new ToolChainKey(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
return get(toolChainKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(String key, String delimiter) throws EdkException {
|
||||||
|
ToolChainKey toolChainKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
toolChainKey = new ToolChainKey(key, delimiter);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
return get(toolChainKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(String[] key) throws EdkException {
|
||||||
|
ToolChainKey toolChainKey;
|
||||||
|
|
||||||
|
try {
|
||||||
|
toolChainKey = new ToolChainKey(key);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
return get(toolChainKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String get(ToolChainKey key) throws EdkException {
|
||||||
|
String result = map.get(key);
|
||||||
|
if (result != null || map.containsKey(key)) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] keySet = key.getKeySet();
|
||||||
|
ToolChainKey tmpKey;
|
||||||
|
try {
|
||||||
|
tmpKey = new ToolChainKey(keySet);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
int level = matchLevel;
|
||||||
|
while (level >= 0) {
|
||||||
|
int tmpLevel = level;
|
||||||
|
while (tmpLevel >= level) {
|
||||||
|
String[] tmpKeySet = tmpKey.getKeySet();
|
||||||
|
try {
|
||||||
|
if (!tmpKeySet[tmpLevel].equals("*")) {
|
||||||
|
tmpKey.setKey("*", tmpLevel);
|
||||||
|
tmpLevel = matchLevel;
|
||||||
|
} else {
|
||||||
|
tmpKey.setKey(keySet[tmpLevel], tmpLevel);
|
||||||
|
--tmpLevel;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new EdkException(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
result = map.get(tmpKey);
|
||||||
|
if (result != null) {
|
||||||
|
map.put(key, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--level;
|
||||||
|
}
|
||||||
|
|
||||||
|
map.put(key, result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int size() {
|
||||||
|
return map.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<ToolChainKey> keySet() {
|
||||||
|
return (Set<ToolChainKey>)map.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
// public String toString() {
|
||||||
|
// return map.toString();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
@ -15,6 +15,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
**/
|
**/
|
||||||
package org.tianocore.build.toolchain;
|
package org.tianocore.build.toolchain;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import org.apache.tools.ant.BuildException;
|
import org.apache.tools.ant.BuildException;
|
||||||
import org.apache.tools.ant.Task;
|
import org.apache.tools.ant.Task;
|
||||||
|
|
||||||
@ -25,7 +27,13 @@ import org.apache.tools.ant.Task;
|
|||||||
@since GenBuild 1.0
|
@since GenBuild 1.0
|
||||||
**/
|
**/
|
||||||
public class ToolChainTask extends Task{
|
public class ToolChainTask extends Task{
|
||||||
|
///
|
||||||
|
/// environment variable name of toolchain
|
||||||
|
///
|
||||||
|
static private String toolsEnv = "env.TOOLS_DEF";
|
||||||
|
///
|
||||||
|
/// configuration file path
|
||||||
|
///
|
||||||
private String confPath = ".";
|
private String confPath = ".";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,10 +51,9 @@ public class ToolChainTask extends Task{
|
|||||||
Config files are invalid.
|
Config files are invalid.
|
||||||
**/
|
**/
|
||||||
public void execute() throws BuildException {
|
public void execute() throws BuildException {
|
||||||
String toolChain = getProject().getProperty("env.TOOL_CHAIN");
|
String toolChain = getProject().getProperty(toolsEnv);
|
||||||
ToolChainFactory toolchain = new ToolChainFactory(confPath, toolChain);
|
// ToolChainConfig toolchain = new ToolChainConfig(new File(confPath + File.separatorChar + toolChain));
|
||||||
toolchain.setupToolChain();
|
//getProject().setProperty("TARGET", toolchain.getCurrentTarget());
|
||||||
getProject().setProperty("TARGET", toolchain.getCurrentTarget());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user