/** \r
<p><code>FfsProcess</code> is a class to find the corresponding FFS layout. </p>\r
\r
- <p>Property <code>COMMON_FILE</code> specified which file to search. The element\r
- in <code>COMMON_FILE</code> is like following: </p>\r
+ <p>The FFS Layout is like following: </p>\r
\r
<pre>\r
<Ffs type="APPLICATION">\r
}\r
\r
/**\r
- Find the corresponding FFS layout in <code>COMMON_FILE</code> if it\r
- does not specify in module's surface area. \r
+ Find the corresponding FFS layout in <code>FPD</code>. \r
\r
@param buildType Current module's component type\r
@param project Ant project\r
@return whether find the corresponding FFS layout\r
@throws BuildException\r
- If specified COMMON_FILE XML file is not valide.\r
+ If can't find FFS Layout in FPD.\r
**/\r
public boolean initSections(String buildType, Project project, FpdModuleIdentification fpdModuleId) throws BuildException {\r
//\r
<p>The main function of this task is to parse module's surface area (MSA),\r
then generate the corresponding <em>BaseName_build.xml</em> (the real ANT\r
build script) and call this to build the module. The whole process including:\r
+ \r
<pre>\r
1. generate AutoGen.c and AutoGen.h; \r
2. build all dependent library instances;\r
</p>\r
\r
<pre>\r
- <GenBuild\r
- msaFilename="HelloWorld.msa"/>\r
- processTo="ALL"/>\r
+ <GenBuild \r
+ msaFile="${PACKAGE_DIR}/Application/HelloWorld/HelloWorld.msa"\r
+ type="cleanall" />\r
</pre>\r
\r
- <p><code>processTo</code> provides a way to customize the whole build process.\r
- processTo can be one value of ALL, AUTOGEN, FILES, LIBRARYINSTANCES, SECTIONS, NONE.\r
- Default is ALL, means whole\r
- </p>\r
-\r
<p>\r
This task calls <code>AutoGen</code> to generate <em>AutoGen.c</em> and\r
- <em>AutoGen.h</em>. The task also parses the development environment\r
- configuration files, such as collecting package information, setting compiler\r
- flags and so on.\r
+ <em>AutoGen.h</em>. \r
</p>\r
\r
-\r
+ <p>\r
+ This task will also set properties for current module, such as PACKAGE, \r
+ PACKAGE_GUID, PACKAGE_VERSION, PACKAGE_DIR, PACKAGE_RELATIVE_DIR \r
+ (relative to Workspace), MODULE or BASE_NAME, GUID, VERSION, MODULE_DIR, \r
+ MODULE_RELATIVE_DIR (relative to Package), CONFIG_DIR, BIN_DIR, \r
+ DEST_DIR_DEBUG, DEST_DIR_OUTPUT, TARGET, ARCH, TOOLCHAIN, TOOLCHAIN_FAMILY, \r
+ SUBSYSTEM, ENTRYPOINT, EBC_TOOL_LIB_PATH, all compiler command related \r
+ properties (CC, CC_FLAGS, CC_DPATH, CC_SPATH, CC_FAMILY, CC_EXT). \r
+ </p>\r
+ \r
@since GenBuild 1.0\r
**/\r
public class GenBuildTask extends Ant {\r
// then call the exist BaseName_build.xml directly.\r
//\r
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r
- GlobalData.log.info("Call user-defined " + moduleId.getName() + "_build.xml");\r
+ System.out.println("Call user-defined " + moduleId.getName() + "_build.xml");\r
\r
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r
antCall(antFilename, null);\r
// then call the exist BaseName_build.xml directly.\r
//\r
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r
- GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml");\r
+ System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");\r
\r
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r
antCall(antFilename, "clean");\r
// then call the exist BaseName_build.xml directly.\r
//\r
if (moduleId.getModuleType().equalsIgnoreCase("USER_DEFINED")) {\r
- GlobalData.log.info("Calling user-defined " + moduleId.getName() + "_build.xml");\r
+ System.out.println("Calling user-defined " + moduleId.getName() + "_build.xml");\r
\r
String antFilename = getProject().getProperty("MODULE_DIR") + File.separatorChar + moduleId.getName() + "_build.xml";\r
antCall(antFilename, "cleanall");\r
\r
**/\r
public class CommonDefinition {\r
- public final static String spdSuffix = ".spd";\r
- public final static String mbdSuffix = ".mbd";\r
- public final static String msaSuffix = ".msa";\r
+\r
public final static String LibraryStr = "LIBRARY";\r
public final static String autoGenHbegin = "extern int __make_me_compile_correctly;\r\n";\r
public final static String include = "#include";\r
public final static String tianoR8FlashMapH = "TianoR8FlashMap.h";\r
public final static String flashMapH = "FlashMap.h";\r
\r
- //\r
- // The defintions for identifying current module\r
- // is PEI Pcd driver or Dxe Pcd driver.\r
- // \r
+ ///\r
+ /// The defintions for identifying current module\r
+ /// is PEI Pcd driver or Dxe Pcd driver.\r
+ /// \r
public static enum PCD_DRIVER_TYPE { NOT_PCD_DRIVER,\r
PEI_PCD_DRIVER, \r
DXE_PCD_DRIVER,\r
UNKNOWN_PCD_DRIVER};\r
\r
- //\r
- // AutoGen.h and AutoGen.c file's header\r
- //\r
+ ///\r
+ /// AutoGen.h and AutoGen.c file's header\r
+ ///\r
public final static String autogenHNotation = \r
"/**\r\n" +\r
" DO NOT EDIT\r\n" +\r
" Auto-generated AutoGen.c for building module or library.\r\n" +\r
"**/\r\n\r\n";\r
\r
- //\r
- // module type\r
- //\r
+ ///\r
+ /// module type\r
+ ///\r
public final static int ModuleTypeBase = 0;\r
public final static int ModuleTypeSec = 1;\r
public final static int ModuleTypePeiCore = 2;\r
public final static int ModuleTypeUefiApplication = 10;\r
public final static int ModuleTypeUnknown = 11;\r
\r
-\r
- //\r
- // component type\r
- // \r
- public final static int ComponentTypeNull = 0;\r
- public final static int ComponentTypeApriori = 1;\r
- public final static int ComponentTypeSec = 2;\r
- public final static int ComponentTypeLibrary = 3;\r
- public final static int ComponentTypeFvImageFile = 4;\r
- public final static int ComponentTypeBsDriver = 5;\r
- public final static int ComponentTypeRtDriver = 6;\r
- public final static int ComponentTypeSalRtDriver =7;\r
- public final static int ComponentTypePe32Peim = 8;\r
- public final static int ComponentTypePicPeim =9;\r
- public final static int ComponentTypeCombinedPeimDriver =10;\r
- public final static int ComponentTypePeiCore = 11;\r
- public final static int ComponentTypeDxeCore = 12;\r
- public final static int ComponentTypeApplication = 13;\r
- public final static int ComponentTypeBsDriverEfi = 14;\r
- public final static int ComponentTypeShellApp = 15;\r
- public final static int ComponentTypeBinary =16;\r
- public final static int ComponentTypeLogo = 17;\r
- public final static int ComponentTypeCustomBuild = 18;\r
- public final static int ComponentTypeUnknown = 19;\r
-\r
-\r
- //\r
- // Usaged style\r
- //\r
+ ///\r
+ /// Usaged style\r
+ ///\r
public final static String AlwaysConsumed = "ALWAYS_CONSUMED";\r
public final static String AlwaysProduced = "ALWAYS_PRODUCED";\r
\r
}\r
}\r
\r
- //\r
- // Module type\r
- //\r
+ ///\r
+ /// Module type\r
+ ///\r
public static final MyEnum[] moduleEnum = new MyEnum[] {\r
new MyEnum("BASE", ModuleTypeBase),\r
new MyEnum("SEC", ModuleTypeSec),\r
new MyEnum("UEFI_DRIVER", ModuleTypeUefiDriver),\r
new MyEnum("UEFI_APPLICATION", ModuleTypeUefiApplication)};\r
\r
- //\r
- // Component type\r
- //\r
- public static final MyEnum[] componentEnum = new MyEnum[]{\r
- new MyEnum("APRIORI", ComponentTypeApriori),\r
- new MyEnum("SEC", ComponentTypeSec),\r
- new MyEnum("LIBRARY", ComponentTypeLibrary),\r
- new MyEnum("FV_IMAGE_FILE", ComponentTypeFvImageFile),\r
- new MyEnum("BS_DRIVER", ComponentTypeBsDriver),\r
- new MyEnum("RT_DRIVER", ComponentTypeRtDriver),\r
- new MyEnum("SAL_RT_DRIVER", ComponentTypeSalRtDriver),\r
- new MyEnum("PE32_PEIM", ComponentTypePe32Peim),\r
- new MyEnum("PIC_PEIM", ComponentTypePicPeim),\r
- new MyEnum("COMBINED_PEIM_DRIVER", ComponentTypeCombinedPeimDriver),\r
- new MyEnum("PEI_CORE", ComponentTypePeiCore),\r
- new MyEnum("DXE_CORE", ComponentTypeDxeCore),\r
- new MyEnum("APPLICATION", ComponentTypeApplication),\r
- new MyEnum("BS_DRIVER_EFI", ComponentTypeBsDriverEfi),\r
- new MyEnum("SHELLAPP", ComponentTypeShellApp),\r
- new MyEnum("BINARY", ComponentTypeBinary),\r
- new MyEnum("LOGO", ComponentTypeLogo),\r
- new MyEnum("CUSTOM_BUILD", ComponentTypeCustomBuild)\r
- };\r
-\r
/**\r
getModuleType\r
\r
}\r
\r
/**\r
- getComponentType\r
- \r
- This function get the component type value according commponet type \r
- string.\r
- \r
- @param componentTypeStr String of component type.\r
- @return\r
- **/\r
- static public int getComponentType (String componentTypeStr){\r
- int returnValue = -1;\r
- for (int i = 0; i < CommonDefinition.componentEnum.length; i++) {\r
- returnValue = CommonDefinition.componentEnum[i].ForInt(componentTypeStr);\r
- if (returnValue != -1) {\r
- return returnValue;\r
- }\r
- }\r
- return CommonDefinition.ComponentTypeUnknown;\r
- }\r
-\r
- /**\r
- getComponentTypeString\r
- \r
- This function get the commponet type string according component type value.\r
- \r
- @param componentType Integer value of component type.\r
- @return\r
- **/\r
- static public String getComponentTypeString (int componentType) {\r
- if ((componentType > CommonDefinition.ComponentTypeUnknown) || \r
- (componentType < CommonDefinition.ComponentTypeNull)) {\r
- return null;\r
- }\r
- for (int index = 0; index < CommonDefinition.componentEnum.length; index ++) {\r
- if (componentType == CommonDefinition.componentEnum[index].type) {\r
- return CommonDefinition.componentEnum[index].moduleTypeStr;\r
- }\r
- }\r
- return null;\r
- }\r
-\r
- /**\r
- isLibraryComponent \r
+ formateGuidName\r
\r
- This function is to check does componet is library according to commponet\r
- type value.\r
+ This function is to formate GUID to ANSI c form.\r
\r
- @param componentType Integer value of component type.\r
- @return\r
+ @param guidNameCon\r
+ String of GUID.\r
+ @return Formated GUID.\r
**/\r
- static public boolean isLibraryComponent (int componentType) {\r
- if (ComponentTypeLibrary == componentType) {\r
- return true;\r
- }\r
- return false;\r
- }\r
-\r
- /**\r
- * formateGuidName\r
- * \r
- * This function is to formate GUID to ANSI c form.\r
- * \r
- * @param guidNameCon\r
- * String of GUID.\r
- * @return Formated GUID.\r
- */\r
public static String formatGuidName(String guidNameConv) {\r
String[] strList;\r
String guid = "";\r
}\r
\r
/**\r
- * Remove deuplicat string in list\r
- * \r
- * This function is to duplicat string in list\r
- * \r
- * @param String[]\r
- * String list.\r
- * @return String[] String list which remove the duplicate string.\r
- */\r
+ Remove deuplicat string in list\r
+ \r
+ This function is to duplicat string in list\r
+ \r
+ @param String[]\r
+ String list.\r
+ @return String[] String list which remove the duplicate string.\r
+ **/\r
public static String[] remDupString (String[] orgList){\r
Set<String> strList = new LinkedHashSet<String>();\r
String[] desList ;\r
and BUILD_DIR. </p>\r
\r
<p>The task generates ${PLATFORM}_build.xml file which will be called by top level\r
- build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage)\r
- and flash definition file (File is for Tool FlashMap) if necessary. </p>\r
+ build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage). </p>\r
\r
<p>FpdParserTask task stores all FPD information to GlobalData. And parse\r
tools definition file to set up compiler options for different Target and\r
<FPDParser platformName="Nt32" />\r
</pre>\r
\r
- <p>The task will initialize all information through parsing Framework Database,\r
- SPD, Tool chain configuration files. </p>\r
-\r
@since GenBuild 1.0\r
**/\r
public class FpdParserTask extends Task {\r
\r
private boolean isUnified = true;\r
\r
-\r
/**\r
Public construct method. It is necessary for ANT task.\r
**/\r
//\r
// Gen build.xml\r
//\r
- PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, isUnified);\r
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified);\r
fileGenerator.genBuildFile();\r
\r
//\r
package org.tianocore.build.fpd;\r
\r
import java.io.File;\r
+import java.util.HashMap;\r
import java.util.Iterator;\r
import java.util.Map;\r
import java.util.Set;\r
/// Mapping from modules identification to out put file name\r
///\r
private Map<FpdModuleIdentification, String> outfiles;\r
+ \r
+ ///\r
+ /// Mapping from FV name to its modules\r
+ ///\r
+ private Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();\r
+\r
\r
private boolean isUnified = true;\r
\r
+ "Abstract:\n"\r
+ "Auto-generated ANT build file for building EFI Modules and Platforms\n";\r
\r
- public PlatformBuildFileGenerator(Project project, Map<FpdModuleIdentification, String> outfiles, boolean isUnified){\r
+ public PlatformBuildFileGenerator(Project project, Map<FpdModuleIdentification, String> outfiles, Map<String, Set<FpdModuleIdentification>> fvs, boolean isUnified){\r
this.project = project;\r
this.outfiles = outfiles;\r
this.isUnified = isUnified;\r
+ this.fvs = fvs;\r
this.platformName = project.getProperty("PLATFORM");\r
}\r
\r
}\r
}\r
\r
+ /**\r
+ 1. Get All valid Fv Image Names in sequence\r
+ 2. For each FV, get modules by sequences\r
+ 3. Get other modules\r
+ \r
+ @param document XML document\r
+ @param root Node\r
+ **/\r
private void applyModules(Document document, Node root) {\r
root.appendChild(document.createComment("Modules target"));\r
Element ele = document.createElement("target");\r
ele.setAttribute("name", "modules");\r
\r
- Set<FpdModuleIdentification> set = outfiles.keySet();\r
- Iterator iter = set.iterator();\r
- while (iter.hasNext()) {\r
- FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();\r
- ModuleIdentification moduleId = fpdModuleId.getModule();\r
- Element moduleEle = document.createElement("GenBuild");\r
- moduleEle.setAttribute("type", "build");\r
- //\r
- // Inherit Properties.\r
- //{"ARCH", "PACKAGE", "PACKAGE_GUID", "PACKAGE_VERSION", "MODULE_DIR"}\r
- //\r
- \r
- //\r
- // ARCH\r
- //\r
- Element property = document.createElement("property");\r
- property.setAttribute("name", "ARCH");\r
- property.setAttribute("value", fpdModuleId.getArch());\r
- moduleEle.appendChild(property);\r
-\r
- //\r
- // MODULE_GUID\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "MODULE_GUID");\r
- property.setAttribute("value", moduleId.getGuid());\r
- moduleEle.appendChild(property);\r
- \r
- //\r
- // MODULE_VERSION\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "MODULE_VERSION");\r
- property.setAttribute("value", moduleId.getVersion());\r
- moduleEle.appendChild(property);\r
- \r
- //\r
- // PACKAGE_GUID\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE_GUID");\r
- property.setAttribute("value", moduleId.getPackage().getGuid());\r
- moduleEle.appendChild(property);\r
- \r
- //\r
- // PACKAGE_VERSION\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE_VERSION");\r
- property.setAttribute("value", moduleId.getPackage().getVersion());\r
- moduleEle.appendChild(property);\r
- \r
- ele.appendChild(moduleEle);\r
+ //\r
+ // Get all valid FV name\r
+ //\r
+ String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();\r
+ \r
+ //\r
+ // For each valid FV, get all modules in sequence\r
+ //\r
+ for (int i = 0; i < validFv.length; i++) {\r
+ if (fvs.containsKey(validFv[i])) {\r
+ Set<FpdModuleIdentification> set = fvs.get(validFv[i]);\r
+ Iterator<FpdModuleIdentification> iter = set.iterator();\r
+ while (iter.hasNext()) {\r
+ FpdModuleIdentification fpdModuleId = iter.next();\r
+ applySingleModule(document, ele, fpdModuleId);\r
+ }\r
+ }\r
}\r
+ \r
+ //\r
+ // Get all other modules\r
+ //\r
+ Iterator<String> fvsNameIter = fvs.keySet().iterator();\r
+ \r
+ while (fvsNameIter.hasNext()) {\r
+ String fvName = fvsNameIter.next();\r
+ if (!isContain(validFv, fvName)) {\r
+ Set<FpdModuleIdentification> set = fvs.get(fvName);\r
+ Iterator iter = set.iterator();\r
+ while (iter.hasNext()) {\r
+ FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();\r
+ applySingleModule(document, ele, fpdModuleId);\r
+ }\r
+ }\r
+ }\r
+\r
root.appendChild(ele);\r
}\r
\r
+ private void applySingleModule(Document document, Node root, FpdModuleIdentification fpdModuleId) {\r
+ ModuleIdentification moduleId = fpdModuleId.getModule();\r
+ Element moduleEle = document.createElement("GenBuild");\r
+ moduleEle.setAttribute("type", "build");\r
+ //\r
+ // Inherit Properties.\r
+ //{"ARCH", "PACKAGE", "PACKAGE_GUID", "PACKAGE_VERSION", "MODULE_DIR"}\r
+ //\r
+ \r
+ //\r
+ // ARCH\r
+ //\r
+ Element property = document.createElement("property");\r
+ property.setAttribute("name", "ARCH");\r
+ property.setAttribute("value", fpdModuleId.getArch());\r
+ moduleEle.appendChild(property);\r
+\r
+ //\r
+ // MODULE_GUID\r
+ //\r
+ property = document.createElement("property");\r
+ property.setAttribute("name", "MODULE_GUID");\r
+ property.setAttribute("value", moduleId.getGuid());\r
+ moduleEle.appendChild(property);\r
+ \r
+ //\r
+ // MODULE_VERSION\r
+ //\r
+ property = document.createElement("property");\r
+ property.setAttribute("name", "MODULE_VERSION");\r
+ property.setAttribute("value", moduleId.getVersion());\r
+ moduleEle.appendChild(property);\r
+ \r
+ //\r
+ // PACKAGE_GUID\r
+ //\r
+ property = document.createElement("property");\r
+ property.setAttribute("name", "PACKAGE_GUID");\r
+ property.setAttribute("value", moduleId.getPackage().getGuid());\r
+ moduleEle.appendChild(property);\r
+ \r
+ //\r
+ // PACKAGE_VERSION\r
+ //\r
+ property = document.createElement("property");\r
+ property.setAttribute("name", "PACKAGE_VERSION");\r
+ property.setAttribute("value", moduleId.getPackage().getVersion());\r
+ moduleEle.appendChild(property);\r
+ \r
+ root.appendChild(moduleEle);\r
+ }\r
+ \r
+ private boolean isContain(String[] list, String item) {\r
+ for (int i = 0; i < list.length; i++) {\r
+ if (list[i].equalsIgnoreCase(item)) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+ \r
private void applyFvs(Document document, Node root) {\r
//\r
// FVS Target\r
import java.util.List;\r
import java.util.Map;\r
import java.util.Set;\r
-import java.util.logging.Logger;\r
\r
import org.apache.tools.ant.BuildException;\r
import org.apache.xmlbeans.XmlObject;\r
@since GenBuild 1.0\r
**/\r
public class GlobalData {\r
-\r
- public static Logger log = Logger.getAnonymousLogger();\r
-\r
///\r
/// Record current WORKSPACE Directory\r
///\r
return result;\r
}\r
\r
- ////// Tool Chain Related, try to refine and put some logic process to ToolChainFactory\r
-\r
+ ///\r
+ /// Tool Chain Related, try to refine and put some logic process to ToolChainFactory\r
+ ///\r
public static ToolChainInfo getToolChainInfo() {\r
-// GlobalData.log.info(toolsDef.getConfigInfo() + "" + toolChainEnvInfo + toolChainPlatformInfo);\r
if (toolChainInfo == null) {\r
toolChainInfo = toolsDef.getConfigInfo().intersection(toolChainEnvInfo);\r
if (toolChainPlatformInfo != null) {\r
}\r
toolChainInfo.addCommands(toolsDef.getConfigInfo().getCommands());\r
toolChainInfo.normalize();\r
- GlobalData.log.info(toolChainInfo + "");\r
+ System.out.println("Current build tool chain information summary: ");\r
+ System.out.println(toolChainInfo + "");\r
}\r
return toolChainInfo;\r
}\r
\r
-\r
-\r
public static void setPlatformToolChainFamilyOption(ToolChainMap map) {\r
platformToolChainFamilyOption = map;\r
}\r