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