]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
initialize text fields to empty when switching dynamic pcd entries.
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / fpd / FpdParserTask.java
CommitLineData
878ddf1f 1/** @file\r
ff225cbb 2 This file is ANT task FpdParserTask.\r
3\r
a29c47e0 4 FpdParserTask is used to parse FPD (Framework Platform Description) and generate\r
ff225cbb 5 build.out.xml. It is for Package or Platform build use.\r
6\r
a29c47e0 7 Copyright (c) 2006, Intel Corporation\r
8 All rights reserved. This program and the accompanying materials\r
9 are licensed and made available under the terms and conditions of the BSD License\r
10 which accompanies this distribution. The full text of the license may be found at\r
11 http://opensource.org/licenses/bsd-license.php\r
12\r
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
15 **/\r
878ddf1f 16package org.tianocore.build.fpd;\r
17\r
18import java.io.BufferedWriter;\r
19import java.io.File;\r
20import java.io.FileWriter;\r
21import java.util.HashMap;\r
22import java.util.Iterator;\r
23import java.util.LinkedHashMap;\r
24import java.util.LinkedHashSet;\r
25import java.util.Map;\r
26import java.util.Set;\r
27import java.util.Vector;\r
878ddf1f 28\r
29import org.apache.tools.ant.BuildException;\r
30import org.apache.tools.ant.Task;\r
a29c47e0 31import org.apache.tools.ant.taskdefs.Ant;\r
878ddf1f 32import org.apache.tools.ant.taskdefs.Property;\r
33import org.apache.xmlbeans.XmlObject;\r
878ddf1f 34\r
4a6a5026 35import org.tianocore.common.definitions.EdkDefinitions;\r
ff225cbb 36import org.tianocore.common.exception.EdkException;\r
37import org.tianocore.pcd.action.ActionMessage;\r
878ddf1f 38import org.tianocore.build.global.GlobalData;\r
39import org.tianocore.build.global.OutputManager;\r
878ddf1f 40import org.tianocore.build.global.SurfaceAreaQuery;\r
a29c47e0 41import org.tianocore.build.id.FpdModuleIdentification;\r
42import org.tianocore.build.id.ModuleIdentification;\r
43import org.tianocore.build.id.PlatformIdentification;\r
af98370e 44import org.tianocore.build.pcd.action.PlatformPcdPreprocessActionForBuilding;\r
a29c47e0 45import org.tianocore.build.toolchain.ToolChainAttribute;\r
46import org.tianocore.build.toolchain.ToolChainElement;\r
47import org.tianocore.build.toolchain.ToolChainMap;\r
878ddf1f 48\r
49/**\r
a29c47e0 50 <code>FpdParserTask</code> is an ANT task. The main function is parsing Framework\r
ff225cbb 51 Platform Descritpion (FPD) XML file and generating its ANT build script for\r
52 corresponding platform.\r
a29c47e0 53\r
54 <p>The task sets global properties PLATFORM, PLATFORM_DIR, PLATFORM_RELATIVE_DIR\r
55 and BUILD_DIR. </p>\r
ff225cbb 56\r
a29c47e0 57 <p>The task generates ${PLATFORM}_build.xml file which will be called by top level\r
4b5f5549 58 build.xml. The task also generate Fv.inf files (File is for Tool GenFvImage). </p>\r
ff225cbb 59\r
a29c47e0 60 <p>FpdParserTask task stores all FPD information to GlobalData. And parse\r
61 tools definition file to set up compiler options for different Target and\r
62 different ToolChainTag. </p>\r
ff225cbb 63\r
a29c47e0 64 <p>The method parseFpdFile is also prepared for single module build. </p>\r
ff225cbb 65\r
a29c47e0 66 <p>The usage is (take NT32 Platform for example):</p>\r
67\r
878ddf1f 68 <pre>\r
a29c47e0 69 &lt;FPDParser platformName="Nt32" /&gt;\r
878ddf1f 70 </pre>\r
a29c47e0 71\r
878ddf1f 72 @since GenBuild 1.0\r
73**/\r
74public class FpdParserTask extends Task {\r
ff225cbb 75\r
a29c47e0 76 private String platformName;\r
878ddf1f 77\r
a29c47e0 78 private File fpdFile = null;\r
ff225cbb 79\r
a29c47e0 80 private PlatformIdentification platformId;\r
ff225cbb 81\r
a29c47e0 82 private String type;\r
ff225cbb 83\r
878ddf1f 84 ///\r
85 /// Mapping from modules identification to out put file name\r
86 ///\r
87 private Map<FpdModuleIdentification, String> outfiles = new LinkedHashMap<FpdModuleIdentification, String>();\r
88\r
89 ///\r
90 /// Mapping from FV name to its modules\r
91 ///\r
a29c47e0 92 private Map<String, Set<FpdModuleIdentification>> fvs = new HashMap<String, Set<FpdModuleIdentification>>();\r
878ddf1f 93\r
878ddf1f 94 ///\r
ff225cbb 95 /// FpdParserTask can specify some ANT properties.\r
878ddf1f 96 ///\r
97 private Vector<Property> properties = new Vector<Property>();\r
ff225cbb 98\r
a29c47e0 99 private boolean isUnified = true;\r
878ddf1f 100\r
878ddf1f 101 /**\r
102 Public construct method. It is necessary for ANT task.\r
103 **/\r
a29c47e0 104 public FpdParserTask() {\r
878ddf1f 105 }\r
106\r
107 /**\r
ff225cbb 108 ANT task's entry method. The main steps is described as following:\r
109\r
a29c47e0 110 <ul>\r
ff225cbb 111 <li>Initialize global information (Framework DB, SPD files and all MSA files\r
a29c47e0 112 listed in SPD). This step will execute only once in whole build process;</li>\r
113 <li>Parse specified FPD file; </li>\r
114 <li>Generate FV.inf files; </li>\r
115 <li>Generate PlatformName_build.xml file for Flatform build; </li>\r
116 <li>Collect PCD information. </li>\r
117 </ul>\r
ff225cbb 118\r
a29c47e0 119 @throws BuildException\r
ff225cbb 120 Surface area is not valid.\r
878ddf1f 121 **/\r
122 public void execute() throws BuildException {\r
82516887 123 //\r
124 // If fpdFile is not specified, \r
125 // then try to get FPD file by platformName\r
126 //\r
a29c47e0 127 if ( fpdFile == null) {\r
128 if (platformName == null) {\r
391dbbb1 129 throw new BuildException("FpdParserTask parameter error. Please specify either the platform name or FPD file!");\r
a29c47e0 130 }\r
de4bb9f6 131 platformId = GlobalData.getPlatformByName(platformName);\r
a29c47e0 132 fpdFile = platformId.getFpdFile();\r
133 }\r
ff225cbb 134\r
878ddf1f 135 //\r
136 // Parse FPD file\r
137 //\r
138 parseFpdFile();\r
ff225cbb 139\r
a29c47e0 140 //\r
141 // Prepare BUILD_DIR\r
878ddf1f 142 //\r
a29c47e0 143 isUnified = OutputManager.getInstance().prepareBuildDir(getProject());\r
ff225cbb 144\r
a29c47e0 145 //\r
146 // For every Target and ToolChain\r
147 //\r
148 String[] targetList = GlobalData.getToolChainInfo().getTargets();\r
82516887 149 for (int i = 0; i < targetList.length; i++) {\r
a29c47e0 150 String[] toolchainList = GlobalData.getToolChainInfo().getTagnames();\r
82516887 151 for(int j = 0; j < toolchainList.length; j++) {\r
a29c47e0 152 //\r
153 // Prepare FV_DIR\r
154 //\r
ff225cbb 155 String ffsCommonDir = getProject().getProperty("BUILD_DIR") + File.separatorChar\r
6ae1510e 156 + targetList[i] + "_"\r
a29c47e0 157 + toolchainList[j];\r
158 File fvDir = new File(ffsCommonDir + File.separatorChar + "FV");\r
159 fvDir.mkdirs();\r
160 getProject().setProperty("FV_DIR", fvDir.getPath().replaceAll("(\\\\)", "/"));\r
ff225cbb 161\r
a29c47e0 162 //\r
163 // Gen Fv.inf files\r
164 //\r
165 genFvInfFiles(ffsCommonDir);\r
166 }\r
167 }\r
168\r
878ddf1f 169 //\r
170 // Gen build.xml\r
171 //\r
4b5f5549 172 PlatformBuildFileGenerator fileGenerator = new PlatformBuildFileGenerator(getProject(), outfiles, fvs, isUnified);\r
a29c47e0 173 fileGenerator.genBuildFile();\r
ff225cbb 174\r
a29c47e0 175 //\r
176 // Ant call ${PLATFORM}_build.xml\r
878ddf1f 177 //\r
ff225cbb 178\r
a29c47e0 179 Ant ant = new Ant();\r
180 ant.setProject(getProject());\r
181 ant.setAntfile(platformId.getFpdFile().getParent() + File.separatorChar + platformId.getName() + "_build.xml");\r
182 ant.setTarget(type);\r
183 ant.setInheritAll(true);\r
184 ant.init();\r
185 ant.execute();\r
878ddf1f 186 }\r
a29c47e0 187\r
878ddf1f 188 /**\r
ff225cbb 189 Generate Fv.inf files. The Fv.inf file is composed with four\r
190 parts: Options, Attributes, Components and Files. The Fv.inf files\r
a29c47e0 191 will be under FV_DIR.\r
ff225cbb 192\r
878ddf1f 193 @throws BuildException\r
ff225cbb 194 File write FV.inf files error.\r
878ddf1f 195 **/\r
a29c47e0 196 private void genFvInfFiles(String ffsCommonDir) throws BuildException {\r
878ddf1f 197 String[] validFv = SurfaceAreaQuery.getFpdValidImageNames();\r
198 for (int i = 0; i < validFv.length; i++) {\r
878ddf1f 199 //\r
200 // Get all global variables from FPD and set them to properties\r
201 //\r
a29c47e0 202 String[][] globalVariables = SurfaceAreaQuery.getFpdGlobalVariable();\r
878ddf1f 203 for (int j = 0; j < globalVariables.length; j++) {\r
a29c47e0 204 getProject().setProperty(globalVariables[j][0], globalVariables[j][1]);\r
878ddf1f 205 }\r
206\r
57cc2ee7 207 getProject().setProperty("FV_FILENAME", validFv[i]);\r
ff225cbb 208\r
57cc2ee7 209 File fvFile = new File(getProject().replaceProperties( getProject().getProperty("FV_DIR") + File.separatorChar + validFv[i] + ".inf"));\r
878ddf1f 210 fvFile.getParentFile().mkdirs();\r
211\r
212 try {\r
213 FileWriter fw = new FileWriter(fvFile);\r
214 BufferedWriter bw = new BufferedWriter(fw);\r
ff225cbb 215\r
878ddf1f 216 //\r
217 // Options\r
218 //\r
219 String[][] options = SurfaceAreaQuery.getFpdOptions(validFv[i]);\r
220 if (options.length > 0) {\r
221 bw.write("[options]");\r
222 bw.newLine();\r
223 for (int j = 0; j < options.length; j++) {\r
224 StringBuffer str = new StringBuffer(100);\r
225 str.append(options[j][0]);\r
226 while (str.length() < 40) {\r
227 str.append(' ');\r
228 }\r
229 str.append("= ");\r
230 str.append(options[j][1]);\r
231 bw.write(getProject().replaceProperties(str.toString()));\r
232 bw.newLine();\r
233 }\r
234 bw.newLine();\r
235 }\r
ff225cbb 236\r
878ddf1f 237 //\r
238 // Attributes;\r
239 //\r
a29c47e0 240 String[][] attributes = SurfaceAreaQuery.getFpdAttributes(validFv[i]);\r
878ddf1f 241 if (attributes.length > 0) {\r
242 bw.write("[attributes]");\r
243 bw.newLine();\r
244 for (int j = 0; j < attributes.length; j++) {\r
245 StringBuffer str = new StringBuffer(100);\r
246 str.append(attributes[j][0]);\r
247 while (str.length() < 40) {\r
248 str.append(' ');\r
249 }\r
250 str.append("= ");\r
251 str.append(attributes[j][1]);\r
a29c47e0 252 bw.write(getProject().replaceProperties(str.toString()));\r
878ddf1f 253 bw.newLine();\r
254 }\r
255 bw.newLine();\r
256 }\r
ff225cbb 257\r
878ddf1f 258 //\r
259 // Components\r
260 //\r
a29c47e0 261 String[][] components = SurfaceAreaQuery.getFpdComponents(validFv[i]);\r
878ddf1f 262 if (components.length > 0) {\r
263 bw.write("[components]");\r
264 bw.newLine();\r
265 for (int j = 0; j < components.length; j++) {\r
266 StringBuffer str = new StringBuffer(100);\r
267 str.append(components[j][0]);\r
268 while (str.length() < 40) {\r
269 str.append(' ');\r
270 }\r
271 str.append("= ");\r
272 str.append(components[j][1]);\r
a29c47e0 273 bw.write(getProject().replaceProperties(str.toString()));\r
878ddf1f 274 bw.newLine();\r
275 }\r
276 bw.newLine();\r
277 }\r
ff225cbb 278\r
878ddf1f 279 //\r
280 // Files\r
281 //\r
57cc2ee7 282 Set<FpdModuleIdentification> filesSet = fvs.get(validFv[i]);\r
878ddf1f 283 if (filesSet != null) {\r
a29c47e0 284 FpdModuleIdentification[] files = filesSet.toArray(new FpdModuleIdentification[filesSet.size()]);\r
878ddf1f 285 bw.write("[files]");\r
286 bw.newLine();\r
287 for (int j = 0; j < files.length; j++) {\r
a29c47e0 288 String str = ffsCommonDir + File.separatorChar + outfiles.get(files[j]);\r
289 bw.write(getProject().replaceProperties("EFI_FILE_NAME = " + str));\r
878ddf1f 290 bw.newLine();\r
291 }\r
292 }\r
293 bw.flush();\r
294 bw.close();\r
295 fw.close();\r
296 } catch (Exception e) {\r
391dbbb1 297 throw new BuildException("Generation of the FV file [" + fvFile.getPath() + "] failed!\n" + e.getMessage());\r
878ddf1f 298 }\r
299 }\r
300 }\r
a29c47e0 301 /**\r
302 This method is used for Single Module Build.\r
ff225cbb 303\r
304\r
a29c47e0 305 @throws BuildException\r
ff225cbb 306 FPD file is not valid.\r
a29c47e0 307 **/\r
3790e93c 308 public void parseFpdFile(File fpdFile, ModuleIdentification singleModuleId) throws BuildException {\r
a29c47e0 309 this.fpdFile = fpdFile;\r
3790e93c 310 parseFpdFile(singleModuleId);\r
a29c47e0 311 }\r
878ddf1f 312\r
3790e93c 313 private void parseFpdFile() throws BuildException {\r
314 parseFpdFile(null);\r
315 }\r
878ddf1f 316 /**\r
ff225cbb 317 Parse FPD file.\r
318\r
878ddf1f 319 @throws BuildException\r
ff225cbb 320 FPD file is not valid.\r
a29c47e0 321 **/\r
3790e93c 322 private void parseFpdFile(ModuleIdentification singleModuleId) throws BuildException {\r
878ddf1f 323 try {\r
a29c47e0 324 XmlObject doc = XmlObject.Factory.parse(fpdFile);\r
ff225cbb 325\r
a29c47e0 326 if (!doc.validate()) {\r
391dbbb1 327 throw new BuildException("Platform Surface Area file [" + fpdFile.getPath() + "] format is invalid!");\r
878ddf1f 328 }\r
ff225cbb 329\r
a29c47e0 330 Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
331 map.put("PlatformSurfaceArea", doc);\r
878ddf1f 332 SurfaceAreaQuery.setDoc(map);\r
8031d48d 333\r
a29c47e0 334 //\r
335 // Initialize\r
336 //\r
337 platformId = SurfaceAreaQuery.getFpdHeader();\r
338 platformId.setFpdFile(fpdFile);\r
de4bb9f6 339 getProject().setProperty("PLATFORM", platformId.getName());\r
340 getProject().setProperty("PLATFORM_FILE", platformId.getRelativeFpdFile().replaceAll("(\\\\)", "/"));\r
341 getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));\r
342 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));\r
a29c47e0 343\r
344 //\r
ff225cbb 345 // Build mode. User-defined output dir.\r
a29c47e0 346 //\r
347 String buildMode = SurfaceAreaQuery.getFpdIntermediateDirectories();\r
348 String userDefinedOutputDir = SurfaceAreaQuery.getFpdOutputDirectory();\r
349\r
350 OutputManager.getInstance().setup(userDefinedOutputDir, buildMode);\r
351\r
352 //\r
353 // TBD. Deal PCD and BuildOption related Info\r
354 //\r
355 GlobalData.setFpdBuildOptions(SurfaceAreaQuery.getFpdBuildOptions());\r
ff225cbb 356\r
a29c47e0 357 GlobalData.setToolChainPlatformInfo(SurfaceAreaQuery.getFpdToolChainInfo());\r
ff225cbb 358\r
878ddf1f 359 //\r
360 // Parse all list modules SA\r
361 //\r
3790e93c 362 parseModuleSAFiles(singleModuleId);\r
a29c47e0 363\r
364 //\r
365 // TBD. Deal PCD and BuildOption related Info\r
366 //\r
367 parseToolChainFamilyOptions();\r
368 parseToolChainOptions();\r
369\r
878ddf1f 370 SurfaceAreaQuery.setDoc(map);\r
ff225cbb 371\r
de4bb9f6 372 //\r
373 // Pcd Collection. Call CollectPCDAction to collect pcd info.\r
374 //\r
8b7bd455 375 PlatformPcdPreprocessActionForBuilding ca = new PlatformPcdPreprocessActionForBuilding();\r
376 ca.perform(platformId.getFpdFile().getPath(), ActionMessage.NULL_MESSAGE_LEVEL);\r
878ddf1f 377 } catch (Exception e) {\r
391dbbb1 378 throw new BuildException("Parsing of the FPD file [" + fpdFile.getPath() + "] failed!\n" + e.getMessage());\r
878ddf1f 379 }\r
380 }\r
381\r
a29c47e0 382\r
ff225cbb 383\r
878ddf1f 384 /**\r
ff225cbb 385 Parse all modules listed in FPD file.\r
878ddf1f 386 **/\r
3790e93c 387 private void parseModuleSAFiles(ModuleIdentification singleModuleId) throws EdkException{\r
a29c47e0 388 Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = SurfaceAreaQuery.getFpdModules();\r
136adffc 389\r
878ddf1f 390 //\r
391 // For every Module lists in FPD file.\r
392 //\r
a29c47e0 393 Set<FpdModuleIdentification> keys = moduleSAs.keySet();\r
394 Iterator iter = keys.iterator();\r
395 while (iter.hasNext()) {\r
396 FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();\r
ff225cbb 397\r
3790e93c 398 //\r
399 // If is stand-alone module build, just parse this module, pass others\r
400 //\r
401 if (singleModuleId != null) {\r
402 //\r
403 // pass others modules\r
404 //\r
405 if ( ! fpdModuleId.getModule().equals(singleModuleId)) {\r
406 continue ;\r
407 }\r
408 }\r
409 \r
878ddf1f 410 //\r
ff225cbb 411 // Judge if Module is existed?\r
a29c47e0 412 // TBD\r
a29c47e0 413 GlobalData.registerFpdModuleSA(fpdModuleId, moduleSAs.get(fpdModuleId));\r
414\r
878ddf1f 415 //\r
a29c47e0 416 // Put fpdModuleId to the corresponding FV\r
878ddf1f 417 //\r
a29c47e0 418 SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));\r
419 String fvBinding = SurfaceAreaQuery.getModuleFvBindingKeyword();\r
a29c47e0 420\r
421 fpdModuleId.setFvBinding(fvBinding);\r
01413f0c 422 updateFvs(fvBinding, fpdModuleId);\r
ff225cbb 423\r
878ddf1f 424 //\r
a29c47e0 425 // Prepare for out put file name\r
878ddf1f 426 //\r
a29c47e0 427 ModuleIdentification moduleId = fpdModuleId.getModule();\r
82516887 428\r
a29c47e0 429 String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();\r
82516887 430 \r
a29c47e0 431 if (baseName == null) {\r
432 baseName = moduleId.getName();\r
878ddf1f 433 }\r
ff225cbb 434 outfiles.put(fpdModuleId, fpdModuleId.getArch() + File.separatorChar\r
435 + moduleId.getGuid() + "-" + baseName\r
a29c47e0 436 + getSuffix(moduleId.getModuleType()));\r
437\r
438 //\r
439 // parse module build options, if any\r
ff225cbb 440 //\r
a29c47e0 441 GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));\r
442 GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));\r
443 SurfaceAreaQuery.pop();\r
878ddf1f 444 }\r
445 }\r
446\r
a29c47e0 447 private ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
448 String[][] options = SurfaceAreaQuery.getModuleBuildOptions(toolChainFamilyFlag);\r
449 if (options == null || options.length == 0) {\r
80eb97ff 450 return new ToolChainMap();\r
878ddf1f 451 }\r
a29c47e0 452 return parseOptions(options);\r
878ddf1f 453 }\r
ff225cbb 454\r
a29c47e0 455 private ToolChainMap parsePlatformBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
456 String[][] options = SurfaceAreaQuery.getPlatformBuildOptions(toolChainFamilyFlag);\r
457 if (options == null || options.length == 0) {\r
80eb97ff 458 return new ToolChainMap();\r
878ddf1f 459 }\r
a29c47e0 460 return parseOptions(options);\r
878ddf1f 461 }\r
462\r
a29c47e0 463 private ToolChainMap parseOptions(String[][] options) throws EdkException {\r
464 ToolChainMap map = new ToolChainMap();\r
465 int flagIndex = ToolChainElement.ATTRIBUTE.value;\r
466\r
467 for (int i = 0; i < options.length; ++i) {\r
468 String flagString = options[i][flagIndex];\r
469 if (flagString == null) {\r
470 flagString = "";\r
471 }\r
472 options[i][flagIndex] = ToolChainAttribute.FLAGS + "";\r
473 map.put(options[i], flagString.trim());\r
474 }\r
475\r
878ddf1f 476 return map;\r
477 }\r
ff225cbb 478\r
a29c47e0 479 private void parseToolChainFamilyOptions() throws EdkException {\r
480 GlobalData.setPlatformToolChainFamilyOption(parsePlatformBuildOptions(true));\r
481 }\r
482\r
483 private void parseToolChainOptions() throws EdkException {\r
484 GlobalData.setPlatformToolChainOption(parsePlatformBuildOptions(false));\r
485 }\r
878ddf1f 486\r
487 /**\r
ff225cbb 488 Add the current module to corresponding FV.\r
489\r
a29c47e0 490 @param fvName current FV name\r
491 @param moduleName current module identification\r
878ddf1f 492 **/\r
01413f0c 493 private void updateFvs(String fvName, FpdModuleIdentification fpdModuleId) {\r
fa2da5b1 494 if (fvName == null || fvName.trim().length() == 0) {\r
495 fvName = "NULL";\r
496 }\r
57cc2ee7 497 String[] fvNameArray = fvName.split("[, \t]+");\r
a29c47e0 498 for (int i = 0; i < fvNameArray.length; i++) {\r
878ddf1f 499 //\r
a29c47e0 500 // Put module to corresponding fvName\r
878ddf1f 501 //\r
a29c47e0 502 if (fvs.containsKey(fvNameArray[i])) {\r
503 Set<FpdModuleIdentification> set = fvs.get(fvNameArray[i]);\r
504 set.add(fpdModuleId);\r
82516887 505 } else {\r
a29c47e0 506 Set<FpdModuleIdentification> set = new LinkedHashSet<FpdModuleIdentification>();\r
507 set.add(fpdModuleId);\r
508 fvs.put(fvNameArray[i], set);\r
878ddf1f 509 }\r
878ddf1f 510 }\r
511 }\r
512\r
513 /**\r
ff225cbb 514 Get the suffix based on module type. Current relationship are listed:\r
515\r
a29c47e0 516 <pre>\r
517 <b>ModuleType</b> <b>Suffix</b>\r
518 BASE .FFS\r
519 SEC .SEC\r
520 PEI_CORE .PEI\r
521 PEIM .PEI\r
522 DXE_CORE .DXE\r
523 DXE_DRIVER .DXE\r
524 DXE_RUNTIME_DRIVER .DXE\r
525 DXE_SAL_DRIVER .DXE\r
526 DXE_SMM_DRIVER .DXE\r
527 TOOL .FFS\r
528 UEFI_DRIVER .DXE\r
529 UEFI_APPLICATION .APP\r
530 USER_DEFINED .FFS\r
531 </pre>\r
ff225cbb 532\r
a29c47e0 533 @param moduleType module type\r
534 @return\r
535 @throws BuildException\r
536 If module type is null\r
878ddf1f 537 **/\r
a29c47e0 538 public static String getSuffix(String moduleType) throws BuildException {\r
539 if (moduleType == null) {\r
540 throw new BuildException("Module type is not specified.");\r
541 }\r
878ddf1f 542\r
4a6a5026 543 String[][] suffix = EdkDefinitions.ModuleTypeExtensions;\r
ff225cbb 544\r
a29c47e0 545 for (int i = 0; i < suffix.length; i++) {\r
546 if (suffix[i][0].equalsIgnoreCase(moduleType)) {\r
547 return suffix[i][1];\r
548 }\r
549 }\r
550 //\r
551 // Default is '.FFS'\r
552 //\r
553 return ".FFS";\r
878ddf1f 554 }\r
878ddf1f 555 /**\r
ff225cbb 556 Add a property.\r
557\r
a29c47e0 558 @param p property\r
559 **/\r
560 public void addProperty(Property p) {\r
561 properties.addElement(p);\r
878ddf1f 562 }\r
563\r
a29c47e0 564 public void setPlatformName(String platformName) {\r
565 this.platformName = platformName;\r
878ddf1f 566 }\r
567\r
a29c47e0 568 public void setFpdFile(File fpdFile) {\r
569 this.fpdFile = fpdFile;\r
878ddf1f 570 }\r
571\r
a29c47e0 572 public void setType(String type) {\r
573 this.type = type;\r
878ddf1f 574 }\r
3790e93c 575 \r
576 public String getAllArchForModule(ModuleIdentification moduleId) {\r
577 String archs = "";\r
578 Iterator<FpdModuleIdentification> iter = outfiles.keySet().iterator();\r
579 while (iter.hasNext()) {\r
580 FpdModuleIdentification fpdModuleId = iter.next();\r
581 \r
582 if (fpdModuleId.getModule().equals(moduleId)) {\r
583 archs += fpdModuleId.getArch() + " ";\r
584 }\r
585 }\r
586 \r
587 return archs;\r
588 }\r
878ddf1f 589}\r