]>
Commit | Line | Data |
---|---|---|
a13899c5 | 1 | /** @file\r |
2 | Java class FpdFileContents is used to parse fpd xml file.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | **/\r | |
13 | package org.tianocore.frameworkwizard.platform.ui;\r | |
14 | \r | |
15 | import java.io.File;\r | |
16 | import java.io.IOException;\r | |
17 | import java.math.BigInteger;\r | |
18 | import java.util.ArrayList;\r | |
19 | import java.util.HashMap;\r | |
20 | import java.util.Iterator;\r | |
21 | import java.util.LinkedHashMap;\r | |
22 | import java.util.List;\r | |
23 | import java.util.ListIterator;\r | |
24 | import java.util.Map;\r | |
25 | import java.util.Set;\r | |
6a09eb19 | 26 | import java.util.Vector;\r |
a13899c5 | 27 | \r |
28 | import javax.xml.namespace.QName;\r | |
29 | \r | |
30 | import org.apache.xmlbeans.XmlCursor;\r | |
31 | import org.apache.xmlbeans.XmlObject;\r | |
32 | import org.apache.xmlbeans.XmlOptions;\r | |
33 | import org.tianocore.AntTaskDocument;\r | |
34 | import org.tianocore.BuildOptionsDocument;\r | |
35 | import org.tianocore.DynamicPcdBuildDefinitionsDocument;\r | |
6cba26e8 | 36 | import org.tianocore.EfiSectionType;\r |
a13899c5 | 37 | import org.tianocore.FlashDefinitionFileDocument;\r |
a13899c5 | 38 | import org.tianocore.FlashDocument;\r |
39 | import org.tianocore.FrameworkModulesDocument;\r | |
6a09eb19 | 40 | import org.tianocore.IntermediateOutputType;\r |
a13899c5 | 41 | import org.tianocore.LibrariesDocument;\r |
42 | import org.tianocore.ModuleSADocument;\r | |
8f55ea73 | 43 | import org.tianocore.ModuleSaBuildOptionsDocument;\r |
a13899c5 | 44 | import org.tianocore.ModuleSurfaceAreaDocument;\r |
45 | import org.tianocore.OptionDocument;\r | |
46 | import org.tianocore.OptionsDocument;\r | |
47 | import org.tianocore.PcdBuildDefinitionDocument;\r | |
48 | import org.tianocore.PcdCodedDocument;\r | |
49 | import org.tianocore.PcdDataTypes;\r | |
50 | import org.tianocore.PcdDeclarationsDocument;\r | |
51 | import org.tianocore.PcdItemTypes;\r | |
52 | import org.tianocore.PlatformDefinitionsDocument;\r | |
53 | import org.tianocore.PlatformSurfaceAreaDocument;\r | |
54 | import org.tianocore.FvImageTypes;\r | |
55 | import org.tianocore.FvImagesDocument;\r | |
56 | import org.tianocore.LicenseDocument;\r | |
57 | import org.tianocore.PlatformHeaderDocument;\r | |
58 | import org.tianocore.SkuInfoDocument;\r | |
59 | import org.tianocore.UserDefinedAntTasksDocument;\r | |
1bf9fa5a | 60 | import org.tianocore.UserExtensionsDocument;\r |
61 | import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r | |
a13899c5 | 62 | import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r |
3658f95e | 63 | import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r |
64 | import org.tianocore.frameworkwizard.packaging.PackageIdentification;\r | |
a13899c5 | 65 | \r |
66 | /**\r | |
67 | This class processes fpd file contents such as add remove xml elements. \r | |
68 | @since PackageEditor 1.0\r | |
69 | **/\r | |
70 | public class FpdFileContents {\r | |
71 | \r | |
72 | static final String xmlNs = "http://www.TianoCore.org/2006/Edk2.0";\r | |
73 | \r | |
74 | private PlatformSurfaceAreaDocument fpdd = null;\r | |
75 | \r | |
76 | private PlatformSurfaceAreaDocument.PlatformSurfaceArea fpdRoot = null;\r | |
77 | \r | |
78 | private PlatformHeaderDocument.PlatformHeader fpdHdr = null;\r | |
79 | \r | |
80 | private PlatformDefinitionsDocument.PlatformDefinitions fpdPlatformDefs = null;\r | |
81 | \r | |
82 | private FlashDocument.Flash fpdFlash = null;\r | |
83 | \r | |
84 | private BuildOptionsDocument.BuildOptions fpdBuildOpts = null;\r | |
85 | \r | |
86 | private FrameworkModulesDocument.FrameworkModules fpdFrameworkModules = null;\r | |
87 | \r | |
88 | private DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs = null;\r | |
89 | \r | |
908b1c05 | 90 | private HashMap<String, ArrayList<String>> dynPcdMap = null;\r |
a13899c5 | 91 | \r |
1bf9fa5a | 92 | private HashMap<String, String> defaultPcdValue = new HashMap<String, String>();\r |
93 | \r | |
a13899c5 | 94 | /**\r |
95 | * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.\r | |
96 | */\r | |
97 | public void initDynPcdMap() {\r | |
98 | if (dynPcdMap == null) {\r | |
99 | dynPcdMap = new HashMap<String, ArrayList<String>>();\r | |
100 | List<ModuleSADocument.ModuleSA> l = getfpdFrameworkModules().getModuleSAList();\r | |
101 | if (l == null) {\r | |
e232295e | 102 | removeElement(getfpdFrameworkModules());\r |
103 | fpdFrameworkModules = null;\r | |
a13899c5 | 104 | return;\r |
105 | }\r | |
106 | ListIterator<ModuleSADocument.ModuleSA> li = l.listIterator();\r | |
107 | while (li.hasNext()) {\r | |
1dac04ab | 108 | ModuleSADocument.ModuleSA moduleSa = li.next();\r |
109 | if (moduleSa.getPcdBuildDefinition() == null || moduleSa.getPcdBuildDefinition().getPcdDataList() == null) {\r | |
a13899c5 | 110 | continue;\r |
111 | }\r | |
1dac04ab | 112 | String ModuleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() +\r |
113 | " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r | |
114 | List<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lp = moduleSa.getPcdBuildDefinition().getPcdDataList();\r | |
a13899c5 | 115 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> lpi = lp.listIterator();\r |
116 | while (lpi.hasNext()) {\r | |
117 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = lpi.next();\r | |
118 | String pcdKey = pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName();\r | |
119 | if (dynPcdMap.get(pcdKey) == null) {\r | |
120 | ArrayList<String> al = new ArrayList<String>();\r | |
121 | al.add(ModuleInfo + " " + pcdData.getItemType().toString());\r | |
122 | dynPcdMap.put(pcdKey, al);\r | |
123 | }\r | |
124 | else{\r | |
125 | dynPcdMap.get(pcdKey).add(ModuleInfo + " " + pcdData.getItemType().toString());\r | |
126 | }\r | |
127 | }\r | |
128 | }\r | |
129 | }\r | |
130 | }\r | |
908b1c05 | 131 | \r |
132 | public ArrayList<String> getDynPcdMapValue(String key) {\r | |
133 | return dynPcdMap.get(key);\r | |
134 | }\r | |
a13899c5 | 135 | /**\r |
136 | Constructor to create a new spd file\r | |
137 | **/\r | |
138 | public FpdFileContents() {\r | |
139 | \r | |
140 | fpdd = PlatformSurfaceAreaDocument.Factory.newInstance();\r | |
141 | fpdRoot = fpdd.addNewPlatformSurfaceArea();\r | |
142 | \r | |
143 | }\r | |
144 | \r | |
145 | /**\r | |
146 | Constructor for existing document object\r | |
147 | @param psa\r | |
148 | **/\r | |
149 | public FpdFileContents(PlatformSurfaceAreaDocument.PlatformSurfaceArea fpd) {\r | |
150 | fpdRoot = fpd;\r | |
151 | fpdHdr = fpdRoot.getPlatformHeader();\r | |
152 | fpdPlatformDefs = fpdRoot.getPlatformDefinitions();\r | |
153 | fpdBuildOpts = fpdRoot.getBuildOptions();\r | |
154 | fpdFrameworkModules = fpdRoot.getFrameworkModules();\r | |
155 | fpdDynPcdBuildDefs = fpdRoot.getDynamicPcdBuildDefinitions();\r | |
156 | fpdFlash = fpdRoot.getFlash();\r | |
157 | }\r | |
158 | \r | |
159 | /**\r | |
160 | Constructor based on an existing spd file\r | |
161 | \r | |
162 | @param f Existing spd file\r | |
163 | **/\r | |
164 | public FpdFileContents(File f) {\r | |
165 | try {\r | |
166 | fpdd = PlatformSurfaceAreaDocument.Factory.parse(f);\r | |
167 | fpdRoot = fpdd.getPlatformSurfaceArea();\r | |
168 | } catch (Exception e) {\r | |
169 | System.out.println(e.toString());\r | |
170 | }\r | |
171 | }\r | |
172 | \r | |
173 | public DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions getfpdDynPcdBuildDefs() {\r | |
174 | if (fpdDynPcdBuildDefs == null){\r | |
175 | fpdDynPcdBuildDefs = fpdRoot.addNewDynamicPcdBuildDefinitions();\r | |
176 | }\r | |
177 | return fpdDynPcdBuildDefs;\r | |
178 | }\r | |
179 | \r | |
180 | public FrameworkModulesDocument.FrameworkModules getfpdFrameworkModules() {\r | |
181 | if (fpdFrameworkModules == null){\r | |
182 | fpdFrameworkModules = fpdRoot.addNewFrameworkModules();\r | |
183 | }\r | |
184 | return fpdFrameworkModules;\r | |
185 | }\r | |
186 | \r | |
61919f8c | 187 | public void getFrameworkModuleGuid (String fvName, Vector<String> vGuid) {\r |
188 | if (getFrameworkModulesCount() == 0){\r | |
189 | return;\r | |
190 | }\r | |
191 | \r | |
192 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
193 | while(li.hasNext()) {\r | |
194 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r | |
195 | if (moduleSa.getModuleSaBuildOptions() == null) {\r | |
196 | continue;\r | |
197 | }\r | |
198 | String fvBinding = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
199 | if (fvBinding == null) {\r | |
200 | continue;\r | |
201 | }\r | |
202 | \r | |
203 | String[] fvNames = fvBinding.split(" ");\r | |
204 | for (int i = 0; i < fvNames.length; ++i) {\r | |
205 | if (fvNames[i].equals(fvName) || fvNames[i].replaceAll("_", "").equals(fvName)) {\r | |
206 | vGuid.add(moduleSa.getModuleGuid());\r | |
207 | break;\r | |
208 | }\r | |
209 | }\r | |
210 | }\r | |
211 | }\r | |
212 | \r | |
a13899c5 | 213 | public int getFrameworkModulesCount() {\r |
5af6b67f | 214 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r |
e232295e | 215 | removeElement(getfpdFrameworkModules());\r |
216 | fpdFrameworkModules = null;\r | |
a13899c5 | 217 | return 0;\r |
218 | }\r | |
219 | return getfpdFrameworkModules().getModuleSAList().size();\r | |
220 | }\r | |
221 | \r | |
222 | public void getFrameworkModulesInfo(String[][] saa) {\r | |
223 | if (getFrameworkModulesCount() == 0){\r | |
224 | return;\r | |
225 | }\r | |
226 | \r | |
227 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
228 | int i = 0;\r | |
229 | while(li.hasNext()) {\r | |
61919f8c | 230 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r |
231 | saa[i][0] = moduleSa.getModuleGuid();\r | |
232 | saa[i][1] = moduleSa.getModuleVersion();\r | |
a13899c5 | 233 | \r |
61919f8c | 234 | saa[i][2] = moduleSa.getPackageGuid();\r |
235 | saa[i][3] = moduleSa.getPackageVersion();\r | |
236 | saa[i][4] = listToString(moduleSa.getSupArchList());\r | |
a13899c5 | 237 | ++i;\r |
238 | }\r | |
239 | }\r | |
240 | \r | |
bf5abaff | 241 | public void getFrameworkModuleInfo(int i, String[] sa) {\r |
242 | ModuleSADocument.ModuleSA msa = getModuleSA(i);\r | |
243 | if (msa == null) {\r | |
244 | return;\r | |
245 | }\r | |
246 | sa[0] = msa.getModuleGuid();\r | |
247 | sa[1] = msa.getModuleVersion();\r | |
248 | sa[2] = msa.getPackageGuid();\r | |
249 | sa[3] = msa.getPackageVersion();\r | |
250 | sa[4] = listToString(msa.getSupArchList());\r | |
251 | }\r | |
252 | \r | |
a13899c5 | 253 | public ModuleSADocument.ModuleSA getModuleSA(String key) {\r |
254 | String[] s = key.split(" ");\r | |
5af6b67f | 255 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {\r |
e232295e | 256 | removeElement(getfpdFrameworkModules());\r |
257 | fpdFrameworkModules = null;\r | |
a13899c5 | 258 | return null;\r |
259 | }\r | |
260 | ListIterator li = getfpdFrameworkModules().getModuleSAList().listIterator();\r | |
261 | while(li.hasNext()) {\r | |
1dac04ab | 262 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)li.next();\r |
263 | if (moduleSa.getModuleGuid().equalsIgnoreCase(s[0]) && moduleSa.getPackageGuid().equalsIgnoreCase(s[2])) {\r | |
264 | if (moduleSa.getModuleVersion() != null) {\r | |
265 | if (!moduleSa.getModuleVersion().equals(s[1])) {\r | |
12e17a0a | 266 | continue;\r |
267 | }\r | |
268 | }\r | |
1dac04ab | 269 | if (moduleSa.getPackageVersion() != null) {\r |
270 | if (!moduleSa.getPackageVersion().equals(s[3])) {\r | |
12e17a0a | 271 | continue;\r |
272 | }\r | |
273 | }\r | |
bf5abaff | 274 | //ToDo add arch check for s[4]\r |
1dac04ab | 275 | if (moduleSa.getSupArchList() != null) {\r |
276 | if (!listToString(moduleSa.getSupArchList()).equals(s[4])) {\r | |
bf5abaff | 277 | continue;\r |
278 | }\r | |
279 | }\r | |
1dac04ab | 280 | return moduleSa;\r |
a13899c5 | 281 | }\r |
282 | }\r | |
283 | return null;\r | |
284 | }\r | |
bf5abaff | 285 | \r |
286 | private ModuleSADocument.ModuleSA getModuleSA(int i) {\r | |
1dac04ab | 287 | ModuleSADocument.ModuleSA moduleSa = null;\r |
e232295e | 288 | if (fpdRoot.getFrameworkModules() == null) {\r |
289 | return null;\r | |
290 | }\r | |
291 | XmlCursor cursor = fpdRoot.getFrameworkModules().newCursor();\r | |
bf5abaff | 292 | if (cursor.toFirstChild()) {\r |
293 | for (int j = 0; j < i; ++j) {\r | |
294 | cursor.toNextSibling();\r | |
295 | }\r | |
1dac04ab | 296 | moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();\r |
bf5abaff | 297 | }\r |
298 | cursor.dispose();\r | |
1dac04ab | 299 | return moduleSa;\r |
bf5abaff | 300 | }\r |
301 | \r | |
a13899c5 | 302 | public void removeModuleSA(int i) {\r |
e232295e | 303 | XmlObject o = fpdRoot.getFrameworkModules();\r |
a13899c5 | 304 | if (o == null) {\r |
305 | return;\r | |
306 | }\r | |
307 | \r | |
308 | XmlCursor cursor = o.newCursor();\r | |
309 | if (cursor.toFirstChild()) {\r | |
310 | for (int j = 0; j < i; ++j) {\r | |
311 | cursor.toNextSibling();\r | |
312 | }\r | |
313 | //\r | |
314 | // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.\r | |
315 | //\r | |
316 | ModuleSADocument.ModuleSA moduleSa = (ModuleSADocument.ModuleSA)cursor.getObject();\r | |
317 | String moduleInfo = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() + " " +\r | |
bf5abaff | 318 | moduleSa.getPackageGuid()+ " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList());\r |
a13899c5 | 319 | PcdBuildDefinitionDocument.PcdBuildDefinition pcdBuildDef = moduleSa.getPcdBuildDefinition();\r |
908b1c05 | 320 | if (pcdBuildDef != null && pcdBuildDef.getPcdDataList() != null) {\r |
321 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData> li = pcdBuildDef.getPcdDataList().listIterator();\r | |
322 | while(li.hasNext()) {\r | |
323 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();\r | |
324 | maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleInfo);\r | |
325 | }\r | |
a13899c5 | 326 | }\r |
82dcbb45 | 327 | \r |
328 | cursor.push();\r | |
329 | cursor.toPrevToken();\r | |
330 | if (cursor.isComment()) {\r | |
331 | cursor.removeXml();\r | |
332 | }\r | |
333 | cursor.pop();\r | |
a13899c5 | 334 | cursor.removeXml();\r |
af25df16 | 335 | if (getFrameworkModulesCount() == 0) {\r |
336 | cursor.toParent();\r | |
337 | cursor.removeXml();\r | |
338 | }\r | |
a13899c5 | 339 | }\r |
340 | cursor.dispose();\r | |
341 | }\r | |
342 | \r | |
1dac04ab | 343 | public boolean adjustPcd (int seqModuleSa) throws Exception {\r |
344 | boolean dataModified = false;\r | |
345 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r | |
346 | int pcdCount = getPcdDataCount(seqModuleSa);\r | |
347 | String[][] saaModuleSaPcd = new String[pcdCount][7];\r | |
348 | getPcdData(seqModuleSa, saaModuleSaPcd);\r | |
349 | String mg = moduleSa.getModuleGuid();\r | |
350 | String mv = moduleSa.getModuleVersion();\r | |
351 | String pg = moduleSa.getPackageGuid();\r | |
352 | String pv = moduleSa.getPackageVersion();\r | |
353 | String arch = listToString(moduleSa.getSupArchList());\r | |
354 | //\r | |
355 | // delete pcd in ModuleSA but not in MSA files any longer.\r | |
356 | //\r | |
357 | String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r | |
358 | int libCount = getLibraryInstancesCount(moduleKey);\r | |
359 | String[][] saaLib = new String[libCount][5];\r | |
360 | getLibraryInstances(moduleKey, saaLib);\r | |
1bf9fa5a | 361 | ModuleIdentification mi = WorkspaceProfile.getModuleId(moduleKey);\r |
1dac04ab | 362 | Vector<ModuleIdentification> vMi = new Vector<ModuleIdentification>();\r |
363 | vMi.add(mi);\r | |
364 | try {\r | |
365 | nextPcd:for (int i = 0; i < saaModuleSaPcd.length; ++i) {\r | |
1bf9fa5a | 366 | if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], mi)){\r |
1dac04ab | 367 | continue;\r |
368 | }\r | |
369 | for (int j = 0; j < saaLib.length; ++j) {\r | |
370 | String libKey = saaLib[j][1] + " " + saaLib[j][2] + " " + saaLib[j][3] + " " + saaLib[j][4];\r | |
1bf9fa5a | 371 | ModuleIdentification libMi = WorkspaceProfile.getModuleId(libKey);\r |
1dac04ab | 372 | vMi.add(libMi);\r |
1bf9fa5a | 373 | if (WorkspaceProfile.pcdInMsa(saaModuleSaPcd[i][0], saaModuleSaPcd[i][1], libMi)) {\r |
1dac04ab | 374 | continue nextPcd;\r |
375 | }\r | |
376 | }\r | |
377 | removePcdData(seqModuleSa, saaModuleSaPcd[i][0], saaModuleSaPcd[i][1]);\r | |
378 | dataModified = true;\r | |
379 | }\r | |
380 | }\r | |
381 | catch (Exception e) {\r | |
382 | \r | |
383 | }\r | |
384 | //\r | |
385 | // add new Pcd from MSA file to ModuleSA.\r | |
386 | //\r | |
387 | try {\r | |
388 | \r | |
389 | for (int i = 0; i < vMi.size(); ++i) {\r | |
1bf9fa5a | 390 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea) WorkspaceProfile\r |
1dac04ab | 391 | .getModuleXmlObject(vMi\r |
392 | .get(i));\r | |
393 | if (msa.getPcdCoded() == null || msa.getPcdCoded().getPcdEntryList() == null) {\r | |
394 | continue;\r | |
395 | }\r | |
396 | ListIterator li = msa.getPcdCoded().getPcdEntryList().listIterator();\r | |
397 | msaPcdIter:while (li.hasNext()) {\r | |
398 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry) li.next();\r | |
399 | ArrayList<String> al = getDynPcdMapValue(msaPcd.getCName() + " " + msaPcd.getTokenSpaceGuidCName());\r | |
400 | if (al != null) {\r | |
401 | for (int j = 0; j < al.size(); ++j) {\r | |
402 | if (al.get(j).contains(moduleKey)) {\r | |
403 | continue msaPcdIter;\r | |
404 | }\r | |
405 | }\r | |
406 | }\r | |
407 | \r | |
408 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r | |
409 | m.put("ModuleSurfaceArea", msa);\r | |
410 | SurfaceAreaQuery.setDoc(m);\r | |
daa4663b | 411 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, vMi.get(i));\r |
1dac04ab | 412 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r |
413 | if (spdPcd == null) {\r | |
414 | //\r | |
415 | // ToDo Error \r | |
416 | //\r | |
417 | throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module "\r | |
418 | + mi.getName());\r | |
419 | }\r | |
420 | //\r | |
421 | // AddItem to ModuleSA PcdBuildDefinitions\r | |
422 | //\r | |
423 | String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue()\r | |
424 | : msaPcd.getDefaultValue();\r | |
425 | \r | |
426 | genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(),\r | |
427 | msaPcd.getPcdItemType().toString(), spdPcd.getDatumType() + "", defaultVal, moduleSa);\r | |
428 | dataModified = true;\r | |
429 | }\r | |
430 | \r | |
431 | }\r | |
432 | }\r | |
433 | catch (Exception e){\r | |
434 | throw e;\r | |
435 | }\r | |
436 | \r | |
437 | return dataModified;\r | |
438 | }\r | |
439 | \r | |
908b1c05 | 440 | private void maintainDynPcdMap(String pcdKey, String moduleInfo) {\r |
441 | \r | |
442 | ArrayList<String> al = dynPcdMap.get(pcdKey);\r | |
443 | if (al == null) {\r | |
a13899c5 | 444 | return;\r |
445 | }\r | |
908b1c05 | 446 | String[] s = moduleInfo.split(" ");\r |
a13899c5 | 447 | for(int i = 0; i < al.size(); ++i){\r |
908b1c05 | 448 | String consumer = al.get(i);\r |
449 | if (consumer.contains(s[0]) && consumer.contains(s[2])){\r | |
bf5abaff | 450 | String[] consumerPart = consumer.split(" ");\r |
451 | if (!consumerPart[4].equals(s[4])) {\r | |
452 | continue;\r | |
453 | }\r | |
908b1c05 | 454 | al.remove(consumer);\r |
a13899c5 | 455 | break;\r |
456 | }\r | |
457 | }\r | |
908b1c05 | 458 | \r |
a13899c5 | 459 | if (al.size() == 0) {\r |
1bf9fa5a | 460 | defaultPcdValue.remove(pcdKey);\r |
a13899c5 | 461 | dynPcdMap.remove(pcdKey);\r |
908b1c05 | 462 | String[] s1 = pcdKey.split(" ");\r |
463 | removeDynamicPcdBuildData(s1[0], s1[1]);\r | |
a13899c5 | 464 | }\r |
465 | \r | |
a13899c5 | 466 | }\r |
467 | //\r | |
bf5abaff | 468 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r |
a13899c5 | 469 | //\r |
1dac04ab | 470 | public int getPcdDataCount (int i){\r |
bf5abaff | 471 | ModuleSADocument.ModuleSA msa = getModuleSA(i);\r |
055e7ae6 | 472 | \r |
a13899c5 | 473 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r |
474 | return 0;\r | |
475 | }\r | |
476 | return msa.getPcdBuildDefinition().getPcdDataList().size();\r | |
055e7ae6 | 477 | \r |
a13899c5 | 478 | }\r |
479 | \r | |
1dac04ab | 480 | public void getPcdData (int i, String[][] saa) {\r |
bf5abaff | 481 | ModuleSADocument.ModuleSA msa = getModuleSA(i);\r |
055e7ae6 | 482 | \r |
a13899c5 | 483 | if (msa == null || msa.getPcdBuildDefinition() == null || msa.getPcdBuildDefinition().getPcdDataList() == null){\r |
484 | return;\r | |
485 | }\r | |
486 | ListIterator<PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData>li = msa.getPcdBuildDefinition().getPcdDataList().listIterator();\r | |
055e7ae6 | 487 | for (int k = 0; k < saa.length; ++k) {\r |
a13899c5 | 488 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = li.next();\r |
055e7ae6 | 489 | saa[k][0] = pcdData.getCName();\r |
490 | saa[k][1] = pcdData.getTokenSpaceGuidCName();\r | |
491 | saa[k][2] = pcdData.getItemType()+"";\r | |
492 | saa[k][3] = pcdData.getToken().toString();\r | |
493 | saa[k][4] = pcdData.getMaxDatumSize()+"";\r | |
494 | saa[k][5] = pcdData.getDatumType()+"";\r | |
495 | saa[k][6] = pcdData.getValue();\r | |
a13899c5 | 496 | \r |
497 | }\r | |
498 | }\r | |
908b1c05 | 499 | \r |
1dac04ab | 500 | public void removePcdData (int seqModuleSa, String cName, String tsGuid) {\r |
501 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(seqModuleSa);\r | |
502 | if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){\r | |
908b1c05 | 503 | return;\r |
504 | }\r | |
505 | \r | |
1dac04ab | 506 | String mg = moduleSa.getModuleGuid();\r |
507 | String mv = moduleSa.getModuleVersion();\r | |
508 | String pg = moduleSa.getPackageGuid();\r | |
509 | String pv = moduleSa.getPackageVersion();\r | |
510 | String arch = listToString(moduleSa.getSupArchList());\r | |
511 | String moduleKey = mg + " " + mv + " " + pg + " " + pv + " " + arch;\r | |
512 | \r | |
513 | XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor();\r | |
514 | if (cursor.toFirstChild()){\r | |
515 | \r | |
516 | do {\r | |
517 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r | |
518 | if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r | |
519 | maintainDynPcdMap(cName + " " + tsGuid, moduleKey);\r | |
520 | if (getPcdDataCount(seqModuleSa) == 1) {\r | |
521 | cursor.toParent();\r | |
522 | }\r | |
523 | cursor.removeXml();\r | |
524 | break;\r | |
525 | }\r | |
526 | }\r | |
527 | while(cursor.toNextSibling());\r | |
528 | \r | |
529 | }\r | |
530 | cursor.dispose();\r | |
531 | }\r | |
532 | \r | |
533 | public void updatePcdData (String key, String cName, String tsGuid, String itemType, String maxSize, String value){\r | |
534 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(key);\r | |
535 | if (moduleSa == null || moduleSa.getPcdBuildDefinition() == null){\r | |
536 | return;\r | |
537 | }\r | |
538 | \r | |
539 | XmlCursor cursor = moduleSa.getPcdBuildDefinition().newCursor();\r | |
908b1c05 | 540 | if (cursor.toFirstChild()){\r |
541 | do {\r | |
542 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData)cursor.getObject();\r | |
543 | if (pcdData.getCName().equals(cName) && pcdData.getTokenSpaceGuidCName().equals(tsGuid)) {\r | |
544 | pcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
545 | if(pcdData.getDatumType().equals("VOID*")) {\r | |
546 | pcdData.setMaxDatumSize(new Integer(maxSize));\r | |
547 | }\r | |
548 | pcdData.setValue(value);\r | |
1bf9fa5a | 549 | defaultPcdValue.put(cName + " " + tsGuid, value);\r |
908b1c05 | 550 | break;\r |
551 | }\r | |
552 | }\r | |
553 | while(cursor.toNextSibling());\r | |
554 | }\r | |
555 | cursor.dispose();\r | |
556 | }\r | |
557 | \r | |
558 | /**Get original Pcd info from MSA & SPD files.\r | |
559 | * @param mi ModuleIdentification from which MSA & SPD come\r | |
560 | * @param cName PCD cName\r | |
561 | * @param sa Results: HelpText, Original item type.\r | |
562 | * @return\r | |
563 | */\r | |
1dac04ab | 564 | public boolean getPcdBuildDataInfo(ModuleIdentification mi, String cName, String tsGuid, String[] sa) throws Exception{\r |
908b1c05 | 565 | try {\r |
566 | \r | |
1bf9fa5a | 567 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r |
908b1c05 | 568 | if (msa.getPcdCoded() == null) {\r |
569 | return false;\r | |
570 | }\r | |
571 | \r | |
572 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r | |
573 | m.put("ModuleSurfaceArea", msa);\r | |
574 | SurfaceAreaQuery.setDoc(m);\r | |
daa4663b | 575 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r |
908b1c05 | 576 | //\r |
577 | // First look through MSA pcd entries.\r | |
578 | //\r | |
579 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
580 | ListIterator li = l.listIterator();\r | |
581 | while(li.hasNext()) {\r | |
582 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
583 | if (!msaPcd.getCName().equals(cName)) {\r | |
584 | continue;\r | |
585 | }\r | |
1dac04ab | 586 | if (!msaPcd.getTokenSpaceGuidCName().equals(tsGuid)) {\r |
587 | continue;\r | |
588 | }\r | |
908b1c05 | 589 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r |
590 | if (spdPcd == null) {\r | |
591 | //\r | |
592 | // ToDo Error \r | |
593 | //\r | |
594 | throw new PcdDeclNotFound(mi.getName() + " " + msaPcd.getCName());\r | |
595 | }\r | |
596 | //\r | |
597 | // Get Pcd help text and original item type.\r | |
598 | //\r | |
599 | sa[0] = spdPcd.getHelpText() + msaPcd.getHelpText();\r | |
600 | sa[1] = msaPcd.getPcdItemType()+"";\r | |
601 | return true;\r | |
602 | }\r | |
603 | \r | |
604 | \r | |
605 | }\r | |
606 | catch (Exception e){\r | |
e232295e | 607 | e.printStackTrace();\r |
908b1c05 | 608 | throw e;\r |
609 | }\r | |
610 | \r | |
611 | return false;\r | |
612 | }\r | |
613 | \r | |
614 | /**Remove PCDBuildDefinition entries from ModuleSA\r | |
615 | * @param moduleKey identifier of ModuleSA.\r | |
616 | * @param consumer where these entries come from.\r | |
617 | */\r | |
618 | public void removePcdData(String moduleKey, ModuleIdentification consumer) {\r | |
619 | try {\r | |
1bf9fa5a | 620 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(consumer);\r |
908b1c05 | 621 | if (msa.getPcdCoded() == null) {\r |
622 | return;\r | |
623 | }\r | |
624 | \r | |
625 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
626 | ListIterator li = l.listIterator();\r | |
627 | \r | |
628 | while(li.hasNext()) {\r | |
629 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
630 | ModuleSADocument.ModuleSA moduleSA = getModuleSA(moduleKey);\r | |
82dcbb45 | 631 | if (moduleSA.getPcdBuildDefinition() != null) {\r |
632 | XmlCursor cursor = moduleSA.getPcdBuildDefinition().newCursor();\r | |
633 | if (cursor.toFirstChild()) {\r | |
634 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r | |
635 | .getObject();\r | |
636 | if (msaPcd.getCName().equals(pcdData.getCName())\r | |
637 | && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r | |
638 | \r | |
639 | maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(), moduleKey);\r | |
908b1c05 | 640 | cursor.removeXml();\r |
641 | break;\r | |
642 | }\r | |
82dcbb45 | 643 | while (cursor.toNextSibling()) {\r |
644 | pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor.getObject();\r | |
645 | if (msaPcd.getCName().equals(pcdData.getCName())\r | |
646 | && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r | |
647 | maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r | |
648 | moduleKey);\r | |
649 | cursor.removeXml();\r | |
650 | break;\r | |
651 | }\r | |
652 | }\r | |
908b1c05 | 653 | }\r |
82dcbb45 | 654 | cursor.dispose();\r |
908b1c05 | 655 | }\r |
908b1c05 | 656 | }\r |
657 | \r | |
658 | }\r | |
659 | catch (Exception e){\r | |
660 | e.printStackTrace();\r | |
661 | \r | |
662 | }\r | |
663 | }\r | |
a13899c5 | 664 | //\r |
bf5abaff | 665 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r |
a13899c5 | 666 | //\r |
667 | public int getLibraryInstancesCount(String key) {\r | |
668 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
669 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
670 | return 0;\r | |
671 | }\r | |
672 | return msa.getLibraries().getInstanceList().size();\r | |
673 | }\r | |
674 | \r | |
675 | public void getLibraryInstances(String key, String[][] saa){\r | |
676 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
677 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
678 | return ;\r | |
679 | }\r | |
680 | \r | |
681 | ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();\r | |
682 | for (int i = 0; i < saa.length; ++i) {\r | |
683 | LibrariesDocument.Libraries.Instance instance = li.next();\r | |
684 | saa[i][1] = instance.getModuleGuid();\r | |
685 | saa[i][2] = instance.getModuleVersion();\r | |
686 | saa[i][3] = instance.getPackageGuid();\r | |
687 | saa[i][4] = instance.getPackageVersion();\r | |
688 | }\r | |
689 | }\r | |
690 | \r | |
908b1c05 | 691 | public void removeLibraryInstance(String key, int i) {\r |
a13899c5 | 692 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
693 | if (msa == null || msa.getLibraries() == null){\r | |
694 | return ;\r | |
695 | }\r | |
696 | \r | |
697 | XmlCursor cursor = msa.getLibraries().newCursor();\r | |
908b1c05 | 698 | if (cursor.toFirstChild()) {\r |
699 | for (int j = 0; j < i; ++j) {\r | |
700 | cursor.toNextSibling();\r | |
701 | }\r | |
82dcbb45 | 702 | cursor.push();\r |
703 | cursor.toPrevToken();\r | |
704 | if (cursor.isComment()) {\r | |
705 | cursor.removeXml();\r | |
706 | }\r | |
707 | cursor.pop();\r | |
908b1c05 | 708 | cursor.removeXml();\r |
82dcbb45 | 709 | if (getLibraryInstancesCount(key) == 0) {\r |
710 | cursor.toParent();\r | |
711 | cursor.removeXml();\r | |
712 | }\r | |
908b1c05 | 713 | }\r |
714 | \r | |
a13899c5 | 715 | cursor.dispose();\r |
716 | }\r | |
717 | \r | |
82dcbb45 | 718 | public void genLibraryInstance(ModuleIdentification libMi, String key) {\r |
a13899c5 | 719 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
720 | if (msa == null){\r | |
721 | msa = getfpdFrameworkModules().addNewModuleSA();\r | |
722 | }\r | |
723 | LibrariesDocument.Libraries libs = msa.getLibraries();\r | |
724 | if(libs == null){\r | |
725 | libs = msa.addNewLibraries();\r | |
726 | }\r | |
727 | \r | |
82dcbb45 | 728 | String mn = libMi.getName();\r |
729 | String mg = libMi.getGuid();\r | |
730 | String mv = libMi.getVersion();\r | |
3658f95e | 731 | String pn = libMi.getPackageId().getName();\r |
732 | String pg = libMi.getPackageId().getGuid();\r | |
733 | String pv = libMi.getPackageId().getVersion();\r | |
a13899c5 | 734 | LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r |
82dcbb45 | 735 | XmlCursor cursor = instance.newCursor();\r |
736 | try{\r | |
737 | String comment = "Pkg: " + pn + " Mod: " + mn \r | |
3658f95e | 738 | + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r |
82dcbb45 | 739 | cursor.insertComment(comment);\r |
740 | }\r | |
741 | catch (Exception e){\r | |
742 | e.printStackTrace();\r | |
743 | }\r | |
744 | finally {\r | |
745 | cursor.dispose();\r | |
746 | }\r | |
747 | \r | |
a13899c5 | 748 | instance.setModuleGuid(mg);\r |
749 | instance.setModuleVersion(mv);\r | |
750 | instance.setPackageGuid(pg);\r | |
751 | instance.setPackageVersion(pv);\r | |
752 | \r | |
753 | }\r | |
1800d80f | 754 | \r |
755 | public String getFvBinding(String moduleKey){\r | |
756 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
757 | if (msa == null || msa.getModuleSaBuildOptions() == null) {\r | |
758 | return null;\r | |
759 | }\r | |
760 | return msa.getModuleSaBuildOptions().getFvBinding();\r | |
761 | }\r | |
762 | \r | |
2b70a636 | 763 | public void setFvBinding(ModuleSADocument.ModuleSA moduleSa, String fvBinding) {\r |
764 | if (moduleSa == null ) {\r | |
1800d80f | 765 | return;\r |
766 | }\r | |
61919f8c | 767 | if (fvBinding == null || fvBinding.length() == 0) {\r |
2b70a636 | 768 | if(moduleSa.getModuleSaBuildOptions() != null){\r |
769 | moduleSa.getModuleSaBuildOptions().unsetFvBinding();\r | |
61919f8c | 770 | }\r |
771 | }\r | |
772 | else {\r | |
2b70a636 | 773 | if(moduleSa.getModuleSaBuildOptions() == null){\r |
774 | moduleSa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r | |
61919f8c | 775 | return;\r |
776 | }\r | |
2b70a636 | 777 | moduleSa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r |
778 | }\r | |
779 | }\r | |
780 | \r | |
781 | public void setFvBinding(String moduleKey, String fvBinding){\r | |
782 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r | |
783 | setFvBinding (moduleSa, fvBinding);\r | |
784 | }\r | |
785 | \r | |
786 | public void removeFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r | |
787 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
788 | return;\r | |
789 | }\r | |
790 | \r | |
791 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
792 | String[] fvNamesArray = fvNameList.split(" ");\r | |
793 | int occursAt = -1;\r | |
794 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
795 | if (fvNamesArray[i].equals(fvName)) {\r | |
796 | occursAt = i;\r | |
797 | break;\r | |
798 | }\r | |
799 | }\r | |
800 | // jump over where the input fvName occurs in the original Fv list.\r | |
801 | if (occursAt != -1) {\r | |
802 | String newFvNameList = " ";\r | |
803 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
804 | if (i == occursAt) {\r | |
805 | continue;\r | |
806 | }\r | |
807 | newFvNameList += fvNamesArray[i];\r | |
808 | }\r | |
809 | setFvBinding (moduleSa, newFvNameList.trim());\r | |
810 | }\r | |
811 | \r | |
812 | }\r | |
813 | \r | |
814 | /**\r | |
815 | * @param fvName The FV name that to be removed from FvBinding List.\r | |
816 | */\r | |
817 | public void removeFvBindingAll (String fvName) {\r | |
818 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r | |
819 | removeElement(getfpdFrameworkModules());\r | |
820 | fpdFrameworkModules = null;\r | |
821 | return;\r | |
822 | }\r | |
823 | \r | |
824 | Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r | |
825 | while (li.hasNext()) {\r | |
826 | ModuleSADocument.ModuleSA moduleSa = li.next();\r | |
827 | removeFvBinding (moduleSa, fvName); \r | |
828 | }\r | |
829 | }\r | |
830 | \r | |
831 | public void appendFvBinding (String moduleKey, String fvName) {\r | |
832 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r | |
833 | appendFvBinding (moduleSa, fvName);\r | |
834 | }\r | |
835 | \r | |
836 | public void appendFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r | |
837 | if (moduleSa == null) {\r | |
838 | return;\r | |
839 | }\r | |
840 | \r | |
841 | if (moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
842 | setFvBinding(moduleSa, fvName);\r | |
843 | return;\r | |
844 | }\r | |
845 | \r | |
846 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
847 | String newFvNameList = fvNameList + " " + fvName;\r | |
848 | setFvBinding (moduleSa, newFvNameList.trim());\r | |
849 | }\r | |
850 | \r | |
851 | public void updateFvBindingInModuleSA (ModuleIdentification mi, String fvName) {\r | |
852 | Vector<Object> vSupArchs = new Vector<Object>();\r | |
853 | getPlatformDefsSupportedArchs(vSupArchs);\r | |
854 | String moduleInfo = mi.getGuid() + " " + mi.getVersion() + " " + mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion();\r | |
855 | for (int i = 0; i < vSupArchs.size(); ++i) {\r | |
856 | String moduleKey = moduleInfo + " " + vSupArchs.get(i);\r | |
857 | appendFvBinding (moduleKey, fvName);\r | |
1800d80f | 858 | }\r |
1800d80f | 859 | }\r |
860 | \r | |
861 | public String getFfsFileNameGuid(String moduleKey){\r | |
2b70a636 | 862 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r |
863 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r | |
1800d80f | 864 | return null;\r |
865 | }\r | |
2b70a636 | 866 | return moduleSa.getModuleSaBuildOptions().getFfsFileNameGuid();\r |
1800d80f | 867 | }\r |
868 | \r | |
869 | public void setFfsFileNameGuid(String moduleKey, String fileGuid){\r | |
870 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
871 | if (msa == null ) {\r | |
872 | return;\r | |
873 | }\r | |
874 | if(msa.getModuleSaBuildOptions() == null){\r | |
8f55ea73 | 875 | msa.addNewModuleSaBuildOptions();\r |
876 | \r | |
1800d80f | 877 | }\r |
8f55ea73 | 878 | ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions();\r |
879 | if (fileGuid != null) {\r | |
880 | msaBuildOpts.setFfsFileNameGuid(fileGuid);\r | |
881 | }\r | |
882 | else{\r | |
883 | XmlCursor cursor = msaBuildOpts.newCursor();\r | |
884 | if (cursor.toChild(xmlNs, "FfsFileNameGuid")) {\r | |
885 | cursor.removeXml();\r | |
886 | }\r | |
887 | cursor.dispose();\r | |
888 | }\r | |
889 | \r | |
1800d80f | 890 | }\r |
891 | \r | |
892 | public String getFfsFormatKey(String moduleKey){\r | |
893 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
894 | if (msa == null || msa.getModuleSaBuildOptions() == null) {\r | |
895 | return null;\r | |
896 | }\r | |
897 | return msa.getModuleSaBuildOptions().getFfsFormatKey();\r | |
898 | }\r | |
899 | \r | |
900 | public void setFfsFormatKey(String moduleKey, String ffsKey){\r | |
901 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
902 | if (msa == null ) {\r | |
903 | return;\r | |
904 | }\r | |
905 | if(msa.getModuleSaBuildOptions() == null){\r | |
906 | msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r | |
907 | return;\r | |
908 | }\r | |
bf5abaff | 909 | msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r |
1800d80f | 910 | }\r |
911 | \r | |
e7cc0547 | 912 | public void setModuleSAForceDebug(int i, boolean dbgEnable) {\r |
913 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r | |
914 | moduleSa.setForceDebug(dbgEnable);\r | |
915 | }\r | |
916 | \r | |
917 | public boolean getModuleSAForceDebug (int i) {\r | |
918 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r | |
919 | if (moduleSa.getForceDebug() == true) {\r | |
920 | return true;\r | |
921 | }\r | |
922 | return false;\r | |
923 | }\r | |
924 | \r | |
1800d80f | 925 | public void getModuleSAOptions(String moduleKey, String[][] saa) {\r |
926 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
e232295e | 927 | if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r |
1800d80f | 928 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r |
929 | return ;\r | |
930 | }\r | |
931 | \r | |
932 | List<OptionDocument.Option> lOpt = msa.getModuleSaBuildOptions().getOptions().getOptionList();\r | |
933 | ListIterator li = lOpt.listIterator();\r | |
934 | int i = 0;\r | |
935 | while(li.hasNext()) {\r | |
936 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
937 | if (opt.getBuildTargets() != null) {\r | |
938 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
939 | }\r | |
940 | saa[i][1] = opt.getToolChainFamily();\r | |
bf5abaff | 941 | saa[i][2] = opt.getTagName();\r |
942 | saa[i][3] = opt.getToolCode();\r | |
943 | \r | |
1800d80f | 944 | if (opt.getSupArchList() != null){\r |
bf5abaff | 945 | saa[i][4] = listToString(opt.getSupArchList());\r |
1800d80f | 946 | \r |
947 | }\r | |
bf5abaff | 948 | \r |
1800d80f | 949 | saa[i][5] = opt.getStringValue();\r |
950 | \r | |
951 | ++i;\r | |
952 | }\r | |
953 | }\r | |
954 | \r | |
955 | public int getModuleSAOptionsCount(String moduleKey){\r | |
956 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
e232295e | 957 | if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r |
1800d80f | 958 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r |
959 | return 0;\r | |
960 | }\r | |
961 | return msa.getModuleSaBuildOptions().getOptions().getOptionList().size();\r | |
962 | }\r | |
963 | \r | |
964 | public void genModuleSAOptionsOpt(String moduleKey, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
965 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
966 | if (msa.getModuleSaBuildOptions() == null) {\r | |
967 | msa.addNewModuleSaBuildOptions();\r | |
968 | }\r | |
969 | if (msa.getModuleSaBuildOptions().getOptions() == null){\r | |
970 | msa.getModuleSaBuildOptions().addNewOptions();\r | |
971 | }\r | |
972 | OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption();\r | |
973 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
974 | }\r | |
975 | \r | |
976 | public void removeModuleSAOptionsOpt(String moduleKey, int i) {\r | |
977 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
978 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
979 | return ;\r | |
980 | }\r | |
981 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
982 | XmlCursor cursor = opts.newCursor();\r | |
983 | if (cursor.toFirstChild()) {\r | |
984 | for (int j = 0; j < i; ++j){\r | |
985 | cursor.toNextSibling();\r | |
986 | }\r | |
987 | cursor.removeXml();\r | |
988 | }\r | |
989 | cursor.dispose();\r | |
990 | }\r | |
991 | \r | |
992 | public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
993 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
994 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
995 | return ;\r | |
996 | }\r | |
997 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
998 | XmlCursor cursor = opts.newCursor();\r | |
999 | if (cursor.toFirstChild()) {\r | |
1000 | for (int j = 0; j < i; ++j){\r | |
1001 | cursor.toNextSibling();\r | |
1002 | }\r | |
1003 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
1004 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1005 | }\r | |
1006 | cursor.dispose();\r | |
1007 | }\r | |
1008 | \r | |
a13899c5 | 1009 | /**add pcd information of module mi to a ModuleSA. \r |
1010 | * @param mi\r | |
1011 | * @param moduleSa if null, generate a new ModuleSA.\r | |
1012 | */\r | |
bf5abaff | 1013 | public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {\r |
a13899c5 | 1014 | //ToDo add Arch filter\r |
1015 | \r | |
1016 | try {\r | |
af25df16 | 1017 | if (moduleSa == null) {\r |
bf5abaff | 1018 | moduleSa = genModuleSA(mi, arch);\r |
af25df16 | 1019 | }\r |
1020 | \r | |
1bf9fa5a | 1021 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r |
a13899c5 | 1022 | if (msa.getPcdCoded() == null) {\r |
1023 | return;\r | |
1024 | }\r | |
af25df16 | 1025 | \r |
a13899c5 | 1026 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r |
1027 | m.put("ModuleSurfaceArea", msa);\r | |
1028 | SurfaceAreaQuery.setDoc(m);\r | |
daa4663b | 1029 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r |
a13899c5 | 1030 | //\r |
1031 | // Implementing InitializePlatformPcdBuildDefinitions\r | |
1032 | //\r | |
1033 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
1034 | ListIterator li = l.listIterator();\r | |
1035 | while(li.hasNext()) {\r | |
1036 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
1037 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r | |
1038 | if (spdPcd == null) {\r | |
1039 | //\r | |
1040 | // ToDo Error \r | |
1041 | //\r | |
34c614e1 | 1042 | throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());\r |
a13899c5 | 1043 | }\r |
1044 | //\r | |
1045 | // AddItem to ModuleSA PcdBuildDefinitions\r | |
1046 | //\r | |
1047 | String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r | |
908b1c05 | 1048 | \r |
a13899c5 | 1049 | genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r |
1050 | }\r | |
1051 | \r | |
1052 | }\r | |
1053 | catch (Exception e){\r | |
34c614e1 | 1054 | \r |
82961247 | 1055 | throw e; \r |
a13899c5 | 1056 | }\r |
1057 | \r | |
1058 | }\r | |
1059 | \r | |
1060 | private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r | |
1061 | \r | |
a13899c5 | 1062 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r |
1063 | for (int i = 0; i < depPkgs.length; ++i) {\r | |
3658f95e | 1064 | \r |
1065 | XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]);\r | |
a13899c5 | 1066 | if (xo == null) {\r |
1067 | continue;\r | |
1068 | }\r | |
1069 | for (int j = 0; j < xo.length; ++j) {\r | |
1070 | spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];\r | |
1071 | if (msaPcd.getTokenSpaceGuidCName() == null) {\r | |
1072 | if (spdPcd.getCName().equals(msaPcd.getCName())) {\r | |
1073 | return spdPcd;\r | |
1074 | }\r | |
1075 | }\r | |
1076 | else{\r | |
1077 | if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {\r | |
1078 | return spdPcd;\r | |
1079 | }\r | |
1080 | }\r | |
1081 | \r | |
1082 | }\r | |
1083 | \r | |
1084 | }\r | |
1085 | return null;\r | |
1086 | }\r | |
1087 | \r | |
bf5abaff | 1088 | private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {\r |
1bf9fa5a | 1089 | PackageIdentification pi = WorkspaceProfile.getPackageForModule(mi);\r |
a13899c5 | 1090 | ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r |
82dcbb45 | 1091 | XmlCursor cursor = msa.newCursor();\r |
1092 | try{\r | |
3658f95e | 1093 | String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r |
1094 | + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r | |
82dcbb45 | 1095 | cursor.insertComment(comment);\r |
1096 | }\r | |
1097 | catch(Exception e){\r | |
1098 | e.printStackTrace();\r | |
1099 | }\r | |
1100 | finally { \r | |
1101 | cursor.dispose();\r | |
1102 | }\r | |
a13899c5 | 1103 | msa.setModuleGuid(mi.getGuid());\r |
1104 | msa.setModuleVersion(mi.getVersion());\r | |
1105 | msa.setPackageGuid(pi.getGuid());\r | |
1106 | msa.setPackageVersion(pi.getVersion());\r | |
bf5abaff | 1107 | if (arch != null) {\r |
1108 | Vector<String> v = new Vector<String>();\r | |
1109 | v.add(arch);\r | |
1110 | msa.setSupArchList(v); \r | |
1111 | }\r | |
a13899c5 | 1112 | \r |
1113 | return msa;\r | |
1114 | }\r | |
1115 | \r | |
82961247 | 1116 | private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) \r |
1117 | throws PcdItemTypeConflictException, PcdValueMalFormed{\r | |
a13899c5 | 1118 | if (moduleSa.getPcdBuildDefinition() == null){\r |
1119 | moduleSa.addNewPcdBuildDefinition();\r | |
1120 | }\r | |
1121 | //\r | |
1122 | // constructe pcd to modulesa mapping first.\r | |
1123 | // Attention : for any error condition, remove from map this pcd.\r | |
1124 | //\r | |
1125 | ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);\r | |
1126 | if (pcdConsumer == null) {\r | |
1127 | pcdConsumer = new ArrayList<String>();\r | |
1128 | }\r | |
1bf9fa5a | 1129 | //\r |
1130 | // Using existing Pcd type, if this pcd already exists in other ModuleSA\r | |
1131 | //\r | |
1132 | if (pcdConsumer.size() > 0) {\r | |
1133 | String[] valPart = pcdConsumer.get(0).split(" ");\r | |
1134 | itemType = valPart[5];\r | |
1135 | }\r | |
a13899c5 | 1136 | String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r |
bf5abaff | 1137 | + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r |
a13899c5 | 1138 | + " " + itemType;\r |
1139 | pcdConsumer.add(listValue);\r | |
1140 | dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r | |
1bf9fa5a | 1141 | \r |
a13899c5 | 1142 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r |
1143 | fpdPcd.setCName(cName);\r | |
1144 | fpdPcd.setToken(token);\r | |
1145 | fpdPcd.setTokenSpaceGuidCName(tsGuid);\r | |
1146 | fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
1147 | fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
a390c35d | 1148 | \r |
1149 | if (defaultVal != null){\r | |
1150 | fpdPcd.setValue(defaultVal);\r | |
1151 | }\r | |
1152 | else {\r | |
1153 | if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r | |
1154 | fpdPcd.setValue("0");\r | |
1155 | }\r | |
1156 | if (dataType.equals("BOOLEAN")){\r | |
1157 | fpdPcd.setValue("false");\r | |
1158 | }\r | |
1159 | if (dataType.equals("VOID*")) {\r | |
1160 | fpdPcd.setValue("");\r | |
1161 | }\r | |
1162 | }\r | |
1bf9fa5a | 1163 | //\r |
1164 | // Using existing pcd value, if this pcd already exists in other moduleSa.\r | |
1165 | //\r | |
1166 | if (defaultPcdValue.get(cName + " " + tsGuid) == null) {\r | |
1167 | defaultPcdValue.put(cName + " " + tsGuid, fpdPcd.getValue());\r | |
1168 | }\r | |
1169 | else {\r | |
1170 | fpdPcd.setValue(defaultPcdValue.get(cName + " " + tsGuid));\r | |
1171 | }\r | |
1172 | \r | |
802e0055 | 1173 | if (dataType.equals("UINT8")){\r |
1174 | fpdPcd.setMaxDatumSize(1);\r | |
1175 | }\r | |
1176 | if (dataType.equals("UINT16")) {\r | |
1177 | fpdPcd.setMaxDatumSize(2);\r | |
1178 | }\r | |
1179 | if (dataType.equals("UINT32")) {\r | |
1180 | fpdPcd.setMaxDatumSize(4);\r | |
1181 | }\r | |
1182 | if (dataType.equals("UINT64")){\r | |
1183 | fpdPcd.setMaxDatumSize(8);\r | |
1184 | }\r | |
1185 | if (dataType.equals("BOOLEAN")){\r | |
1186 | fpdPcd.setMaxDatumSize(1);\r | |
1187 | }\r | |
1188 | if (dataType.equals("VOID*")) {\r | |
1189 | int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r | |
1190 | fpdPcd.setMaxDatumSize(maxSize);\r | |
1191 | }\r | |
a13899c5 | 1192 | \r |
a390c35d | 1193 | \r |
a13899c5 | 1194 | if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r |
1195 | ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r | |
1196 | //\r | |
1197 | // if only one module mapped to this pcd, then the one is myself. so no other module mapped.\r | |
1198 | // so need to add one dyn pcd.\r | |
1199 | //\r | |
1200 | if (al.size() == 1) {\r | |
1201 | addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);\r | |
1202 | }\r | |
1203 | }\r | |
1bf9fa5a | 1204 | \r |
a13899c5 | 1205 | }\r |
1206 | \r | |
908b1c05 | 1207 | public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{\r |
a13899c5 | 1208 | if (datum == null) {\r |
1209 | return 0;\r | |
1210 | }\r | |
1211 | char ch = datum.charAt(0);\r | |
1212 | int start, end;\r | |
1213 | String strValue;\r | |
1214 | //\r | |
1215 | // For void* type PCD, only three datum is support:\r | |
1216 | // 1) Unicode: string with start char is "L"\r | |
1217 | // 2) Ansci: String is ""\r | |
1218 | // 3) byte array: String start char "{"\r | |
1219 | // \r | |
1220 | if (ch == 'L') {\r | |
1221 | start = datum.indexOf('\"');\r | |
1222 | end = datum.lastIndexOf('\"');\r | |
1223 | if ((start > end) || \r | |
1224 | (end > datum.length())||\r | |
1225 | ((start == end) && (datum.length() > 0))) {\r | |
1226 | //ToDo Error handling here\r | |
82961247 | 1227 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1228 | }\r |
1229 | \r | |
1230 | strValue = datum.substring(start + 1, end);\r | |
1231 | return strValue.length() * 2;\r | |
1232 | } else if (ch == '\"'){\r | |
1233 | start = datum.indexOf('\"');\r | |
1234 | end = datum.lastIndexOf('\"');\r | |
1235 | if ((start > end) || \r | |
1236 | (end > datum.length())||\r | |
1237 | ((start == end) && (datum.length() > 0))) {\r | |
82961247 | 1238 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1239 | }\r |
1240 | strValue = datum.substring(start + 1, end);\r | |
1241 | return strValue.length();\r | |
1242 | } else if (ch =='{') {\r | |
1243 | String[] strValueArray;\r | |
1244 | \r | |
1245 | start = datum.indexOf('{');\r | |
1246 | end = datum.lastIndexOf('}');\r | |
1247 | strValue = datum.substring(start + 1, end);\r | |
1248 | strValue = strValue.trim();\r | |
1249 | if (strValue.length() == 0) {\r | |
1250 | return 0;\r | |
1251 | }\r | |
1252 | strValueArray = strValue.split(",");\r | |
1253 | for (int index = 0; index < strValueArray.length; index ++) {\r | |
1254 | Integer value = Integer.decode(strValueArray[index].trim());\r | |
1255 | \r | |
1256 | if (value > 0xFF) {\r | |
1257 | // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r | |
a70d444e | 1258 | // "it must be a byte array. But the element of %s exceed the byte range",\r |
82961247 | 1259 | throw new PcdValueMalFormed (datum); \r |
a13899c5 | 1260 | }\r |
1261 | }\r | |
1262 | return strValueArray.length;\r | |
1263 | \r | |
1264 | \r | |
1265 | } else {\r | |
1266 | // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r | |
1267 | // "1) UNICODE string: like L\"xxxx\";\r\n"+\r | |
1268 | // "2) ANSIC string: like \"xxx\";\r\n"+\r | |
1269 | // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r | |
1270 | // "but the datum in seems does not following above format!",\r | |
82961247 | 1271 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1272 | \r |
1273 | }\r | |
1274 | }\r | |
1275 | \r | |
1276 | private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {\r | |
1277 | ArrayList<String> al = dynPcdMap.get(dynPcdKey);\r | |
1278 | \r | |
1279 | return al;\r | |
1280 | }\r | |
1281 | \r | |
1282 | private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r | |
1283 | \r | |
34c614e1 | 1284 | return dynPcdMap.get(pcdKey);\r |
a13899c5 | 1285 | }\r |
1286 | \r | |
1287 | public int getDynamicPcdBuildDataCount() {\r | |
5af6b67f | 1288 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
e232295e | 1289 | removeElement(getfpdDynPcdBuildDefs());\r |
1290 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1291 | return 0;\r |
1292 | }\r | |
1293 | return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();\r | |
1294 | }\r | |
1295 | \r | |
1296 | public void getDynamicPcdBuildData(String[][] saa) {\r | |
5af6b67f | 1297 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
e232295e | 1298 | removeElement(getfpdDynPcdBuildDefs());\r |
1299 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1300 | return ;\r |
1301 | }\r | |
1302 | List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();\r | |
1303 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();\r | |
1304 | int i = 0;\r | |
1305 | while(li.hasNext()) {\r | |
1306 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();\r | |
1307 | saa[i][0] = dynPcd.getCName();\r | |
1308 | saa[i][1] = dynPcd.getToken().toString();\r | |
1309 | saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r | |
1310 | saa[i][3] = dynPcd.getMaxDatumSize()+"";\r | |
1311 | saa[i][4] = dynPcd.getDatumType().toString();\r | |
1312 | \r | |
1313 | ++i;\r | |
1314 | }\r | |
1315 | }\r | |
1316 | \r | |
908b1c05 | 1317 | public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) \r |
82961247 | 1318 | throws PcdValueMalFormed{\r |
a13899c5 | 1319 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();\r |
1320 | dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
1321 | dynPcdData.setCName(cName);\r | |
1322 | dynPcdData.setToken(token);\r | |
1323 | dynPcdData.setTokenSpaceGuidCName(tsGuid);\r | |
1324 | dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
1325 | \r | |
1326 | BigInteger bigInt = new BigInteger("0");\r | |
1327 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();\r | |
1328 | skuInfo.setSkuId(bigInt);\r | |
1329 | if (defaultVal != null){\r | |
1330 | skuInfo.setValue(defaultVal);\r | |
1331 | }\r | |
1332 | else {\r | |
1333 | if (dataType.equals("UINT8")){\r | |
1334 | skuInfo.setValue("0");\r | |
1335 | }\r | |
1336 | if (dataType.equals("UINT16")) {\r | |
1337 | skuInfo.setValue("0");\r | |
1338 | }\r | |
1339 | if (dataType.equals("UINT32")) {\r | |
1340 | skuInfo.setValue("0");\r | |
1341 | }\r | |
1342 | if (dataType.equals("UINT64")){\r | |
1343 | skuInfo.setValue("0");\r | |
1344 | }\r | |
1345 | if (dataType.equals("BOOLEAN")){\r | |
1346 | skuInfo.setValue("false");\r | |
1347 | }\r | |
1348 | if (dataType.equals("VOID*")) {\r | |
1349 | skuInfo.setValue("");\r | |
1350 | }\r | |
1351 | }\r | |
1352 | if (dataType.equals("UINT8")){\r | |
1353 | dynPcdData.setMaxDatumSize(1);\r | |
1354 | }\r | |
1355 | if (dataType.equals("UINT16")) {\r | |
1356 | dynPcdData.setMaxDatumSize(2);\r | |
1357 | }\r | |
1358 | if (dataType.equals("UINT32")) {\r | |
1359 | dynPcdData.setMaxDatumSize(4);\r | |
1360 | }\r | |
1361 | if (dataType.equals("UINT64")){\r | |
1362 | dynPcdData.setMaxDatumSize(8);\r | |
1363 | }\r | |
1364 | if (dataType.equals("BOOLEAN")){\r | |
1365 | dynPcdData.setMaxDatumSize(1);\r | |
1366 | }\r | |
1367 | if (dataType.equals("VOID*")) {\r | |
1368 | int maxSize = setMaxSizeForPointer(defaultVal);\r | |
1369 | dynPcdData.setMaxDatumSize(maxSize);\r | |
1370 | }\r | |
1371 | }\r | |
1372 | \r | |
908b1c05 | 1373 | public void removeDynamicPcdBuildData(String cName, String tsGuid) {\r |
e232295e | 1374 | XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions();\r |
1375 | if (o == null) {\r | |
1376 | return;\r | |
1377 | }\r | |
a13899c5 | 1378 | \r |
1379 | XmlCursor cursor = o.newCursor();\r | |
1380 | if (cursor.toFirstChild()) {\r | |
af25df16 | 1381 | do {\r |
1382 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = \r | |
1383 | (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
908b1c05 | 1384 | if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {\r |
add40ab2 | 1385 | \r |
1386 | if (getDynamicPcdBuildDataCount() == 1) {\r | |
af25df16 | 1387 | cursor.toParent();\r |
af25df16 | 1388 | }\r |
add40ab2 | 1389 | cursor.removeXml();\r |
908b1c05 | 1390 | cursor.dispose();\r |
1391 | return;\r | |
1392 | }\r | |
a13899c5 | 1393 | }\r |
af25df16 | 1394 | while (cursor.toNextSibling());\r |
a13899c5 | 1395 | }\r |
1396 | cursor.dispose();\r | |
1397 | }\r | |
1398 | //\r | |
1399 | // Get the Sku Info count of ith dyn pcd element.\r | |
1400 | //\r | |
1401 | public int getDynamicPcdSkuInfoCount(int i){\r | |
e232295e | 1402 | if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null \r |
1403 | || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {\r | |
a13899c5 | 1404 | return 0;\r |
1405 | }\r | |
1406 | \r | |
1407 | int skuInfoCount = 0;\r | |
1408 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1409 | if (cursor.toFirstChild()) {\r | |
1410 | for (int j = 0; j < i; ++j) {\r | |
1411 | cursor.toNextSibling();\r | |
1412 | }\r | |
1413 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1414 | if (pcdData.getSkuInfoList() == null) {\r | |
1415 | skuInfoCount = 0;\r | |
1416 | }\r | |
1417 | else {\r | |
1418 | skuInfoCount = pcdData.getSkuInfoList().size();\r | |
1419 | }\r | |
1420 | }\r | |
1421 | cursor.dispose();\r | |
1422 | return skuInfoCount;\r | |
1423 | }\r | |
1424 | \r | |
1425 | public void getDynamicPcdSkuInfos(int i, String[][] saa){\r | |
1426 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1427 | removeElement(getfpdDynPcdBuildDefs());\r |
1428 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1429 | return;\r |
1430 | }\r | |
1431 | \r | |
1432 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1433 | if (cursor.toFirstChild()) {\r | |
1434 | for (int j = 0; j < i; ++j) {\r | |
1435 | cursor.toNextSibling();\r | |
1436 | }\r | |
1437 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1438 | if (pcdData.getSkuInfoList() == null) {\r | |
1439 | cursor.dispose();\r | |
1440 | return;\r | |
1441 | }\r | |
1442 | else {\r | |
1443 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1444 | int k = 0;\r | |
1445 | while (li.hasNext()) {\r | |
1446 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1447 | saa[k][0] = skuInfo.getSkuId()+"";\r | |
1448 | saa[k][1] = skuInfo.getVariableName();\r | |
1449 | saa[k][2] = skuInfo.getVariableGuid();\r | |
1450 | saa[k][3] = skuInfo.getVariableOffset();\r | |
1451 | saa[k][4] = skuInfo.getHiiDefaultValue();\r | |
1452 | saa[k][5] = skuInfo.getVpdOffset();\r | |
1453 | saa[k][6] = skuInfo.getValue();\r | |
1454 | ++k;\r | |
1455 | }\r | |
1456 | \r | |
1457 | }\r | |
1458 | }\r | |
1459 | cursor.dispose();\r | |
1460 | \r | |
1461 | }\r | |
1462 | \r | |
1463 | public String getDynamicPcdBuildDataValue(int i){\r | |
1464 | String value = null;\r | |
1465 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1466 | removeElement(getfpdDynPcdBuildDefs());\r |
1467 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1468 | return value;\r |
1469 | }\r | |
1470 | \r | |
1471 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1472 | if (cursor.toFirstChild()) {\r | |
1473 | for (int j = 0; j < i; ++j) {\r | |
1474 | cursor.toNextSibling();\r | |
1475 | }\r | |
1476 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1477 | if (pcdData.getSkuInfoList() == null) {\r | |
1478 | value = null;\r | |
1479 | }\r | |
1480 | else {\r | |
1481 | value = pcdData.getSkuInfoArray(0).getValue();\r | |
1482 | }\r | |
1483 | }\r | |
1484 | cursor.dispose();\r | |
1485 | return value;\r | |
1486 | }\r | |
1487 | \r | |
1488 | public String getDynamicPcdBuildDataVpdOffset(int i){\r | |
1489 | String vpdOffset = null;\r | |
1490 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1491 | removeElement(getfpdDynPcdBuildDefs());\r |
1492 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1493 | return vpdOffset;\r |
1494 | }\r | |
1495 | \r | |
1496 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1497 | if (cursor.toFirstChild()) {\r | |
1498 | for (int j = 0; j < i; ++j) {\r | |
1499 | cursor.toNextSibling();\r | |
1500 | }\r | |
1501 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1502 | if (pcdData.getSkuInfoList() == null) {\r | |
1503 | vpdOffset = null;\r | |
1504 | }\r | |
1505 | else {\r | |
1506 | vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();\r | |
1507 | }\r | |
1508 | }\r | |
1509 | cursor.dispose();\r | |
1510 | return vpdOffset;\r | |
1511 | }\r | |
1512 | \r | |
1513 | public void removeDynamicPcdBuildDataSkuInfo(int i) {\r | |
1514 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1515 | removeElement(getfpdDynPcdBuildDefs());\r |
1516 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1517 | return;\r |
1518 | }\r | |
1519 | \r | |
1520 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1521 | if (cursor.toFirstChild()) {\r | |
1522 | for (int j = 0; j < i; ++j) {\r | |
1523 | cursor.toNextSibling();\r | |
1524 | }\r | |
1525 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1526 | if (pcdData.getSkuInfoList() == null) {\r | |
1527 | cursor.dispose();\r | |
1528 | return;\r | |
1529 | }\r | |
1530 | else {\r | |
1531 | QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r | |
1532 | cursor.toChild(qSkuInfo);\r | |
1533 | cursor.removeXml();\r | |
1534 | }\r | |
1535 | }\r | |
1536 | cursor.dispose();\r | |
1537 | }\r | |
1538 | //\r | |
1539 | // generate sku info for ith dyn pcd build data.\r | |
1540 | //\r | |
1541 | public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1542 | String hiiDefault, String vpdOffset, String value, int i) {\r | |
e232295e | 1543 | // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
1544 | // return;\r | |
1545 | // }\r | |
a13899c5 | 1546 | \r |
1547 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1548 | if (cursor.toFirstChild()) {\r | |
1549 | for (int j = 0; j < i; ++j) {\r | |
1550 | cursor.toNextSibling();\r | |
1551 | }\r | |
1552 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1553 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();\r | |
1554 | skuInfo.setSkuId(new BigInteger(id));\r | |
1555 | if (varName != null){\r | |
1556 | skuInfo.setVariableName(varName);\r | |
1557 | skuInfo.setVariableGuid(varGuid);\r | |
1558 | skuInfo.setVariableOffset(varOffset);\r | |
1559 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1560 | }\r | |
1561 | else if (vpdOffset != null){\r | |
1562 | skuInfo.setVpdOffset(vpdOffset);\r | |
1563 | }\r | |
1564 | else{\r | |
1565 | skuInfo.setValue(value);\r | |
1566 | }\r | |
1567 | }\r | |
1568 | }\r | |
1569 | \r | |
1570 | public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1571 | String hiiDefault, String vpdOffset, String value, int i){\r | |
e232295e | 1572 | // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
1573 | // return;\r | |
1574 | // }\r | |
a13899c5 | 1575 | \r |
1576 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1577 | if (cursor.toFirstChild()) {\r | |
1578 | for (int j = 0; j < i; ++j) {\r | |
1579 | cursor.toNextSibling();\r | |
1580 | }\r | |
1581 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1582 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1583 | while (li.hasNext()) {\r | |
1584 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1585 | if (skuInfo.getSkuId().toString().equals(id)){\r | |
1586 | if (varName != null){\r | |
1587 | skuInfo.setVariableName(varName);\r | |
1588 | skuInfo.setVariableGuid(varGuid);\r | |
1589 | skuInfo.setVariableOffset(varOffset);\r | |
1590 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1591 | }\r | |
1592 | else if (vpdOffset != null){\r | |
1593 | skuInfo.setVpdOffset(vpdOffset);\r | |
1594 | }\r | |
1595 | else{\r | |
1596 | skuInfo.setValue(value);\r | |
1597 | }\r | |
1598 | break;\r | |
1599 | }\r | |
1600 | }\r | |
1601 | }\r | |
1602 | }\r | |
1603 | \r | |
a13899c5 | 1604 | public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {\r |
1605 | if (fpdBuildOpts == null) {\r | |
1606 | fpdBuildOpts = fpdRoot.addNewBuildOptions();\r | |
1607 | }\r | |
1608 | return fpdBuildOpts;\r | |
1609 | }\r | |
1610 | \r | |
2b70a636 | 1611 | public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {\r |
1bf9fa5a | 1612 | UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r |
1613 | userExts.setUserID("IMAGES");\r | |
1614 | userExts.setIdentifier(new BigInteger("1"));\r | |
1615 | XmlCursor cursor = userExts.newCursor();\r | |
1616 | cursor.toEndToken();\r | |
1617 | \r | |
1618 | cursor.beginElement("FvName");\r | |
1619 | cursor.insertChars(fvName);\r | |
1620 | cursor.toNextToken();\r | |
1621 | \r | |
1622 | cursor.beginElement("InfFileName");\r | |
61919f8c | 1623 | cursor.insertChars(fvName + ".inf");\r |
1bf9fa5a | 1624 | cursor.toNextToken();\r |
1625 | \r | |
1626 | cursor.beginElement("IncludeModules");\r | |
2b70a636 | 1627 | for (int i = 0; i < includeModules.size(); ++i) {\r |
1bf9fa5a | 1628 | cursor.beginElement("Module");\r |
2b70a636 | 1629 | cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);\r |
1630 | cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);\r | |
1bf9fa5a | 1631 | cursor.toEndToken();\r |
1632 | cursor.toNextToken();\r | |
1633 | }\r | |
1634 | cursor.dispose();\r | |
1635 | }\r | |
1636 | \r | |
1637 | public int getUserExtsIncModCount (String fvName) {\r | |
1638 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1639 | return -1;\r | |
1640 | }\r | |
1641 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r | |
1642 | while (li.hasNext()) {\r | |
1643 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1644 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1645 | continue;\r | |
1646 | }\r | |
1647 | XmlCursor cursor = ues.newCursor();\r | |
1648 | cursor.toFirstChild();\r | |
1649 | String elementName = cursor.getTextValue();\r | |
1650 | if (elementName.equals(fvName)) {\r | |
1651 | cursor.toNextSibling(new QName("", "IncludeModules"));\r | |
1652 | if (cursor.toFirstChild()) {\r | |
1653 | int i = 1;\r | |
1654 | for (i = 1; cursor.toNextSibling(); ++i);\r | |
1655 | cursor.dispose();\r | |
1656 | return i;\r | |
1657 | }\r | |
1658 | cursor.dispose();\r | |
1659 | return 0;\r | |
1660 | }\r | |
1661 | cursor.dispose();\r | |
1662 | }\r | |
1663 | return -1;\r | |
1664 | }\r | |
1665 | \r | |
1666 | public void getUserExtsIncMods(String fvName, String[][] saa) {\r | |
1667 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1668 | return;\r | |
1669 | }\r | |
1670 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r | |
1671 | while (li.hasNext()) {\r | |
1672 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1673 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1674 | continue;\r | |
1675 | }\r | |
1676 | XmlCursor cursor = ues.newCursor();\r | |
1677 | cursor.toFirstChild();\r | |
1678 | String elementName = cursor.getTextValue();\r | |
1679 | if (elementName.equals(fvName)) {\r | |
1680 | cursor.toNextSibling(new QName("", "IncludeModules"));\r | |
1681 | if (cursor.toFirstChild()) {\r | |
1682 | int i = 0;\r | |
1683 | do {\r | |
1684 | saa[i][0] = cursor.getAttributeText(new QName("ModuleGuid"));\r | |
1685 | saa[i][1] = cursor.getAttributeText(new QName("BaseName"));\r | |
1686 | ++i;\r | |
1687 | }while (cursor.toNextSibling());\r | |
1688 | }\r | |
1689 | cursor.dispose();\r | |
1690 | return;\r | |
1691 | }\r | |
1692 | cursor.dispose();\r | |
1693 | }\r | |
1694 | \r | |
1695 | }\r | |
1696 | \r | |
61919f8c | 1697 | public void removeBuildOptionsUserExtensions (String fvName) {\r |
1698 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1699 | return;\r | |
1700 | }\r | |
1701 | \r | |
1702 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r | |
1703 | while (li.hasNext()) {\r | |
1704 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1705 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1706 | continue;\r | |
1707 | }\r | |
1708 | XmlCursor cursor = ues.newCursor();\r | |
1709 | cursor.toFirstChild();\r | |
1710 | String elementName = cursor.getTextValue();\r | |
1711 | if (elementName.equals(fvName)) {\r | |
1712 | cursor.toParent();\r | |
1713 | cursor.removeXml();\r | |
1714 | cursor.dispose();\r | |
1715 | return;\r | |
1716 | }\r | |
1717 | cursor.dispose();\r | |
1718 | }\r | |
1719 | \r | |
1720 | }\r | |
1721 | \r | |
1722 | \r | |
a13899c5 | 1723 | public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r |
1724 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1725 | if (udats == null) {\r | |
1726 | udats = getfpdBuildOpts().addNewUserDefinedAntTasks();\r | |
1727 | }\r | |
1728 | \r | |
1729 | AntTaskDocument.AntTask at = udats.addNewAntTask();\r | |
1730 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1731 | }\r | |
1732 | \r | |
1733 | private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {\r | |
1734 | at.setId(new Integer(id));\r | |
bf5abaff | 1735 | XmlCursor cursor = at.newCursor();\r |
a13899c5 | 1736 | if (fileName != null){\r |
1737 | at.setFilename(fileName);\r | |
1738 | }\r | |
bf5abaff | 1739 | else if (cursor.toChild(xmlNs, "Filename")) {\r |
1740 | cursor.removeXml();\r | |
1741 | }\r | |
202c4f38 | 1742 | if (execOrder != null) {\r |
a13899c5 | 1743 | at.setAntCmdOptions(execOrder);\r |
1744 | }\r | |
bf5abaff | 1745 | else if (cursor.toChild(xmlNs, "AntCmdOptions")) {\r |
1746 | cursor.removeXml();\r | |
1747 | }\r | |
1748 | cursor.dispose();\r | |
a13899c5 | 1749 | }\r |
1750 | \r | |
1751 | public void removeBuildOptionsUserDefAntTask(int i) {\r | |
1752 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1753 | if (o == null) {\r | |
1754 | return;\r | |
1755 | }\r | |
1756 | XmlCursor cursor = o.newCursor();\r | |
1757 | if (cursor.toFirstChild()) {\r | |
1758 | for (int j = 0; j < i; ++j) {\r | |
1759 | cursor.toNextSibling();\r | |
1760 | }\r | |
1761 | cursor.removeXml();\r | |
af25df16 | 1762 | if (getBuildOptionsUserDefAntTaskCount() == 0) {\r |
1763 | cursor.toParent();\r | |
1764 | cursor.removeXml();\r | |
1765 | }\r | |
a13899c5 | 1766 | }\r |
1767 | cursor.dispose();\r | |
1768 | }\r | |
1769 | \r | |
1770 | public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){\r | |
1771 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1772 | if (o == null) {\r | |
1773 | return;\r | |
1774 | }\r | |
1775 | XmlCursor cursor = o.newCursor();\r | |
1776 | if (cursor.toFirstChild()) {\r | |
1777 | for (int j = 0; j < i; ++j) {\r | |
1778 | cursor.toNextSibling();\r | |
1779 | }\r | |
1780 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();\r | |
1781 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1782 | }\r | |
1783 | cursor.dispose();\r | |
1784 | }\r | |
1785 | \r | |
1786 | public int getBuildOptionsUserDefAntTaskCount() {\r | |
1787 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1788 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1789 | return 0;\r | |
1790 | }\r | |
1791 | \r | |
1792 | return udats.getAntTaskList().size();\r | |
1793 | }\r | |
1794 | \r | |
1795 | public void getBuildOptionsUserDefAntTasks(String[][] saa) {\r | |
1796 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1797 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1798 | return ;\r | |
1799 | }\r | |
1800 | \r | |
1801 | List<AntTaskDocument.AntTask> l = udats.getAntTaskList();\r | |
1802 | ListIterator li = l.listIterator();\r | |
1803 | int i = 0;\r | |
1804 | while (li.hasNext()) {\r | |
1805 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();\r | |
1806 | saa[i][0] = at.getId() + "";\r | |
1807 | saa[i][1] = saa[i][2] = "";\r | |
1808 | if (at.getFilename() != null){\r | |
1809 | saa[i][1] = at.getFilename();\r | |
1810 | }\r | |
1811 | if (at.getAntCmdOptions() != null) {\r | |
1812 | saa[i][2] = at.getAntCmdOptions();\r | |
1813 | }\r | |
1814 | ++i;\r | |
1815 | }\r | |
1816 | }\r | |
1800d80f | 1817 | public void genBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1818 | OptionsDocument.Options opts = getfpdBuildOpts().getOptions();\r |
1819 | if (opts == null) {\r | |
1820 | opts = getfpdBuildOpts().addNewOptions();\r | |
1821 | }\r | |
1822 | OptionDocument.Option opt = opts.addNewOption();\r | |
1823 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1824 | }\r | |
1825 | \r | |
1800d80f | 1826 | private void setBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents, OptionDocument.Option opt){\r |
a13899c5 | 1827 | opt.setStringValue(contents);\r |
1800d80f | 1828 | \r |
1829 | opt.setBuildTargets(buildTargets);\r | |
a13899c5 | 1830 | opt.setToolChainFamily(toolChain);\r |
1831 | opt.setTagName(tagName);\r | |
1832 | opt.setToolCode(toolCmd);\r | |
1800d80f | 1833 | \r |
bf5abaff | 1834 | if (archList != null) {\r |
1835 | opt.setSupArchList(archList);\r | |
1836 | }\r | |
1837 | else {\r | |
1838 | if (opt.isSetSupArchList()) {\r | |
1839 | opt.unsetSupArchList();\r | |
1840 | }\r | |
1841 | }\r | |
a13899c5 | 1842 | }\r |
1843 | \r | |
1844 | public void removeBuildOptionsOpt(int i){\r | |
1845 | \r | |
1846 | XmlObject o = getfpdBuildOpts().getOptions();\r | |
1847 | if (o == null) {\r | |
1848 | return;\r | |
1849 | }\r | |
1850 | \r | |
1851 | XmlCursor cursor = o.newCursor();\r | |
1852 | if (cursor.toFirstChild()) {\r | |
1853 | for (int j = 0; j < i; ++j) {\r | |
1854 | cursor.toNextSibling();\r | |
1855 | }\r | |
1856 | cursor.removeXml();\r | |
af25df16 | 1857 | if (getBuildOptionsOptCount() == 0) {\r |
1858 | cursor.toParent();\r | |
1859 | cursor.removeXml();\r | |
1860 | }\r | |
a13899c5 | 1861 | }\r |
1862 | cursor.dispose();\r | |
1863 | }\r | |
1864 | \r | |
1800d80f | 1865 | public void updateBuildOptionsOpt(int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1866 | XmlObject o = getfpdBuildOpts().getOptions();\r |
1867 | if (o == null) {\r | |
1868 | return;\r | |
1869 | }\r | |
1870 | \r | |
1871 | XmlCursor cursor = o.newCursor();\r | |
1872 | if (cursor.toFirstChild()) {\r | |
1873 | for (int j = 0; j < i; ++j) {\r | |
1874 | cursor.toNextSibling();\r | |
1875 | }\r | |
1876 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
1877 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1878 | }\r | |
1879 | cursor.dispose();\r | |
1880 | }\r | |
1881 | \r | |
1882 | public int getBuildOptionsOptCount(){\r | |
1883 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1884 | return 0;\r | |
1885 | }\r | |
1886 | return getfpdBuildOpts().getOptions().getOptionList().size();\r | |
1887 | }\r | |
1888 | \r | |
1889 | public void getBuildOptionsOpts(String[][] saa) {\r | |
1890 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1891 | return ;\r | |
1892 | }\r | |
1893 | \r | |
1894 | List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();\r | |
1895 | ListIterator li = lOpt.listIterator();\r | |
1896 | int i = 0;\r | |
1897 | while(li.hasNext()) {\r | |
1898 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
6cba26e8 | 1899 | if (opt.getBuildTargets() != null) {\r |
1900 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
1901 | }\r | |
a13899c5 | 1902 | saa[i][1] = opt.getToolChainFamily();\r |
1903 | if (opt.getSupArchList() != null){\r | |
6cba26e8 | 1904 | saa[i][2] = listToString(opt.getSupArchList());\r |
1905 | \r | |
a13899c5 | 1906 | }\r |
1907 | saa[i][3] = opt.getToolCode();\r | |
1908 | saa[i][4] = opt.getTagName();\r | |
1909 | saa[i][5] = opt.getStringValue();\r | |
1910 | \r | |
1911 | ++i;\r | |
1912 | }\r | |
1913 | }\r | |
1914 | \r | |
6cba26e8 | 1915 | public void genBuildOptionsFfs(String ffsKey, String type) {\r |
1916 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
1917 | ffs.setFfsKey(ffsKey);\r | |
1918 | if (type != null) {\r | |
1919 | ffs.addNewSections().setEncapsulationType(type);\r | |
1920 | }\r | |
1921 | }\r | |
1922 | \r | |
3b405e9b | 1923 | public void updateBuildOptionsFfsSectionsType(int i, String type) {\r |
1924 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
1925 | if (type != null) {\r | |
1926 | ffs.addNewSections().setEncapsulationType(type);\r | |
1927 | }\r | |
1928 | }\r | |
1929 | \r | |
6cba26e8 | 1930 | public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r |
1931 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1932 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();\r | |
1933 | attrib.setName(name);\r | |
1934 | attrib.setValue(value);\r | |
1935 | }\r | |
1936 | \r | |
1937 | /**update jth attribute of ith ffs.\r | |
1938 | * @param i\r | |
1939 | * @param j\r | |
1940 | */\r | |
1941 | public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){\r | |
1942 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1943 | XmlCursor cursor = ffs.newCursor();\r | |
1944 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
1945 | if (cursor.toChild(qAttrib)) {\r | |
1946 | for (int k = 0; k < j; ++k) {\r | |
1947 | cursor.toNextSibling(qAttrib);\r | |
1948 | }\r | |
1949 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();\r | |
1950 | attrib.setName(name);\r | |
1951 | attrib.setValue(value);\r | |
1952 | }\r | |
1953 | cursor.dispose();\r | |
1954 | }\r | |
1955 | \r | |
1956 | public void removeBuildOptionsFfsAttribute(int i, int j){\r | |
1957 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1958 | XmlCursor cursor = ffs.newCursor();\r | |
1959 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
1960 | if (cursor.toChild(qAttrib)) {\r | |
1961 | for (int k = 0; k < j; ++k) {\r | |
1962 | cursor.toNextSibling(qAttrib);\r | |
1963 | }\r | |
1964 | cursor.removeXml();\r | |
1965 | }\r | |
1966 | cursor.dispose();\r | |
1967 | }\r | |
1968 | \r | |
1969 | public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {\r | |
1970 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1971 | if (ffs == null) {\r | |
1972 | return;\r | |
1973 | }\r | |
1974 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1975 | \r | |
1976 | if (sections == null){\r | |
1977 | sections = ffs.addNewSections();\r | |
1978 | }\r | |
1979 | sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));\r | |
1980 | }\r | |
1981 | \r | |
3b405e9b | 1982 | public void removeBuildOptionsFfsSectionsSection(int i, int j) {\r |
1983 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
1984 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
1985 | if (sections == null) {\r | |
1986 | return;\r | |
1987 | }\r | |
1988 | XmlCursor cursor = sections.newCursor();\r | |
1989 | QName qSection = new QName(xmlNs, "Section");\r | |
1990 | if (cursor.toChild(qSection)) {\r | |
1991 | for (int k = 0; k < j; ++k) {\r | |
1992 | cursor.toNextSibling(qSection);\r | |
1993 | }\r | |
1994 | cursor.removeXml();\r | |
1995 | }\r | |
1996 | cursor.dispose();\r | |
1997 | }\r | |
1998 | \r | |
1999 | public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){\r | |
2000 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2001 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2002 | if (sections == null) {\r | |
2003 | return;\r | |
2004 | }\r | |
2005 | XmlCursor cursor = sections.newCursor();\r | |
2006 | QName qSection = new QName(xmlNs, "Section");\r | |
2007 | if (cursor.toChild(qSection)) {\r | |
2008 | for (int k = 0; k < j; ++k) {\r | |
2009 | cursor.toNextSibling(qSection);\r | |
2010 | }\r | |
2011 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();\r | |
2012 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
2013 | }\r | |
2014 | cursor.dispose();\r | |
2015 | } \r | |
2016 | \r | |
6cba26e8 | 2017 | public void genBuildOptionsFfsSectionsSections(int i, String encapType) {\r |
2018 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2019 | if (ffs == null) {\r | |
2020 | return;\r | |
2021 | }\r | |
2022 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2023 | \r | |
2024 | if (sections == null){\r | |
2025 | sections = ffs.addNewSections();\r | |
2026 | }\r | |
2027 | sections.addNewSections().setEncapsulationType(encapType);\r | |
2028 | }\r | |
2029 | \r | |
3b405e9b | 2030 | public void removeBuildOptionsFfsSectionsSections(int i, int j) {\r |
2031 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2032 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2033 | if (sections == null) {\r | |
2034 | return;\r | |
2035 | }\r | |
2036 | XmlCursor cursor = sections.newCursor();\r | |
2037 | QName qSections = new QName(xmlNs, "Sections");\r | |
2038 | if (cursor.toChild(qSections)) {\r | |
2039 | for (int k = 0; k < j; ++k) {\r | |
2040 | cursor.toNextSibling(qSections);\r | |
2041 | }\r | |
2042 | cursor.removeXml();\r | |
2043 | }\r | |
2044 | cursor.dispose();\r | |
2045 | }\r | |
2046 | \r | |
2047 | public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {\r | |
2048 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2049 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2050 | if (sections == null) {\r | |
2051 | return;\r | |
2052 | }\r | |
2053 | XmlCursor cursor = sections.newCursor();\r | |
2054 | QName qSections = new QName(xmlNs, "Sections");\r | |
2055 | if (cursor.toChild(qSections)) {\r | |
2056 | for (int k = 0; k < j; ++k) {\r | |
2057 | cursor.toNextSibling(qSections);\r | |
2058 | }\r | |
2059 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2060 | sections2.setEncapsulationType(type);\r | |
2061 | }\r | |
2062 | cursor.dispose();\r | |
2063 | }\r | |
2064 | \r | |
6cba26e8 | 2065 | public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {\r |
2066 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2067 | if (ffs == null) {\r | |
2068 | return;\r | |
2069 | }\r | |
2070 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2071 | XmlCursor cursor = sections.newCursor();\r | |
2072 | QName qSections = new QName(xmlNs, "Sections");\r | |
2073 | if (cursor.toChild(qSections)){\r | |
2074 | for (int k = 0; k < j; ++k) {\r | |
2075 | cursor.toNextSibling(qSections);\r | |
2076 | }\r | |
2077 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2078 | sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));\r | |
2079 | }\r | |
2080 | cursor.dispose();\r | |
2081 | }\r | |
2082 | \r | |
3b405e9b | 2083 | public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {\r |
2084 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2085 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2086 | if (sections == null) {\r | |
2087 | return;\r | |
2088 | }\r | |
2089 | XmlCursor cursor = sections.newCursor();\r | |
2090 | QName qSections = new QName(xmlNs, "Sections");\r | |
2091 | if (cursor.toChild(qSections)) {\r | |
2092 | for (int l = 0; l < j; ++l) {\r | |
2093 | cursor.toNextSibling(qSections);\r | |
2094 | }\r | |
2095 | if (cursor.toFirstChild()) {\r | |
af25df16 | 2096 | int m = 0;\r |
2097 | for (; m < k; ++m) {\r | |
3b405e9b | 2098 | cursor.toNextSibling();\r |
2099 | }\r | |
2100 | cursor.removeXml();\r | |
af25df16 | 2101 | if (m == 0) {\r |
2102 | cursor.toParent();\r | |
2103 | cursor.removeXml();\r | |
2104 | }\r | |
3b405e9b | 2105 | }\r |
2106 | }\r | |
2107 | cursor.dispose();\r | |
2108 | }\r | |
2109 | \r | |
2110 | public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {\r | |
2111 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2112 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2113 | if (sections == null) {\r | |
2114 | return;\r | |
2115 | }\r | |
2116 | XmlCursor cursor = sections.newCursor();\r | |
2117 | QName qSections = new QName(xmlNs, "Sections");\r | |
2118 | if (cursor.toChild(qSections)) {\r | |
2119 | for (int l = 0; l < j; ++l) {\r | |
2120 | cursor.toNextSibling(qSections);\r | |
2121 | }\r | |
2122 | if (cursor.toFirstChild()) {\r | |
2123 | for (int m = 0; m < k; ++m) {\r | |
2124 | cursor.toNextSibling();\r | |
2125 | }\r | |
2126 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();\r | |
2127 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
2128 | }\r | |
2129 | }\r | |
2130 | cursor.dispose();\r | |
2131 | }\r | |
2132 | \r | |
6cba26e8 | 2133 | public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {\r |
2134 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2135 | if (ffs == null) {\r | |
2136 | return;\r | |
2137 | }\r | |
2138 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2139 | XmlCursor cursor = sections.newCursor();\r | |
2140 | QName qSections = new QName(xmlNs, "Sections");\r | |
2141 | if (cursor.toChild(qSections)){\r | |
2142 | for (int k = 0; k < j; ++k) {\r | |
2143 | cursor.toNextSibling(qSections);\r | |
2144 | }\r | |
2145 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2146 | if (sections2.getSectionList() == null){\r | |
2147 | cursor.dispose();\r | |
2148 | return;\r | |
2149 | }\r | |
2150 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();\r | |
2151 | while(li.hasNext()) {\r | |
2152 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();\r | |
3b405e9b | 2153 | if (section.isSetSectionType()) {\r |
1800d80f | 2154 | al.add(section.getSectionType().toString());\r |
2155 | }\r | |
3b405e9b | 2156 | \r |
2157 | }\r | |
6cba26e8 | 2158 | }\r |
2159 | cursor.dispose();\r | |
2160 | \r | |
2161 | }\r | |
2162 | \r | |
2163 | public int getBuildOptionsFfsCount(){\r | |
2164 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
2165 | return 0;\r | |
2166 | }\r | |
2167 | return getfpdBuildOpts().getFfsList().size();\r | |
2168 | }\r | |
2169 | \r | |
2170 | public void getBuildOptionsFfsKey(String[][] saa) {\r | |
2171 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
2172 | return;\r | |
2173 | }\r | |
2174 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();\r | |
2175 | int i = 0;\r | |
2176 | while(li.hasNext()){\r | |
2177 | BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();\r | |
2178 | saa[i][0] = ffs.getFfsKey();\r | |
2179 | ++i;\r | |
2180 | }\r | |
2181 | }\r | |
2182 | \r | |
3b405e9b | 2183 | public void updateBuildOptionsFfsKey(int i, String key) {\r |
2184 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2185 | ffs.setFfsKey(key);\r | |
2186 | }\r | |
2187 | \r | |
6cba26e8 | 2188 | /**Get ith FFS key and contents.\r |
2189 | * @param saa\r | |
2190 | */\r | |
2191 | public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {\r | |
2192 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2193 | \r | |
2194 | if (ffs != null) {\r | |
2195 | \r | |
2196 | sa[0] = ffs.getFfsKey();\r | |
2197 | if (ffs.getSections() != null) {\r | |
2198 | if(ffs.getSections().getEncapsulationType() != null){\r | |
2199 | sa[1] = ffs.getSections().getEncapsulationType();\r | |
2200 | }\r | |
2201 | if (ffs.getSections().getSectionList() != null){\r | |
2202 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();\r | |
2203 | while (li.hasNext()) {\r | |
2204 | firstLevelSection.add(li.next().getSectionType().toString());\r | |
2205 | }\r | |
2206 | }\r | |
2207 | if (ffs.getSections().getSectionsList() != null) {\r | |
2208 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();\r | |
2209 | while(li.hasNext()) {\r | |
2210 | firstLevelSections.add(li.next().getEncapsulationType());\r | |
2211 | }\r | |
2212 | }\r | |
2213 | }\r | |
2214 | if (ffs.getAttributeList() != null) {\r | |
2215 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();\r | |
2216 | while(li.hasNext()) {\r | |
2217 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();\r | |
2218 | ffsAttribMap.put(attrib.getName(), attrib.getValue());\r | |
2219 | }\r | |
2220 | \r | |
2221 | }\r | |
2222 | }\r | |
2223 | \r | |
2224 | \r | |
2225 | }\r | |
2226 | \r | |
2227 | private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {\r | |
2228 | XmlObject o = getfpdBuildOpts();\r | |
2229 | BuildOptionsDocument.BuildOptions.Ffs ffs = null;\r | |
2230 | \r | |
2231 | XmlCursor cursor = o.newCursor();\r | |
2232 | QName qFfs = new QName(xmlNs, "Ffs");\r | |
2233 | if (cursor.toChild(qFfs)) {\r | |
2234 | for (int j = 0; j < i; ++j) {\r | |
2235 | cursor.toNextSibling(qFfs);\r | |
2236 | }\r | |
2237 | ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();\r | |
2238 | }\r | |
2239 | cursor.dispose();\r | |
2240 | return ffs;\r | |
2241 | }\r | |
2242 | \r | |
2243 | public void removeBuildOptionsFfs(int i) {\r | |
2244 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2245 | if (ffs == null){\r | |
2246 | return;\r | |
2247 | }\r | |
2248 | \r | |
2249 | XmlCursor cursor = ffs.newCursor();\r | |
2250 | cursor.removeXml();\r | |
2251 | cursor.dispose();\r | |
2252 | }\r | |
2253 | \r | |
3b405e9b | 2254 | \r |
2255 | \r | |
a13899c5 | 2256 | public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){\r |
2257 | if (fpdPlatformDefs == null){\r | |
2258 | fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();\r | |
2259 | }\r | |
2260 | return fpdPlatformDefs;\r | |
2261 | }\r | |
2262 | \r | |
6a09eb19 | 2263 | public void getPlatformDefsSupportedArchs(Vector<Object> archs){\r |
2264 | if (getfpdPlatformDefs().getSupportedArchitectures() == null) {\r | |
2265 | return;\r | |
2266 | }\r | |
2267 | ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();\r | |
2268 | while(li.hasNext()) {\r | |
2269 | archs.add(li.next());\r | |
2270 | }\r | |
2271 | }\r | |
2272 | \r | |
2273 | public void setPlatformDefsSupportedArchs(Vector<Object> archs) {\r | |
bf5abaff | 2274 | if (archs != null) {\r |
2275 | getfpdPlatformDefs().setSupportedArchitectures(archs);\r | |
2276 | }\r | |
2277 | // else {\r | |
2278 | // XmlCursor cursor = getfpdPlatformDefs().newCursor();\r | |
2279 | // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {\r | |
2280 | // cursor.removeXml();\r | |
2281 | // }\r | |
2282 | // cursor.dispose();\r | |
2283 | // }\r | |
6a09eb19 | 2284 | }\r |
2285 | \r | |
2286 | public void getPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
2287 | if (getfpdPlatformDefs().getBuildTargets() == null) {\r | |
2288 | return;\r | |
2289 | }\r | |
2290 | ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();\r | |
2291 | while(li.hasNext()) {\r | |
2292 | targets.add(li.next());\r | |
2293 | }\r | |
2294 | }\r | |
2295 | \r | |
2296 | public void setPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
2297 | getfpdPlatformDefs().setBuildTargets(targets);\r | |
2298 | }\r | |
2299 | \r | |
2300 | public void genPlatformDefsSkuInfo(String id, String name) {\r | |
2301 | SkuInfoDocument.SkuInfo skuInfo = null;\r | |
2302 | if (getfpdPlatformDefs().getSkuInfo() == null) {\r | |
2303 | skuInfo = getfpdPlatformDefs().addNewSkuInfo();\r | |
2304 | }\r | |
2305 | skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2306 | if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {\r | |
2307 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
2308 | skuName.setSkuID(new BigInteger("0"));\r | |
2309 | skuName.setStringValue("DEFAULT");\r | |
2310 | }\r | |
2311 | if (id.equals("0")) {\r | |
2312 | return;\r | |
2313 | }\r | |
2314 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
2315 | skuName.setSkuID(new BigInteger(id));\r | |
2316 | skuName.setStringValue(name);\r | |
2317 | }\r | |
2318 | \r | |
2319 | public int getPlatformDefsSkuInfoCount(){\r | |
2320 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
2321 | return 0;\r | |
2322 | }\r | |
2323 | return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();\r | |
2324 | }\r | |
2325 | \r | |
2326 | public void getPlatformDefsSkuInfos(String[][] saa){\r | |
2327 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
5af6b67f | 2328 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r |
2329 | removeElement(getfpdDynPcdBuildDefs());\r | |
2330 | fpdDynPcdBuildDefs = null;\r | |
2331 | }\r | |
6a09eb19 | 2332 | return ;\r |
2333 | }\r | |
2334 | \r | |
2335 | List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();\r | |
2336 | ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();\r | |
2337 | int i = 0;\r | |
2338 | while(li.hasNext()) {\r | |
2339 | SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();\r | |
2340 | saa[i][0] = sku.getSkuID()+"";\r | |
2341 | saa[i][1] = sku.getStringValue();\r | |
2342 | ++i;\r | |
2343 | }\r | |
2344 | }\r | |
2345 | \r | |
2346 | public void removePlatformDefsSkuInfo(int i) {\r | |
2347 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2348 | if (skuInfo == null || i == 0) {\r | |
2349 | return ;\r | |
2350 | }\r | |
2351 | \r | |
2352 | XmlCursor cursor = skuInfo.newCursor();\r | |
2353 | if (cursor.toFirstChild()) {\r | |
2354 | for (int j = 0; j < i; ++j) {\r | |
2355 | cursor.toNextSibling();\r | |
2356 | }\r | |
2357 | cursor.removeXml();\r | |
2358 | }\r | |
2359 | cursor.dispose();\r | |
2360 | }\r | |
2361 | \r | |
2362 | public void updatePlatformDefsSkuInfo(int i, String id, String name) {\r | |
2363 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2364 | if (skuInfo == null || i == 0) {\r | |
2365 | return ;\r | |
2366 | }\r | |
2367 | \r | |
2368 | XmlCursor cursor = skuInfo.newCursor();\r | |
2369 | if (cursor.toFirstChild()) {\r | |
2370 | for (int j = 0; j < i; ++j) {\r | |
2371 | cursor.toNextSibling();\r | |
2372 | }\r | |
2373 | SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();\r | |
2374 | sku.setSkuID(new BigInteger(id));\r | |
2375 | sku.setStringValue(name);\r | |
2376 | }\r | |
2377 | cursor.dispose();\r | |
2378 | }\r | |
2379 | \r | |
2380 | public String getPlatformDefsInterDir(){\r | |
2381 | if (getfpdPlatformDefs().getIntermediateDirectories() == null) {\r | |
2382 | return null;\r | |
2383 | }\r | |
2384 | return getfpdPlatformDefs().getIntermediateDirectories().toString();\r | |
2385 | }\r | |
2386 | \r | |
2387 | public void setPlatformDefsInterDir(String interDir){\r | |
2388 | getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));\r | |
2389 | }\r | |
2390 | \r | |
2391 | public String getPlatformDefsOutputDir() {\r | |
2392 | return getfpdPlatformDefs().getOutputDirectory();\r | |
2393 | }\r | |
2394 | \r | |
2395 | public void setPlatformDefsOutputDir(String outputDir) {\r | |
af25df16 | 2396 | if (outputDir != null && outputDir.length() > 0) {\r |
2397 | getfpdPlatformDefs().setOutputDirectory(outputDir);\r | |
2398 | }\r | |
2399 | else{\r | |
2400 | XmlCursor cursor = getfpdPlatformDefs().newCursor();\r | |
2401 | if (cursor.toChild(new QName(xmlNs, "OutputDirectory"))) {\r | |
2402 | cursor.removeXml();\r | |
2403 | }\r | |
2404 | cursor.dispose();\r | |
2405 | }\r | |
6a09eb19 | 2406 | }\r |
2407 | \r | |
a13899c5 | 2408 | public FlashDocument.Flash getfpdFlash() {\r |
2409 | if (fpdFlash == null) {\r | |
2410 | fpdFlash = fpdRoot.addNewFlash();\r | |
2411 | }\r | |
2412 | return fpdFlash;\r | |
2413 | }\r | |
2414 | \r | |
2415 | public void genFlashDefinitionFile(String file) {\r | |
2416 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
2417 | if (fdf == null) {\r | |
2418 | fdf = getfpdFlash().addNewFlashDefinitionFile();\r | |
2419 | }\r | |
2420 | \r | |
2421 | fdf.setStringValue(file);\r | |
2422 | }\r | |
2423 | \r | |
2424 | public String getFlashDefinitionFile() {\r | |
2425 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
2426 | if (fdf == null) {\r | |
2427 | return "";\r | |
2428 | }\r | |
2429 | \r | |
2430 | return fdf.getStringValue();\r | |
2431 | }\r | |
2432 | \r | |
a13899c5 | 2433 | public void genFvImagesNameValue(String name, String value) {\r |
2434 | \r | |
2435 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
2436 | if (fi == null) {\r | |
2437 | fi = getfpdFlash().addNewFvImages();\r | |
2438 | }\r | |
2439 | \r | |
2440 | FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();\r | |
2441 | nv.setName(name);\r | |
2442 | nv.setValue(value);\r | |
2443 | }\r | |
2444 | \r | |
2445 | public void removeFvImagesNameValue(int i){\r | |
2446 | \r | |
2447 | XmlObject o = getfpdFlash().getFvImages();\r | |
2448 | if (o == null) {\r | |
2449 | return;\r | |
2450 | }\r | |
2451 | \r | |
2452 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
2453 | XmlCursor cursor = o.newCursor();\r | |
2454 | if (cursor.toChild(qNameValue)) {\r | |
2455 | for (int j = 0; j < i; ++j) {\r | |
2456 | cursor.toNextSibling(qNameValue);\r | |
2457 | }\r | |
2458 | cursor.removeXml();\r | |
2459 | }\r | |
2460 | cursor.dispose();\r | |
2461 | }\r | |
2462 | \r | |
2463 | public void updateFvImagesNameValue(int i, String name, String value){\r | |
2464 | \r | |
2465 | XmlObject o = getfpdFlash().getFvImages();\r | |
2466 | if (o == null) {\r | |
2467 | return;\r | |
2468 | }\r | |
2469 | \r | |
2470 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
2471 | XmlCursor cursor = o.newCursor();\r | |
2472 | if (cursor.toChild(qNameValue)) {\r | |
2473 | for (int j = 0; j < i; ++j) {\r | |
2474 | cursor.toNextSibling(qNameValue);\r | |
2475 | }\r | |
2476 | FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();\r | |
2477 | nv.setName(name);\r | |
2478 | nv.setValue(value);\r | |
2479 | }\r | |
2480 | cursor.dispose();\r | |
2481 | }\r | |
2482 | \r | |
2483 | public int getFvImagesNameValueCount() {\r | |
2484 | \r | |
2485 | FvImagesDocument.FvImages fi = null;\r | |
2486 | if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {\r | |
2487 | return 0;\r | |
2488 | }\r | |
2489 | return fi.getNameValueList().size();\r | |
2490 | }\r | |
2491 | \r | |
2492 | public void getFvImagesNameValues(String[][] nv) {\r | |
2493 | \r | |
2494 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
2495 | if (fi == null){\r | |
2496 | return;\r | |
2497 | }\r | |
2498 | List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();\r | |
2499 | int i = 0;\r | |
2500 | ListIterator li = l.listIterator();\r | |
2501 | while (li.hasNext()) {\r | |
2502 | FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li\r | |
2503 | .next();\r | |
2504 | nv[i][0] = e.getName();\r | |
2505 | nv[i][1] = e.getValue();\r | |
2506 | \r | |
2507 | i++;\r | |
2508 | }\r | |
2509 | }\r | |
2510 | \r | |
2511 | public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r | |
2512 | \r | |
2513 | FvImagesDocument.FvImages fis = null;\r | |
2514 | if ((fis = getfpdFlash().getFvImages()) == null) {\r | |
2515 | fis = getfpdFlash().addNewFvImages();\r | |
2516 | }\r | |
2517 | \r | |
2518 | //\r | |
2519 | //gen FvImage with FvImageNames array\r | |
2520 | //\r | |
2521 | FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();\r | |
2522 | for (int i = 0; i < names.length; ++i) {\r | |
2523 | fi.addFvImageNames(names[i]);\r | |
2524 | }\r | |
2525 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
2526 | if (options != null){\r | |
2527 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
2528 | }\r | |
2529 | }\r | |
2530 | \r | |
2531 | private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){\r | |
2532 | FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();\r | |
2533 | if (fio == null){\r | |
2534 | fio = fi.addNewFvImageOptions();\r | |
2535 | }\r | |
2536 | \r | |
2537 | Set<String> key = options.keySet();\r | |
2538 | Iterator<String> i = key.iterator();\r | |
2539 | while (i.hasNext()) {\r | |
44053733 | 2540 | \r |
a13899c5 | 2541 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();\r |
2542 | String k = (String)i.next();\r | |
ae0d4fd2 | 2543 | \r |
a13899c5 | 2544 | nv.setName(k);\r |
2545 | nv.setValue((String)options.get(k));\r | |
2546 | \r | |
2547 | }\r | |
2548 | \r | |
2549 | }\r | |
2550 | \r | |
44053733 | 2551 | \r |
a13899c5 | 2552 | public void removeFvImagesFvImage(int i) {\r |
2553 | \r | |
2554 | XmlObject o = getfpdFlash().getFvImages();\r | |
2555 | if (o == null) {\r | |
2556 | return;\r | |
2557 | }\r | |
2558 | \r | |
2559 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2560 | XmlCursor cursor = o.newCursor();\r | |
2561 | if (cursor.toChild(qFvImage)) {\r | |
2562 | for (int j = 0; j < i; ++j) {\r | |
2563 | cursor.toNextSibling(qFvImage);\r | |
2564 | }\r | |
2565 | cursor.removeXml();\r | |
2566 | }\r | |
2567 | cursor.dispose();\r | |
2568 | }\r | |
2569 | \r | |
2570 | public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r | |
2571 | \r | |
2572 | XmlObject o = getfpdFlash().getFvImages();\r | |
2573 | if (o == null) {\r | |
2574 | return;\r | |
2575 | }\r | |
2576 | XmlCursor cursor = o.newCursor();\r | |
2577 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2578 | if (cursor.toChild(qFvImage)) {\r | |
2579 | for (int j = 0; j < i; ++j) {\r | |
2580 | cursor.toNextSibling(qFvImage);\r | |
2581 | }\r | |
2582 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2583 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
2584 | \r | |
2585 | //\r | |
2586 | // remove old FvImageNames before adding new ones\r | |
2587 | //\r | |
2588 | QName qFvImageNames = new QName(xmlNs, "FvImageNames"); \r | |
2589 | cursor.toChild(qFvImageNames);\r | |
2590 | cursor.removeXml();\r | |
2591 | while (cursor.toNextSibling(qFvImageNames)) {\r | |
2592 | cursor.removeXml();\r | |
2593 | }\r | |
2594 | \r | |
2595 | for (int k = 0; k < names.length; ++k) {\r | |
2596 | fi.addFvImageNames(names[k]);\r | |
2597 | }\r | |
2598 | //\r | |
2599 | // remove old FvImageOptions before adding new options\r | |
2600 | //\r | |
2601 | QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");\r | |
2602 | cursor.toNextSibling(qFvImageOptions);\r | |
2603 | cursor.removeXml();\r | |
2604 | \r | |
2605 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
2606 | }\r | |
2607 | cursor.dispose();\r | |
2608 | }\r | |
2609 | \r | |
2610 | public int getFvImagesFvImageCount() {\r | |
2611 | \r | |
2612 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r | |
2613 | return 0;\r | |
2614 | }\r | |
2615 | return getfpdFlash().getFvImages().getFvImageList().size();\r | |
2616 | }\r | |
2617 | \r | |
ae0d4fd2 | 2618 | /**Only Get Fv image setting - name and type.\r |
2619 | * @param saa\r | |
2620 | */\r | |
2621 | public void getFvImagesFvImages(String[][] saa) {\r | |
a13899c5 | 2622 | \r |
2623 | if (getfpdFlash().getFvImages() == null) {\r | |
2624 | return;\r | |
2625 | }\r | |
2626 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r | |
2627 | if (l == null) {\r | |
2628 | return;\r | |
2629 | }\r | |
2630 | ListIterator li = l.listIterator();\r | |
2631 | int i = 0;\r | |
2632 | while(li.hasNext()) {\r | |
2633 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
2634 | //\r | |
2635 | // get FvImageNames array, space separated\r | |
2636 | //\r | |
2637 | List<String> lfn = fi.getFvImageNamesList();\r | |
2638 | ListIterator lfni = lfn.listIterator();\r | |
2639 | saa[i][0] = " ";\r | |
2640 | while (lfni.hasNext()) {\r | |
2641 | saa[i][0] += (String)lfni.next();\r | |
2642 | saa[i][0] += " ";\r | |
2643 | }\r | |
2644 | saa[i][0] = saa[i][0].trim();\r | |
2645 | \r | |
2646 | saa[i][1] = fi.getType()+"";\r | |
2647 | \r | |
ae0d4fd2 | 2648 | ++i;\r |
2649 | }\r | |
2650 | }\r | |
2651 | \r | |
2652 | /**Get FvImage Options for FvImage i\r | |
2653 | * @param i the ith FvImage\r | |
2654 | */\r | |
2655 | public void getFvImagesFvImageOptions(int i, Map<String, String> m) {\r | |
2656 | XmlObject o = getfpdFlash().getFvImages();\r | |
2657 | if (o == null) {\r | |
2658 | return;\r | |
2659 | }\r | |
2660 | XmlCursor cursor = o.newCursor();\r | |
2661 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2662 | if (cursor.toChild(qFvImage)) {\r | |
2663 | for (int j = 0; j < i; ++j) {\r | |
2664 | cursor.toNextSibling(qFvImage);\r | |
a13899c5 | 2665 | }\r |
ae0d4fd2 | 2666 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r |
2667 | if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){\r | |
2668 | return;\r | |
a13899c5 | 2669 | }\r |
ae0d4fd2 | 2670 | ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r |
2671 | while(li.hasNext()){\r | |
2672 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r | |
a13899c5 | 2673 | m.put(nv.getName(), nv.getValue());\r |
2674 | }\r | |
a13899c5 | 2675 | }\r |
2676 | }\r | |
2677 | \r | |
2678 | /**\r | |
2679 | Get platform header element\r | |
2680 | @return PlatformHeaderDocument.PlatformHeader\r | |
2681 | **/\r | |
2682 | public PlatformHeaderDocument.PlatformHeader getFpdHdr() {\r | |
2683 | if (fpdHdr == null) {\r | |
2684 | fpdHdr = fpdRoot.addNewPlatformHeader();\r | |
2685 | }\r | |
1faac7b6 | 2686 | \r |
a13899c5 | 2687 | return fpdHdr;\r |
2688 | }\r | |
2689 | \r | |
a13899c5 | 2690 | public String getFpdHdrPlatformName() {\r |
2691 | return getFpdHdr().getPlatformName();\r | |
2692 | }\r | |
2693 | \r | |
2694 | public String getFpdHdrGuidValue() {\r | |
2695 | return getFpdHdr().getGuidValue();\r | |
2696 | }\r | |
2697 | \r | |
2698 | public String getFpdHdrVer() {\r | |
2699 | return getFpdHdr().getVersion();\r | |
2700 | }\r | |
2701 | \r | |
2702 | public String getFpdHdrAbs() {\r | |
2703 | return getFpdHdr().getAbstract();\r | |
2704 | }\r | |
2705 | \r | |
2706 | public String getFpdHdrDescription() {\r | |
2707 | return getFpdHdr().getDescription();\r | |
2708 | }\r | |
2709 | \r | |
2710 | public String getFpdHdrCopyright() {\r | |
2711 | return getFpdHdr().getCopyright();\r | |
2712 | }\r | |
2713 | \r | |
2714 | public String getFpdHdrLicense() {\r | |
2715 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2716 | if (l == null) {\r | |
2717 | return null;\r | |
2718 | }\r | |
2719 | return l.getStringValue();\r | |
2720 | }\r | |
2721 | \r | |
2722 | public String getFpdHdrUrl() {\r | |
2723 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2724 | if (l == null) {\r | |
2725 | return null;\r | |
2726 | }\r | |
2727 | return l.getURL();\r | |
2728 | }\r | |
2729 | \r | |
2730 | public String getFpdHdrSpec() {\r | |
2731 | \r | |
c06e8657 | 2732 | return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
a13899c5 | 2733 | // return getFpdHdr().getSpecification();\r |
2734 | }\r | |
2735 | \r | |
2736 | public void setFpdHdrPlatformName(String name){\r | |
2737 | getFpdHdr().setPlatformName(name);\r | |
2738 | }\r | |
2739 | \r | |
2740 | public void setFpdHdrGuidValue(String guid){\r | |
2741 | getFpdHdr().setGuidValue(guid);\r | |
2742 | }\r | |
2743 | \r | |
2744 | public void setFpdHdrVer(String v){\r | |
2745 | getFpdHdr().setVersion(v);\r | |
2746 | }\r | |
2747 | \r | |
2748 | public void setFpdHdrAbs(String abs) {\r | |
2749 | getFpdHdr().setAbstract(abs);\r | |
2750 | }\r | |
2751 | \r | |
2752 | public void setFpdHdrDescription(String desc){\r | |
2753 | getFpdHdr().setDescription(desc);\r | |
2754 | }\r | |
2755 | \r | |
2756 | public void setFpdHdrCopyright(String cr) {\r | |
2757 | getFpdHdr().setCopyright(cr);\r | |
2758 | }\r | |
2759 | \r | |
2760 | public void setFpdHdrLicense(String license){\r | |
2761 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2762 | if (l == null) {\r | |
2763 | getFpdHdr().addNewLicense().setStringValue(license);\r | |
2764 | }\r | |
2765 | else {\r | |
2766 | l.setStringValue(license);\r | |
2767 | }\r | |
2768 | }\r | |
2769 | \r | |
2770 | public void setFpdHdrUrl(String url){\r | |
2771 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2772 | \r | |
2773 | l.setURL(url);\r | |
2774 | \r | |
2775 | }\r | |
2776 | \r | |
2777 | public void setFpdHdrSpec(String s){\r | |
c06e8657 | 2778 | s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
a13899c5 | 2779 | getFpdHdr().setSpecification(s);\r |
2780 | }\r | |
2781 | /**\r | |
2782 | Save the processed xml contents to file\r | |
2783 | \r | |
2784 | @param fpdFile The file to save xml contents\r | |
2785 | @throws IOException Exceptions during file operation\r | |
2786 | **/\r | |
2787 | public void saveAs(File fpdFile) throws IOException {\r | |
2788 | \r | |
2789 | XmlOptions options = new XmlOptions();\r | |
2790 | \r | |
2791 | options.setCharacterEncoding("UTF-8");\r | |
2792 | options.setSavePrettyPrint();\r | |
2793 | options.setSavePrettyPrintIndent(2);\r | |
2794 | try {\r | |
2795 | fpdd.save(fpdFile, options);\r | |
2796 | } catch (IOException e) {\r | |
2797 | e.printStackTrace();\r | |
2798 | }\r | |
2799 | \r | |
2800 | }\r | |
2801 | \r | |
1800d80f | 2802 | private String listToString(List l) {\r |
a13899c5 | 2803 | if (l == null) {\r |
2804 | return null;\r | |
2805 | }\r | |
2806 | String s = " ";\r | |
2807 | ListIterator li = l.listIterator();\r | |
2808 | while(li.hasNext()) {\r | |
2809 | s += li.next();\r | |
2810 | s += " ";\r | |
2811 | }\r | |
2812 | return s.trim();\r | |
2813 | }\r | |
e232295e | 2814 | \r |
2815 | private void removeElement(XmlObject o) {\r | |
2816 | XmlCursor cursor = o.newCursor();\r | |
2817 | cursor.removeXml();\r | |
2818 | cursor.dispose();\r | |
2819 | }\r | |
a13899c5 | 2820 | }\r |
82961247 | 2821 | \r |
2822 | class PcdItemTypeConflictException extends Exception {\r | |
2823 | \r | |
2824 | /**\r | |
2825 | * \r | |
2826 | */\r | |
2827 | private static final long serialVersionUID = 1L;\r | |
2828 | private String details = null;\r | |
2829 | \r | |
34c614e1 | 2830 | PcdItemTypeConflictException(String pcdName, String info){\r |
1bf9fa5a | 2831 | ModuleIdentification mi = WorkspaceProfile.getModuleId(info);\r |
3658f95e | 2832 | details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();\r |
82961247 | 2833 | }\r |
2834 | \r | |
2835 | public String getMessage() {\r | |
2836 | return details;\r | |
2837 | }\r | |
2838 | }\r | |
2839 | \r | |
2840 | class PcdDeclNotFound extends Exception {\r | |
2841 | \r | |
2842 | /**\r | |
2843 | * \r | |
2844 | */\r | |
2845 | private static final long serialVersionUID = 1L;\r | |
2846 | private String details = null;\r | |
2847 | \r | |
2848 | PcdDeclNotFound(String info) {\r | |
4da2e625 | 2849 | details = "PcdDeclNotFound: " + info;\r |
82961247 | 2850 | }\r |
2851 | \r | |
2852 | public String getMessage() {\r | |
2853 | return details;\r | |
2854 | }\r | |
2855 | }\r | |
2856 | \r | |
2857 | class PcdValueMalFormed extends Exception {\r | |
2858 | \r | |
2859 | /**\r | |
2860 | * \r | |
2861 | */\r | |
2862 | private static final long serialVersionUID = 1L;\r | |
2863 | private String details = null;\r | |
2864 | \r | |
2865 | PcdValueMalFormed(String info) {\r | |
4da2e625 | 2866 | details = "PcdValueMalFormed: " + info;\r |
82961247 | 2867 | }\r |
2868 | \r | |
2869 | public String getMessage() {\r | |
2870 | return details;\r | |
2871 | }\r | |
2872 | }\r |