]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/fpd/FpdParserTask.java
Commented out the throwing exception when not supported file type is found, because...
[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 throw new BuildException("Generate FV file [" + fvFile.getPath() + "] failed. \n" + e.getMessage());\r
878ddf1f 315 }\r
316 }\r
317 }\r
a29c47e0 318 /**\r
319 This method is used for Single Module Build.\r
320 \r
321 \r
322 @throws BuildException\r
323 FPD file is not valid. \r
324 **/\r
325 public void parseFpdFile(File fpdFile) throws BuildException {\r
326 this.fpdFile = fpdFile;\r
327 parseFpdFile();\r
328 }\r
878ddf1f 329\r
330 /**\r
331 Parse FPD file. \r
a29c47e0 332 \r
878ddf1f 333 @throws BuildException\r
a29c47e0 334 FPD file is not valid. \r
335 **/\r
878ddf1f 336 private void parseFpdFile() throws BuildException {\r
337 try {\r
a29c47e0 338 XmlObject doc = XmlObject.Factory.parse(fpdFile);\r
339 \r
340 if (!doc.validate()) {\r
341 throw new BuildException("Platform Surface Area file [" + fpdFile.getPath() + "] is invalid.");\r
878ddf1f 342 }\r
a29c47e0 343 \r
344 Map<String, XmlObject> map = new HashMap<String, XmlObject>();\r
345 map.put("PlatformSurfaceArea", doc);\r
878ddf1f 346 SurfaceAreaQuery.setDoc(map);\r
8031d48d 347\r
a29c47e0 348 //\r
349 // Initialize\r
350 //\r
351 platformId = SurfaceAreaQuery.getFpdHeader();\r
352 platformId.setFpdFile(fpdFile);\r
de4bb9f6 353 getProject().setProperty("PLATFORM", platformId.getName());\r
354 getProject().setProperty("PLATFORM_FILE", platformId.getRelativeFpdFile().replaceAll("(\\\\)", "/"));\r
355 getProject().setProperty("PLATFORM_DIR", platformId.getFpdFile().getParent().replaceAll("(\\\\)", "/"));\r
356 getProject().setProperty("PLATFORM_RELATIVE_DIR", platformId.getPlatformRelativeDir().replaceAll("(\\\\)", "/"));\r
a29c47e0 357\r
358 //\r
359 // Build mode. User-defined output dir. \r
360 //\r
361 String buildMode = SurfaceAreaQuery.getFpdIntermediateDirectories();\r
362 String userDefinedOutputDir = SurfaceAreaQuery.getFpdOutputDirectory();\r
363\r
364 OutputManager.getInstance().setup(userDefinedOutputDir, buildMode);\r
365\r
366 //\r
367 // TBD. Deal PCD and BuildOption related Info\r
368 //\r
369 GlobalData.setFpdBuildOptions(SurfaceAreaQuery.getFpdBuildOptions());\r
370 \r
371 GlobalData.setToolChainPlatformInfo(SurfaceAreaQuery.getFpdToolChainInfo());\r
372 \r
878ddf1f 373 //\r
374 // Parse all list modules SA\r
375 //\r
376 parseModuleSAFiles();\r
a29c47e0 377\r
378 //\r
379 // TBD. Deal PCD and BuildOption related Info\r
380 //\r
381 parseToolChainFamilyOptions();\r
382 parseToolChainOptions();\r
383\r
878ddf1f 384 SurfaceAreaQuery.setDoc(map);\r
de4bb9f6 385 \r
386 //\r
387 // Pcd Collection. Call CollectPCDAction to collect pcd info.\r
388 //\r
389 try {\r
390 CollectPCDAction ca = new CollectPCDAction();\r
391 ca.perform(GlobalData.getWorkspacePath(),platformId.getFpdFile().getPath(),ActionMessage.NULL_MESSAGE_LEVEL);\r
392 } catch (Exception e){\r
393 throw new BuildException(e.getMessage());\r
394 }\r
878ddf1f 395 } catch (Exception e) {\r
a29c47e0 396 throw new BuildException("Load FPD file [" + fpdFile.getPath() + "] error. \n" + e.getMessage());\r
878ddf1f 397 }\r
398 }\r
399\r
a29c47e0 400\r
401 \r
878ddf1f 402 /**\r
403 Parse all modules listed in FPD file. \r
404 **/\r
a29c47e0 405 private void parseModuleSAFiles() throws EdkException{\r
406 Map<FpdModuleIdentification, Map<String, XmlObject>> moduleSAs = SurfaceAreaQuery.getFpdModules();\r
136adffc 407\r
878ddf1f 408 //\r
409 // For every Module lists in FPD file.\r
410 //\r
a29c47e0 411 Set<FpdModuleIdentification> keys = moduleSAs.keySet();\r
412 Iterator iter = keys.iterator();\r
413 while (iter.hasNext()) {\r
414 FpdModuleIdentification fpdModuleId = (FpdModuleIdentification) iter.next();\r
415 \r
878ddf1f 416 //\r
a29c47e0 417 // Judge if Module is existed? \r
418 // TBD\r
419 \r
420 GlobalData.registerFpdModuleSA(fpdModuleId, moduleSAs.get(fpdModuleId));\r
421\r
878ddf1f 422 //\r
a29c47e0 423 // Put fpdModuleId to the corresponding FV\r
878ddf1f 424 //\r
a29c47e0 425 SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));\r
426 String fvBinding = SurfaceAreaQuery.getModuleFvBindingKeyword();\r
427 SurfaceAreaQuery.pop();\r
428\r
429 fpdModuleId.setFvBinding(fvBinding);\r
430 String fvSequence = fpdModuleId.getSequence();\r
431 updateFvs(fvSequence, fvBinding, fpdModuleId);\r
432 \r
878ddf1f 433 //\r
a29c47e0 434 // Prepare for out put file name\r
878ddf1f 435 //\r
a29c47e0 436 ModuleIdentification moduleId = fpdModuleId.getModule();\r
437 SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));\r
438 String baseName = SurfaceAreaQuery.getModuleOutputFileBasename();\r
439 SurfaceAreaQuery.pop();\r
440 if (baseName == null) {\r
441 baseName = moduleId.getName();\r
878ddf1f 442 }\r
a29c47e0 443 outfiles.put(fpdModuleId, fpdModuleId.getArch() + File.separatorChar \r
444 + moduleId.getGuid() + "-" + baseName \r
445 + getSuffix(moduleId.getModuleType()));\r
446\r
447 //\r
448 // parse module build options, if any\r
449 // \r
450 SurfaceAreaQuery.push(GlobalData.getDoc(fpdModuleId));\r
451 GlobalData.addModuleToolChainOption(fpdModuleId, parseModuleBuildOptions(false));\r
452 GlobalData.addModuleToolChainFamilyOption(fpdModuleId, parseModuleBuildOptions(true));\r
453 SurfaceAreaQuery.pop();\r
878ddf1f 454 }\r
455 }\r
456\r
a29c47e0 457 private ToolChainMap parseModuleBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
458 String[][] options = SurfaceAreaQuery.getModuleBuildOptions(toolChainFamilyFlag);\r
459 if (options == null || options.length == 0) {\r
460 return null;\r
878ddf1f 461 }\r
a29c47e0 462 return parseOptions(options);\r
878ddf1f 463 }\r
878ddf1f 464 \r
a29c47e0 465 private ToolChainMap parsePlatformBuildOptions(boolean toolChainFamilyFlag) throws EdkException {\r
466 String[][] options = SurfaceAreaQuery.getPlatformBuildOptions(toolChainFamilyFlag);\r
467 if (options == null || options.length == 0) {\r
468 return null;\r
878ddf1f 469 }\r
a29c47e0 470 return parseOptions(options);\r
878ddf1f 471 }\r
472\r
a29c47e0 473 private ToolChainMap parseOptions(String[][] options) throws EdkException {\r
474 ToolChainMap map = new ToolChainMap();\r
475 int flagIndex = ToolChainElement.ATTRIBUTE.value;\r
476\r
477 for (int i = 0; i < options.length; ++i) {\r
478 String flagString = options[i][flagIndex];\r
479 if (flagString == null) {\r
480 flagString = "";\r
481 }\r
482 options[i][flagIndex] = ToolChainAttribute.FLAGS + "";\r
483 map.put(options[i], flagString.trim());\r
484 }\r
485\r
878ddf1f 486 return map;\r
487 }\r
a29c47e0 488 \r
489 private void parseToolChainFamilyOptions() throws EdkException {\r
490 GlobalData.setPlatformToolChainFamilyOption(parsePlatformBuildOptions(true));\r
491 }\r
492\r
493 private void parseToolChainOptions() throws EdkException {\r
494 GlobalData.setPlatformToolChainOption(parsePlatformBuildOptions(false));\r
495 }\r
878ddf1f 496\r
497 /**\r
a29c47e0 498 Add the current module to corresponding FV. \r
499 \r
500 @param fvName current FV name\r
501 @param moduleName current module identification\r
878ddf1f 502 **/\r
a29c47e0 503 private void updateFvs(String fvSequence, String fvName, FpdModuleIdentification fpdModuleId) {\r
504 String upcaseFvName = fvName.toUpperCase();\r
505 String[] fvNameArray = upcaseFvName.split("[, \t]+");\r
506 for (int i = 0; i < fvNameArray.length; i++) {\r
878ddf1f 507 //\r
a29c47e0 508 // Put module to corresponding fvName\r
878ddf1f 509 //\r
a29c47e0 510 if (fvs.containsKey(fvNameArray[i])) {\r
511 Set<FpdModuleIdentification> set = fvs.get(fvNameArray[i]);\r
512 set.add(fpdModuleId);\r
878ddf1f 513 }\r
514 else {\r
a29c47e0 515 Set<FpdModuleIdentification> set = new LinkedHashSet<FpdModuleIdentification>();\r
516 set.add(fpdModuleId);\r
517 fvs.put(fvNameArray[i], set);\r
878ddf1f 518 }\r
a29c47e0 519 \r
878ddf1f 520 //\r
a29c47e0 521 // Put fvName to corresponding fvSequence\r
878ddf1f 522 //\r
a29c47e0 523 if (sequences.containsKey(fvSequence)) {\r
524 Set<String> set = sequences.get(fvSequence);\r
525 set.add(fvNameArray[i]);\r
878ddf1f 526 }\r
527 else {\r
a29c47e0 528 Set<String> set = new LinkedHashSet<String>();\r
529 set.add(fvNameArray[i]);\r
530 sequences.put(fvSequence, set);\r
878ddf1f 531 }\r
878ddf1f 532 }\r
533 }\r
534\r
535 /**\r
a29c47e0 536 Get the suffix based on module type. Current relationship are listed: \r
878ddf1f 537 \r
a29c47e0 538 <pre>\r
539 <b>ModuleType</b> <b>Suffix</b>\r
540 BASE .FFS\r
541 SEC .SEC\r
542 PEI_CORE .PEI\r
543 PEIM .PEI\r
544 DXE_CORE .DXE\r
545 DXE_DRIVER .DXE\r
546 DXE_RUNTIME_DRIVER .DXE\r
547 DXE_SAL_DRIVER .DXE\r
548 DXE_SMM_DRIVER .DXE\r
549 TOOL .FFS\r
550 UEFI_DRIVER .DXE\r
551 UEFI_APPLICATION .APP\r
552 USER_DEFINED .FFS\r
553 </pre>\r
554 \r
555 @param moduleType module type\r
556 @return\r
557 @throws BuildException\r
558 If module type is null\r
878ddf1f 559 **/\r
a29c47e0 560 public static String getSuffix(String moduleType) throws BuildException {\r
561 if (moduleType == null) {\r
562 throw new BuildException("Module type is not specified.");\r
563 }\r
878ddf1f 564\r
a29c47e0 565 String[][] suffix = { { "BASE", ".FFS"},\r
566 { "SEC", ".SEC" }, { "PEI_CORE", ".PEI" }, \r
567 { "PEIM", ".PEI" }, { "DXE_CORE", ".DXE" },\r
568 { "DXE_DRIVER", ".DXE" }, { "DXE_RUNTIME_DRIVER", ".DXE" }, \r
569 { "DXE_SAL_DRIVER", ".DXE" }, { "DXE_SMM_DRIVER", ".DXE" }, \r
570 { "TOOL", ".FFS" }, { "UEFI_DRIVER", ".DXE" },\r
571 { "UEFI_APPLICATION", ".APP" }, { "USER_DEFINED", ".FFS" } };\r
572 \r
573 for (int i = 0; i < suffix.length; i++) {\r
574 if (suffix[i][0].equalsIgnoreCase(moduleType)) {\r
575 return suffix[i][1];\r
576 }\r
577 }\r
578 //\r
579 // Default is '.FFS'\r
580 //\r
581 return ".FFS";\r
878ddf1f 582 }\r
878ddf1f 583 /**\r
a29c47e0 584 Add a property. \r
585 \r
586 @param p property\r
587 **/\r
588 public void addProperty(Property p) {\r
589 properties.addElement(p);\r
878ddf1f 590 }\r
591\r
a29c47e0 592 public void setPlatformName(String platformName) {\r
593 this.platformName = platformName;\r
878ddf1f 594 }\r
595\r
a29c47e0 596 public void setFpdFile(File fpdFile) {\r
597 this.fpdFile = fpdFile;\r
878ddf1f 598 }\r
599\r
a29c47e0 600 public void setType(String type) {\r
601 this.type = type;\r
878ddf1f 602 }\r
a29c47e0 603 \r
604\r
878ddf1f 605}\r