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