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