import org.apache.tools.ant.taskdefs.Property;\r
import org.apache.xmlbeans.XmlObject;\r
\r
+import org.tianocore.common.definitions.EdkDefinitions;\r
import org.tianocore.common.exception.EdkException;\r
import org.tianocore.pcd.action.ActionMessage;\r
import org.tianocore.build.global.GlobalData;\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 File fpdFile = null;\r
\r
- private PlatformIdentification platformId;\r
+ PlatformIdentification platformId;\r
\r
- ///\r
- ///\r
- ///\r
private String type;\r
\r
///\r
/// Mapping from modules identification to out put file name\r
///\r
- private Map<FpdModuleIdentification, String> outfiles = new LinkedHashMap<FpdModuleIdentification, String>();\r
+ Map<FpdModuleIdentification, String> outfiles = new LinkedHashMap<FpdModuleIdentification, String>();\r
\r
///\r
/// Mapping from FV name to its modules\r
///\r
- private Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();\r
+ Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();\r
\r
///\r
/// FpdParserTask can specify some ANT properties.\r
///\r
private Vector<Property> properties = new Vector<Property>();\r
\r
- private boolean isUnified = true;\r
-\r
+ SurfaceAreaQuery saq = null;\r
+ \r
+ boolean isUnified = true;\r
\r
/**\r
Public construct method. It is necessary for ANT task.\r
Surface area is not valid.\r
**/\r
public void execute() throws BuildException {\r
- // Remove !!\r
+ //\r
+ // If fpdFile is not specified, \r
+ // then try to get FPD file by platformName\r
+ //\r
if ( fpdFile == null) {\r
if (platformName == null) {\r
throw new BuildException("FpdParserTask parameter error. Please specify either the platform name or FPD file!");\r
// For every Target and ToolChain\r
//\r
String[] targetList = GlobalData.getToolChainInfo().getTargets();\r
- for (int i = 0; i < targetList.length; i++){\r
+ for (int i = 0; i < targetList.length; i++) {\r
String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();\r
- for(int j = 0; j < toolchainList.length; j++){\r
+ for(int j = 0; j < toolchainList.length; j++) {\r
//\r
// Prepare FV_DIR\r
//\r
String ffsCommonDir = getProject().getProperty("BUILD_DIR") + File.separatorChar\r
- + targetList[i] + File.separatorChar\r
+ + targetList[i] + "_"\r
+ toolchainList[j];\r
File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");\r
fvDir.mkdirs();\r
//\r
// Gen build.xml\r
//\r
- PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, isUnified);\r
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq);\r
fileGenerator.genBuildFile();\r
\r
//\r
ant.setInheritAll(true);\r
ant.init();\r
ant.execute();\r
-\r
-// GlobalData.log.info("Fpd build end. ");\r
}\r
\r
/**\r
@throws BuildException\r
File write FV.inf files error.\r
**/\r
- private void genFvInfFiles(String ffsCommonDir) throws BuildException {\r
- String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();\r
+ void genFvInfFiles(String ffsCommonDir) throws BuildException {\r
+ String[] validFv = saq.getFpdValidImageNames();\r
for (int i = 0; i < validFv.length; i++) {\r
//\r
// Get all global variables from FPD and set them to properties\r
//\r
- String[][] globalVariables = SurfaceAreaQuery.getFpdGlobalVariable();\r
+ String[][] globalVariables = saq.getFpdGlobalVariable();\r
for (int j = 0; j < globalVariables.length; j++) {\r
getProject().setProperty(globalVariables[j][0], globalVariables[j][1]);\r
}\r
//\r
// Options\r
//\r
- String[][] options = SurfaceAreaQuery.getFpdOptions(validFv[i]);\r
+ String[][] options = saq.getFpdOptions(validFv[i]);\r
if (options.length > 0) {\r
bw.write("[options]");\r
bw.newLine();\r
//\r
// Attributes;\r
//\r
- String[][] attributes = SurfaceAreaQuery.getFpdAttributes(validFv[i]);\r
+ String[][] attributes = saq.getFpdAttributes(validFv[i]);\r
if (attributes.length > 0) {\r
bw.write("[attributes]");\r
bw.newLine();\r
//\r
// Components\r
//\r
- String[][] components = SurfaceAreaQuery.getFpdComponents(validFv[i]);\r
+ String[][] components = saq.getFpdComponents(validFv[i]);\r
if (components.length > 0) {\r
bw.write("[components]");\r
bw.newLine();\r
@throws BuildException\r
FPD file is not valid.\r
**/\r
- private void parseFpdFile() throws BuildException {\r
+ void parseFpdFile() throws BuildException {\r
try {\r
XmlObject doc = XmlObject.Factory.parse(fpdFile);\r
\r
\r
Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
map.put("PlatformSurfaceArea", doc);\r
- SurfaceAreaQuery.setDoc(map);\r
+ saq = new SurfaceAreaQuery(map);\r
\r
//\r
// Initialize\r
//\r
- platformId = SurfaceAreaQuery.getFpdHeader();\r
+ platformId = saq.getFpdHeader();\r
platformId.setFpdFile(fpdFile);\r
getProject().setProperty("PLATFORM", platformId.getName());\r
getProject().setProperty("PLATFORM_FILE", platformId.getRelativeFpdFile().replaceAll("(\\\\)", "/"));\r
//\r
// Build mode. User-defined output dir.\r
//\r
- String buildMode = SurfaceAreaQuery.getFpdIntermediateDirectories();\r
- String userDefinedOutputDir = SurfaceAreaQuery.getFpdOutputDirectory();\r
+ String buildMode = saq.getFpdIntermediateDirectories();\r
+ String userDefinedOutputDir = saq.getFpdOutputDirectory();\r
\r
OutputManager.getInstance().setup(userDefinedOutputDir, buildMode);\r
\r
//\r
// TBD. Deal PCD and BuildOption related Info\r
//\r
- GlobalData.setFpdBuildOptions(SurfaceAreaQuery.getFpdBuildOptions());\r
+ GlobalData.setFpdBuildOptions(saq.getFpdBuildOptions());\r
\r
- GlobalData.setToolChainPlatformInfo(SurfaceAreaQuery.getFpdToolChainInfo());\r
+ GlobalData.setToolChainPlatformInfo(saq.getFpdToolChainInfo());\r
\r
//\r
// Parse all list modules SA\r
parseToolChainFamilyOptions();\r
parseToolChainOptions();\r
\r
- SurfaceAreaQuery.setDoc(map);\r
+ saq.push(map);\r
\r
//\r
// Pcd Collection. Call CollectPCDAction to collect pcd info.\r
}\r
}\r
\r
-\r
-\r
/**\r
Parse all modules listed in FPD file.\r
**/\r
- private void parseModuleSAFiles() throws EdkException{\r
- Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = SurfaceAreaQuery.getFpdModules();\r
+ void parseModuleSAFiles() throws EdkException{\r
+ Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = saq.getFpdModules();\r
\r
//\r
// For every Module lists in FPD file.\r
//\r
// Judge if Module is existed?\r
// TBD\r
-\r
GlobalData.registerFpdModuleSA(fpdModuleId, moduleSAs.get(fpdModuleId));\r
\r
//\r
// Put fpdModuleId to the corresponding FV\r
//\r
- SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));\r
- String fvBinding = SurfaceAreaQuery.getModuleFvBindingKeyword();\r
- SurfaceAreaQuery.pop();\r
+ saq.push(GlobalData.getDoc(fpdModuleId));\r
+ String fvBinding = saq.getModuleFvBindingKeyword();\r
\r
fpdModuleId.setFvBinding(fvBinding);\r
updateFvs(fvBinding, fpdModuleId);\r
// Prepare for out put file name\r
//\r
ModuleIdentification moduleId = fpdModuleId.getModule();\r
- SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));\r
- String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();\r
- SurfaceAreaQuery.pop();\r
+\r
+ String baseName = saq.getModuleOutputFileBasename();\r
+ \r
if (baseName == null) {\r
baseName = moduleId.getName();\r
}\r
//\r
// parse module build options, if any\r
//\r
- SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));\r
GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));\r
GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));\r
- SurfaceAreaQuery.pop();\r
+ saq.pop();\r
}\r
}\r
\r
- private ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
- String[][] options = SurfaceAreaQuery.getModuleBuildOptions(toolChainFamilyFlag);\r
+ ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
+ String[][] options = saq.getModuleBuildOptions(toolChainFamilyFlag);\r
if (options == null || options.length == 0) {\r
- return null;\r
+ return new ToolChainMap();\r
}\r
return parseOptions(options);\r
}\r
\r
private ToolChainMap parsePlatformBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
- String[][] options = SurfaceAreaQuery.getPlatformBuildOptions(toolChainFamilyFlag);\r
+ String[][] options = saq.getPlatformBuildOptions(toolChainFamilyFlag);\r
if (options == null || options.length == 0) {\r
- return null;\r
+ return new ToolChainMap();\r
}\r
return parseOptions(options);\r
}\r
@param fvName current FV name\r
@param moduleName current module identification\r
**/\r
- private void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {\r
+ void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {\r
if (fvName == null || fvName.trim().length() == 0) {\r
fvName = "NULL";\r
}\r
if (fvs.containsKey(fvNameArray[i])) {\r
Set<FpdModuleIdentification> set = fvs.get(fvNameArray[i]);\r
set.add(fpdModuleId);\r
- }\r
- else {\r
+ } else {\r
Set<FpdModuleIdentification> set = new LinkedHashSet<FpdModuleIdentification>();\r
set.add(fpdModuleId);\r
fvs.put(fvNameArray[i], set);\r
throw new BuildException("Module type is not specified.");\r
}\r
\r
- String[][] suffix = { { "BASE", ".FFS"},\r
- { "SEC", ".SEC" }, { "PEI_CORE", ".PEI" },\r
- { "PEIM", ".PEI" }, { "DXE_CORE", ".DXE" },\r
- { "DXE_DRIVER", ".DXE" }, { "DXE_RUNTIME_DRIVER", ".DXE" },\r
- { "DXE_SAL_DRIVER", ".DXE" }, { "DXE_SMM_DRIVER", ".DXE" },\r
- { "TOOL", ".FFS" }, { "UEFI_DRIVER", ".DXE" },\r
- { "UEFI_APPLICATION", ".APP" }, { "USER_DEFINED", ".FFS" } };\r
+ String[][] suffix = EdkDefinitions.ModuleTypeExtensions;\r
\r
for (int i = 0; i < suffix.length; i++) {\r
if (suffix[i][0].equalsIgnoreCase(moduleType)) {\r
public void setType(String type) {\r
this.type = type;\r
}\r
-\r
-\r
+ \r
+ public String getAllArchForModule(ModuleIdentification moduleId) {\r
+ String archs = "";\r
+ Iterator<FpdModuleIdentification> iter = outfiles.keySet().iterator();\r
+ while (iter.hasNext()) {\r
+ FpdModuleIdentification fpdModuleId = iter.next();\r
+ \r
+ if (fpdModuleId.getModule().equals(moduleId)) {\r
+ archs += fpdModuleId.getArch() + " ";\r
+ }\r
+ }\r
+ \r
+ return archs;\r
+ }\r
}\r