/** @file\r
- This file is ANT task FpdParserTask. \r
- \r
- FpdParserTask is used to parse FPD (Framework Platform Description) and generate\r
- build.out.xml. It is for Package or Platform build use. \r
- \r
-Copyright (c) 2006, Intel Corporation\r
-All rights reserved. This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
+ This file is ANT task FpdParserTask.\r
+\r
+ FpdParserTask is used to parse FPD (Framework Platform Description) and generate\r
+ build.out.xml. It is for Package or Platform build use.\r
+\r
+ Copyright (c) 2006, Intel Corporation\r
+ All rights reserved. This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ **/\r
package org.tianocore.build.fpd;\r
\r
import java.io.BufferedWriter;\r
import java.io.File;\r
import java.io.FileWriter;\r
+import java.io.IOException;\r
import java.util.HashMap;\r
import java.util.Iterator;\r
import java.util.LinkedHashMap;\r
import java.util.Set;\r
import java.util.Vector;\r
\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.transform.OutputKeys;\r
-import javax.xml.transform.Result;\r
-import javax.xml.transform.Source;\r
-import javax.xml.transform.Transformer;\r
-import javax.xml.transform.TransformerFactory;\r
-import javax.xml.transform.dom.DOMSource;\r
-import javax.xml.transform.stream.StreamResult;\r
-\r
import org.apache.tools.ant.BuildException;\r
import org.apache.tools.ant.Task;\r
+import org.apache.tools.ant.taskdefs.Ant;\r
import org.apache.tools.ant.taskdefs.Property;\r
+import org.apache.xmlbeans.XmlException;\r
import org.apache.xmlbeans.XmlObject;\r
-import org.w3c.dom.Comment;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
\r
+import org.tianocore.common.definitions.EdkDefinitions;\r
+import org.tianocore.common.exception.EdkException;\r
+import org.tianocore.common.logger.EdkLog;\r
+import org.tianocore.pcd.action.ActionMessage;\r
+import org.tianocore.build.FrameworkBuildTask;\r
import org.tianocore.build.global.GlobalData;\r
import org.tianocore.build.global.OutputManager;\r
-import org.tianocore.build.global.OverrideProcess;\r
import org.tianocore.build.global.SurfaceAreaQuery;\r
-import org.tianocore.build.pcd.action.CollectPCDAction;\r
-import org.tianocore.build.pcd.action.ActionMessage;\r
-import org.tianocore.BuildOptionsDocument;\r
-import org.tianocore.FrameworkPlatformDescriptionDocument;\r
-import org.tianocore.ModuleSADocument;\r
-\r
+import org.tianocore.build.id.FpdModuleIdentification;\r
+import org.tianocore.build.id.ModuleIdentification;\r
+import org.tianocore.build.id.PackageIdentification;\r
+import org.tianocore.build.id.PlatformIdentification;\r
+import org.tianocore.build.pcd.action.PlatformPcdPreprocessActionForBuilding;\r
+import org.tianocore.build.toolchain.ToolChainAttribute;\r
+import org.tianocore.build.toolchain.ToolChainElement;\r
+import org.tianocore.build.toolchain.ToolChainMap;\r
+import org.w3c.dom.NamedNodeMap;\r
+import org.w3c.dom.Node;\r
+import org.w3c.dom.NodeList;\r
\r
/**\r
- <code>FpdParserTask</code> is an ANT task. The main function is parsing FPD\r
- XML file and generating its ANT build script for Platform or Package. \r
- \r
- <p>The usage is (take NT32 Platform for example):</p>\r
- \r
- <pre>\r
- <FPDParser fpdfilename="Build\Nt32.fpd" />\r
- </pre>\r
- \r
- <p>The task will initialize all information through parsing Framework Database, \r
- SPD, Tool chain configuration files. </p>\r
- \r
+ <code>FpdParserTask</code> is an ANT task. The main function is parsing Framework\r
+ Platform Descritpion (FPD) XML file and generating its ANT build script for\r
+ corresponding platform.\r
+\r
+ <p>The task sets global properties PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR\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). </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
+ different ToolChainTag. </p>\r
+\r
+ <p>The method parseFpdFile is also prepared for single module build. </p>\r
+\r
@since GenBuild 1.0\r
**/\r
public class FpdParserTask extends Task {\r
\r
- ///\r
- /// FV dir: ${PLATFORM_DIR}/Build/FV\r
- ///\r
- public static final String FV_OUTPUT_DIR = "${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar + "FV";\r
-\r
- private File fpdFilename;\r
+ private File fpdFile = null;\r
\r
- private File guiddatabase;\r
+ PlatformIdentification platformId;\r
\r
- ///\r
- /// Keep platform buildoption information\r
- ///\r
- public static XmlObject platformBuildOptions = null;\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
- /// Mapping from sequence number to its modules\r
- ///\r
- private Map<String, Set<FpdModuleIdentification> > sequences = new HashMap<String, Set<FpdModuleIdentification> >();\r
-\r
- ///\r
- /// FpdParserTask can specify some ANT properties. \r
+ /// FpdParserTask can specify some ANT properties.\r
///\r
private Vector<Property> properties = new Vector<Property>();\r
\r
- private String info = "====================================================================\n"\r
- + "DO NOT EDIT \n"\r
- + "File auto-generated by build utility\n"\r
- + "\n"\r
- + "Abstract:\n"\r
- + "Auto-generated ANT build file for building of EFI Modules/Platforms\n"\r
- + "=====================================================================";\r
+ SurfaceAreaQuery saq = null;\r
+ \r
+ boolean isUnified = true;\r
\r
/**\r
Public construct method. It is necessary for ANT task.\r
**/\r
- public FpdParserTask () {\r
+ public FpdParserTask() {\r
}\r
\r
/**\r
- ANT task's entry method. The main steps is described as following: \r
- \r
- <ul>\r
- <li>Initialize global information (Framework DB, SPD files and all MSA files \r
- listed in SPD). This step will execute only once in whole build process;</li>\r
- <li>Parse specified FPD file; </li>\r
- <li>Generate FV.inf files; </li>\r
- <li>Generate build.out.xml file for Flatform or Package build; </li>\r
- <li>Collect PCD information. </li>\r
- </ul>\r
- \r
- @throws BuildException\r
- Surface area is not valid. \r
+ ANT task's entry method. The main steps is described as following:\r
+\r
+ <ul>\r
+ <li>Initialize global information (Framework DB, SPD files and all MSA files\r
+ listed in SPD). This step will execute only once in whole build process;</li>\r
+ <li>Parse specified FPD file; </li>\r
+ <li>Generate FV.inf files; </li>\r
+ <li>Generate PlatformName_build.xml file for Flatform build; </li>\r
+ <li>Collect PCD information. </li>\r
+ </ul>\r
+\r
+ @throws BuildException\r
+ Surface area is not valid.\r
**/\r
public void execute() throws BuildException {\r
- OutputManager.update(getProject());\r
- //\r
- // Parse DB and SPDs files. Initialize Global Data\r
- //\r
- GlobalData.initInfo("Tools" + File.separatorChar + "Conf" + File.separatorChar + "FrameworkDatabase.db", getProject()\r
- .getProperty("WORKSPACE_DIR"));\r
+ this.setTaskName("FpdParser");\r
+ \r
//\r
// Parse FPD file\r
//\r
parseFpdFile();\r
+\r
//\r
- // Gen Fv.inf files\r
+ // Prepare BUILD_DIR\r
//\r
- genFvInfFiles();\r
+ isUnified = OutputManager.getInstance().prepareBuildDir(getProject());\r
+\r
+ String buildDir = getProject().getProperty("BUILD_DIR");\r
+ //\r
+ // For every Target and ToolChain\r
+ //\r
+ String[] targetList = GlobalData.getToolChainInfo().getTargets();\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
+ //\r
+ // Prepare FV_DIR\r
+ //\r
+ String ffsCommonDir = buildDir + File.separatorChar\r
+ + targetList[i] + "_"\r
+ + toolchainList[j];\r
+ File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");\r
+ fvDir.mkdirs();\r
+ getProject().setProperty("FV_DIR", fvDir.getPath().replaceAll("(\\\\)", "/"));\r
+\r
+ //\r
+ // Gen Fv.inf files\r
+ //\r
+ genFvInfFiles(ffsCommonDir);\r
+ }\r
+ }\r
+\r
//\r
// Gen build.xml\r
//\r
- genBuildFile();\r
+ String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";\r
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);\r
+ fileGenerator.genBuildFile();\r
+\r
+ //\r
+ // Ant call ${PLATFORM}_build.xml\r
//\r
- // Collect PCD information \r
- // \r
- collectPCDInformation (); \r
+ Ant ant = new Ant();\r
+ ant.setProject(getProject());\r
+ ant.setAntfile(platformBuildFile);\r
+ ant.setTarget(type);\r
+ ant.setInheritAll(true);\r
+ ant.init();\r
+ ant.execute();\r
}\r
- \r
+\r
/**\r
- Generate Fv.inf files. The Fv.inf file is composed with four \r
- parts: Options, Attributes, Components and Files. The Fv.inf files \r
- will be under ${PLATFOMR_DIR}\Build\Fv.\r
- \r
+ Generate Fv.inf files. The Fv.inf file is composed with four\r
+ parts: Options, Attributes, Components and Files. The Fv.inf files\r
+ will be under FV_DIR.\r
+\r
@throws BuildException\r
- File write FV.inf files error. \r
+ File write FV.inf files error.\r
**/\r
- private void genFvInfFiles() 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
- getProject().setProperty("FV_FILENAME", validFv[i].toUpperCase());\r
//\r
// Get all global variables from FPD and set them to properties\r
//\r
- String[][] globalVariables = SurfaceAreaQuery\r
- .getFpdGlobalVariable();\r
+ String[][] globalVariables = saq.getFpdGlobalVariable();\r
for (int j = 0; j < globalVariables.length; j++) {\r
- getProject().setProperty(globalVariables[j][0],\r
- globalVariables[j][1]);\r
+ getProject().setProperty(globalVariables[j][0], globalVariables[j][1]);\r
}\r
\r
- File fvFile = new File(getProject().replaceProperties(\r
- FV_OUTPUT_DIR + File.separatorChar + validFv[i].toUpperCase()\r
- + ".inf"));\r
+ getProject().setProperty("FV_FILENAME", validFv[i]);\r
+\r
+ File fvFile = new File(getProject().replaceProperties( getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i] + ".inf"));\r
+ if (fvFile.exists() && (fvFile.lastModified() >= fpdFile.lastModified())) {\r
+ //\r
+ // don't re-generate FV.inf if fpd has not been changed\r
+ // \r
+ continue;\r
+ }\r
fvFile.getParentFile().mkdirs();\r
\r
try {\r
FileWriter fw = new FileWriter(fvFile);\r
BufferedWriter bw = new BufferedWriter(fw);\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
bw.newLine();\r
}\r
+\r
//\r
// Attributes;\r
//\r
- String[][] attributes = SurfaceAreaQuery\r
- .getFpdAttributes(validFv[i]);\r
+ String[][] attributes = saq.getFpdAttributes(validFv[i]);\r
if (attributes.length > 0) {\r
bw.write("[attributes]");\r
bw.newLine();\r
}\r
str.append("= ");\r
str.append(attributes[j][1]);\r
- bw\r
- .write(getProject().replaceProperties(\r
- str.toString()));\r
+ bw.write(getProject().replaceProperties(str.toString()));\r
bw.newLine();\r
}\r
bw.newLine();\r
}\r
+\r
//\r
// Components\r
//\r
- String[][] components = SurfaceAreaQuery\r
- .getFpdComponents(validFv[i]);\r
+ String[][] components = saq.getFpdComponents(validFv[i]);\r
if (components.length > 0) {\r
bw.write("[components]");\r
bw.newLine();\r
}\r
str.append("= ");\r
str.append(components[j][1]);\r
- bw\r
- .write(getProject().replaceProperties(\r
- str.toString()));\r
+ bw.write(getProject().replaceProperties(str.toString()));\r
bw.newLine();\r
}\r
bw.newLine();\r
}\r
+ \r
//\r
// Files\r
//\r
- Set<FpdModuleIdentification> filesSet = fvs.get(validFv[i].toUpperCase());\r
- if (filesSet != null) {\r
- FpdModuleIdentification[] files = filesSet.toArray(new FpdModuleIdentification[filesSet\r
- .size()]);\r
+ Set<FpdModuleIdentification> moduleSeqSet = getModuleSequenceForFv(validFv[i]);\r
+ \r
+ Set<FpdModuleIdentification> filesSet = fvs.get(validFv[i]);\r
+ \r
+ FpdModuleIdentification[] files = null;\r
+ \r
+ if (moduleSeqSet == null) {\r
+ if (filesSet != null) {\r
+ files = filesSet.toArray(new FpdModuleIdentification[filesSet.size()]);\r
+ }\r
+ } else if (filesSet == null) {\r
+ if (moduleSeqSet.size() != 0) {\r
+ throw new BuildException("Can not find any modules belongs to FV[" + validFv[i] + "], but listed some in BuildOptions.UserExtensions[@UserID='IMAGES' @Identifier='1']");\r
+ }\r
+ } else {\r
+ //\r
+ // if moduleSeqSet and filesSet is inconsistent, report error\r
+ //\r
+ if(moduleSeqSet.size() != filesSet.size()){\r
+ throw new BuildException("Modules for FV[" + validFv[i] + "] defined in FrameworkModules and in BuildOptions.UserExtensions[@UserID='IMAGES' @Identifier='1'] are inconsistent. ");\r
+ } else {\r
+ //\r
+ // whether all modules in moduleSeqSet listed in filesSet\r
+ //\r
+ Iterator<FpdModuleIdentification> iter = moduleSeqSet.iterator();\r
+ while (iter.hasNext()) {\r
+ FpdModuleIdentification item = iter.next();\r
+ if (!filesSet.contains(item)) {\r
+ throw new BuildException("Can not find " + item + " belongs to FV[" + validFv[i] + "]");\r
+ }\r
+ }\r
+ }\r
+ \r
+ files = moduleSeqSet.toArray(new FpdModuleIdentification[moduleSeqSet.size()]);\r
+ }\r
+ \r
+ \r
+ if (files != null) {\r
bw.write("[files]");\r
bw.newLine();\r
for (int j = 0; j < files.length; j++) {\r
- String str = outfiles.get(files[j]);\r
- bw.write(getProject().replaceProperties(\r
- "EFI_FILE_NAME = " + str));\r
+ String str = ffsCommonDir + File.separatorChar + outfiles.get(files[j]);\r
+ bw.write(getProject().replaceProperties("EFI_FILE_NAME = " + str));\r
bw.newLine();\r
}\r
}\r
bw.flush();\r
bw.close();\r
fw.close();\r
- } catch (Exception e) {\r
- throw new BuildException("Generate Fv.inf file failed. \n" + e.getMessage());\r
+ } catch (IOException ex) {\r
+ BuildException buildException = new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + ex.getMessage());\r
+ buildException.setStackTrace(ex.getStackTrace());\r
+ throw buildException;\r
+ } catch (EdkException ex) {\r
+ BuildException buildException = new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + ex.getMessage());\r
+ buildException.setStackTrace(ex.getStackTrace());\r
+ throw buildException;\r
}\r
}\r
}\r
-\r
/**\r
- Parse FPD file. \r
- \r
+ This method is used for Single Module Build.\r
+\r
+\r
@throws BuildException\r
- FPD file is not valid. \r
+ FPD file is not valid.\r
**/\r
- private void parseFpdFile() throws BuildException {\r
+ public void parseFpdFile(File fpdFile) throws BuildException, EdkException {\r
+ this.fpdFile = fpdFile;\r
+ parseFpdFile();\r
+ \r
+ //\r
+ // Call Platform_build.xml prebuild firstly in stand-alone build\r
+ // Prepare BUILD_DIR\r
+ //\r
+ isUnified = OutputManager.getInstance().prepareBuildDir(getProject());\r
+\r
+ String buildDir = getProject().getProperty("BUILD_DIR");\r
+ //\r
+ // For every Target and ToolChain\r
+ //\r
+ String[] targetList = GlobalData.getToolChainInfo().getTargets();\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
+ //\r
+ // Prepare FV_DIR\r
+ //\r
+ String ffsCommonDir = buildDir + File.separatorChar\r
+ + targetList[i] + "_"\r
+ + toolchainList[j];\r
+ File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");\r
+ fvDir.mkdirs();\r
+ }\r
+ }\r
+\r
+ String platformBuildFile = buildDir + File.separatorChar + platformId.getName() + "_build.xml";\r
+ PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified, saq, platformBuildFile);\r
+ fileGenerator.genBuildFile();\r
+ \r
+ Ant ant = new Ant();\r
+ ant.setProject(getProject());\r
+ ant.setAntfile(platformBuildFile);\r
+ ant.setTarget("prebuild");\r
+ ant.setInheritAll(true);\r
+ ant.init();\r
+ ant.execute();\r
+ }\r
+\r
+ /**\r
+ Parse FPD file.\r
+\r
+ @throws BuildException\r
+ FPD file is not valid.\r
+ **/\r
+ void parseFpdFile() throws BuildException {\r
try {\r
- FrameworkPlatformDescriptionDocument doc = (FrameworkPlatformDescriptionDocument) XmlObject.Factory\r
- .parse(fpdFilename);\r
- if ( ! doc.validate() ){\r
- throw new BuildException("FPD file is invalid.");\r
+ XmlObject doc = XmlObject.Factory.parse(fpdFile);\r
+\r
+ if (!doc.validate()) {\r
+ throw new BuildException("Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");\r
}\r
- platformBuildOptions = doc.getFrameworkPlatformDescription()\r
- .getBuildOptions();\r
- HashMap<String, XmlObject> map = new HashMap<String, XmlObject>();\r
- map.put("FrameworkPlatformDescription", doc);\r
- SurfaceAreaQuery.setDoc(map);\r
+\r
+ Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
+ map.put("PlatformSurfaceArea", doc);\r
+ saq = new SurfaceAreaQuery(map);\r
+\r
+ //\r
+ // Initialize\r
+ //\r
+ platformId = saq.getFpdHeader();\r
+ platformId.setFpdFile(fpdFile);\r
+ getProject().setProperty("PLATFORM", platformId.getName());\r
+ getProject().setProperty("PLATFORM_FILE", platformId.getRelativeFpdFile().replaceAll("(\\\\)", "/"));\r
+ getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));\r
+ getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));\r
+ \r
+ if( !FrameworkBuildTask.multithread) {\r
+ FrameworkBuildTask.originalProperties.put("PLATFORM", platformId.getName());\r
+ FrameworkBuildTask.originalProperties.put("PLATFORM_FILE", platformId.getRelativeFpdFile().replaceAll("(\\\\)", "/"));\r
+ FrameworkBuildTask.originalProperties.put("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));\r
+ FrameworkBuildTask.originalProperties.put("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));\r
+ }\r
+\r
+ //\r
+ // Build mode. User-defined output dir.\r
+ //\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(saq.getFpdBuildOptions());\r
+\r
+ GlobalData.setToolChainPlatformInfo(saq.getFpdToolChainInfo());\r
+\r
//\r
// Parse all list modules SA\r
//\r
parseModuleSAFiles();\r
- SurfaceAreaQuery.setDoc(map);\r
- } catch (Exception e) {\r
- throw new BuildException("Load FPD file [" + fpdFilename.getPath()\r
- + "] error. \n" + e.getMessage());\r
+\r
+ //\r
+ // TBD. Deal PCD and BuildOption related Info\r
+ //\r
+ parseToolChainFamilyOptions();\r
+ parseToolChainOptions();\r
+\r
+ saq.push(map);\r
+\r
+ //\r
+ // Pcd Collection. Call CollectPCDAction to collect pcd info.\r
+ //\r
+ PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
+ ca.perform(platformId.getFpdFile().getPath(), ActionMessage.NULL_MESSAGE_LEVEL);\r
+ } catch (IOException ex) {\r
+ BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());\r
+ buildException.setStackTrace(ex.getStackTrace());\r
+ throw buildException;\r
+ } catch (XmlException ex) {\r
+ BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());\r
+ buildException.setStackTrace(ex.getStackTrace());\r
+ throw buildException;\r
+ } catch (EdkException ex) {\r
+ BuildException buildException = new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + ex.getMessage());\r
+ buildException.setStackTrace(ex.getStackTrace());\r
+ throw buildException;\r
}\r
}\r
\r
/**\r
- Parse all modules listed in FPD file. \r
+ Parse all modules listed in FPD file.\r
**/\r
- private void parseModuleSAFiles() {\r
- ModuleSADocument.ModuleSA[] moduleSAs = SurfaceAreaQuery\r
- .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
- for (int i = 0; i < moduleSAs.length; i++) {\r
- String defaultFv = "NULL";\r
- String defaultArch = "IA32";\r
- String baseName = moduleSAs[i].getModuleName();\r
- if (baseName == null) {\r
- System.out.println("Warning: Module Name is not specified.");\r
- continue;\r
- }\r
- String fvBinding = moduleSAs[i].getFvBinding();\r
+ Set<FpdModuleIdentification> keys = moduleSAs.keySet();\r
+ Iterator iter = keys.iterator();\r
+ while (iter.hasNext()) {\r
+ FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();\r
+\r
//\r
- // If the module do not specify any FvBinding, use the default value.\r
- // Else update the default FvBinding value to this value.\r
+ // Judge if Module is existed?\r
+ // TBD\r
+ GlobalData.registerFpdModuleSA(fpdModuleId, moduleSAs.get(fpdModuleId));\r
+\r
//\r
- if (fvBinding == null) {\r
- fvBinding = defaultFv;\r
- }\r
- else {\r
- defaultFv = fvBinding;\r
- }\r
- String arch;\r
+ // Put fpdModuleId to the corresponding FV\r
//\r
- // If the module do not specify any Arch, use the default value.\r
- // Else update the default Arch value to this value.\r
+ saq.push(GlobalData.getDoc(fpdModuleId));\r
+ String fvBinding = saq.getModuleFvBindingKeyword();\r
+\r
+ fpdModuleId.setFvBinding(fvBinding);\r
+ updateFvs(fvBinding, fpdModuleId);\r
+\r
//\r
- if (moduleSAs[i].getArch() == null ){\r
- arch = defaultArch;\r
- }\r
- else {\r
- arch = moduleSAs[i].getArch().toString();\r
- defaultArch = arch;\r
+ // Prepare for out put file name\r
+ //\r
+ ModuleIdentification moduleId = fpdModuleId.getModule();\r
+\r
+ String baseName = saq.getModuleOutputFileBasename();\r
+ \r
+ if (baseName == null) {\r
+ baseName = moduleId.getName();\r
}\r
- Map<String, XmlObject> msaMap = GlobalData.getNativeMsa(baseName);\r
- Map<String, XmlObject> mbdMap = GlobalData.getNativeMbd(baseName);\r
- Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
+ outfiles.put(fpdModuleId, fpdModuleId.getArch() + File.separatorChar\r
+ + moduleId.getGuid() + "-" + baseName\r
+ + getSuffix(moduleId.getModuleType()));\r
+\r
//\r
- // Whether the Module SA has parsed before or not\r
+ // parse module build options, if any\r
//\r
- if (!GlobalData.isModuleParsed(baseName)) {\r
- OverrideProcess op = new OverrideProcess();\r
- //\r
- // using overriding rules\r
- // Here we can also put platform Build override\r
- //\r
- map = op.override(mbdMap, msaMap);\r
- Map<String, XmlObject> overrideMap = op.override(\r
- getPlatformOverrideInfo(moduleSAs[i]),\r
- OverrideProcess.deal(map));\r
- GlobalData.registerModule(baseName, overrideMap);\r
- } else {\r
- map = GlobalData.getDoc(baseName);\r
+ GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));\r
+ GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));\r
+ saq.pop();\r
+ }\r
+ }\r
+\r
+ ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
+ String[][] options = saq.getModuleBuildOptions(toolChainFamilyFlag);\r
+ if (options == null || options.length == 0) {\r
+ return new ToolChainMap();\r
+ }\r
+ return parseOptions(options);\r
+ }\r
+\r
+ private ToolChainMap parsePlatformBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
+ String[][] options = saq.getPlatformBuildOptions(toolChainFamilyFlag);\r
+ if (options == null || options.length == 0) {\r
+ return new ToolChainMap();\r
+ }\r
+ return parseOptions(options);\r
+ }\r
+\r
+ private ToolChainMap parseOptions(String[][] options) throws EdkException {\r
+ ToolChainMap map = new ToolChainMap();\r
+ int flagIndex = ToolChainElement.ATTRIBUTE.value;\r
+\r
+ for (int i = 0; i < options.length; ++i) {\r
+ String flagString = options[i][flagIndex];\r
+ if (flagString == null) {\r
+ flagString = "";\r
}\r
- SurfaceAreaQuery.setDoc(map);\r
- String guid = SurfaceAreaQuery.getModuleGuid();\r
- String componentType = SurfaceAreaQuery.getComponentType();\r
- FpdModuleIdentification moduleId = new FpdModuleIdentification(baseName, guid, arch);\r
- updateFvs(fvBinding, moduleId);\r
- outfiles.put(moduleId, "${PLATFORM_DIR}" + File.separatorChar + "Build" + File.separatorChar \r
- + "${TARGET}" + File.separatorChar + arch\r
- + File.separatorChar + guid + "-" + baseName\r
- + getSuffix(componentType));\r
+ options[i][flagIndex] = ToolChainAttribute.FLAGS + "";\r
+ map.put(options[i], flagString.trim());\r
}\r
+\r
+ return map;\r
+ }\r
+\r
+ private void parseToolChainFamilyOptions() throws EdkException {\r
+ GlobalData.setPlatformToolChainFamilyOption(parsePlatformBuildOptions(true));\r
+ }\r
+\r
+ private void parseToolChainOptions() throws EdkException {\r
+ GlobalData.setPlatformToolChainOption(parsePlatformBuildOptions(false));\r
}\r
\r
/**\r
- Add the current module to corresponding FV. \r
- \r
+ Add the current module to corresponding FV.\r
+\r
@param fvName current FV name\r
@param moduleName current module identification\r
**/\r
- private void updateFvs(String fvName, FpdModuleIdentification moduleName) {\r
- String upcaseFvName = fvName.toUpperCase();\r
- if (fvs.containsKey(upcaseFvName)) {\r
- Set<FpdModuleIdentification> set = fvs.get(upcaseFvName);\r
- set.add(moduleName);\r
- } else {\r
- Set<FpdModuleIdentification> set = new LinkedHashSet<FpdModuleIdentification>();\r
- set.add(moduleName);\r
- fvs.put(upcaseFvName, set);\r
+ void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {\r
+ if (fvName == null || fvName.trim().length() == 0) {\r
+ fvName = "NULL";\r
+ }\r
+ String[] fvNameArray = fvName.split("[, \t]+");\r
+ for (int i = 0; i < fvNameArray.length; i++) {\r
+ //\r
+ // Put module to corresponding fvName\r
+ //\r
+ if (fvs.containsKey(fvNameArray[i])) {\r
+ Set<FpdModuleIdentification> set = fvs.get(fvNameArray[i]);\r
+ set.add(fpdModuleId);\r
+ } else {\r
+ Set<FpdModuleIdentification> set = new LinkedHashSet<FpdModuleIdentification>();\r
+ set.add(fpdModuleId);\r
+ fvs.put(fvNameArray[i], set);\r
+ }\r
}\r
}\r
\r
/**\r
- Get the suffix based on component type. Current relationship are listed: \r
- \r
+ Get the suffix based on module type. Current relationship are listed:\r
+\r
<pre>\r
- <b>ComponentType</b> <b>Suffix</b>\r
- APPLICATION .APP\r
- SEC .SEC\r
- PEI_CORE .PEI\r
- PE32_PEIM .PEI\r
- RELOCATABLE_PEIM .PEI\r
- PIC_PEIM .PEI\r
- COMBINED_PEIM_DRIVER .PEI\r
- TE_PEIM .PEI\r
- LOGO .FFS\r
- others .DXE\r
+ <b>ModuleType</b> <b>Suffix</b>\r
+ BASE .FFS\r
+ SEC .SEC\r
+ PEI_CORE .PEI\r
+ PEIM .PEI\r
+ DXE_CORE .DXE\r
+ DXE_DRIVER .DXE\r
+ DXE_RUNTIME_DRIVER .DXE\r
+ DXE_SAL_DRIVER .DXE\r
+ DXE_SMM_DRIVER .DXE\r
+ TOOL .FFS\r
+ UEFI_DRIVER .DXE\r
+ UEFI_APPLICATION .APP\r
+ USER_DEFINED .FFS\r
</pre>\r
- \r
- @param componentType component type\r
+\r
+ @param moduleType module type\r
@return\r
@throws BuildException\r
- If component type is null\r
+ If module type is null\r
**/\r
- public static String getSuffix(String componentType) throws BuildException{\r
- if (componentType == null) {\r
- throw new BuildException("Component type is not specified.");\r
+ public static String getSuffix(String moduleType) throws BuildException {\r
+ if (moduleType == null) {\r
+ throw new BuildException("Module type is not specified.");\r
}\r
- String str = ".DXE";\r
- if (componentType.equalsIgnoreCase("APPLICATION")) {\r
- str = ".APP";\r
- } else if (componentType.equalsIgnoreCase("SEC")) {\r
- str = ".SEC";\r
- } else if (componentType.equalsIgnoreCase("PEI_CORE")) {\r
- str = ".PEI";\r
- } else if (componentType.equalsIgnoreCase("PE32_PEIM")) {\r
- str = ".PEI";\r
- } else if (componentType.equalsIgnoreCase("RELOCATABLE_PEIM")) {\r
- str = ".PEI";\r
- } else if (componentType.equalsIgnoreCase("PIC_PEIM")) {\r
- str = ".PEI";\r
- } else if (componentType.equalsIgnoreCase("COMBINED_PEIM_DRIVER")) {\r
- str = ".PEI";\r
- } else if (componentType.equalsIgnoreCase("TE_PEIM")) {\r
- str = ".PEI";\r
- } else if (componentType.equalsIgnoreCase("LOGO")) {\r
- str = ".FFS";\r
+\r
+ String[][] suffix = EdkDefinitions.ModuleTypeExtensions;\r
+\r
+ for (int i = 0; i < suffix.length; i++) {\r
+ if (suffix[i][0].equalsIgnoreCase(moduleType)) {\r
+ return suffix[i][1];\r
+ }\r
}\r
- return str;\r
+ //\r
+ // Default is '.FFS'\r
+ //\r
+ return ".FFS";\r
}\r
-\r
/**\r
- Parse module surface are info described in FPD file and put them into map. \r
- \r
- @param sa module surface area info descibed in FPD file\r
- @return map list with top level elements\r
- **/\r
- private Map<String, XmlObject> getPlatformOverrideInfo(\r
- ModuleSADocument.ModuleSA sa) {\r
- Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
- map.put("SourceFiles", sa.getSourceFiles());\r
- map.put("Includes", sa.getIncludes());\r
- map.put("Libraries", sa.getLibraries());\r
- map.put("Protocols", sa.getProtocols());\r
- map.put("Events", sa.getEvents());\r
- map.put("Hobs", sa.getHobs());\r
- map.put("PPIs", sa.getPPIs());\r
- map.put("Variables", sa.getVariables());\r
- map.put("BootModes", sa.getBootModes());\r
- map.put("SystemTables", sa.getSystemTables());\r
- map.put("DataHubs", sa.getDataHubs());\r
- map.put("Formsets", sa.getFormsets());\r
- map.put("Guids", sa.getGuids());\r
- map.put("Externs", sa.getExterns());\r
- map.put("BuildOptions", platformBuildOptions);\r
- return map;\r
+ Add a property.\r
+\r
+ @param p property\r
+ **/\r
+ public void addProperty(Property p) {\r
+ properties.addElement(p);\r
}\r
\r
- /**\r
- Generate build.out.xml file.\r
- \r
- @throws BuildException\r
- build.out.xml XML document create error\r
- **/\r
- private void genBuildFile() throws BuildException {\r
- DocumentBuilderFactory domfac = DocumentBuilderFactory.newInstance();\r
- try {\r
- DocumentBuilder dombuilder = domfac.newDocumentBuilder();\r
- Document document = dombuilder.newDocument();\r
- Comment rootComment = document.createComment(info);\r
- //\r
- // create root element and its attributes\r
- //\r
- Element root = document.createElement("project");\r
- root.setAttribute("name", getProject().getProperty("PLATFORM"));\r
- root.setAttribute("default", "main");\r
- root.setAttribute("basedir", ".");\r
- //\r
- // element for External ANT tasks\r
- //\r
- root.appendChild(document.createComment("Apply external ANT tasks"));\r
- Element ele = document.createElement("taskdef");\r
- ele.setAttribute("resource", "GenBuild.tasks");\r
- root.appendChild(ele);\r
-\r
- ele = document.createElement("taskdef");\r
- ele.setAttribute("resource", "frameworktasks.tasks");\r
- root.appendChild(ele);\r
-\r
- ele = document.createElement("property");\r
- ele.setAttribute("environment", "env");\r
- root.appendChild(ele);\r
- //\r
- // Default Target\r
- //\r
- root.appendChild(document.createComment("Default target"));\r
- ele = document.createElement("target");\r
- ele.setAttribute("name", "main");\r
- ele.setAttribute("depends", "modules, fvs");\r
- root.appendChild(ele);\r
- //\r
- // Modules Target\r
- //\r
- root.appendChild(document.createComment("Modules target"));\r
- ele = document.createElement("target");\r
- ele.setAttribute("name", "modules");\r
-\r
- Set set = outfiles.keySet();\r
- Iterator iter = set.iterator();\r
- while (iter.hasNext()) {\r
- FpdModuleIdentification moduleId = (FpdModuleIdentification) iter.next();\r
- String baseName = moduleId.getBaseName();\r
- Element moduleEle = document.createElement("ant");\r
- moduleEle.setAttribute("antfile", GlobalData\r
- .getModulePath(baseName)\r
- + File.separatorChar + "build.xml");\r
- moduleEle.setAttribute("target", baseName);\r
- //\r
- // ARCH\r
- //\r
- Element property = document.createElement("property");\r
- property.setAttribute("name", "ARCH");\r
- property.setAttribute("value", moduleId.getArch());\r
- moduleEle.appendChild(property);\r
- //\r
- // PACKAGE_DIR\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE_DIR");\r
- property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar\r
- + GlobalData.getPackagePathForModule(baseName));\r
- moduleEle.appendChild(property);\r
- //\r
- // PACKAGE\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE");\r
- property.setAttribute("value", GlobalData\r
- .getPackageNameForModule(baseName));\r
- moduleEle.appendChild(property);\r
- ele.appendChild(moduleEle);\r
- }\r
- root.appendChild(ele);\r
- //\r
- // FVS Target\r
- //\r
- root.appendChild(document.createComment("FVs target"));\r
- ele = document.createElement("target");\r
- ele.setAttribute("name", "fvs");\r
-\r
- String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();\r
- for (int i = 0; i < validFv.length; i++) {\r
- String inputFile = FV_OUTPUT_DIR + "" + File.separatorChar\r
- + validFv[i].toUpperCase() + ".inf";\r
- Element fvEle = document.createElement("genfvimage");\r
- fvEle.setAttribute("infFile", inputFile);\r
- ele.appendChild(fvEle);\r
- Element moveEle = document.createElement("move");\r
- moveEle.setAttribute("file", validFv[i].toUpperCase() + ".fv");\r
- moveEle.setAttribute("todir", FV_OUTPUT_DIR);\r
- ele.appendChild(moveEle);\r
- }\r
- root.appendChild(ele);\r
- \r
- boolean isUnified = false;\r
- BuildOptionsDocument.BuildOptions buildOptions = (BuildOptionsDocument.BuildOptions)platformBuildOptions;\r
- if (buildOptions.getOutputDirectory() != null){\r
- if (buildOptions.getOutputDirectory().getIntermediateDirectories() != null){\r
- if (buildOptions.getOutputDirectory().getIntermediateDirectories().toString().equalsIgnoreCase("UNIFIED")){\r
- isUnified = true;\r
- }\r
- }\r
- }\r
- //\r
- // Clean Target\r
- //\r
- root.appendChild(document.createComment("Clean target"));\r
- ele = document.createElement("target");\r
- ele.setAttribute("name", "clean");\r
+ public void setFpdFile(File fpdFile) {\r
+ this.fpdFile = fpdFile;\r
+ }\r
+\r
+ public void setType(String type) {\r
+ this.type = type;\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 (isUnified) {\r
- Element cleanEle = document.createElement("delete");\r
- cleanEle.setAttribute("includeemptydirs", "true");\r
- Element filesetEle = document.createElement("fileset");\r
- filesetEle.setAttribute("dir", getProject().getProperty("PLATFORM_DIR") + File.separatorChar + "Build" + File.separatorChar + "${TARGET}");\r
- filesetEle.setAttribute("includes", "**/OUTPUT/**");\r
- cleanEle.appendChild(filesetEle);\r
- ele.appendChild(cleanEle);\r
+ if (fpdModuleId.getModule().equals(moduleId)) {\r
+ archs += fpdModuleId.getArch() + " ";\r
}\r
- else {\r
- set = outfiles.keySet();\r
- iter = set.iterator();\r
- while (iter.hasNext()) {\r
- FpdModuleIdentification moduleId = (FpdModuleIdentification) iter.next();\r
- String baseName = moduleId.getBaseName();\r
- \r
- Element ifEle = document.createElement("if");\r
- Element availableEle = document.createElement("available");\r
- availableEle.setAttribute("file", GlobalData\r
- .getModulePath(baseName)\r
- + File.separatorChar + "build.xml");\r
- ifEle.appendChild(availableEle);\r
- Element elseEle = document.createElement("then");\r
+ }\r
+ \r
+ return archs;\r
+ }\r
\r
- Element moduleEle = document.createElement("ant");\r
- moduleEle.setAttribute("antfile", GlobalData\r
- .getModulePath(baseName)\r
- + File.separatorChar + "build.xml");\r
- moduleEle.setAttribute("target", baseName + "_clean");\r
- //\r
- // ARCH\r
- //\r
- Element property = document.createElement("property");\r
- property.setAttribute("name", "ARCH");\r
- property.setAttribute("value", moduleId.getArch());\r
- moduleEle.appendChild(property);\r
- //\r
- // PACKAGE_DIR\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE_DIR");\r
- property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar\r
- + GlobalData.getPackagePathForModule(baseName));\r
- moduleEle.appendChild(property);\r
+ private Set<FpdModuleIdentification> getModuleSequenceForFv(String fvName) throws EdkException {\r
+ Node node = saq.getFpdModuleSequence(fvName);\r
+ Set<FpdModuleIdentification> result = new LinkedHashSet<FpdModuleIdentification>();\r
+ \r
+ if ( node == null) {\r
+ EdkLog.log(this, EdkLog.EDK_WARNING, "FV[" + fvName + "] does not specify module sequence in FPD. Assuming present sequence as default sequence in FV. ");\r
+ return null;\r
+ } else {\r
+ NodeList childNodes = node.getChildNodes();\r
+ for (int i = 0; i < childNodes.getLength(); i++) {\r
+ Node childItem = childNodes.item(i);\r
+ if (childItem.getNodeType() == Node.ELEMENT_NODE) {\r
//\r
- // PACKAGE\r
+ // Find child elements "IncludeModules"\r
//\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE");\r
- property.setAttribute("value", GlobalData\r
- .getPackageNameForModule(baseName));\r
- moduleEle.appendChild(property);\r
- elseEle.appendChild(moduleEle);\r
- ifEle.appendChild(elseEle);\r
- ele.appendChild(ifEle);\r
+ if (childItem.getNodeName().compareTo("IncludeModules") == 0) {\r
+ //\r
+ // result will be updated\r
+ //\r
+ processNodes(childItem, result);\r
+ } else if (childItem.getNodeName().compareTo("FvName") == 0) {\r
+ \r
+ } else if (childItem.getNodeName().compareTo("InfFileName") == 0) {\r
+ \r
+ } else {\r
+ //\r
+ // Report Warning\r
+ //\r
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1']");\r
+ }\r
}\r
}\r
- root.appendChild(ele);\r
- //\r
- // Deep Clean Target\r
- //\r
- root.appendChild(document.createComment("Clean All target"));\r
- ele = document.createElement("target");\r
- ele.setAttribute("name", "cleanall");\r
-\r
- if (isUnified) {\r
- Element cleanAllEle = document.createElement("delete");\r
- cleanAllEle.setAttribute("dir", getProject().getProperty("PLATFORM_DIR") + File.separatorChar + "Build" + File.separatorChar + "${TARGET}");\r
- ele.appendChild(cleanAllEle);\r
- }\r
- else {\r
- set = outfiles.keySet();\r
- iter = set.iterator();\r
- while (iter.hasNext()) {\r
- FpdModuleIdentification moduleId = (FpdModuleIdentification) iter.next();\r
- String baseName = moduleId.getBaseName();\r
- \r
- Element ifEle = document.createElement("if");\r
- Element availableEle = document.createElement("available");\r
- availableEle.setAttribute("file", GlobalData\r
- .getModulePath(baseName)\r
- + File.separatorChar + "build.xml");\r
- ifEle.appendChild(availableEle);\r
- Element elseEle = document.createElement("then");\r
+ }\r
+ \r
+ return result;\r
+ }\r
\r
- Element moduleEle = document.createElement("ant");\r
- moduleEle.setAttribute("antfile", GlobalData\r
- .getModulePath(baseName)\r
- + File.separatorChar + "build.xml");\r
- moduleEle.setAttribute("target", baseName + "_cleanall");\r
- //\r
- // ARCH\r
- //\r
- Element property = document.createElement("property");\r
- property.setAttribute("name", "ARCH");\r
- property.setAttribute("value", moduleId.getArch());\r
- moduleEle.appendChild(property);\r
- //\r
- // PACKAGE_DIR\r
- //\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE_DIR");\r
- property.setAttribute("value", "${WORKSPACE_DIR}" + File.separatorChar\r
- + GlobalData.getPackagePathForModule(baseName));\r
- moduleEle.appendChild(property);\r
+ private void processNodes(Node node, Set<FpdModuleIdentification> result) throws EdkException {\r
+ //\r
+ // Found out all elements "Module"\r
+ //\r
+ NodeList childNodes = node.getChildNodes();\r
+ for (int j = 0; j < childNodes.getLength(); j++) {\r
+ Node childItem = childNodes.item(j);\r
+ if (childItem.getNodeType() == Node.ELEMENT_NODE) {\r
+ if (childItem.getNodeName().compareTo("Module") == 0) {\r
+ String moduleGuid = null;\r
+ String moduleVersion = null;\r
+ String packageGuid = null;\r
+ String packageVersion = null;\r
+ String arch = null;\r
+ \r
+ NamedNodeMap attr = childItem.getAttributes();\r
+ for (int i = 0; i < attr.getLength(); i++) {\r
+ Node attrItem = attr.item(i);\r
+ if (attrItem.getNodeName().compareTo("ModuleGuid") == 0) {\r
+ moduleGuid = attrItem.getNodeValue();\r
+ } else if (attrItem.getNodeName().compareTo("ModuleVersion") == 0) {\r
+ moduleVersion = attrItem.getNodeValue();\r
+ } else if (attrItem.getNodeName().compareTo("PackageGuid") == 0) {\r
+ packageGuid = attrItem.getNodeValue();\r
+ } else if (attrItem.getNodeName().compareTo("PackageVersion") == 0) {\r
+ packageVersion = attrItem.getNodeValue();\r
+ } else if (attrItem.getNodeName().compareTo("Arch") == 0) {\r
+ arch = attrItem.getNodeValue();\r
+ } else {\r
+ //\r
+ // Report warning\r
+ //\r
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised attribute " + attrItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules.Module");\r
+ }\r
+ }\r
+ \r
+ PackageIdentification packageId = new PackageIdentification(packageGuid, packageVersion);\r
+ GlobalData.refreshPackageIdentification(packageId);\r
+ \r
+ ModuleIdentification moduleId = new ModuleIdentification(moduleGuid, moduleVersion);\r
+ moduleId.setPackage(packageId);\r
+ GlobalData.refreshModuleIdentification(moduleId);\r
+ \r
+ if (arch == null) {\r
+ throw new EdkException("Attribute [Arch] is required for element FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules.Module. ");\r
+ }\r
+ \r
+ result.add(new FpdModuleIdentification(moduleId, arch));\r
+ } else {\r
//\r
- // PACKAGE\r
+ // Report Warning\r
//\r
- property = document.createElement("property");\r
- property.setAttribute("name", "PACKAGE");\r
- property.setAttribute("value", GlobalData\r
- .getPackageNameForModule(baseName));\r
- moduleEle.appendChild(property);\r
- elseEle.appendChild(moduleEle);\r
- ifEle.appendChild(elseEle);\r
- ele.appendChild(ifEle);\r
+ EdkLog.log(this, EdkLog.EDK_WARNING, "Unrecognised element " + childItem.getNodeName() + " under FPD.BuildOptions.UserExtensions[UserID='IMAGES' Identifier='1'].IncludeModules");\r
}\r
}\r
- root.appendChild(ele);\r
- \r
- document.appendChild(rootComment);\r
- document.appendChild(root);\r
- //\r
- // Prepare the DOM document for writing\r
- //\r
- Source source = new DOMSource(document);\r
- //\r
- // Prepare the output file\r
- //\r
- File file = new File(getProject().getProperty("PLATFORM_DIR")\r
- + File.separatorChar + "build.out.xml");\r
- //\r
- // generate all directory path\r
- //\r
- (new File(file.getParent())).mkdirs();\r
- Result result = new StreamResult(file);\r
- //\r
- // Write the DOM document to the file\r
- //\r
- Transformer xformer = TransformerFactory.newInstance()\r
- .newTransformer();\r
- xformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");\r
- xformer.setOutputProperty(OutputKeys.INDENT, "yes");\r
- xformer.transform(source, result);\r
- } catch (Exception ex) {\r
- throw new BuildException("Generate build.out.xml failed. \n" + ex.getMessage());\r
}\r
}\r
-\r
- /**\r
- Add a property. \r
- \r
- @param p property\r
- **/\r
- public void addProperty(Property p) {\r
- properties.addElement(p);\r
- }\r
-\r
- /**\r
- Get FPD file name.\r
- \r
- @return FPD file name.\r
- **/\r
- public File getFpdFilename() {\r
- return fpdFilename;\r
- }\r
-\r
- /**\r
- Set FPD file name.\r
- \r
- @param fpdFilename FPD file name\r
- **/\r
- public void setFpdFilename(File fpdFilename) {\r
- this.fpdFilename = fpdFilename;\r
- }\r
-\r
- public File getGuiddatabase() {\r
- return guiddatabase;\r
- }\r
-\r
- public void setGuiddatabase(File guiddatabase) {\r
- this.guiddatabase = guiddatabase;\r
- }\r
-\r
- public void collectPCDInformation() {\r
- CollectPCDAction collectAction = new CollectPCDAction ();\r
- //\r
- // Set memory database log file path. It should be put into same directory with FPD file. \r
- //\r
- GlobalData.getPCDMemoryDBManager().setLogFileName(\r
- fpdFilename.getPath() + ".PCDMemroyDatabaseLog.txt"\r
- );\r
- //\r
- // Collect all PCD information from FPD to MSA, and get help information from SPD.\r
- // These all information will be stored into memory database for future usage such \r
- // as autogen.\r
- //\r
- try {\r
- collectAction.perform (\r
- getProject().getProperty("WORKSPACE_DIR"),\r
- fpdFilename.getPath(),\r
- ActionMessage.NULL_MESSAGE_LEVEL\r
- );\r
- } catch (Exception exp) {\r
- throw new BuildException (exp.getMessage());\r
- }\r
- }\r
}\r