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