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