]>
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 | |
a094728f | 634 | do {\r |
635 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData pcdData = (PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData) cursor\r | |
636 | .getObject();\r | |
82dcbb45 | 637 | if (msaPcd.getCName().equals(pcdData.getCName())\r |
638 | && msaPcd.getTokenSpaceGuidCName().equals(pcdData.getTokenSpaceGuidCName())) {\r | |
a094728f | 639 | \r |
82dcbb45 | 640 | maintainDynPcdMap(pcdData.getCName() + " " + pcdData.getTokenSpaceGuidCName(),\r |
641 | moduleKey);\r | |
642 | cursor.removeXml();\r | |
643 | break;\r | |
644 | }\r | |
a094728f | 645 | } while (cursor.toNextSibling());\r |
908b1c05 | 646 | }\r |
82dcbb45 | 647 | cursor.dispose();\r |
908b1c05 | 648 | }\r |
908b1c05 | 649 | }\r |
650 | \r | |
651 | }\r | |
652 | catch (Exception e){\r | |
653 | e.printStackTrace();\r | |
654 | \r | |
655 | }\r | |
656 | }\r | |
a13899c5 | 657 | //\r |
bf5abaff | 658 | // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"\r |
a13899c5 | 659 | //\r |
660 | public int getLibraryInstancesCount(String key) {\r | |
661 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
662 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
663 | return 0;\r | |
664 | }\r | |
665 | return msa.getLibraries().getInstanceList().size();\r | |
666 | }\r | |
667 | \r | |
668 | public void getLibraryInstances(String key, String[][] saa){\r | |
669 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r | |
670 | if (msa == null || msa.getLibraries() == null || msa.getLibraries().getInstanceList() == null){\r | |
671 | return ;\r | |
672 | }\r | |
673 | \r | |
674 | ListIterator<LibrariesDocument.Libraries.Instance> li = msa.getLibraries().getInstanceList().listIterator();\r | |
675 | for (int i = 0; i < saa.length; ++i) {\r | |
676 | LibrariesDocument.Libraries.Instance instance = li.next();\r | |
677 | saa[i][1] = instance.getModuleGuid();\r | |
678 | saa[i][2] = instance.getModuleVersion();\r | |
679 | saa[i][3] = instance.getPackageGuid();\r | |
680 | saa[i][4] = instance.getPackageVersion();\r | |
681 | }\r | |
682 | }\r | |
683 | \r | |
908b1c05 | 684 | public void removeLibraryInstance(String key, int i) {\r |
a13899c5 | 685 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
686 | if (msa == null || msa.getLibraries() == null){\r | |
687 | return ;\r | |
688 | }\r | |
689 | \r | |
690 | XmlCursor cursor = msa.getLibraries().newCursor();\r | |
908b1c05 | 691 | if (cursor.toFirstChild()) {\r |
692 | for (int j = 0; j < i; ++j) {\r | |
693 | cursor.toNextSibling();\r | |
694 | }\r | |
82dcbb45 | 695 | cursor.push();\r |
696 | cursor.toPrevToken();\r | |
697 | if (cursor.isComment()) {\r | |
698 | cursor.removeXml();\r | |
699 | }\r | |
700 | cursor.pop();\r | |
908b1c05 | 701 | cursor.removeXml();\r |
82dcbb45 | 702 | if (getLibraryInstancesCount(key) == 0) {\r |
703 | cursor.toParent();\r | |
704 | cursor.removeXml();\r | |
705 | }\r | |
908b1c05 | 706 | }\r |
707 | \r | |
a13899c5 | 708 | cursor.dispose();\r |
709 | }\r | |
710 | \r | |
82dcbb45 | 711 | public void genLibraryInstance(ModuleIdentification libMi, String key) {\r |
a13899c5 | 712 | ModuleSADocument.ModuleSA msa = getModuleSA(key);\r |
713 | if (msa == null){\r | |
714 | msa = getfpdFrameworkModules().addNewModuleSA();\r | |
715 | }\r | |
716 | LibrariesDocument.Libraries libs = msa.getLibraries();\r | |
717 | if(libs == null){\r | |
718 | libs = msa.addNewLibraries();\r | |
719 | }\r | |
720 | \r | |
82dcbb45 | 721 | String mn = libMi.getName();\r |
722 | String mg = libMi.getGuid();\r | |
723 | String mv = libMi.getVersion();\r | |
3658f95e | 724 | String pn = libMi.getPackageId().getName();\r |
725 | String pg = libMi.getPackageId().getGuid();\r | |
726 | String pv = libMi.getPackageId().getVersion();\r | |
a13899c5 | 727 | LibrariesDocument.Libraries.Instance instance = libs.addNewInstance();\r |
82dcbb45 | 728 | XmlCursor cursor = instance.newCursor();\r |
729 | try{\r | |
730 | String comment = "Pkg: " + pn + " Mod: " + mn \r | |
3658f95e | 731 | + " Path: " + libMi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r |
82dcbb45 | 732 | cursor.insertComment(comment);\r |
733 | }\r | |
734 | catch (Exception e){\r | |
735 | e.printStackTrace();\r | |
736 | }\r | |
737 | finally {\r | |
738 | cursor.dispose();\r | |
739 | }\r | |
740 | \r | |
a13899c5 | 741 | instance.setModuleGuid(mg);\r |
742 | instance.setModuleVersion(mv);\r | |
743 | instance.setPackageGuid(pg);\r | |
744 | instance.setPackageVersion(pv);\r | |
745 | \r | |
746 | }\r | |
1800d80f | 747 | \r |
748 | public String getFvBinding(String moduleKey){\r | |
eb8ea829 | 749 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r |
750 | return getFvBinding (moduleSa);\r | |
751 | }\r | |
752 | \r | |
753 | public String getFvBinding (ModuleSADocument.ModuleSA moduleSa) {\r | |
754 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r | |
1800d80f | 755 | return null;\r |
756 | }\r | |
eb8ea829 | 757 | return moduleSa.getModuleSaBuildOptions().getFvBinding();\r |
1800d80f | 758 | }\r |
759 | \r | |
2b70a636 | 760 | public void setFvBinding(ModuleSADocument.ModuleSA moduleSa, String fvBinding) {\r |
761 | if (moduleSa == null ) {\r | |
1800d80f | 762 | return;\r |
763 | }\r | |
61919f8c | 764 | if (fvBinding == null || fvBinding.length() == 0) {\r |
2b70a636 | 765 | if(moduleSa.getModuleSaBuildOptions() != null){\r |
766 | moduleSa.getModuleSaBuildOptions().unsetFvBinding();\r | |
61919f8c | 767 | }\r |
768 | }\r | |
769 | else {\r | |
2b70a636 | 770 | if(moduleSa.getModuleSaBuildOptions() == null){\r |
771 | moduleSa.addNewModuleSaBuildOptions().setFvBinding(fvBinding);\r | |
61919f8c | 772 | return;\r |
773 | }\r | |
2b70a636 | 774 | moduleSa.getModuleSaBuildOptions().setFvBinding(fvBinding);\r |
775 | }\r | |
776 | }\r | |
777 | \r | |
778 | public void setFvBinding(String moduleKey, String fvBinding){\r | |
779 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r | |
780 | setFvBinding (moduleSa, fvBinding);\r | |
781 | }\r | |
782 | \r | |
eb8ea829 | 783 | private int fvBindingForModuleSA (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r |
784 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
785 | return -1;\r | |
786 | }\r | |
787 | \r | |
788 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
789 | String[] fvNamesArray = fvNameList.split(" ");\r | |
790 | int occursAt = -1;\r | |
791 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
792 | if (fvNamesArray[i].equals(fvName)) {\r | |
793 | occursAt = i;\r | |
794 | break;\r | |
795 | }\r | |
796 | }\r | |
797 | return occursAt;\r | |
798 | }\r | |
799 | \r | |
2b70a636 | 800 | public void removeFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r |
801 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
802 | return;\r | |
803 | }\r | |
804 | \r | |
805 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
806 | String[] fvNamesArray = fvNameList.split(" ");\r | |
807 | int occursAt = -1;\r | |
808 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
809 | if (fvNamesArray[i].equals(fvName)) {\r | |
810 | occursAt = i;\r | |
811 | break;\r | |
812 | }\r | |
813 | }\r | |
814 | // jump over where the input fvName occurs in the original Fv list.\r | |
815 | if (occursAt != -1) {\r | |
816 | String newFvNameList = " ";\r | |
817 | for (int i = 0; i < fvNamesArray.length; ++i) {\r | |
818 | if (i == occursAt) {\r | |
819 | continue;\r | |
820 | }\r | |
821 | newFvNameList += fvNamesArray[i];\r | |
822 | }\r | |
823 | setFvBinding (moduleSa, newFvNameList.trim());\r | |
824 | }\r | |
825 | \r | |
826 | }\r | |
827 | \r | |
828 | /**\r | |
829 | * @param fvName The FV name that to be removed from FvBinding List.\r | |
830 | */\r | |
831 | public void removeFvBindingAll (String fvName) {\r | |
832 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r | |
833 | removeElement(getfpdFrameworkModules());\r | |
834 | fpdFrameworkModules = null;\r | |
835 | return;\r | |
836 | }\r | |
837 | \r | |
838 | Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r | |
839 | while (li.hasNext()) {\r | |
840 | ModuleSADocument.ModuleSA moduleSa = li.next();\r | |
841 | removeFvBinding (moduleSa, fvName); \r | |
842 | }\r | |
843 | }\r | |
844 | \r | |
eb8ea829 | 845 | public void appendFvBindingAll (String fvName) {\r |
846 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r | |
847 | removeElement(getfpdFrameworkModules());\r | |
848 | fpdFrameworkModules = null;\r | |
849 | return;\r | |
850 | }\r | |
851 | \r | |
852 | Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r | |
853 | while (li.hasNext()) {\r | |
854 | ModuleSADocument.ModuleSA moduleSa = li.next();\r | |
855 | appendFvBinding (moduleSa, fvName); \r | |
856 | }\r | |
857 | }\r | |
858 | \r | |
859 | public void appendFvBindingFor (String oldFvName, String newFvName) {\r | |
860 | if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0){\r | |
861 | removeElement(getfpdFrameworkModules());\r | |
862 | fpdFrameworkModules = null;\r | |
863 | return;\r | |
864 | }\r | |
865 | \r | |
866 | Iterator<ModuleSADocument.ModuleSA> li = getfpdFrameworkModules().getModuleSAList().iterator();\r | |
867 | while (li.hasNext()) {\r | |
868 | ModuleSADocument.ModuleSA moduleSa = li.next();\r | |
869 | String fvBinding = getFvBinding (moduleSa);\r | |
870 | if (fvBinding != null && fvBindingForModuleSA (moduleSa, oldFvName) >= 0) {\r | |
871 | appendFvBinding (moduleSa, newFvName); \r | |
872 | }\r | |
873 | }\r | |
874 | }\r | |
875 | \r | |
2b70a636 | 876 | public void appendFvBinding (String moduleKey, String fvName) {\r |
877 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r | |
878 | appendFvBinding (moduleSa, fvName);\r | |
879 | }\r | |
880 | \r | |
881 | public void appendFvBinding (ModuleSADocument.ModuleSA moduleSa, String fvName) {\r | |
882 | if (moduleSa == null) {\r | |
883 | return;\r | |
884 | }\r | |
885 | \r | |
886 | if (moduleSa.getModuleSaBuildOptions() == null || moduleSa.getModuleSaBuildOptions().getFvBinding() == null) {\r | |
887 | setFvBinding(moduleSa, fvName);\r | |
888 | return;\r | |
889 | }\r | |
890 | \r | |
891 | String fvNameList = moduleSa.getModuleSaBuildOptions().getFvBinding();\r | |
892 | String newFvNameList = fvNameList + " " + fvName;\r | |
893 | setFvBinding (moduleSa, newFvNameList.trim());\r | |
894 | }\r | |
895 | \r | |
896 | public void updateFvBindingInModuleSA (ModuleIdentification mi, String fvName) {\r | |
897 | Vector<Object> vSupArchs = new Vector<Object>();\r | |
898 | getPlatformDefsSupportedArchs(vSupArchs);\r | |
899 | String moduleInfo = mi.getGuid() + " " + mi.getVersion() + " " + mi.getPackageId().getGuid() + " " + mi.getPackageId().getVersion();\r | |
900 | for (int i = 0; i < vSupArchs.size(); ++i) {\r | |
901 | String moduleKey = moduleInfo + " " + vSupArchs.get(i);\r | |
902 | appendFvBinding (moduleKey, fvName);\r | |
1800d80f | 903 | }\r |
1800d80f | 904 | }\r |
905 | \r | |
906 | public String getFfsFileNameGuid(String moduleKey){\r | |
2b70a636 | 907 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(moduleKey);\r |
908 | if (moduleSa == null || moduleSa.getModuleSaBuildOptions() == null) {\r | |
1800d80f | 909 | return null;\r |
910 | }\r | |
2b70a636 | 911 | return moduleSa.getModuleSaBuildOptions().getFfsFileNameGuid();\r |
1800d80f | 912 | }\r |
913 | \r | |
914 | public void setFfsFileNameGuid(String moduleKey, String fileGuid){\r | |
915 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
916 | if (msa == null ) {\r | |
917 | return;\r | |
918 | }\r | |
919 | if(msa.getModuleSaBuildOptions() == null){\r | |
8f55ea73 | 920 | msa.addNewModuleSaBuildOptions();\r |
921 | \r | |
1800d80f | 922 | }\r |
8f55ea73 | 923 | ModuleSaBuildOptionsDocument.ModuleSaBuildOptions msaBuildOpts= msa.getModuleSaBuildOptions();\r |
924 | if (fileGuid != null) {\r | |
925 | msaBuildOpts.setFfsFileNameGuid(fileGuid);\r | |
926 | }\r | |
927 | else{\r | |
928 | XmlCursor cursor = msaBuildOpts.newCursor();\r | |
929 | if (cursor.toChild(xmlNs, "FfsFileNameGuid")) {\r | |
930 | cursor.removeXml();\r | |
931 | }\r | |
932 | cursor.dispose();\r | |
933 | }\r | |
934 | \r | |
1800d80f | 935 | }\r |
936 | \r | |
937 | public String getFfsFormatKey(String moduleKey){\r | |
938 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
939 | if (msa == null || msa.getModuleSaBuildOptions() == null) {\r | |
940 | return null;\r | |
941 | }\r | |
942 | return msa.getModuleSaBuildOptions().getFfsFormatKey();\r | |
943 | }\r | |
944 | \r | |
945 | public void setFfsFormatKey(String moduleKey, String ffsKey){\r | |
946 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
947 | if (msa == null ) {\r | |
948 | return;\r | |
949 | }\r | |
950 | if(msa.getModuleSaBuildOptions() == null){\r | |
951 | msa.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r | |
952 | return;\r | |
953 | }\r | |
bf5abaff | 954 | msa.getModuleSaBuildOptions().setFfsFormatKey(ffsKey);\r |
1800d80f | 955 | }\r |
956 | \r | |
e7cc0547 | 957 | public void setModuleSAForceDebug(int i, boolean dbgEnable) {\r |
958 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r | |
959 | moduleSa.setForceDebug(dbgEnable);\r | |
960 | }\r | |
961 | \r | |
962 | public boolean getModuleSAForceDebug (int i) {\r | |
963 | ModuleSADocument.ModuleSA moduleSa = getModuleSA(i);\r | |
964 | if (moduleSa.getForceDebug() == true) {\r | |
965 | return true;\r | |
966 | }\r | |
967 | return false;\r | |
968 | }\r | |
969 | \r | |
1800d80f | 970 | public void getModuleSAOptions(String moduleKey, String[][] saa) {\r |
971 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
e232295e | 972 | if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r |
1800d80f | 973 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r |
974 | return ;\r | |
975 | }\r | |
976 | \r | |
977 | List<OptionDocument.Option> lOpt = msa.getModuleSaBuildOptions().getOptions().getOptionList();\r | |
978 | ListIterator li = lOpt.listIterator();\r | |
979 | int i = 0;\r | |
980 | while(li.hasNext()) {\r | |
981 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
982 | if (opt.getBuildTargets() != null) {\r | |
983 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
984 | }\r | |
985 | saa[i][1] = opt.getToolChainFamily();\r | |
bf5abaff | 986 | saa[i][2] = opt.getTagName();\r |
987 | saa[i][3] = opt.getToolCode();\r | |
988 | \r | |
1800d80f | 989 | if (opt.getSupArchList() != null){\r |
bf5abaff | 990 | saa[i][4] = listToString(opt.getSupArchList());\r |
1800d80f | 991 | \r |
992 | }\r | |
bf5abaff | 993 | \r |
1800d80f | 994 | saa[i][5] = opt.getStringValue();\r |
995 | \r | |
996 | ++i;\r | |
997 | }\r | |
998 | }\r | |
999 | \r | |
1000 | public int getModuleSAOptionsCount(String moduleKey){\r | |
1001 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
e232295e | 1002 | if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r |
1800d80f | 1003 | || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r |
1004 | return 0;\r | |
1005 | }\r | |
1006 | return msa.getModuleSaBuildOptions().getOptions().getOptionList().size();\r | |
1007 | }\r | |
1008 | \r | |
1009 | public void genModuleSAOptionsOpt(String moduleKey, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
1010 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
1011 | if (msa.getModuleSaBuildOptions() == null) {\r | |
1012 | msa.addNewModuleSaBuildOptions();\r | |
1013 | }\r | |
1014 | if (msa.getModuleSaBuildOptions().getOptions() == null){\r | |
1015 | msa.getModuleSaBuildOptions().addNewOptions();\r | |
1016 | }\r | |
1017 | OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption();\r | |
1018 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1019 | }\r | |
1020 | \r | |
1021 | public void removeModuleSAOptionsOpt(String moduleKey, int i) {\r | |
1022 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
1023 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
1024 | return ;\r | |
1025 | }\r | |
1026 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
1027 | XmlCursor cursor = opts.newCursor();\r | |
1028 | if (cursor.toFirstChild()) {\r | |
1029 | for (int j = 0; j < i; ++j){\r | |
1030 | cursor.toNextSibling();\r | |
1031 | }\r | |
1032 | cursor.removeXml();\r | |
1033 | }\r | |
1034 | cursor.dispose();\r | |
1035 | }\r | |
1036 | \r | |
1037 | public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r | |
1038 | ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r | |
1039 | if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r | |
1040 | return ;\r | |
1041 | }\r | |
1042 | OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r | |
1043 | XmlCursor cursor = opts.newCursor();\r | |
1044 | if (cursor.toFirstChild()) {\r | |
1045 | for (int j = 0; j < i; ++j){\r | |
1046 | cursor.toNextSibling();\r | |
1047 | }\r | |
1048 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
1049 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1050 | }\r | |
1051 | cursor.dispose();\r | |
1052 | }\r | |
1053 | \r | |
a13899c5 | 1054 | /**add pcd information of module mi to a ModuleSA. \r |
1055 | * @param mi\r | |
1056 | * @param moduleSa if null, generate a new ModuleSA.\r | |
1057 | */\r | |
bf5abaff | 1058 | public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {\r |
a13899c5 | 1059 | //ToDo add Arch filter\r |
1060 | \r | |
1061 | try {\r | |
af25df16 | 1062 | if (moduleSa == null) {\r |
bf5abaff | 1063 | moduleSa = genModuleSA(mi, arch);\r |
af25df16 | 1064 | }\r |
1065 | \r | |
1bf9fa5a | 1066 | ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r |
a13899c5 | 1067 | if (msa.getPcdCoded() == null) {\r |
1068 | return;\r | |
1069 | }\r | |
af25df16 | 1070 | \r |
a13899c5 | 1071 | Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r |
1072 | m.put("ModuleSurfaceArea", msa);\r | |
1073 | SurfaceAreaQuery.setDoc(m);\r | |
daa4663b | 1074 | PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r |
a13899c5 | 1075 | //\r |
1076 | // Implementing InitializePlatformPcdBuildDefinitions\r | |
1077 | //\r | |
1078 | List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r | |
1079 | ListIterator li = l.listIterator();\r | |
1080 | while(li.hasNext()) {\r | |
1081 | PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r | |
1082 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r | |
1083 | if (spdPcd == null) {\r | |
1084 | //\r | |
1085 | // ToDo Error \r | |
1086 | //\r | |
34c614e1 | 1087 | throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());\r |
a13899c5 | 1088 | }\r |
1089 | //\r | |
1090 | // AddItem to ModuleSA PcdBuildDefinitions\r | |
1091 | //\r | |
1092 | String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r | |
908b1c05 | 1093 | \r |
a13899c5 | 1094 | genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r |
1095 | }\r | |
1096 | \r | |
1097 | }\r | |
1098 | catch (Exception e){\r | |
34c614e1 | 1099 | \r |
82961247 | 1100 | throw e; \r |
a13899c5 | 1101 | }\r |
1102 | \r | |
1103 | }\r | |
1104 | \r | |
1105 | private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r | |
1106 | \r | |
a13899c5 | 1107 | PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r |
1108 | for (int i = 0; i < depPkgs.length; ++i) {\r | |
3658f95e | 1109 | \r |
1110 | XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]);\r | |
a13899c5 | 1111 | if (xo == null) {\r |
1112 | continue;\r | |
1113 | }\r | |
1114 | for (int j = 0; j < xo.length; ++j) {\r | |
1115 | spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];\r | |
1116 | if (msaPcd.getTokenSpaceGuidCName() == null) {\r | |
1117 | if (spdPcd.getCName().equals(msaPcd.getCName())) {\r | |
1118 | return spdPcd;\r | |
1119 | }\r | |
1120 | }\r | |
1121 | else{\r | |
1122 | if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {\r | |
1123 | return spdPcd;\r | |
1124 | }\r | |
1125 | }\r | |
1126 | \r | |
1127 | }\r | |
1128 | \r | |
1129 | }\r | |
1130 | return null;\r | |
1131 | }\r | |
1132 | \r | |
bf5abaff | 1133 | private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {\r |
1bf9fa5a | 1134 | PackageIdentification pi = WorkspaceProfile.getPackageForModule(mi);\r |
a13899c5 | 1135 | ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r |
82dcbb45 | 1136 | XmlCursor cursor = msa.newCursor();\r |
1137 | try{\r | |
3658f95e | 1138 | String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r |
1139 | + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r | |
82dcbb45 | 1140 | cursor.insertComment(comment);\r |
1141 | }\r | |
1142 | catch(Exception e){\r | |
1143 | e.printStackTrace();\r | |
1144 | }\r | |
1145 | finally { \r | |
1146 | cursor.dispose();\r | |
1147 | }\r | |
a13899c5 | 1148 | msa.setModuleGuid(mi.getGuid());\r |
1149 | msa.setModuleVersion(mi.getVersion());\r | |
1150 | msa.setPackageGuid(pi.getGuid());\r | |
1151 | msa.setPackageVersion(pi.getVersion());\r | |
bf5abaff | 1152 | if (arch != null) {\r |
1153 | Vector<String> v = new Vector<String>();\r | |
1154 | v.add(arch);\r | |
1155 | msa.setSupArchList(v); \r | |
1156 | }\r | |
a13899c5 | 1157 | \r |
1158 | return msa;\r | |
1159 | }\r | |
1160 | \r | |
82961247 | 1161 | private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) \r |
1162 | throws PcdItemTypeConflictException, PcdValueMalFormed{\r | |
a13899c5 | 1163 | if (moduleSa.getPcdBuildDefinition() == null){\r |
1164 | moduleSa.addNewPcdBuildDefinition();\r | |
1165 | }\r | |
1166 | //\r | |
1167 | // constructe pcd to modulesa mapping first.\r | |
1168 | // Attention : for any error condition, remove from map this pcd.\r | |
1169 | //\r | |
1170 | ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);\r | |
1171 | if (pcdConsumer == null) {\r | |
1172 | pcdConsumer = new ArrayList<String>();\r | |
1173 | }\r | |
1bf9fa5a | 1174 | //\r |
1175 | // Using existing Pcd type, if this pcd already exists in other ModuleSA\r | |
1176 | //\r | |
1177 | if (pcdConsumer.size() > 0) {\r | |
1178 | String[] valPart = pcdConsumer.get(0).split(" ");\r | |
1179 | itemType = valPart[5];\r | |
1180 | }\r | |
a13899c5 | 1181 | String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r |
bf5abaff | 1182 | + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r |
a13899c5 | 1183 | + " " + itemType;\r |
1184 | pcdConsumer.add(listValue);\r | |
1185 | dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r | |
1bf9fa5a | 1186 | \r |
a13899c5 | 1187 | PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r |
1188 | fpdPcd.setCName(cName);\r | |
1189 | fpdPcd.setToken(token);\r | |
1190 | fpdPcd.setTokenSpaceGuidCName(tsGuid);\r | |
1191 | fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
1192 | fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
a390c35d | 1193 | \r |
1194 | if (defaultVal != null){\r | |
1195 | fpdPcd.setValue(defaultVal);\r | |
1196 | }\r | |
1197 | else {\r | |
1198 | if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r | |
1199 | fpdPcd.setValue("0");\r | |
1200 | }\r | |
1201 | if (dataType.equals("BOOLEAN")){\r | |
b3151273 | 1202 | fpdPcd.setValue("FALSE");\r |
a390c35d | 1203 | }\r |
1204 | if (dataType.equals("VOID*")) {\r | |
1205 | fpdPcd.setValue("");\r | |
1206 | }\r | |
1207 | }\r | |
1bf9fa5a | 1208 | //\r |
1209 | // Using existing pcd value, if this pcd already exists in other moduleSa.\r | |
1210 | //\r | |
1211 | if (defaultPcdValue.get(cName + " " + tsGuid) == null) {\r | |
1212 | defaultPcdValue.put(cName + " " + tsGuid, fpdPcd.getValue());\r | |
1213 | }\r | |
1214 | else {\r | |
1215 | fpdPcd.setValue(defaultPcdValue.get(cName + " " + tsGuid));\r | |
1216 | }\r | |
1217 | \r | |
802e0055 | 1218 | if (dataType.equals("UINT8")){\r |
1219 | fpdPcd.setMaxDatumSize(1);\r | |
1220 | }\r | |
1221 | if (dataType.equals("UINT16")) {\r | |
1222 | fpdPcd.setMaxDatumSize(2);\r | |
1223 | }\r | |
1224 | if (dataType.equals("UINT32")) {\r | |
1225 | fpdPcd.setMaxDatumSize(4);\r | |
1226 | }\r | |
1227 | if (dataType.equals("UINT64")){\r | |
1228 | fpdPcd.setMaxDatumSize(8);\r | |
1229 | }\r | |
1230 | if (dataType.equals("BOOLEAN")){\r | |
1231 | fpdPcd.setMaxDatumSize(1);\r | |
1232 | }\r | |
1233 | if (dataType.equals("VOID*")) {\r | |
1234 | int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r | |
1235 | fpdPcd.setMaxDatumSize(maxSize);\r | |
1236 | }\r | |
a13899c5 | 1237 | \r |
a390c35d | 1238 | \r |
a13899c5 | 1239 | if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r |
1240 | ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r | |
1241 | //\r | |
1242 | // if only one module mapped to this pcd, then the one is myself. so no other module mapped.\r | |
1243 | // so need to add one dyn pcd.\r | |
1244 | //\r | |
1245 | if (al.size() == 1) {\r | |
1246 | addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);\r | |
1247 | }\r | |
1248 | }\r | |
1bf9fa5a | 1249 | \r |
a13899c5 | 1250 | }\r |
1251 | \r | |
908b1c05 | 1252 | public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{\r |
a13899c5 | 1253 | if (datum == null) {\r |
1254 | return 0;\r | |
1255 | }\r | |
1256 | char ch = datum.charAt(0);\r | |
1257 | int start, end;\r | |
1258 | String strValue;\r | |
1259 | //\r | |
1260 | // For void* type PCD, only three datum is support:\r | |
1261 | // 1) Unicode: string with start char is "L"\r | |
1262 | // 2) Ansci: String is ""\r | |
1263 | // 3) byte array: String start char "{"\r | |
1264 | // \r | |
1265 | if (ch == 'L') {\r | |
1266 | start = datum.indexOf('\"');\r | |
1267 | end = datum.lastIndexOf('\"');\r | |
1268 | if ((start > end) || \r | |
1269 | (end > datum.length())||\r | |
1270 | ((start == end) && (datum.length() > 0))) {\r | |
1271 | //ToDo Error handling here\r | |
82961247 | 1272 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1273 | }\r |
1274 | \r | |
1275 | strValue = datum.substring(start + 1, end);\r | |
1276 | return strValue.length() * 2;\r | |
1277 | } else if (ch == '\"'){\r | |
1278 | start = datum.indexOf('\"');\r | |
1279 | end = datum.lastIndexOf('\"');\r | |
1280 | if ((start > end) || \r | |
1281 | (end > datum.length())||\r | |
1282 | ((start == end) && (datum.length() > 0))) {\r | |
82961247 | 1283 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1284 | }\r |
1285 | strValue = datum.substring(start + 1, end);\r | |
1286 | return strValue.length();\r | |
1287 | } else if (ch =='{') {\r | |
1288 | String[] strValueArray;\r | |
1289 | \r | |
1290 | start = datum.indexOf('{');\r | |
1291 | end = datum.lastIndexOf('}');\r | |
1292 | strValue = datum.substring(start + 1, end);\r | |
1293 | strValue = strValue.trim();\r | |
1294 | if (strValue.length() == 0) {\r | |
1295 | return 0;\r | |
1296 | }\r | |
1297 | strValueArray = strValue.split(",");\r | |
1298 | for (int index = 0; index < strValueArray.length; index ++) {\r | |
1299 | Integer value = Integer.decode(strValueArray[index].trim());\r | |
1300 | \r | |
1301 | if (value > 0xFF) {\r | |
1302 | // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r | |
a70d444e | 1303 | // "it must be a byte array. But the element of %s exceed the byte range",\r |
82961247 | 1304 | throw new PcdValueMalFormed (datum); \r |
a13899c5 | 1305 | }\r |
1306 | }\r | |
1307 | return strValueArray.length;\r | |
1308 | \r | |
1309 | \r | |
1310 | } else {\r | |
1311 | // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r | |
1312 | // "1) UNICODE string: like L\"xxxx\";\r\n"+\r | |
1313 | // "2) ANSIC string: like \"xxx\";\r\n"+\r | |
1314 | // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r | |
1315 | // "but the datum in seems does not following above format!",\r | |
82961247 | 1316 | throw new PcdValueMalFormed (datum);\r |
a13899c5 | 1317 | \r |
1318 | }\r | |
1319 | }\r | |
1320 | \r | |
1321 | private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {\r | |
1322 | ArrayList<String> al = dynPcdMap.get(dynPcdKey);\r | |
1323 | \r | |
1324 | return al;\r | |
1325 | }\r | |
1326 | \r | |
1327 | private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r | |
1328 | \r | |
34c614e1 | 1329 | return dynPcdMap.get(pcdKey);\r |
a13899c5 | 1330 | }\r |
1331 | \r | |
1332 | public int getDynamicPcdBuildDataCount() {\r | |
5af6b67f | 1333 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
e232295e | 1334 | removeElement(getfpdDynPcdBuildDefs());\r |
1335 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1336 | return 0;\r |
1337 | }\r | |
1338 | return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();\r | |
1339 | }\r | |
1340 | \r | |
1341 | public void getDynamicPcdBuildData(String[][] saa) {\r | |
5af6b67f | 1342 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
e232295e | 1343 | removeElement(getfpdDynPcdBuildDefs());\r |
1344 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1345 | return ;\r |
1346 | }\r | |
1347 | List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();\r | |
1348 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();\r | |
1349 | int i = 0;\r | |
1350 | while(li.hasNext()) {\r | |
1351 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();\r | |
1352 | saa[i][0] = dynPcd.getCName();\r | |
1353 | saa[i][1] = dynPcd.getToken().toString();\r | |
1354 | saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r | |
1355 | saa[i][3] = dynPcd.getMaxDatumSize()+"";\r | |
1356 | saa[i][4] = dynPcd.getDatumType().toString();\r | |
1357 | \r | |
1358 | ++i;\r | |
1359 | }\r | |
1360 | }\r | |
1361 | \r | |
908b1c05 | 1362 | public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) \r |
82961247 | 1363 | throws PcdValueMalFormed{\r |
a13899c5 | 1364 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();\r |
1365 | dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r | |
1366 | dynPcdData.setCName(cName);\r | |
1367 | dynPcdData.setToken(token);\r | |
1368 | dynPcdData.setTokenSpaceGuidCName(tsGuid);\r | |
1369 | dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));\r | |
1370 | \r | |
1371 | BigInteger bigInt = new BigInteger("0");\r | |
1372 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();\r | |
1373 | skuInfo.setSkuId(bigInt);\r | |
1374 | if (defaultVal != null){\r | |
1375 | skuInfo.setValue(defaultVal);\r | |
1376 | }\r | |
1377 | else {\r | |
1378 | if (dataType.equals("UINT8")){\r | |
1379 | skuInfo.setValue("0");\r | |
1380 | }\r | |
1381 | if (dataType.equals("UINT16")) {\r | |
1382 | skuInfo.setValue("0");\r | |
1383 | }\r | |
1384 | if (dataType.equals("UINT32")) {\r | |
1385 | skuInfo.setValue("0");\r | |
1386 | }\r | |
1387 | if (dataType.equals("UINT64")){\r | |
1388 | skuInfo.setValue("0");\r | |
1389 | }\r | |
1390 | if (dataType.equals("BOOLEAN")){\r | |
1391 | skuInfo.setValue("false");\r | |
1392 | }\r | |
1393 | if (dataType.equals("VOID*")) {\r | |
1394 | skuInfo.setValue("");\r | |
1395 | }\r | |
1396 | }\r | |
1397 | if (dataType.equals("UINT8")){\r | |
1398 | dynPcdData.setMaxDatumSize(1);\r | |
1399 | }\r | |
1400 | if (dataType.equals("UINT16")) {\r | |
1401 | dynPcdData.setMaxDatumSize(2);\r | |
1402 | }\r | |
1403 | if (dataType.equals("UINT32")) {\r | |
1404 | dynPcdData.setMaxDatumSize(4);\r | |
1405 | }\r | |
1406 | if (dataType.equals("UINT64")){\r | |
1407 | dynPcdData.setMaxDatumSize(8);\r | |
1408 | }\r | |
1409 | if (dataType.equals("BOOLEAN")){\r | |
1410 | dynPcdData.setMaxDatumSize(1);\r | |
1411 | }\r | |
1412 | if (dataType.equals("VOID*")) {\r | |
1413 | int maxSize = setMaxSizeForPointer(defaultVal);\r | |
1414 | dynPcdData.setMaxDatumSize(maxSize);\r | |
1415 | }\r | |
1416 | }\r | |
1417 | \r | |
908b1c05 | 1418 | public void removeDynamicPcdBuildData(String cName, String tsGuid) {\r |
e232295e | 1419 | XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions();\r |
1420 | if (o == null) {\r | |
1421 | return;\r | |
1422 | }\r | |
a13899c5 | 1423 | \r |
1424 | XmlCursor cursor = o.newCursor();\r | |
1425 | if (cursor.toFirstChild()) {\r | |
af25df16 | 1426 | do {\r |
1427 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = \r | |
1428 | (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
908b1c05 | 1429 | if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {\r |
add40ab2 | 1430 | \r |
1431 | if (getDynamicPcdBuildDataCount() == 1) {\r | |
af25df16 | 1432 | cursor.toParent();\r |
af25df16 | 1433 | }\r |
add40ab2 | 1434 | cursor.removeXml();\r |
908b1c05 | 1435 | cursor.dispose();\r |
1436 | return;\r | |
1437 | }\r | |
a13899c5 | 1438 | }\r |
af25df16 | 1439 | while (cursor.toNextSibling());\r |
a13899c5 | 1440 | }\r |
1441 | cursor.dispose();\r | |
1442 | }\r | |
1443 | //\r | |
1444 | // Get the Sku Info count of ith dyn pcd element.\r | |
1445 | //\r | |
1446 | public int getDynamicPcdSkuInfoCount(int i){\r | |
e232295e | 1447 | if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null \r |
1448 | || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {\r | |
a13899c5 | 1449 | return 0;\r |
1450 | }\r | |
1451 | \r | |
1452 | int skuInfoCount = 0;\r | |
1453 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1454 | if (cursor.toFirstChild()) {\r | |
1455 | for (int j = 0; j < i; ++j) {\r | |
1456 | cursor.toNextSibling();\r | |
1457 | }\r | |
1458 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1459 | if (pcdData.getSkuInfoList() == null) {\r | |
1460 | skuInfoCount = 0;\r | |
1461 | }\r | |
1462 | else {\r | |
1463 | skuInfoCount = pcdData.getSkuInfoList().size();\r | |
1464 | }\r | |
1465 | }\r | |
1466 | cursor.dispose();\r | |
1467 | return skuInfoCount;\r | |
1468 | }\r | |
1469 | \r | |
1470 | public void getDynamicPcdSkuInfos(int i, String[][] saa){\r | |
1471 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1472 | removeElement(getfpdDynPcdBuildDefs());\r |
1473 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1474 | return;\r |
1475 | }\r | |
1476 | \r | |
1477 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1478 | if (cursor.toFirstChild()) {\r | |
1479 | for (int j = 0; j < i; ++j) {\r | |
1480 | cursor.toNextSibling();\r | |
1481 | }\r | |
1482 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1483 | if (pcdData.getSkuInfoList() == null) {\r | |
1484 | cursor.dispose();\r | |
1485 | return;\r | |
1486 | }\r | |
1487 | else {\r | |
1488 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1489 | int k = 0;\r | |
1490 | while (li.hasNext()) {\r | |
1491 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1492 | saa[k][0] = skuInfo.getSkuId()+"";\r | |
1493 | saa[k][1] = skuInfo.getVariableName();\r | |
1494 | saa[k][2] = skuInfo.getVariableGuid();\r | |
1495 | saa[k][3] = skuInfo.getVariableOffset();\r | |
1496 | saa[k][4] = skuInfo.getHiiDefaultValue();\r | |
1497 | saa[k][5] = skuInfo.getVpdOffset();\r | |
1498 | saa[k][6] = skuInfo.getValue();\r | |
1499 | ++k;\r | |
1500 | }\r | |
1501 | \r | |
1502 | }\r | |
1503 | }\r | |
1504 | cursor.dispose();\r | |
1505 | \r | |
1506 | }\r | |
1507 | \r | |
1508 | public String getDynamicPcdBuildDataValue(int i){\r | |
1509 | String value = null;\r | |
1510 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1511 | removeElement(getfpdDynPcdBuildDefs());\r |
1512 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1513 | return value;\r |
1514 | }\r | |
1515 | \r | |
1516 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1517 | if (cursor.toFirstChild()) {\r | |
1518 | for (int j = 0; j < i; ++j) {\r | |
1519 | cursor.toNextSibling();\r | |
1520 | }\r | |
1521 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1522 | if (pcdData.getSkuInfoList() == null) {\r | |
1523 | value = null;\r | |
1524 | }\r | |
1525 | else {\r | |
1526 | value = pcdData.getSkuInfoArray(0).getValue();\r | |
1527 | }\r | |
1528 | }\r | |
1529 | cursor.dispose();\r | |
1530 | return value;\r | |
1531 | }\r | |
1532 | \r | |
1533 | public String getDynamicPcdBuildDataVpdOffset(int i){\r | |
1534 | String vpdOffset = null;\r | |
1535 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1536 | removeElement(getfpdDynPcdBuildDefs());\r |
1537 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1538 | return vpdOffset;\r |
1539 | }\r | |
1540 | \r | |
1541 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1542 | if (cursor.toFirstChild()) {\r | |
1543 | for (int j = 0; j < i; ++j) {\r | |
1544 | cursor.toNextSibling();\r | |
1545 | }\r | |
1546 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1547 | if (pcdData.getSkuInfoList() == null) {\r | |
1548 | vpdOffset = null;\r | |
1549 | }\r | |
1550 | else {\r | |
1551 | vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();\r | |
1552 | }\r | |
1553 | }\r | |
1554 | cursor.dispose();\r | |
1555 | return vpdOffset;\r | |
1556 | }\r | |
1557 | \r | |
1558 | public void removeDynamicPcdBuildDataSkuInfo(int i) {\r | |
1559 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r | |
e232295e | 1560 | removeElement(getfpdDynPcdBuildDefs());\r |
1561 | fpdDynPcdBuildDefs = null;\r | |
a13899c5 | 1562 | return;\r |
1563 | }\r | |
1564 | \r | |
1565 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1566 | if (cursor.toFirstChild()) {\r | |
1567 | for (int j = 0; j < i; ++j) {\r | |
1568 | cursor.toNextSibling();\r | |
1569 | }\r | |
1570 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1571 | if (pcdData.getSkuInfoList() == null) {\r | |
1572 | cursor.dispose();\r | |
1573 | return;\r | |
1574 | }\r | |
1575 | else {\r | |
1576 | QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r | |
1577 | cursor.toChild(qSkuInfo);\r | |
1578 | cursor.removeXml();\r | |
1579 | }\r | |
1580 | }\r | |
1581 | cursor.dispose();\r | |
1582 | }\r | |
1583 | //\r | |
1584 | // generate sku info for ith dyn pcd build data.\r | |
1585 | //\r | |
1586 | public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1587 | String hiiDefault, String vpdOffset, String value, int i) {\r | |
e232295e | 1588 | // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
1589 | // return;\r | |
1590 | // }\r | |
a13899c5 | 1591 | \r |
1592 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1593 | if (cursor.toFirstChild()) {\r | |
1594 | for (int j = 0; j < i; ++j) {\r | |
1595 | cursor.toNextSibling();\r | |
1596 | }\r | |
1597 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1598 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();\r | |
1599 | skuInfo.setSkuId(new BigInteger(id));\r | |
1600 | if (varName != null){\r | |
1601 | skuInfo.setVariableName(varName);\r | |
1602 | skuInfo.setVariableGuid(varGuid);\r | |
1603 | skuInfo.setVariableOffset(varOffset);\r | |
1604 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1605 | }\r | |
1606 | else if (vpdOffset != null){\r | |
1607 | skuInfo.setVpdOffset(vpdOffset);\r | |
1608 | }\r | |
1609 | else{\r | |
1610 | skuInfo.setValue(value);\r | |
1611 | }\r | |
1612 | }\r | |
1613 | }\r | |
1614 | \r | |
1615 | public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r | |
1616 | String hiiDefault, String vpdOffset, String value, int i){\r | |
e232295e | 1617 | // if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r |
1618 | // return;\r | |
1619 | // }\r | |
a13899c5 | 1620 | \r |
1621 | XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r | |
1622 | if (cursor.toFirstChild()) {\r | |
1623 | for (int j = 0; j < i; ++j) {\r | |
1624 | cursor.toNextSibling();\r | |
1625 | }\r | |
1626 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r | |
1627 | ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r | |
1628 | while (li.hasNext()) {\r | |
1629 | DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r | |
1630 | if (skuInfo.getSkuId().toString().equals(id)){\r | |
1631 | if (varName != null){\r | |
1632 | skuInfo.setVariableName(varName);\r | |
1633 | skuInfo.setVariableGuid(varGuid);\r | |
1634 | skuInfo.setVariableOffset(varOffset);\r | |
1635 | skuInfo.setHiiDefaultValue(hiiDefault);\r | |
1636 | }\r | |
1637 | else if (vpdOffset != null){\r | |
1638 | skuInfo.setVpdOffset(vpdOffset);\r | |
1639 | }\r | |
1640 | else{\r | |
1641 | skuInfo.setValue(value);\r | |
1642 | }\r | |
1643 | break;\r | |
1644 | }\r | |
1645 | }\r | |
1646 | }\r | |
1647 | }\r | |
1648 | \r | |
a13899c5 | 1649 | public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {\r |
1650 | if (fpdBuildOpts == null) {\r | |
1651 | fpdBuildOpts = fpdRoot.addNewBuildOptions();\r | |
1652 | }\r | |
1653 | return fpdBuildOpts;\r | |
1654 | }\r | |
1655 | \r | |
2b70a636 | 1656 | public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {\r |
eb8ea829 | 1657 | QName elementFvName = new QName (xmlNs, "FvName");\r |
1658 | QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r | |
1659 | QName elementInfFileName = new QName(xmlNs, "InfFileName");\r | |
1660 | QName elementModule = new QName(xmlNs, "Module");\r | |
1661 | \r | |
1bf9fa5a | 1662 | UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r |
1663 | userExts.setUserID("IMAGES");\r | |
1664 | userExts.setIdentifier(new BigInteger("1"));\r | |
1665 | XmlCursor cursor = userExts.newCursor();\r | |
1666 | cursor.toEndToken();\r | |
1667 | \r | |
eb8ea829 | 1668 | cursor.beginElement(elementFvName);\r |
1bf9fa5a | 1669 | cursor.insertChars(fvName);\r |
1670 | cursor.toNextToken();\r | |
1671 | \r | |
eb8ea829 | 1672 | cursor.beginElement(elementInfFileName);\r |
61919f8c | 1673 | cursor.insertChars(fvName + ".inf");\r |
1bf9fa5a | 1674 | cursor.toNextToken();\r |
1675 | \r | |
eb8ea829 | 1676 | cursor.beginElement(elementIncludeModules);\r |
2b70a636 | 1677 | for (int i = 0; i < includeModules.size(); ++i) {\r |
eb8ea829 | 1678 | cursor.beginElement(elementModule);\r |
2b70a636 | 1679 | cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);\r |
1680 | cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);\r | |
1bf9fa5a | 1681 | cursor.toEndToken();\r |
1682 | cursor.toNextToken();\r | |
1683 | }\r | |
1684 | cursor.dispose();\r | |
1685 | }\r | |
1686 | \r | |
1687 | public int getUserExtsIncModCount (String fvName) {\r | |
1688 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1689 | return -1;\r | |
1690 | }\r | |
1691 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r | |
eb8ea829 | 1692 | QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r |
1bf9fa5a | 1693 | while (li.hasNext()) {\r |
1694 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1695 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1696 | continue;\r | |
1697 | }\r | |
1698 | XmlCursor cursor = ues.newCursor();\r | |
1699 | cursor.toFirstChild();\r | |
1700 | String elementName = cursor.getTextValue();\r | |
1701 | if (elementName.equals(fvName)) {\r | |
eb8ea829 | 1702 | cursor.toNextSibling(elementIncludeModules);\r |
1bf9fa5a | 1703 | if (cursor.toFirstChild()) {\r |
1704 | int i = 1;\r | |
1705 | for (i = 1; cursor.toNextSibling(); ++i);\r | |
1706 | cursor.dispose();\r | |
1707 | return i;\r | |
1708 | }\r | |
1709 | cursor.dispose();\r | |
1710 | return 0;\r | |
1711 | }\r | |
1712 | cursor.dispose();\r | |
1713 | }\r | |
1714 | return -1;\r | |
1715 | }\r | |
1716 | \r | |
1717 | public void getUserExtsIncMods(String fvName, String[][] saa) {\r | |
1718 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1719 | return;\r | |
1720 | }\r | |
eb8ea829 | 1721 | \r |
1722 | XmlCursor cursor = getfpdBuildOpts().newCursor();\r | |
1723 | QName elementUserExts = new QName (xmlNs, "UserExtensions");\r | |
1724 | QName attribUserId = new QName ("UserID");\r | |
1725 | QName elementFvName = new QName (xmlNs, "FvName");\r | |
1726 | QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r | |
1727 | QName attribModuleGuid = new QName("ModuleGuid");\r | |
1728 | QName attribBaseName = new QName("BaseName");\r | |
1729 | \r | |
1730 | if (cursor.toChild(elementUserExts)) {\r | |
1731 | do {\r | |
1732 | cursor.push();\r | |
1733 | if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {\r | |
1734 | cursor.toChild(elementFvName);\r | |
1735 | String elementName = cursor.getTextValue();\r | |
1736 | if (elementName.equals(fvName)) {\r | |
1737 | cursor.toNextSibling(elementIncludeModules);\r | |
1738 | if (cursor.toFirstChild()) {\r | |
1739 | int i = 0;\r | |
1740 | do {\r | |
1741 | saa[i][0] = cursor.getAttributeText(attribModuleGuid);\r | |
1742 | saa[i][1] = cursor.getAttributeText(attribBaseName);\r | |
1743 | ++i;\r | |
1744 | }while (cursor.toNextSibling());\r | |
1745 | }\r | |
1746 | break;\r | |
1747 | }\r | |
1748 | }\r | |
1749 | cursor.pop();\r | |
1750 | }while (cursor.toNextSibling(elementUserExts));\r | |
1751 | }\r | |
1752 | cursor.dispose();\r | |
1753 | \r | |
1754 | }\r | |
1755 | \r | |
1756 | public void updateBuildOptionsUserExtensions (String oldFvName, String newFvName) {\r | |
1757 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1758 | return;\r | |
1759 | }\r | |
1bf9fa5a | 1760 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r |
1761 | while (li.hasNext()) {\r | |
1762 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1763 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1764 | continue;\r | |
1765 | }\r | |
1766 | XmlCursor cursor = ues.newCursor();\r | |
1767 | cursor.toFirstChild();\r | |
1768 | String elementName = cursor.getTextValue();\r | |
eb8ea829 | 1769 | if (elementName.equals(oldFvName)) {\r |
1770 | cursor.setTextValue(newFvName);\r | |
1bf9fa5a | 1771 | }\r |
1772 | cursor.dispose();\r | |
1773 | }\r | |
1774 | \r | |
1775 | }\r | |
1776 | \r | |
61919f8c | 1777 | public void removeBuildOptionsUserExtensions (String fvName) {\r |
1778 | if (getfpdBuildOpts().getUserExtensionsList() == null) {\r | |
1779 | return;\r | |
1780 | }\r | |
1781 | \r | |
1782 | ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r | |
1783 | while (li.hasNext()) {\r | |
1784 | UserExtensionsDocument.UserExtensions ues = li.next();\r | |
1785 | if (!ues.getUserID().equals("IMAGES")) {\r | |
1786 | continue;\r | |
1787 | }\r | |
1788 | XmlCursor cursor = ues.newCursor();\r | |
1789 | cursor.toFirstChild();\r | |
1790 | String elementName = cursor.getTextValue();\r | |
1791 | if (elementName.equals(fvName)) {\r | |
1792 | cursor.toParent();\r | |
1793 | cursor.removeXml();\r | |
1794 | cursor.dispose();\r | |
1795 | return;\r | |
1796 | }\r | |
1797 | cursor.dispose();\r | |
1798 | }\r | |
1799 | \r | |
1800 | }\r | |
1801 | \r | |
1802 | \r | |
a13899c5 | 1803 | public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r |
1804 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1805 | if (udats == null) {\r | |
1806 | udats = getfpdBuildOpts().addNewUserDefinedAntTasks();\r | |
1807 | }\r | |
1808 | \r | |
1809 | AntTaskDocument.AntTask at = udats.addNewAntTask();\r | |
1810 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1811 | }\r | |
1812 | \r | |
1813 | private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {\r | |
1814 | at.setId(new Integer(id));\r | |
bf5abaff | 1815 | XmlCursor cursor = at.newCursor();\r |
a13899c5 | 1816 | if (fileName != null){\r |
1817 | at.setFilename(fileName);\r | |
1818 | }\r | |
bf5abaff | 1819 | else if (cursor.toChild(xmlNs, "Filename")) {\r |
1820 | cursor.removeXml();\r | |
1821 | }\r | |
202c4f38 | 1822 | if (execOrder != null) {\r |
a13899c5 | 1823 | at.setAntCmdOptions(execOrder);\r |
1824 | }\r | |
bf5abaff | 1825 | else if (cursor.toChild(xmlNs, "AntCmdOptions")) {\r |
1826 | cursor.removeXml();\r | |
1827 | }\r | |
1828 | cursor.dispose();\r | |
a13899c5 | 1829 | }\r |
1830 | \r | |
1831 | public void removeBuildOptionsUserDefAntTask(int i) {\r | |
1832 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1833 | if (o == null) {\r | |
1834 | return;\r | |
1835 | }\r | |
1836 | XmlCursor cursor = o.newCursor();\r | |
1837 | if (cursor.toFirstChild()) {\r | |
1838 | for (int j = 0; j < i; ++j) {\r | |
1839 | cursor.toNextSibling();\r | |
1840 | }\r | |
1841 | cursor.removeXml();\r | |
af25df16 | 1842 | if (getBuildOptionsUserDefAntTaskCount() == 0) {\r |
1843 | cursor.toParent();\r | |
1844 | cursor.removeXml();\r | |
1845 | }\r | |
a13899c5 | 1846 | }\r |
1847 | cursor.dispose();\r | |
1848 | }\r | |
1849 | \r | |
1850 | public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){\r | |
1851 | XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1852 | if (o == null) {\r | |
1853 | return;\r | |
1854 | }\r | |
1855 | XmlCursor cursor = o.newCursor();\r | |
1856 | if (cursor.toFirstChild()) {\r | |
1857 | for (int j = 0; j < i; ++j) {\r | |
1858 | cursor.toNextSibling();\r | |
1859 | }\r | |
1860 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();\r | |
1861 | setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r | |
1862 | }\r | |
1863 | cursor.dispose();\r | |
1864 | }\r | |
1865 | \r | |
1866 | public int getBuildOptionsUserDefAntTaskCount() {\r | |
1867 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1868 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1869 | return 0;\r | |
1870 | }\r | |
1871 | \r | |
1872 | return udats.getAntTaskList().size();\r | |
1873 | }\r | |
1874 | \r | |
1875 | public void getBuildOptionsUserDefAntTasks(String[][] saa) {\r | |
1876 | UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r | |
1877 | if (udats == null || udats.getAntTaskList() == null) {\r | |
1878 | return ;\r | |
1879 | }\r | |
1880 | \r | |
1881 | List<AntTaskDocument.AntTask> l = udats.getAntTaskList();\r | |
1882 | ListIterator li = l.listIterator();\r | |
1883 | int i = 0;\r | |
1884 | while (li.hasNext()) {\r | |
1885 | AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();\r | |
1886 | saa[i][0] = at.getId() + "";\r | |
1887 | saa[i][1] = saa[i][2] = "";\r | |
1888 | if (at.getFilename() != null){\r | |
1889 | saa[i][1] = at.getFilename();\r | |
1890 | }\r | |
1891 | if (at.getAntCmdOptions() != null) {\r | |
1892 | saa[i][2] = at.getAntCmdOptions();\r | |
1893 | }\r | |
1894 | ++i;\r | |
1895 | }\r | |
1896 | }\r | |
1800d80f | 1897 | public void genBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1898 | OptionsDocument.Options opts = getfpdBuildOpts().getOptions();\r |
1899 | if (opts == null) {\r | |
1900 | opts = getfpdBuildOpts().addNewOptions();\r | |
1901 | }\r | |
1902 | OptionDocument.Option opt = opts.addNewOption();\r | |
1903 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1904 | }\r | |
1905 | \r | |
1800d80f | 1906 | private void setBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents, OptionDocument.Option opt){\r |
a13899c5 | 1907 | opt.setStringValue(contents);\r |
1800d80f | 1908 | \r |
1909 | opt.setBuildTargets(buildTargets);\r | |
a13899c5 | 1910 | opt.setToolChainFamily(toolChain);\r |
1911 | opt.setTagName(tagName);\r | |
1912 | opt.setToolCode(toolCmd);\r | |
1800d80f | 1913 | \r |
bf5abaff | 1914 | if (archList != null) {\r |
1915 | opt.setSupArchList(archList);\r | |
1916 | }\r | |
1917 | else {\r | |
1918 | if (opt.isSetSupArchList()) {\r | |
1919 | opt.unsetSupArchList();\r | |
1920 | }\r | |
1921 | }\r | |
a13899c5 | 1922 | }\r |
1923 | \r | |
1924 | public void removeBuildOptionsOpt(int i){\r | |
1925 | \r | |
1926 | XmlObject o = getfpdBuildOpts().getOptions();\r | |
1927 | if (o == null) {\r | |
1928 | return;\r | |
1929 | }\r | |
1930 | \r | |
1931 | XmlCursor cursor = o.newCursor();\r | |
1932 | if (cursor.toFirstChild()) {\r | |
1933 | for (int j = 0; j < i; ++j) {\r | |
1934 | cursor.toNextSibling();\r | |
1935 | }\r | |
1936 | cursor.removeXml();\r | |
af25df16 | 1937 | if (getBuildOptionsOptCount() == 0) {\r |
1938 | cursor.toParent();\r | |
1939 | cursor.removeXml();\r | |
1940 | }\r | |
a13899c5 | 1941 | }\r |
1942 | cursor.dispose();\r | |
1943 | }\r | |
1944 | \r | |
1800d80f | 1945 | public void updateBuildOptionsOpt(int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r |
a13899c5 | 1946 | XmlObject o = getfpdBuildOpts().getOptions();\r |
1947 | if (o == null) {\r | |
1948 | return;\r | |
1949 | }\r | |
1950 | \r | |
1951 | XmlCursor cursor = o.newCursor();\r | |
1952 | if (cursor.toFirstChild()) {\r | |
1953 | for (int j = 0; j < i; ++j) {\r | |
1954 | cursor.toNextSibling();\r | |
1955 | }\r | |
1956 | OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r | |
1957 | setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r | |
1958 | }\r | |
1959 | cursor.dispose();\r | |
1960 | }\r | |
1961 | \r | |
1962 | public int getBuildOptionsOptCount(){\r | |
1963 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1964 | return 0;\r | |
1965 | }\r | |
1966 | return getfpdBuildOpts().getOptions().getOptionList().size();\r | |
1967 | }\r | |
1968 | \r | |
1969 | public void getBuildOptionsOpts(String[][] saa) {\r | |
1970 | if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r | |
1971 | return ;\r | |
1972 | }\r | |
1973 | \r | |
1974 | List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();\r | |
1975 | ListIterator li = lOpt.listIterator();\r | |
1976 | int i = 0;\r | |
1977 | while(li.hasNext()) {\r | |
1978 | OptionDocument.Option opt = (OptionDocument.Option)li.next();\r | |
6cba26e8 | 1979 | if (opt.getBuildTargets() != null) {\r |
1980 | saa[i][0] = listToString(opt.getBuildTargets());\r | |
1981 | }\r | |
a13899c5 | 1982 | saa[i][1] = opt.getToolChainFamily();\r |
1983 | if (opt.getSupArchList() != null){\r | |
6cba26e8 | 1984 | saa[i][2] = listToString(opt.getSupArchList());\r |
1985 | \r | |
a13899c5 | 1986 | }\r |
1987 | saa[i][3] = opt.getToolCode();\r | |
1988 | saa[i][4] = opt.getTagName();\r | |
1989 | saa[i][5] = opt.getStringValue();\r | |
1990 | \r | |
1991 | ++i;\r | |
1992 | }\r | |
1993 | }\r | |
1994 | \r | |
6cba26e8 | 1995 | public void genBuildOptionsFfs(String ffsKey, String type) {\r |
1996 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
1997 | ffs.setFfsKey(ffsKey);\r | |
1998 | if (type != null) {\r | |
1999 | ffs.addNewSections().setEncapsulationType(type);\r | |
2000 | }\r | |
2001 | }\r | |
2002 | \r | |
3b405e9b | 2003 | public void updateBuildOptionsFfsSectionsType(int i, String type) {\r |
2004 | BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r | |
2005 | if (type != null) {\r | |
2006 | ffs.addNewSections().setEncapsulationType(type);\r | |
2007 | }\r | |
2008 | }\r | |
2009 | \r | |
6cba26e8 | 2010 | public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r |
2011 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2012 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();\r | |
2013 | attrib.setName(name);\r | |
2014 | attrib.setValue(value);\r | |
2015 | }\r | |
2016 | \r | |
2017 | /**update jth attribute of ith ffs.\r | |
2018 | * @param i\r | |
2019 | * @param j\r | |
2020 | */\r | |
2021 | public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){\r | |
2022 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2023 | XmlCursor cursor = ffs.newCursor();\r | |
2024 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
2025 | if (cursor.toChild(qAttrib)) {\r | |
2026 | for (int k = 0; k < j; ++k) {\r | |
2027 | cursor.toNextSibling(qAttrib);\r | |
2028 | }\r | |
2029 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();\r | |
2030 | attrib.setName(name);\r | |
2031 | attrib.setValue(value);\r | |
2032 | }\r | |
2033 | cursor.dispose();\r | |
2034 | }\r | |
2035 | \r | |
2036 | public void removeBuildOptionsFfsAttribute(int i, int j){\r | |
2037 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2038 | XmlCursor cursor = ffs.newCursor();\r | |
2039 | QName qAttrib = new QName(xmlNs, "Attribute");\r | |
2040 | if (cursor.toChild(qAttrib)) {\r | |
2041 | for (int k = 0; k < j; ++k) {\r | |
2042 | cursor.toNextSibling(qAttrib);\r | |
2043 | }\r | |
2044 | cursor.removeXml();\r | |
2045 | }\r | |
2046 | cursor.dispose();\r | |
2047 | }\r | |
2048 | \r | |
2049 | public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {\r | |
2050 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2051 | if (ffs == null) {\r | |
2052 | return;\r | |
2053 | }\r | |
2054 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2055 | \r | |
2056 | if (sections == null){\r | |
2057 | sections = ffs.addNewSections();\r | |
2058 | }\r | |
2059 | sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));\r | |
2060 | }\r | |
2061 | \r | |
3b405e9b | 2062 | public void removeBuildOptionsFfsSectionsSection(int i, int j) {\r |
2063 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2064 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2065 | if (sections == null) {\r | |
2066 | return;\r | |
2067 | }\r | |
2068 | XmlCursor cursor = sections.newCursor();\r | |
2069 | QName qSection = new QName(xmlNs, "Section");\r | |
2070 | if (cursor.toChild(qSection)) {\r | |
2071 | for (int k = 0; k < j; ++k) {\r | |
2072 | cursor.toNextSibling(qSection);\r | |
2073 | }\r | |
2074 | cursor.removeXml();\r | |
2075 | }\r | |
2076 | cursor.dispose();\r | |
2077 | }\r | |
2078 | \r | |
2079 | public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){\r | |
2080 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2081 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2082 | if (sections == null) {\r | |
2083 | return;\r | |
2084 | }\r | |
2085 | XmlCursor cursor = sections.newCursor();\r | |
2086 | QName qSection = new QName(xmlNs, "Section");\r | |
2087 | if (cursor.toChild(qSection)) {\r | |
2088 | for (int k = 0; k < j; ++k) {\r | |
2089 | cursor.toNextSibling(qSection);\r | |
2090 | }\r | |
2091 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();\r | |
2092 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
2093 | }\r | |
2094 | cursor.dispose();\r | |
2095 | } \r | |
2096 | \r | |
6cba26e8 | 2097 | public void genBuildOptionsFfsSectionsSections(int i, String encapType) {\r |
2098 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2099 | if (ffs == null) {\r | |
2100 | return;\r | |
2101 | }\r | |
2102 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2103 | \r | |
2104 | if (sections == null){\r | |
2105 | sections = ffs.addNewSections();\r | |
2106 | }\r | |
2107 | sections.addNewSections().setEncapsulationType(encapType);\r | |
2108 | }\r | |
2109 | \r | |
3b405e9b | 2110 | public void removeBuildOptionsFfsSectionsSections(int i, int j) {\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 k = 0; k < j; ++k) {\r | |
2120 | cursor.toNextSibling(qSections);\r | |
2121 | }\r | |
2122 | cursor.removeXml();\r | |
2123 | }\r | |
2124 | cursor.dispose();\r | |
2125 | }\r | |
2126 | \r | |
2127 | public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {\r | |
2128 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2129 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2130 | if (sections == null) {\r | |
2131 | return;\r | |
2132 | }\r | |
2133 | XmlCursor cursor = sections.newCursor();\r | |
2134 | QName qSections = new QName(xmlNs, "Sections");\r | |
2135 | if (cursor.toChild(qSections)) {\r | |
2136 | for (int k = 0; k < j; ++k) {\r | |
2137 | cursor.toNextSibling(qSections);\r | |
2138 | }\r | |
2139 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2140 | sections2.setEncapsulationType(type);\r | |
2141 | }\r | |
2142 | cursor.dispose();\r | |
2143 | }\r | |
2144 | \r | |
6cba26e8 | 2145 | public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {\r |
2146 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2147 | if (ffs == null) {\r | |
2148 | return;\r | |
2149 | }\r | |
2150 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2151 | XmlCursor cursor = sections.newCursor();\r | |
2152 | QName qSections = new QName(xmlNs, "Sections");\r | |
2153 | if (cursor.toChild(qSections)){\r | |
2154 | for (int k = 0; k < j; ++k) {\r | |
2155 | cursor.toNextSibling(qSections);\r | |
2156 | }\r | |
2157 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2158 | sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));\r | |
2159 | }\r | |
2160 | cursor.dispose();\r | |
2161 | }\r | |
2162 | \r | |
3b405e9b | 2163 | public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {\r |
2164 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2165 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2166 | if (sections == null) {\r | |
2167 | return;\r | |
2168 | }\r | |
2169 | XmlCursor cursor = sections.newCursor();\r | |
2170 | QName qSections = new QName(xmlNs, "Sections");\r | |
2171 | if (cursor.toChild(qSections)) {\r | |
2172 | for (int l = 0; l < j; ++l) {\r | |
2173 | cursor.toNextSibling(qSections);\r | |
2174 | }\r | |
2175 | if (cursor.toFirstChild()) {\r | |
af25df16 | 2176 | int m = 0;\r |
2177 | for (; m < k; ++m) {\r | |
3b405e9b | 2178 | cursor.toNextSibling();\r |
2179 | }\r | |
2180 | cursor.removeXml();\r | |
af25df16 | 2181 | if (m == 0) {\r |
2182 | cursor.toParent();\r | |
2183 | cursor.removeXml();\r | |
2184 | }\r | |
3b405e9b | 2185 | }\r |
2186 | }\r | |
2187 | cursor.dispose();\r | |
2188 | }\r | |
2189 | \r | |
2190 | public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {\r | |
2191 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2192 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2193 | if (sections == null) {\r | |
2194 | return;\r | |
2195 | }\r | |
2196 | XmlCursor cursor = sections.newCursor();\r | |
2197 | QName qSections = new QName(xmlNs, "Sections");\r | |
2198 | if (cursor.toChild(qSections)) {\r | |
2199 | for (int l = 0; l < j; ++l) {\r | |
2200 | cursor.toNextSibling(qSections);\r | |
2201 | }\r | |
2202 | if (cursor.toFirstChild()) {\r | |
2203 | for (int m = 0; m < k; ++m) {\r | |
2204 | cursor.toNextSibling();\r | |
2205 | }\r | |
2206 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();\r | |
2207 | section.setSectionType(EfiSectionType.Enum.forString(type));\r | |
2208 | }\r | |
2209 | }\r | |
2210 | cursor.dispose();\r | |
2211 | }\r | |
2212 | \r | |
6cba26e8 | 2213 | public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {\r |
2214 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2215 | if (ffs == null) {\r | |
2216 | return;\r | |
2217 | }\r | |
2218 | BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r | |
2219 | XmlCursor cursor = sections.newCursor();\r | |
2220 | QName qSections = new QName(xmlNs, "Sections");\r | |
2221 | if (cursor.toChild(qSections)){\r | |
2222 | for (int k = 0; k < j; ++k) {\r | |
2223 | cursor.toNextSibling(qSections);\r | |
2224 | }\r | |
2225 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r | |
2226 | if (sections2.getSectionList() == null){\r | |
2227 | cursor.dispose();\r | |
2228 | return;\r | |
2229 | }\r | |
2230 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();\r | |
2231 | while(li.hasNext()) {\r | |
2232 | BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();\r | |
3b405e9b | 2233 | if (section.isSetSectionType()) {\r |
1800d80f | 2234 | al.add(section.getSectionType().toString());\r |
2235 | }\r | |
3b405e9b | 2236 | \r |
2237 | }\r | |
6cba26e8 | 2238 | }\r |
2239 | cursor.dispose();\r | |
2240 | \r | |
2241 | }\r | |
2242 | \r | |
2243 | public int getBuildOptionsFfsCount(){\r | |
2244 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
2245 | return 0;\r | |
2246 | }\r | |
2247 | return getfpdBuildOpts().getFfsList().size();\r | |
2248 | }\r | |
2249 | \r | |
2250 | public void getBuildOptionsFfsKey(String[][] saa) {\r | |
2251 | if (getfpdBuildOpts().getFfsList() == null) {\r | |
2252 | return;\r | |
2253 | }\r | |
2254 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();\r | |
2255 | int i = 0;\r | |
2256 | while(li.hasNext()){\r | |
2257 | BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();\r | |
2258 | saa[i][0] = ffs.getFfsKey();\r | |
2259 | ++i;\r | |
2260 | }\r | |
2261 | }\r | |
2262 | \r | |
3b405e9b | 2263 | public void updateBuildOptionsFfsKey(int i, String key) {\r |
2264 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2265 | ffs.setFfsKey(key);\r | |
2266 | }\r | |
2267 | \r | |
6cba26e8 | 2268 | /**Get ith FFS key and contents.\r |
2269 | * @param saa\r | |
2270 | */\r | |
2271 | public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {\r | |
2272 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2273 | \r | |
2274 | if (ffs != null) {\r | |
2275 | \r | |
2276 | sa[0] = ffs.getFfsKey();\r | |
2277 | if (ffs.getSections() != null) {\r | |
2278 | if(ffs.getSections().getEncapsulationType() != null){\r | |
2279 | sa[1] = ffs.getSections().getEncapsulationType();\r | |
2280 | }\r | |
2281 | if (ffs.getSections().getSectionList() != null){\r | |
2282 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();\r | |
2283 | while (li.hasNext()) {\r | |
2284 | firstLevelSection.add(li.next().getSectionType().toString());\r | |
2285 | }\r | |
2286 | }\r | |
2287 | if (ffs.getSections().getSectionsList() != null) {\r | |
2288 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();\r | |
2289 | while(li.hasNext()) {\r | |
2290 | firstLevelSections.add(li.next().getEncapsulationType());\r | |
2291 | }\r | |
2292 | }\r | |
2293 | }\r | |
2294 | if (ffs.getAttributeList() != null) {\r | |
2295 | ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();\r | |
2296 | while(li.hasNext()) {\r | |
2297 | BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();\r | |
2298 | ffsAttribMap.put(attrib.getName(), attrib.getValue());\r | |
2299 | }\r | |
2300 | \r | |
2301 | }\r | |
2302 | }\r | |
2303 | \r | |
2304 | \r | |
2305 | }\r | |
2306 | \r | |
2307 | private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {\r | |
2308 | XmlObject o = getfpdBuildOpts();\r | |
2309 | BuildOptionsDocument.BuildOptions.Ffs ffs = null;\r | |
2310 | \r | |
2311 | XmlCursor cursor = o.newCursor();\r | |
2312 | QName qFfs = new QName(xmlNs, "Ffs");\r | |
2313 | if (cursor.toChild(qFfs)) {\r | |
2314 | for (int j = 0; j < i; ++j) {\r | |
2315 | cursor.toNextSibling(qFfs);\r | |
2316 | }\r | |
2317 | ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();\r | |
2318 | }\r | |
2319 | cursor.dispose();\r | |
2320 | return ffs;\r | |
2321 | }\r | |
2322 | \r | |
2323 | public void removeBuildOptionsFfs(int i) {\r | |
2324 | BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r | |
2325 | if (ffs == null){\r | |
2326 | return;\r | |
2327 | }\r | |
2328 | \r | |
2329 | XmlCursor cursor = ffs.newCursor();\r | |
2330 | cursor.removeXml();\r | |
2331 | cursor.dispose();\r | |
2332 | }\r | |
2333 | \r | |
3b405e9b | 2334 | \r |
2335 | \r | |
a13899c5 | 2336 | public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){\r |
2337 | if (fpdPlatformDefs == null){\r | |
2338 | fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();\r | |
2339 | }\r | |
2340 | return fpdPlatformDefs;\r | |
2341 | }\r | |
2342 | \r | |
6a09eb19 | 2343 | public void getPlatformDefsSupportedArchs(Vector<Object> archs){\r |
2344 | if (getfpdPlatformDefs().getSupportedArchitectures() == null) {\r | |
2345 | return;\r | |
2346 | }\r | |
2347 | ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();\r | |
2348 | while(li.hasNext()) {\r | |
2349 | archs.add(li.next());\r | |
2350 | }\r | |
2351 | }\r | |
2352 | \r | |
2353 | public void setPlatformDefsSupportedArchs(Vector<Object> archs) {\r | |
bf5abaff | 2354 | if (archs != null) {\r |
2355 | getfpdPlatformDefs().setSupportedArchitectures(archs);\r | |
2356 | }\r | |
2357 | // else {\r | |
2358 | // XmlCursor cursor = getfpdPlatformDefs().newCursor();\r | |
2359 | // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {\r | |
2360 | // cursor.removeXml();\r | |
2361 | // }\r | |
2362 | // cursor.dispose();\r | |
2363 | // }\r | |
6a09eb19 | 2364 | }\r |
2365 | \r | |
2366 | public void getPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
2367 | if (getfpdPlatformDefs().getBuildTargets() == null) {\r | |
2368 | return;\r | |
2369 | }\r | |
2370 | ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();\r | |
2371 | while(li.hasNext()) {\r | |
2372 | targets.add(li.next());\r | |
2373 | }\r | |
2374 | }\r | |
2375 | \r | |
2376 | public void setPlatformDefsBuildTargets(Vector<Object> targets) {\r | |
2377 | getfpdPlatformDefs().setBuildTargets(targets);\r | |
2378 | }\r | |
2379 | \r | |
2380 | public void genPlatformDefsSkuInfo(String id, String name) {\r | |
2381 | SkuInfoDocument.SkuInfo skuInfo = null;\r | |
2382 | if (getfpdPlatformDefs().getSkuInfo() == null) {\r | |
2383 | skuInfo = getfpdPlatformDefs().addNewSkuInfo();\r | |
2384 | }\r | |
2385 | skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2386 | if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {\r | |
2387 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
2388 | skuName.setSkuID(new BigInteger("0"));\r | |
2389 | skuName.setStringValue("DEFAULT");\r | |
2390 | }\r | |
2391 | if (id.equals("0")) {\r | |
2392 | return;\r | |
2393 | }\r | |
2394 | SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r | |
2395 | skuName.setSkuID(new BigInteger(id));\r | |
2396 | skuName.setStringValue(name);\r | |
2397 | }\r | |
2398 | \r | |
2399 | public int getPlatformDefsSkuInfoCount(){\r | |
2400 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
2401 | return 0;\r | |
2402 | }\r | |
2403 | return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();\r | |
2404 | }\r | |
2405 | \r | |
2406 | public void getPlatformDefsSkuInfos(String[][] saa){\r | |
2407 | if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r | |
5af6b67f | 2408 | if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r |
2409 | removeElement(getfpdDynPcdBuildDefs());\r | |
2410 | fpdDynPcdBuildDefs = null;\r | |
2411 | }\r | |
6a09eb19 | 2412 | return ;\r |
2413 | }\r | |
2414 | \r | |
2415 | List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();\r | |
2416 | ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();\r | |
2417 | int i = 0;\r | |
2418 | while(li.hasNext()) {\r | |
2419 | SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();\r | |
2420 | saa[i][0] = sku.getSkuID()+"";\r | |
2421 | saa[i][1] = sku.getStringValue();\r | |
2422 | ++i;\r | |
2423 | }\r | |
2424 | }\r | |
2425 | \r | |
2426 | public void removePlatformDefsSkuInfo(int i) {\r | |
2427 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2428 | if (skuInfo == null || i == 0) {\r | |
2429 | return ;\r | |
2430 | }\r | |
2431 | \r | |
2432 | XmlCursor cursor = skuInfo.newCursor();\r | |
2433 | if (cursor.toFirstChild()) {\r | |
2434 | for (int j = 0; j < i; ++j) {\r | |
2435 | cursor.toNextSibling();\r | |
2436 | }\r | |
2437 | cursor.removeXml();\r | |
2438 | }\r | |
2439 | cursor.dispose();\r | |
2440 | }\r | |
2441 | \r | |
2442 | public void updatePlatformDefsSkuInfo(int i, String id, String name) {\r | |
2443 | SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r | |
2444 | if (skuInfo == null || i == 0) {\r | |
2445 | return ;\r | |
2446 | }\r | |
2447 | \r | |
2448 | XmlCursor cursor = skuInfo.newCursor();\r | |
2449 | if (cursor.toFirstChild()) {\r | |
2450 | for (int j = 0; j < i; ++j) {\r | |
2451 | cursor.toNextSibling();\r | |
2452 | }\r | |
2453 | SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();\r | |
2454 | sku.setSkuID(new BigInteger(id));\r | |
2455 | sku.setStringValue(name);\r | |
2456 | }\r | |
2457 | cursor.dispose();\r | |
2458 | }\r | |
2459 | \r | |
2460 | public String getPlatformDefsInterDir(){\r | |
2461 | if (getfpdPlatformDefs().getIntermediateDirectories() == null) {\r | |
2462 | return null;\r | |
2463 | }\r | |
2464 | return getfpdPlatformDefs().getIntermediateDirectories().toString();\r | |
2465 | }\r | |
2466 | \r | |
2467 | public void setPlatformDefsInterDir(String interDir){\r | |
2468 | getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));\r | |
2469 | }\r | |
2470 | \r | |
2471 | public String getPlatformDefsOutputDir() {\r | |
2472 | return getfpdPlatformDefs().getOutputDirectory();\r | |
2473 | }\r | |
2474 | \r | |
2475 | public void setPlatformDefsOutputDir(String outputDir) {\r | |
af25df16 | 2476 | if (outputDir != null && outputDir.length() > 0) {\r |
2477 | getfpdPlatformDefs().setOutputDirectory(outputDir);\r | |
2478 | }\r | |
2479 | else{\r | |
2480 | XmlCursor cursor = getfpdPlatformDefs().newCursor();\r | |
2481 | if (cursor.toChild(new QName(xmlNs, "OutputDirectory"))) {\r | |
2482 | cursor.removeXml();\r | |
2483 | }\r | |
2484 | cursor.dispose();\r | |
2485 | }\r | |
6a09eb19 | 2486 | }\r |
2487 | \r | |
a13899c5 | 2488 | public FlashDocument.Flash getfpdFlash() {\r |
2489 | if (fpdFlash == null) {\r | |
2490 | fpdFlash = fpdRoot.addNewFlash();\r | |
2491 | }\r | |
2492 | return fpdFlash;\r | |
2493 | }\r | |
2494 | \r | |
2495 | public void genFlashDefinitionFile(String file) {\r | |
2496 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
2497 | if (fdf == null) {\r | |
2498 | fdf = getfpdFlash().addNewFlashDefinitionFile();\r | |
2499 | }\r | |
2500 | \r | |
2501 | fdf.setStringValue(file);\r | |
2502 | }\r | |
2503 | \r | |
2504 | public String getFlashDefinitionFile() {\r | |
2505 | FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r | |
2506 | if (fdf == null) {\r | |
2507 | return "";\r | |
2508 | }\r | |
2509 | \r | |
2510 | return fdf.getStringValue();\r | |
2511 | }\r | |
2512 | \r | |
a13899c5 | 2513 | public void genFvImagesNameValue(String name, String value) {\r |
2514 | \r | |
2515 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
2516 | if (fi == null) {\r | |
2517 | fi = getfpdFlash().addNewFvImages();\r | |
2518 | }\r | |
2519 | \r | |
2520 | FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();\r | |
2521 | nv.setName(name);\r | |
2522 | nv.setValue(value);\r | |
2523 | }\r | |
2524 | \r | |
2525 | public void removeFvImagesNameValue(int i){\r | |
2526 | \r | |
2527 | XmlObject o = getfpdFlash().getFvImages();\r | |
2528 | if (o == null) {\r | |
2529 | return;\r | |
2530 | }\r | |
2531 | \r | |
2532 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
2533 | XmlCursor cursor = o.newCursor();\r | |
2534 | if (cursor.toChild(qNameValue)) {\r | |
2535 | for (int j = 0; j < i; ++j) {\r | |
2536 | cursor.toNextSibling(qNameValue);\r | |
2537 | }\r | |
2538 | cursor.removeXml();\r | |
2539 | }\r | |
2540 | cursor.dispose();\r | |
2541 | }\r | |
2542 | \r | |
2543 | public void updateFvImagesNameValue(int i, String name, String value){\r | |
2544 | \r | |
2545 | XmlObject o = getfpdFlash().getFvImages();\r | |
2546 | if (o == null) {\r | |
2547 | return;\r | |
2548 | }\r | |
2549 | \r | |
2550 | QName qNameValue = new QName(xmlNs, "NameValue");\r | |
2551 | XmlCursor cursor = o.newCursor();\r | |
2552 | if (cursor.toChild(qNameValue)) {\r | |
2553 | for (int j = 0; j < i; ++j) {\r | |
2554 | cursor.toNextSibling(qNameValue);\r | |
2555 | }\r | |
2556 | FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();\r | |
2557 | nv.setName(name);\r | |
2558 | nv.setValue(value);\r | |
2559 | }\r | |
2560 | cursor.dispose();\r | |
2561 | }\r | |
2562 | \r | |
2563 | public int getFvImagesNameValueCount() {\r | |
2564 | \r | |
2565 | FvImagesDocument.FvImages fi = null;\r | |
2566 | if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {\r | |
2567 | return 0;\r | |
2568 | }\r | |
2569 | return fi.getNameValueList().size();\r | |
2570 | }\r | |
2571 | \r | |
2572 | public void getFvImagesNameValues(String[][] nv) {\r | |
2573 | \r | |
2574 | FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r | |
2575 | if (fi == null){\r | |
2576 | return;\r | |
2577 | }\r | |
2578 | List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();\r | |
2579 | int i = 0;\r | |
2580 | ListIterator li = l.listIterator();\r | |
2581 | while (li.hasNext()) {\r | |
2582 | FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li\r | |
2583 | .next();\r | |
2584 | nv[i][0] = e.getName();\r | |
2585 | nv[i][1] = e.getValue();\r | |
2586 | \r | |
2587 | i++;\r | |
2588 | }\r | |
2589 | }\r | |
2590 | \r | |
eb8ea829 | 2591 | public void getFvImagesFvImageFvImageNames (Vector<String> vImageNames) {\r |
2592 | \r | |
2593 | }\r | |
2594 | \r | |
2595 | public void AddFvImageFvImageNames (String[] fvNames) {\r | |
2596 | FvImagesDocument.FvImages fis = getfpdFlash().getFvImages();\r | |
2597 | if (fis == null || fis.getFvImageList() == null) {\r | |
2598 | genFvImagesFvImage (fvNames, "ImageName", null);\r | |
2599 | return;\r | |
2600 | }\r | |
2601 | \r | |
2602 | ListIterator<FvImagesDocument.FvImages.FvImage> li = fis.getFvImageList().listIterator();\r | |
2603 | while (li.hasNext()) {\r | |
2604 | FvImagesDocument.FvImages.FvImage fi = li.next();\r | |
2605 | if (fi.getType().toString().equals("ImageName")) {\r | |
2606 | for (int i = 0; i < fvNames.length; ++i) {\r | |
2607 | fi.addFvImageNames(fvNames[i]);\r | |
2608 | }\r | |
2609 | return;\r | |
2610 | }\r | |
2611 | }\r | |
2612 | genFvImagesFvImage (fvNames, "ImageName", null);\r | |
2613 | \r | |
2614 | }\r | |
2615 | \r | |
a13899c5 | 2616 | public void genFvImagesFvImage(String[] names, String types, Map<String, String> options) {\r |
2617 | \r | |
2618 | FvImagesDocument.FvImages fis = null;\r | |
2619 | if ((fis = getfpdFlash().getFvImages()) == null) {\r | |
2620 | fis = getfpdFlash().addNewFvImages();\r | |
2621 | }\r | |
2622 | \r | |
2623 | //\r | |
2624 | //gen FvImage with FvImageNames array\r | |
2625 | //\r | |
2626 | FvImagesDocument.FvImages.FvImage fi = fis.addNewFvImage();\r | |
2627 | for (int i = 0; i < names.length; ++i) {\r | |
2628 | fi.addFvImageNames(names[i]);\r | |
2629 | }\r | |
2630 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
2631 | if (options != null){\r | |
2632 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
2633 | }\r | |
2634 | }\r | |
2635 | \r | |
2636 | private void setFvImagesFvImageFvImageOptions(Map<String, String> options, FvImagesDocument.FvImages.FvImage fi){\r | |
2637 | FvImagesDocument.FvImages.FvImage.FvImageOptions fio = fi.getFvImageOptions();\r | |
2638 | if (fio == null){\r | |
2639 | fio = fi.addNewFvImageOptions();\r | |
2640 | }\r | |
2641 | \r | |
2642 | Set<String> key = options.keySet();\r | |
2643 | Iterator<String> i = key.iterator();\r | |
2644 | while (i.hasNext()) {\r | |
44053733 | 2645 | \r |
a13899c5 | 2646 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = fio.addNewNameValue();\r |
2647 | String k = (String)i.next();\r | |
ae0d4fd2 | 2648 | \r |
a13899c5 | 2649 | nv.setName(k);\r |
2650 | nv.setValue((String)options.get(k));\r | |
2651 | \r | |
2652 | }\r | |
2653 | \r | |
2654 | }\r | |
2655 | \r | |
44053733 | 2656 | \r |
a13899c5 | 2657 | public void removeFvImagesFvImage(int i) {\r |
2658 | \r | |
2659 | XmlObject o = getfpdFlash().getFvImages();\r | |
2660 | if (o == null) {\r | |
2661 | return;\r | |
2662 | }\r | |
2663 | \r | |
2664 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2665 | XmlCursor cursor = o.newCursor();\r | |
2666 | if (cursor.toChild(qFvImage)) {\r | |
2667 | for (int j = 0; j < i; ++j) {\r | |
2668 | cursor.toNextSibling(qFvImage);\r | |
2669 | }\r | |
2670 | cursor.removeXml();\r | |
2671 | }\r | |
2672 | cursor.dispose();\r | |
2673 | }\r | |
2674 | \r | |
eb8ea829 | 2675 | public void updateFvImageNameAll (String oldFvName, String newFvName) {\r |
2676 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r | |
2677 | return;\r | |
2678 | }\r | |
2679 | ListIterator<FvImagesDocument.FvImages.FvImage> li = getfpdFlash().getFvImages().getFvImageList().listIterator();\r | |
2680 | while (li.hasNext()) {\r | |
2681 | FvImagesDocument.FvImages.FvImage fi = li.next();\r | |
2682 | updateFvImageNamesInFvImage (fi, oldFvName, newFvName);\r | |
2683 | }\r | |
2684 | }\r | |
2685 | \r | |
2686 | public void updateFvImageNamesInFvImage (FvImagesDocument.FvImages.FvImage fi, String oldFvName, String newFvName) {\r | |
2687 | QName qFvImageNames = new QName(xmlNs, "FvImageNames");\r | |
2688 | XmlCursor cursor = fi.newCursor();\r | |
2689 | \r | |
2690 | if (cursor.toChild(qFvImageNames)) {\r | |
2691 | do {\r | |
2692 | if (cursor.getTextValue().equals(oldFvName)){\r | |
2693 | cursor.setTextValue(newFvName);\r | |
2694 | }\r | |
2695 | }while (cursor.toNextSibling(qFvImageNames));\r | |
2696 | }\r | |
2697 | \r | |
2698 | cursor.dispose();\r | |
2699 | }\r | |
2700 | \r | |
a13899c5 | 2701 | public void updateFvImagesFvImage(int i, String[] names, String types, Map<String, String> options){\r |
2702 | \r | |
2703 | XmlObject o = getfpdFlash().getFvImages();\r | |
2704 | if (o == null) {\r | |
2705 | return;\r | |
2706 | }\r | |
2707 | XmlCursor cursor = o.newCursor();\r | |
2708 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2709 | if (cursor.toChild(qFvImage)) {\r | |
2710 | for (int j = 0; j < i; ++j) {\r | |
2711 | cursor.toNextSibling(qFvImage);\r | |
2712 | }\r | |
2713 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r | |
2714 | fi.setType(FvImageTypes.Enum.forString(types));\r | |
2715 | \r | |
2716 | //\r | |
2717 | // remove old FvImageNames before adding new ones\r | |
2718 | //\r | |
2719 | QName qFvImageNames = new QName(xmlNs, "FvImageNames"); \r | |
2720 | cursor.toChild(qFvImageNames);\r | |
2721 | cursor.removeXml();\r | |
2722 | while (cursor.toNextSibling(qFvImageNames)) {\r | |
2723 | cursor.removeXml();\r | |
2724 | }\r | |
2725 | \r | |
2726 | for (int k = 0; k < names.length; ++k) {\r | |
2727 | fi.addFvImageNames(names[k]);\r | |
2728 | }\r | |
2729 | //\r | |
2730 | // remove old FvImageOptions before adding new options\r | |
2731 | //\r | |
2732 | QName qFvImageOptions = new QName(xmlNs, "FvImageOptions");\r | |
2733 | cursor.toNextSibling(qFvImageOptions);\r | |
2734 | cursor.removeXml();\r | |
2735 | \r | |
2736 | setFvImagesFvImageFvImageOptions(options, fi);\r | |
2737 | }\r | |
2738 | cursor.dispose();\r | |
2739 | }\r | |
2740 | \r | |
2741 | public int getFvImagesFvImageCount() {\r | |
2742 | \r | |
2743 | if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {\r | |
2744 | return 0;\r | |
2745 | }\r | |
2746 | return getfpdFlash().getFvImages().getFvImageList().size();\r | |
2747 | }\r | |
2748 | \r | |
ae0d4fd2 | 2749 | /**Only Get Fv image setting - name and type.\r |
2750 | * @param saa\r | |
2751 | */\r | |
2752 | public void getFvImagesFvImages(String[][] saa) {\r | |
a13899c5 | 2753 | \r |
2754 | if (getfpdFlash().getFvImages() == null) {\r | |
2755 | return;\r | |
2756 | }\r | |
2757 | List<FvImagesDocument.FvImages.FvImage> l = getfpdFlash().getFvImages().getFvImageList();\r | |
2758 | if (l == null) {\r | |
2759 | return;\r | |
2760 | }\r | |
2761 | ListIterator li = l.listIterator();\r | |
2762 | int i = 0;\r | |
2763 | while(li.hasNext()) {\r | |
2764 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)li.next();\r | |
2765 | //\r | |
2766 | // get FvImageNames array, space separated\r | |
2767 | //\r | |
2768 | List<String> lfn = fi.getFvImageNamesList();\r | |
2769 | ListIterator lfni = lfn.listIterator();\r | |
2770 | saa[i][0] = " ";\r | |
2771 | while (lfni.hasNext()) {\r | |
2772 | saa[i][0] += (String)lfni.next();\r | |
2773 | saa[i][0] += " ";\r | |
2774 | }\r | |
2775 | saa[i][0] = saa[i][0].trim();\r | |
2776 | \r | |
2777 | saa[i][1] = fi.getType()+"";\r | |
2778 | \r | |
ae0d4fd2 | 2779 | ++i;\r |
2780 | }\r | |
2781 | }\r | |
2782 | \r | |
2783 | /**Get FvImage Options for FvImage i\r | |
2784 | * @param i the ith FvImage\r | |
2785 | */\r | |
2786 | public void getFvImagesFvImageOptions(int i, Map<String, String> m) {\r | |
2787 | XmlObject o = getfpdFlash().getFvImages();\r | |
2788 | if (o == null) {\r | |
2789 | return;\r | |
2790 | }\r | |
2791 | XmlCursor cursor = o.newCursor();\r | |
2792 | QName qFvImage = new QName(xmlNs, "FvImage");\r | |
2793 | if (cursor.toChild(qFvImage)) {\r | |
2794 | for (int j = 0; j < i; ++j) {\r | |
2795 | cursor.toNextSibling(qFvImage);\r | |
a13899c5 | 2796 | }\r |
ae0d4fd2 | 2797 | FvImagesDocument.FvImages.FvImage fi = (FvImagesDocument.FvImages.FvImage)cursor.getObject();\r |
2798 | if (fi.getFvImageOptions() == null || fi.getFvImageOptions().getNameValueList() == null){\r | |
2799 | return;\r | |
a13899c5 | 2800 | }\r |
ae0d4fd2 | 2801 | ListIterator<FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue> li = fi.getFvImageOptions().getNameValueList().listIterator();\r |
2802 | while(li.hasNext()){\r | |
2803 | FvImagesDocument.FvImages.FvImage.FvImageOptions.NameValue nv = li.next();\r | |
a13899c5 | 2804 | m.put(nv.getName(), nv.getValue());\r |
2805 | }\r | |
a13899c5 | 2806 | }\r |
2807 | }\r | |
2808 | \r | |
2809 | /**\r | |
2810 | Get platform header element\r | |
2811 | @return PlatformHeaderDocument.PlatformHeader\r | |
2812 | **/\r | |
2813 | public PlatformHeaderDocument.PlatformHeader getFpdHdr() {\r | |
2814 | if (fpdHdr == null) {\r | |
2815 | fpdHdr = fpdRoot.addNewPlatformHeader();\r | |
2816 | }\r | |
1faac7b6 | 2817 | \r |
a13899c5 | 2818 | return fpdHdr;\r |
2819 | }\r | |
2820 | \r | |
a13899c5 | 2821 | public String getFpdHdrPlatformName() {\r |
2822 | return getFpdHdr().getPlatformName();\r | |
2823 | }\r | |
2824 | \r | |
2825 | public String getFpdHdrGuidValue() {\r | |
2826 | return getFpdHdr().getGuidValue();\r | |
2827 | }\r | |
2828 | \r | |
2829 | public String getFpdHdrVer() {\r | |
2830 | return getFpdHdr().getVersion();\r | |
2831 | }\r | |
2832 | \r | |
2833 | public String getFpdHdrAbs() {\r | |
2834 | return getFpdHdr().getAbstract();\r | |
2835 | }\r | |
2836 | \r | |
2837 | public String getFpdHdrDescription() {\r | |
2838 | return getFpdHdr().getDescription();\r | |
2839 | }\r | |
2840 | \r | |
2841 | public String getFpdHdrCopyright() {\r | |
2842 | return getFpdHdr().getCopyright();\r | |
2843 | }\r | |
2844 | \r | |
2845 | public String getFpdHdrLicense() {\r | |
2846 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2847 | if (l == null) {\r | |
2848 | return null;\r | |
2849 | }\r | |
2850 | return l.getStringValue();\r | |
2851 | }\r | |
2852 | \r | |
2853 | public String getFpdHdrUrl() {\r | |
2854 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2855 | if (l == null) {\r | |
2856 | return null;\r | |
2857 | }\r | |
2858 | return l.getURL();\r | |
2859 | }\r | |
2860 | \r | |
2861 | public String getFpdHdrSpec() {\r | |
2862 | \r | |
c06e8657 | 2863 | return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
a13899c5 | 2864 | // return getFpdHdr().getSpecification();\r |
2865 | }\r | |
2866 | \r | |
2867 | public void setFpdHdrPlatformName(String name){\r | |
2868 | getFpdHdr().setPlatformName(name);\r | |
2869 | }\r | |
2870 | \r | |
2871 | public void setFpdHdrGuidValue(String guid){\r | |
2872 | getFpdHdr().setGuidValue(guid);\r | |
2873 | }\r | |
2874 | \r | |
2875 | public void setFpdHdrVer(String v){\r | |
2876 | getFpdHdr().setVersion(v);\r | |
2877 | }\r | |
2878 | \r | |
2879 | public void setFpdHdrAbs(String abs) {\r | |
2880 | getFpdHdr().setAbstract(abs);\r | |
2881 | }\r | |
2882 | \r | |
2883 | public void setFpdHdrDescription(String desc){\r | |
2884 | getFpdHdr().setDescription(desc);\r | |
2885 | }\r | |
2886 | \r | |
2887 | public void setFpdHdrCopyright(String cr) {\r | |
2888 | getFpdHdr().setCopyright(cr);\r | |
2889 | }\r | |
2890 | \r | |
2891 | public void setFpdHdrLicense(String license){\r | |
2892 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2893 | if (l == null) {\r | |
2894 | getFpdHdr().addNewLicense().setStringValue(license);\r | |
2895 | }\r | |
2896 | else {\r | |
2897 | l.setStringValue(license);\r | |
2898 | }\r | |
2899 | }\r | |
2900 | \r | |
2901 | public void setFpdHdrUrl(String url){\r | |
2902 | LicenseDocument.License l = getFpdHdr().getLicense();\r | |
2903 | \r | |
2904 | l.setURL(url);\r | |
2905 | \r | |
2906 | }\r | |
2907 | \r | |
2908 | public void setFpdHdrSpec(String s){\r | |
c06e8657 | 2909 | s = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r |
a13899c5 | 2910 | getFpdHdr().setSpecification(s);\r |
2911 | }\r | |
2912 | /**\r | |
2913 | Save the processed xml contents to file\r | |
2914 | \r | |
2915 | @param fpdFile The file to save xml contents\r | |
2916 | @throws IOException Exceptions during file operation\r | |
2917 | **/\r | |
2918 | public void saveAs(File fpdFile) throws IOException {\r | |
2919 | \r | |
2920 | XmlOptions options = new XmlOptions();\r | |
2921 | \r | |
2922 | options.setCharacterEncoding("UTF-8");\r | |
2923 | options.setSavePrettyPrint();\r | |
2924 | options.setSavePrettyPrintIndent(2);\r | |
2925 | try {\r | |
2926 | fpdd.save(fpdFile, options);\r | |
2927 | } catch (IOException e) {\r | |
2928 | e.printStackTrace();\r | |
2929 | }\r | |
2930 | \r | |
2931 | }\r | |
2932 | \r | |
1800d80f | 2933 | private String listToString(List l) {\r |
a13899c5 | 2934 | if (l == null) {\r |
2935 | return null;\r | |
2936 | }\r | |
2937 | String s = " ";\r | |
2938 | ListIterator li = l.listIterator();\r | |
2939 | while(li.hasNext()) {\r | |
2940 | s += li.next();\r | |
2941 | s += " ";\r | |
2942 | }\r | |
2943 | return s.trim();\r | |
2944 | }\r | |
e232295e | 2945 | \r |
2946 | private void removeElement(XmlObject o) {\r | |
2947 | XmlCursor cursor = o.newCursor();\r | |
2948 | cursor.removeXml();\r | |
2949 | cursor.dispose();\r | |
2950 | }\r | |
a13899c5 | 2951 | }\r |
82961247 | 2952 | \r |
2953 | class PcdItemTypeConflictException extends Exception {\r | |
2954 | \r | |
2955 | /**\r | |
2956 | * \r | |
2957 | */\r | |
2958 | private static final long serialVersionUID = 1L;\r | |
2959 | private String details = null;\r | |
2960 | \r | |
34c614e1 | 2961 | PcdItemTypeConflictException(String pcdName, String info){\r |
1bf9fa5a | 2962 | ModuleIdentification mi = WorkspaceProfile.getModuleId(info);\r |
3658f95e | 2963 | details = pcdName + " ItemType Conflicts with " + mi.getName() + " in Pkg " + mi.getPackageId().getName();\r |
82961247 | 2964 | }\r |
2965 | \r | |
2966 | public String getMessage() {\r | |
2967 | return details;\r | |
2968 | }\r | |
2969 | }\r | |
2970 | \r | |
2971 | class PcdDeclNotFound extends Exception {\r | |
2972 | \r | |
2973 | /**\r | |
2974 | * \r | |
2975 | */\r | |
2976 | private static final long serialVersionUID = 1L;\r | |
2977 | private String details = null;\r | |
2978 | \r | |
2979 | PcdDeclNotFound(String info) {\r | |
4da2e625 | 2980 | details = "PcdDeclNotFound: " + info;\r |
82961247 | 2981 | }\r |
2982 | \r | |
2983 | public String getMessage() {\r | |
2984 | return details;\r | |
2985 | }\r | |
2986 | }\r | |
2987 | \r | |
2988 | class PcdValueMalFormed extends Exception {\r | |
2989 | \r | |
2990 | /**\r | |
2991 | * \r | |
2992 | */\r | |
2993 | private static final long serialVersionUID = 1L;\r | |
2994 | private String details = null;\r | |
2995 | \r | |
2996 | PcdValueMalFormed(String info) {\r | |
4da2e625 | 2997 | details = "PcdValueMalFormed: " + info;\r |
82961247 | 2998 | }\r |
2999 | \r | |
3000 | public String getMessage() {\r | |
3001 | return details;\r | |
3002 | }\r | |
3003 | }\r |