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