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