Change module build sequence. 1. Get FvImageName list according to their declaration order in the fpd file. 2. First build all modules in the first fvimage, then build all modules in the second fvimage, and so on. These modules sequence is still from their layout in the fpd file. 3. At last, build the remaining modules whose FVBinding = NULL. And also clean some unused code, and add and update some comments.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1320 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
wuyizhong 2006-08-18 05:37:49 +00:00
parent 45649fb700
commit 4b5f554990
6 changed files with 171 additions and 230 deletions

View File

@ -32,8 +32,7 @@ import org.w3c.dom.Element;
/**
<p><code>FfsProcess</code> is a class to find the corresponding FFS layout. </p>
<p>Property <code>COMMON_FILE</code> specified which file to search. The element
in <code>COMMON_FILE</code> is like following: </p>
<p>The FFS Layout is like following: </p>
<pre>
&lt;Ffs type="APPLICATION"&gt;
@ -104,14 +103,13 @@ public class FfsProcess {
}
/**
Find the corresponding FFS layout in <code>COMMON_FILE</code> if it
does not specify in module's surface area.
Find the corresponding FFS layout in <code>FPD</code>.
@param buildType Current module's component type
@param project Ant project
@return whether find the corresponding FFS layout
@throws BuildException
If specified COMMON_FILE XML file is not valide.
If can't find FFS Layout in FPD.
**/
public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException {
//

View File

@ -55,6 +55,7 @@ import org.tianocore.build.tools.ModuleItem;
<p>The main function of this task is to parse module's surface area (MSA),
then generate the corresponding <em>BaseName_build.xml</em> (the real ANT
build script) and call this to build the module. The whole process including:
<pre>
1. generate AutoGen.c and AutoGen.h;
2. build all dependent library instances;
@ -69,24 +70,26 @@ import org.tianocore.build.tools.ModuleItem;
</p>
<pre>
&lt;GenBuild
msaFilename=&quot;HelloWorld.msa&quot;/&gt;
processTo=&quot;ALL&quot;/&gt;
&lt;GenBuild
msaFile="${PACKAGE_DIR}/Application/HelloWorld/HelloWorld.msa"
type="cleanall" /&gt;
</pre>
<p><code>processTo</code> provides a way to customize the whole build process.
processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.
Default is ALL, means whole
</p>
<p>
This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and
<em>AutoGen.h</em>. The task also parses the development environment
configuration files, such as collecting package information, setting compiler
flags and so on.
<em>AutoGen.h</em>.
</p>
<p>
This task will also set properties for current module, such as PACKAGE,
PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR
(relative to Workspace), MODULE or BASE_NAME, GUID, VERSION, MODULE_DIR,
MODULE_RELATIVE_DIR (relative to Package), CONFIG_DIR, BIN_DIR,
DEST_DIR_DEBUG, DEST_DIR_OUTPUT, TARGET, ARCH, TOOLCHAIN, TOOLCHAIN_FAMILY,
SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH, all compiler command related
properties (CC, CC_FLAGS, CC_DPATH, CC_SPATH, CC_FAMILY, CC_EXT).
</p>
@since GenBuild 1.0
**/
public class GenBuildTask extends Ant {
@ -569,7 +572,7 @@ public class GenBuildTask extends Ant {
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");
System.out.println("Call user-defined " + moduleId.getName() + "_build.xml");
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
antCall(antFilename, null);
@ -599,7 +602,7 @@ public class GenBuildTask extends Ant {
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml");
System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
antCall(antFilename, "clean");
@ -617,7 +620,7 @@ public class GenBuildTask extends Ant {
// then call the exist BaseName_build.xml directly.
//
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {
GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml");
System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";
antCall(antFilename, "cleanall");

View File

@ -26,9 +26,7 @@ import java.util.Set;
**/
public class CommonDefinition {
public final static String spdSuffix = ".spd";
public final static String mbdSuffix = ".mbd";
public final static String msaSuffix = ".msa";
public final static String LibraryStr = "LIBRARY";
public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n";
public final static String include = "#include";
@ -58,18 +56,18 @@ public class CommonDefinition {
public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";
public final static String flashMapH = "FlashMap.h";
//
// The defintions for identifying current module
// is PEI Pcd driver or Dxe Pcd driver.
//
///
/// The defintions for identifying current module
/// is PEI Pcd driver or Dxe Pcd driver.
///
public static enum PCD_DRIVER_TYPE { NOT_PCD_DRIVER,
PEI_PCD_DRIVER,
DXE_PCD_DRIVER,
UNKNOWN_PCD_DRIVER};
//
// AutoGen.h and AutoGen.c file's header
//
///
/// AutoGen.h and AutoGen.c file's header
///
public final static String autogenHNotation =
"/**\r\n" +
" DO NOT EDIT\r\n" +
@ -90,9 +88,9 @@ public class CommonDefinition {
" Auto-generated AutoGen.c for building module or library.\r\n" +
"**/\r\n\r\n";
//
// module type
//
///
/// module type
///
public final static int ModuleTypeBase = 0;
public final static int ModuleTypeSec = 1;
public final static int ModuleTypePeiCore = 2;
@ -106,35 +104,9 @@ public class CommonDefinition {
public final static int ModuleTypeUefiApplication = 10;
public final static int ModuleTypeUnknown = 11;
//
// component type
//
public final static int ComponentTypeNull = 0;
public final static int ComponentTypeApriori = 1;
public final static int ComponentTypeSec = 2;
public final static int ComponentTypeLibrary = 3;
public final static int ComponentTypeFvImageFile = 4;
public final static int ComponentTypeBsDriver = 5;
public final static int ComponentTypeRtDriver = 6;
public final static int ComponentTypeSalRtDriver =7;
public final static int ComponentTypePe32Peim = 8;
public final static int ComponentTypePicPeim =9;
public final static int ComponentTypeCombinedPeimDriver =10;
public final static int ComponentTypePeiCore = 11;
public final static int ComponentTypeDxeCore = 12;
public final static int ComponentTypeApplication = 13;
public final static int ComponentTypeBsDriverEfi = 14;
public final static int ComponentTypeShellApp = 15;
public final static int ComponentTypeBinary =16;
public final static int ComponentTypeLogo = 17;
public final static int ComponentTypeCustomBuild = 18;
public final static int ComponentTypeUnknown = 19;
//
// Usaged style
//
///
/// Usaged style
///
public final static String AlwaysConsumed = "ALWAYS_CONSUMED";
public final static String AlwaysProduced = "ALWAYS_PRODUCED";
@ -156,9 +128,9 @@ public class CommonDefinition {
}
}
//
// Module type
//
///
/// Module type
///
public static final MyEnum[] moduleEnum = new MyEnum[] {
new MyEnum("BASE", ModuleTypeBase),
new MyEnum("SEC", ModuleTypeSec),
@ -172,30 +144,6 @@ public class CommonDefinition {
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication)};
//
// Component type
//
public static final MyEnum[] componentEnum = new MyEnum[]{
new MyEnum("APRIORI", ComponentTypeApriori),
new MyEnum("SEC", ComponentTypeSec),
new MyEnum("LIBRARY", ComponentTypeLibrary),
new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile),
new MyEnum("BS_DRIVER", ComponentTypeBsDriver),
new MyEnum("RT_DRIVER", ComponentTypeRtDriver),
new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver),
new MyEnum("PE32_PEIM", ComponentTypePe32Peim),
new MyEnum("PIC_PEIM", ComponentTypePicPeim),
new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver),
new MyEnum("PEI_CORE", ComponentTypePeiCore),
new MyEnum("DXE_CORE", ComponentTypeDxeCore),
new MyEnum("APPLICATION", ComponentTypeApplication),
new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi),
new MyEnum("SHELLAPP", ComponentTypeShellApp),
new MyEnum("BINARY", ComponentTypeBinary),
new MyEnum("LOGO", ComponentTypeLogo),
new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)
};
/**
getModuleType
@ -216,71 +164,14 @@ public class CommonDefinition {
}
/**
getComponentType
formateGuidName
This function get the component type value according commponet type
string.
This function is to formate GUID to ANSI c form.
@param componentTypeStr String of component type.
@return
@param guidNameCon
String of GUID.
@return Formated GUID.
**/
static public int getComponentType (String componentTypeStr){
int returnValue = -1;
for (int i = 0; i < CommonDefinition.componentEnum.length; i++) {
returnValue = CommonDefinition.componentEnum[i].ForInt(componentTypeStr);
if (returnValue != -1) {
return returnValue;
}
}
return CommonDefinition.ComponentTypeUnknown;
}
/**
getComponentTypeString
This function get the commponet type string according component type value.
@param componentType Integer value of component type.
@return
**/
static public String getComponentTypeString (int componentType) {
if ((componentType > CommonDefinition.ComponentTypeUnknown) ||
(componentType < CommonDefinition.ComponentTypeNull)) {
return null;
}
for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) {
if (componentType == CommonDefinition.componentEnum[index].type) {
return CommonDefinition.componentEnum[index].moduleTypeStr;
}
}
return null;
}
/**
isLibraryComponent
This function is to check does componet is library according to commponet
type value.
@param componentType Integer value of component type.
@return
**/
static public boolean isLibraryComponent (int componentType) {
if (ComponentTypeLibrary == componentType) {
return true;
}
return false;
}
/**
* formateGuidName
*
* This function is to formate GUID to ANSI c form.
*
* @param guidNameCon
* String of GUID.
* @return Formated GUID.
*/
public static String formatGuidName(String guidNameConv) {
String[] strList;
String guid = "";
@ -332,14 +223,14 @@ public class CommonDefinition {
}
/**
* Remove deuplicat string in list
*
* This function is to duplicat string in list
*
* @param String[]
* String list.
* @return String[] String list which remove the duplicate string.
*/
Remove deuplicat string in list
This function is to duplicat string in list
@param String[]
String list.
@return String[] String list which remove the duplicate string.
**/
public static String[] remDupString (String[] orgList){
Set<String> strList = new LinkedHashSet<String>();
String[] desList ;

View File

@ -55,8 +55,7 @@ import org.tianocore.build.toolchain.ToolChainMap;
and BUILD_DIR. </p>
<p>The task generates ${PLATFORM}_build.xml file which will be called by top level
build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage)
and flash definition file (File is for Tool FlashMap) if necessary. </p>
build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage). </p>
<p>FpdParserTask task stores all FPD information to GlobalData. And parse
tools definition file to set up compiler options for different Target and
@ -70,9 +69,6 @@ import org.tianocore.build.toolchain.ToolChainMap;
&lt;FPDParser platformName="Nt32" /&gt;
</pre>
<p>The task will initialize all information through parsing Framework Database,
SPD, Tool chain configuration files. </p>
@since GenBuild 1.0
**/
public class FpdParserTask extends Task {
@ -102,7 +98,6 @@ public class FpdParserTask extends Task {
private boolean isUnified = true;
/**
Public construct method. It is necessary for ANT task.
**/
@ -174,7 +169,7 @@ public class FpdParserTask extends Task {
//
// Gen build.xml
//
PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, isUnified);
PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified);
fileGenerator.genBuildFile();
//

View File

@ -12,6 +12,7 @@
package org.tianocore.build.fpd;
import java.io.File;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
@ -52,6 +53,12 @@ public class PlatformBuildFileGenerator {
/// 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 = new HashMap<String, Set<FpdModuleIdentification>>();
private boolean isUnified = true;
@ -63,10 +70,11 @@ public class PlatformBuildFileGenerator {
+ "Abstract:\n"
+ "Auto-generated ANT build file for building EFI Modules and Platforms\n";
public PlatformBuildFileGenerator(Project project, Map<FpdModuleIdentification, String> outfiles, boolean isUnified){
public PlatformBuildFileGenerator(Project project, Map<FpdModuleIdentification, String> outfiles, Map<String, Set<FpdModuleIdentification>> fvs, boolean isUnified){
this.project = project;
this.outfiles = outfiles;
this.isUnified = isUnified;
this.fvs = fvs;
this.platformName = project.getProperty("PLATFORM");
}
@ -173,68 +181,119 @@ public class PlatformBuildFileGenerator {
}
}
/**
1. Get All valid Fv Image Names in sequence
2. For each FV, get modules by sequences
3. Get other modules
@param document XML document
@param root Node
**/
private void applyModules(Document document, Node root) {
root.appendChild(document.createComment("Modules target"));
Element ele = document.createElement("target");
ele.setAttribute("name", "modules");
Set<FpdModuleIdentification> set = outfiles.keySet();
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);
//
// Get all valid FV name
//
String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();
//
// For each valid FV, get all modules in sequence
//
for (int i = 0; i < validFv.length; i++) {
if (fvs.containsKey(validFv[i])) {
Set<FpdModuleIdentification> set = fvs.get(validFv[i]);
Iterator<FpdModuleIdentification> iter = set.iterator();
while (iter.hasNext()) {
FpdModuleIdentification fpdModuleId = iter.next();
applySingleModule(document, ele, fpdModuleId);
}
}
}
//
// Get all other modules
//
Iterator<String> fvsNameIter = fvs.keySet().iterator();
while (fvsNameIter.hasNext()) {
String fvName = fvsNameIter.next();
if (!isContain(validFv, fvName)) {
Set<FpdModuleIdentification> set = fvs.get(fvName);
Iterator iter = set.iterator();
while (iter.hasNext()) {
FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();
applySingleModule(document, ele, fpdModuleId);
}
}
}
root.appendChild(ele);
}
private void applySingleModule(Document document, Node root, FpdModuleIdentification fpdModuleId) {
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);
root.appendChild(moduleEle);
}
private boolean isContain(String[] list, String item) {
for (int i = 0; i < list.length; i++) {
if (list[i].equalsIgnoreCase(item)) {
return true;
}
}
return false;
}
private void applyFvs(Document document, Node root) {
//
// FVS Target

View File

@ -23,7 +23,6 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import org.apache.tools.ant.BuildException;
import org.apache.xmlbeans.XmlObject;
@ -57,9 +56,6 @@ import org.tianocore.build.toolchain.ToolChainMap;
@since GenBuild 1.0
**/
public class GlobalData {
public static Logger log = Logger.getAnonymousLogger();
///
/// Record current WORKSPACE Directory
///
@ -654,10 +650,10 @@ public class GlobalData {
return result;
}
////// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
///
/// Tool Chain Related, try to refine and put some logic process to ToolChainFactory
///
public static ToolChainInfo getToolChainInfo() {
// GlobalData.log.info(toolsDef.getConfigInfo() + "" + toolChainEnvInfo + toolChainPlatformInfo);
if (toolChainInfo == null) {
toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);
if (toolChainPlatformInfo != null) {
@ -665,13 +661,12 @@ public class GlobalData {
}
toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());
toolChainInfo.normalize();
GlobalData.log.info(toolChainInfo + "");
System.out.println("Current build tool chain information summary: ");
System.out.println(toolChainInfo + "");
}
return toolChainInfo;
}
public static void setPlatformToolChainFamilyOption(ToolChainMap map) {
platformToolChainFamilyOption = map;
}