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