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