X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Tools%2FSource%2FGenBuild%2Forg%2Ftianocore%2Fbuild%2Ffpd%2FFpdParserTask.java;h=b496e32ed5de3ea933167369a1b7573bbc15bb45;hb=f6390d375c84a8dd7adbc2c76381b6bd41e256d8;hp=b61ad065f137e6b6b5fd1cf6f293f0b2d173ce58;hpb=de4bb9f6edc1db82e0616b24e6685b27d2b66061;p=mirror_edk2.git
diff --git a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
index b61ad065f1..b496e32ed5 100644
--- a/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
+++ b/Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
@@ -1,9 +1,9 @@
/** @file
- This file is ANT task FpdParserTask.
-
+ This file is ANT task FpdParserTask.
+
FpdParserTask is used to parse FPD (Framework Platform Description) and generate
- build.out.xml. It is for Package or Platform build use.
-
+ build.out.xml. It is for Package or Platform build use.
+
Copyright (c) 2006, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -18,6 +18,7 @@ package org.tianocore.build.fpd;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -25,92 +26,79 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.Vector;
-import java.util.TreeMap;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.taskdefs.Ant;
import org.apache.tools.ant.taskdefs.Property;
+import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
+import org.tianocore.common.definitions.EdkDefinitions;
+import org.tianocore.common.exception.EdkException;
+import org.tianocore.common.logger.EdkLog;
+import org.tianocore.pcd.action.ActionMessage;
+import org.tianocore.build.FrameworkBuildTask;
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;
-import org.tianocore.build.pcd.action.ActionMessage;
-import org.tianocore.build.pcd.action.CollectPCDAction;
-import org.tianocore.build.pcd.exception.EntityException;
+import org.tianocore.build.pcd.action.PlatformPcdPreprocessActionForBuilding;
import org.tianocore.build.toolchain.ToolChainAttribute;
import org.tianocore.build.toolchain.ToolChainElement;
import org.tianocore.build.toolchain.ToolChainMap;
-import org.tianocore.exception.EdkException;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
FpdParserTask
is an ANT task. The main function is parsing Framework
- Platform Descritpion (FPD) XML file and generating its ANT build script for
- corresponding platform.
+ Platform Descritpion (FPD) XML file and generating its ANT build script for
+ corresponding platform.
The task sets global properties PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR
and BUILD_DIR.
-
+
The 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.
-
+ build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage).
+
FpdParserTask task stores all FPD information to GlobalData. And parse
tools definition file to set up compiler options for different Target and
different ToolChainTag.
-
- The method parseFpdFile is also prepared for single module build.
-
- The usage is (take NT32 Platform for example):
-
- <FPDParser platformName="Nt32" />
-
-
- The task will initialize all information through parsing Framework Database,
- SPD, Tool chain configuration files.
+ The method parseFpdFile is also prepared for single module build.
@since GenBuild 1.0
**/
public class FpdParserTask extends Task {
-
- private String platformName;
private File fpdFile = null;
-
- private PlatformIdentification platformId;
-
- ///
- ///
- ///
+
+ PlatformIdentification platformId;
+
private String type;
-
+
///
/// Mapping from modules identification to out put file name
///
- private Map outfiles = new LinkedHashMap();
+ Map outfiles = new LinkedHashMap();
///
/// Mapping from FV name to its modules
///
- private Map> fvs = new HashMap>();
+ Map> fvs = new HashMap>();
///
- /// Mapping from sequence number to FV names
- ///
- private Map> sequences = new TreeMap>();
-
- ///
- /// FpdParserTask can specify some ANT properties.
+ /// FpdParserTask can specify some ANT properties.
///
private Vector properties = new Vector();
-
- private boolean isUnified = true;
+ SurfaceAreaQuery saq = null;
+
+ boolean isUnified = true;
/**
Public construct method. It is necessary for ANT task.
@@ -119,61 +107,51 @@ public class FpdParserTask extends Task {
}
/**
- ANT task's entry method. The main steps is described as following:
-
+ ANT task's entry method. The main steps is described as following:
+
- - Initialize global information (Framework DB, SPD files and all MSA files
+
- Initialize global information (Framework DB, SPD files and all MSA files
listed in SPD). This step will execute only once in whole build process;
- Parse specified FPD file;
- Generate FV.inf files;
- Generate PlatformName_build.xml file for Flatform build;
- Collect PCD information.
-
+
@throws BuildException
- Surface area is not valid.
+ Surface area is not valid.
**/
public void execute() throws BuildException {
- // Remove !!
- if ( fpdFile == null) {
- if (platformName == null) {
- throw new BuildException("FpdParserTask parameter error. Please specify platform name or FPD file. ");
- }
- platformId = GlobalData.getPlatformByName(platformName);
- fpdFile = platformId.getFpdFile();
- }
+ this.setTaskName("FpdParser");
//
// Parse FPD file
//
parseFpdFile();
-
+
//
// Prepare BUILD_DIR
//
isUnified = OutputManager.getInstance().prepareBuildDir(getProject());
-
- //
- // Generate FDF (Flash Definition File) file
- //
+ String buildDir = getProject().getProperty("BUILD_DIR");
//
// For every Target and ToolChain
//
String[] targetList = GlobalData.getToolChainInfo().getTargets();
- for (int i = 0; i < targetList.length; i++){
+ for (int i = 0; i < targetList.length; i++) {
String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();
- for(int j = 0; j < toolchainList.length; j++){
+ for(int j = 0; j < toolchainList.length; j++) {
//
// Prepare FV_DIR
//
- String ffsCommonDir = getProject().getProperty("BUILD_DIR") + File.separatorChar
- + targetList[i] + File.separatorChar
+ String ffsCommonDir = buildDir + File.separatorChar
+ + targetList[i] + "_"
+ toolchainList[j];
File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");
fvDir.mkdirs();
getProject().setProperty("FV_DIR", fvDir.getPath().replaceAll("(\\\\)", "/"));
-
+
//
// Gen Fv.inf files
//
@@ -184,56 +162,60 @@ public class FpdParserTask extends Task {
//
// Gen build.xml
//
- PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, sequences, isUnified);
+ String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);
fileGenerator.genBuildFile();
-
+
//
// Ant call ${PLATFORM}_build.xml
//
-
Ant ant = new Ant();
ant.setProject(getProject());
- ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");
+ ant.setAntfile(platformBuildFile);
ant.setTarget(type);
ant.setInheritAll(true);
ant.init();
ant.execute();
-
-// GlobalData.log.info("Fpd build end. ");
}
/**
- Generate Fv.inf files. The Fv.inf file is composed with four
- parts: Options, Attributes, Components and Files. The Fv.inf files
+ Generate Fv.inf files. The Fv.inf file is composed with four
+ parts: Options, Attributes, Components and Files. The Fv.inf files
will be under FV_DIR.
-
+
@throws BuildException
- File write FV.inf files error.
+ File write FV.inf files error.
**/
- private void genFvInfFiles(String ffsCommonDir) throws BuildException {
- String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();
+ void genFvInfFiles(String ffsCommonDir) throws BuildException {
+ String[] validFv = saq.getFpdValidImageNames();
for (int i = 0; i < validFv.length; i++) {
//
// Get all global variables from FPD and set them to properties
//
- String[][] globalVariables = SurfaceAreaQuery.getFpdGlobalVariable();
+ String[][] globalVariables = saq.getFpdGlobalVariable();
for (int j = 0; j < globalVariables.length; j++) {
getProject().setProperty(globalVariables[j][0], globalVariables[j][1]);
}
- getProject().setProperty("FV_FILENAME", validFv[i].toUpperCase());
-
- File fvFile = new File(getProject().replaceProperties( getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i].toUpperCase() + ".inf"));
+ getProject().setProperty("FV_FILENAME", validFv[i]);
+
+ File fvFile = new File(getProject().replaceProperties( getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i] + ".inf"));
+ if (fvFile.exists() && (fvFile.lastModified() >= fpdFile.lastModified())) {
+ //
+ // don't re-generate FV.inf if fpd has not been changed
+ //
+ continue;
+ }
fvFile.getParentFile().mkdirs();
try {
FileWriter fw = new FileWriter(fvFile);
BufferedWriter bw = new BufferedWriter(fw);
-
+
//
// Options
//
- String[][] options = SurfaceAreaQuery.getFpdOptions(validFv[i]);
+ String[][] options = saq.getFpdOptions(validFv[i]);
if (options.length > 0) {
bw.write("[options]");
bw.newLine();
@@ -250,11 +232,11 @@ public class FpdParserTask extends Task {
}
bw.newLine();
}
-
+
//
// Attributes;
//
- String[][] attributes = SurfaceAreaQuery.getFpdAttributes(validFv[i]);
+ String[][] attributes = saq.getFpdAttributes(validFv[i]);
if (attributes.length > 0) {
bw.write("[attributes]");
bw.newLine();
@@ -271,11 +253,11 @@ public class FpdParserTask extends Task {
}
bw.newLine();
}
-
+
//
// Components
//
- String[][] components = SurfaceAreaQuery.getFpdComponents(validFv[i]);
+ String[][] components = saq.getFpdComponents(validFv[i]);
if (components.length > 0) {
bw.write("[components]");
bw.newLine();
@@ -296,9 +278,44 @@ public class FpdParserTask extends Task {
//
// Files
//
- Set filesSet = fvs.get(validFv[i].toUpperCase());
- if (filesSet != null) {
- FpdModuleIdentification[] files = filesSet.toArray(new FpdModuleIdentification[filesSet.size()]);
+ Set moduleSeqSet = getModuleSequenceForFv(validFv[i]);
+
+ Set filesSet = fvs.get(validFv[i]);
+
+ FpdModuleIdentification[] files = null;
+
+ if (moduleSeqSet == null) {
+ if (filesSet != null) {
+ files = filesSet.toArray(new FpdModuleIdentification[filesSet.size()]);
+ }
+ } else if (filesSet == null) {
+ if (moduleSeqSet.size() != 0) {
+ throw new BuildException("Can not find any modules belongs to FV[" + validFv[i] + "], but listed some in BuildOptions.UserExtensions[@UserID='IMAGES' @Identifier='1']");
+ }
+ } else {
+ //
+ // if moduleSeqSet and filesSet is inconsistent, report error
+ //
+ if(moduleSeqSet.size() != filesSet.size()){
+ throw new BuildException("Modules for FV[" + validFv[i] + "] defined in FrameworkModules and in BuildOptions.UserExtensions[@UserID='IMAGES' @Identifier='1'] are inconsistent. ");
+ } else {
+ //
+ // whether all modules in moduleSeqSet listed in filesSet
+ //
+ Iterator iter = moduleSeqSet.iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification item = iter.next();
+ if (!filesSet.contains(item)) {
+ throw new BuildException("Can not find " + item + " belongs to FV[" + validFv[i] + "]");
+ }
+ }
+ }
+
+ files = moduleSeqSet.toArray(new FpdModuleIdentification[moduleSeqSet.size()]);
+ }
+
+
+ if (files != null) {
bw.write("[files]");
bw.newLine();
for (int j = 0; j < files.length; j++) {
@@ -310,67 +327,116 @@ public class FpdParserTask extends Task {
bw.flush();
bw.close();
fw.close();
- } catch (Exception e) {
- e.printStackTrace();
- throw new BuildException("Generate FV file [" + fvFile.getPath() + "] failed. \n" + e.getMessage());
+ } catch (IOException ex) {
+ BuildException buildException = new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + ex.getMessage());
+ buildException.setStackTrace(ex.getStackTrace());
+ throw buildException;
+ } catch (EdkException ex) {
+ BuildException buildException = new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + ex.getMessage());
+ buildException.setStackTrace(ex.getStackTrace());
+ throw buildException;
}
}
}
/**
This method is used for Single Module Build.
-
-
+
+
@throws BuildException
- FPD file is not valid.
+ FPD file is not valid.
**/
- public void parseFpdFile(File fpdFile) throws BuildException {
+ public void parseFpdFile(File fpdFile) throws BuildException, EdkException {
this.fpdFile = fpdFile;
parseFpdFile();
+
+ //
+ // Call Platform_build.xml prebuild firstly in stand-alone build
+ // Prepare BUILD_DIR
+ //
+ isUnified = OutputManager.getInstance().prepareBuildDir(getProject());
+
+ String buildDir = getProject().getProperty("BUILD_DIR");
+ //
+ // 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++) {
+ //
+ // Prepare FV_DIR
+ //
+ String ffsCommonDir = buildDir + File.separatorChar
+ + targetList[i] + "_"
+ + toolchainList[j];
+ File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");
+ fvDir.mkdirs();
+ }
+ }
+
+ String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);
+ fileGenerator.genBuildFile();
+
+ Ant ant = new Ant();
+ ant.setProject(getProject());
+ ant.setAntfile(platformBuildFile);
+ ant.setTarget("prebuild");
+ ant.setInheritAll(true);
+ ant.init();
+ ant.execute();
}
/**
- Parse FPD file.
-
+ Parse FPD file.
+
@throws BuildException
- FPD file is not valid.
+ FPD file is not valid.
**/
- private void parseFpdFile() throws BuildException {
+ void parseFpdFile() throws BuildException {
try {
XmlObject doc = XmlObject.Factory.parse(fpdFile);
-
+
if (!doc.validate()) {
- throw new BuildException("Platform Surface Area file [" + fpdFile.getPath() + "] is invalid.");
+ throw new BuildException("Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");
}
-
+
Map map = new HashMap();
map.put("PlatformSurfaceArea", doc);
- SurfaceAreaQuery.setDoc(map);
- SurfaceAreaQuery.getFpdUserExtension();
+ saq = new SurfaceAreaQuery(map);
+
//
// Initialize
//
- platformId = SurfaceAreaQuery.getFpdHeader();
+ platformId = saq.getFpdHeader();
platformId.setFpdFile(fpdFile);
getProject().setProperty("PLATFORM", platformId.getName());
getProject().setProperty("PLATFORM_FILE", platformId.getRelativeFpdFile().replaceAll("(\\\\)", "/"));
getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
+
+ if( !FrameworkBuildTask.multithread) {
+ FrameworkBuildTask.originalProperties.put("PLATFORM", platformId.getName());
+ FrameworkBuildTask.originalProperties.put("PLATFORM_FILE", platformId.getRelativeFpdFile().replaceAll("(\\\\)", "/"));
+ FrameworkBuildTask.originalProperties.put("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));
+ FrameworkBuildTask.originalProperties.put("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));
+ }
//
- // Build mode. User-defined output dir.
+ // Build mode. User-defined output dir.
//
- String buildMode = SurfaceAreaQuery.getFpdIntermediateDirectories();
- String userDefinedOutputDir = SurfaceAreaQuery.getFpdOutputDirectory();
+ String buildMode = saq.getFpdIntermediateDirectories();
+ String userDefinedOutputDir = saq.getFpdOutputDirectory();
OutputManager.getInstance().setup(userDefinedOutputDir, buildMode);
//
// TBD. Deal PCD and BuildOption related Info
//
- GlobalData.setFpdBuildOptions(SurfaceAreaQuery.getFpdBuildOptions());
-
- GlobalData.setToolChainPlatformInfo(SurfaceAreaQuery.getFpdToolChainInfo());
-
+ GlobalData.setFpdBuildOptions(saq.getFpdBuildOptions());
+
+ GlobalData.setToolChainPlatformInfo(saq.getFpdToolChainInfo());
+
//
// Parse all list modules SA
//
@@ -382,30 +448,33 @@ public class FpdParserTask extends Task {
parseToolChainFamilyOptions();
parseToolChainOptions();
- SurfaceAreaQuery.setDoc(map);
-
+ saq.push(map);
+
//
// Pcd Collection. Call CollectPCDAction to collect pcd info.
//
- try {
- CollectPCDAction ca = new CollectPCDAction();
- ca.perform(GlobalData.getWorkspacePath(),platformId.getFpdFile().getPath(),ActionMessage.NULL_MESSAGE_LEVEL);
- } catch (Exception e){
- throw new BuildException(e.getMessage());
- }
- } catch (Exception e) {
- e.printStackTrace();
- throw new BuildException("Load FPD file [" + fpdFile.getPath() + "] error. \n" + e.getMessage());
+ PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();
+ ca.perform(platformId.getFpdFile().getPath(), ActionMessage.NULL_MESSAGE_LEVEL);
+ } catch (IOException ex) {
+ BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());
+ buildException.setStackTrace(ex.getStackTrace());
+ throw buildException;
+ } catch (XmlException ex) {
+ BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());
+ buildException.setStackTrace(ex.getStackTrace());
+ throw buildException;
+ } catch (EdkException ex) {
+ BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());
+ buildException.setStackTrace(ex.getStackTrace());
+ throw buildException;
}
}
-
-
/**
- Parse all modules listed in FPD file.
+ Parse all modules listed in FPD file.
**/
- private void parseModuleSAFiles() throws EdkException{
- Map> moduleSAs = SurfaceAreaQuery.getFpdModules();
+ void parseModuleSAFiles() throws EdkException{
+ Map> moduleSAs = saq.getFpdModules();
//
// For every Module lists in FPD file.
@@ -414,60 +483,56 @@ public class FpdParserTask extends Task {
Iterator iter = keys.iterator();
while (iter.hasNext()) {
FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();
-
+
//
- // Judge if Module is existed?
+ // Judge if Module is existed?
// TBD
-
GlobalData.registerFpdModuleSA(fpdModuleId, moduleSAs.get(fpdModuleId));
//
// Put fpdModuleId to the corresponding FV
//
- SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));
- String fvBinding = SurfaceAreaQuery.getModuleFvBindingKeyword();
- SurfaceAreaQuery.pop();
+ saq.push(GlobalData.getDoc(fpdModuleId));
+ String fvBinding = saq.getModuleFvBindingKeyword();
fpdModuleId.setFvBinding(fvBinding);
- String fvSequence = fpdModuleId.getSequence();
- updateFvs(fvSequence, fvBinding, fpdModuleId);
-
+ updateFvs(fvBinding, fpdModuleId);
+
//
// Prepare for out put file name
//
ModuleIdentification moduleId = fpdModuleId.getModule();
- SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));
- String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();
- SurfaceAreaQuery.pop();
+
+ String baseName = saq.getModuleOutputFileBasename();
+
if (baseName == null) {
baseName = moduleId.getName();
}
- outfiles.put(fpdModuleId, fpdModuleId.getArch() + File.separatorChar
- + moduleId.getGuid() + "-" + baseName
+ outfiles.put(fpdModuleId, fpdModuleId.getArch() + File.separatorChar
+ + moduleId.getGuid() + "-" + baseName
+ getSuffix(moduleId.getModuleType()));
//
// parse module build options, if any
- //
- SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));
+ //
GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));
GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));
- SurfaceAreaQuery.pop();
+ saq.pop();
}
}
- private ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {
- String[][] options = SurfaceAreaQuery.getModuleBuildOptions(toolChainFamilyFlag);
+ ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {
+ String[][] options = saq.getModuleBuildOptions(toolChainFamilyFlag);
if (options == null || options.length == 0) {
- return null;
+ return new ToolChainMap();
}
return parseOptions(options);
}
-
+
private ToolChainMap parsePlatformBuildOptions(boolean toolChainFamilyFlag) throws EdkException {
- String[][] options = SurfaceAreaQuery.getPlatformBuildOptions(toolChainFamilyFlag);
+ String[][] options = saq.getPlatformBuildOptions(toolChainFamilyFlag);
if (options == null || options.length == 0) {
- return null;
+ return new ToolChainMap();
}
return parseOptions(options);
}
@@ -487,7 +552,7 @@ public class FpdParserTask extends Task {
return map;
}
-
+
private void parseToolChainFamilyOptions() throws EdkException {
GlobalData.setPlatformToolChainFamilyOption(parsePlatformBuildOptions(true));
}
@@ -497,14 +562,16 @@ public class FpdParserTask extends Task {
}
/**
- Add the current module to corresponding FV.
-
+ Add the current module to corresponding FV.
+
@param fvName current FV name
@param moduleName current module identification
**/
- private void updateFvs(String fvSequence, String fvName, FpdModuleIdentification fpdModuleId) {
- String upcaseFvName = fvName.toUpperCase();
- String[] fvNameArray = upcaseFvName.split("[, \t]+");
+ void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {
+ if (fvName == null || fvName.trim().length() == 0) {
+ fvName = "NULL";
+ }
+ String[] fvNameArray = fvName.split("[, \t]+");
for (int i = 0; i < fvNameArray.length; i++) {
//
// Put module to corresponding fvName
@@ -512,31 +579,17 @@ public class FpdParserTask extends Task {
if (fvs.containsKey(fvNameArray[i])) {
Set set = fvs.get(fvNameArray[i]);
set.add(fpdModuleId);
- }
- else {
+ } else {
Set set = new LinkedHashSet();
set.add(fpdModuleId);
fvs.put(fvNameArray[i], set);
}
-
- //
- // Put fvName to corresponding fvSequence
- //
- if (sequences.containsKey(fvSequence)) {
- Set set = sequences.get(fvSequence);
- set.add(fvNameArray[i]);
- }
- else {
- Set set = new LinkedHashSet();
- set.add(fvNameArray[i]);
- sequences.put(fvSequence, set);
- }
}
}
/**
- Get the suffix based on module type. Current relationship are listed:
-
+ Get the suffix based on module type. Current relationship are listed:
+
ModuleType Suffix
BASE .FFS
@@ -553,7 +606,7 @@ public class FpdParserTask extends Task {
UEFI_APPLICATION .APP
USER_DEFINED .FFS
-
+
@param moduleType module type
@return
@throws BuildException
@@ -564,14 +617,8 @@ public class FpdParserTask extends Task {
throw new BuildException("Module type is not specified.");
}
- String[][] suffix = { { "BASE", ".FFS"},
- { "SEC", ".SEC" }, { "PEI_CORE", ".PEI" },
- { "PEIM", ".PEI" }, { "DXE_CORE", ".DXE" },
- { "DXE_DRIVER", ".DXE" }, { "DXE_RUNTIME_DRIVER", ".DXE" },
- { "DXE_SAL_DRIVER", ".DXE" }, { "DXE_SMM_DRIVER", ".DXE" },
- { "TOOL", ".FFS" }, { "UEFI_DRIVER", ".DXE" },
- { "UEFI_APPLICATION", ".APP" }, { "USER_DEFINED", ".FFS" } };
-
+ String[][] suffix = EdkDefinitions.ModuleTypeExtensions;
+
for (int i = 0; i < suffix.length; i++) {
if (suffix[i][0].equalsIgnoreCase(moduleType)) {
return suffix[i][1];
@@ -583,18 +630,14 @@ public class FpdParserTask extends Task {
return ".FFS";
}
/**
- Add a property.
-
+ Add a property.
+
@param p property
**/
public void addProperty(Property p) {
properties.addElement(p);
}
- public void setPlatformName(String platformName) {
- this.platformName = platformName;
- }
-
public void setFpdFile(File fpdFile) {
this.fpdFile = fpdFile;
}
@@ -603,5 +646,112 @@ public class FpdParserTask extends Task {
this.type = type;
}
-
+ public String getAllArchForModule(ModuleIdentification moduleId) {
+ String archs = "";
+ Iterator iter = outfiles.keySet().iterator();
+ while (iter.hasNext()) {
+ FpdModuleIdentification fpdModuleId = iter.next();
+
+ if (fpdModuleId.getModule().equals(moduleId)) {
+ archs += fpdModuleId.getArch() + " ";
+ }
+ }
+
+ return archs;
+ }
+
+ private Set getModuleSequenceForFv(String fvName) throws EdkException {
+ Node node = saq.getFpdModuleSequence(fvName);
+ Set result = new LinkedHashSet();
+
+ if ( node == null) {
+ EdkLog.log(this, EdkLog.EDK_WARNING, "FV[" + fvName + "] does not specify module sequence in FPD. Assuming present sequence as default sequence in FV. ");
+ return null;
+ } else {
+ NodeList childNodes = node.getChildNodes();
+ for (int i = 0; i < childNodes.getLength(); i++) {
+ Node childItem = childNodes.item(i);
+ if (childItem.getNodeType() == Node.ELEMENT_NODE) {
+ //
+ // Find child elements "IncludeModules"
+ //
+ if (childItem.getNodeName().compareTo("IncludeModules") == 0) {
+ //
+ // result will be updated
+ //
+ processNodes(childItem, result);
+ } else if (childItem.getNodeName().compareTo("FvName") == 0) {
+
+ } else if (childItem.getNodeName().compareTo("InfFileName") == 0) {
+
+ } else {
+ //
+ // Report Warning
+ //
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1']");
+ }
+ }
+ }
+ }
+
+ return result;
+ }
+
+ private void processNodes(Node node, Set result) throws EdkException {
+ //
+ // Found out all elements "Module"
+ //
+ NodeList childNodes = node.getChildNodes();
+ for (int j = 0; j < childNodes.getLength(); j++) {
+ Node childItem = childNodes.item(j);
+ if (childItem.getNodeType() == Node.ELEMENT_NODE) {
+ if (childItem.getNodeName().compareTo("Module") == 0) {
+ String moduleGuid = null;
+ String moduleVersion = null;
+ String packageGuid = null;
+ String packageVersion = null;
+ String arch = null;
+
+ NamedNodeMap attr = childItem.getAttributes();
+ for (int i = 0; i < attr.getLength(); i++) {
+ Node attrItem = attr.item(i);
+ if (attrItem.getNodeName().compareTo("ModuleGuid") == 0) {
+ moduleGuid = attrItem.getNodeValue();
+ } else if (attrItem.getNodeName().compareTo("ModuleVersion") == 0) {
+ moduleVersion = attrItem.getNodeValue();
+ } else if (attrItem.getNodeName().compareTo("PackageGuid") == 0) {
+ packageGuid = attrItem.getNodeValue();
+ } else if (attrItem.getNodeName().compareTo("PackageVersion") == 0) {
+ packageVersion = attrItem.getNodeValue();
+ } else if (attrItem.getNodeName().compareTo("Arch") == 0) {
+ arch = attrItem.getNodeValue();
+ } else {
+ //
+ // Report warning
+ //
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised attribute " + attrItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules.Module");
+ }
+ }
+
+ PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);
+ GlobalData.refreshPackageIdentification(packageId);
+
+ ModuleIdentification moduleId = new ModuleIdentification(moduleGuid, moduleVersion);
+ moduleId.setPackage(packageId);
+ GlobalData.refreshModuleIdentification(moduleId);
+
+ if (arch == null) {
+ throw new EdkException("Attribute [Arch] is required for element FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules.Module. ");
+ }
+
+ result.add(new FpdModuleIdentification(moduleId, arch));
+ } else {
+ //
+ // Report Warning
+ //
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules");
+ }
+ }
+ }
+ }
}