a. Enhanced toolchain setting UI for ModuleSa build options and global build options.
[mirror_edk2.git] / Tools / Source / FrameworkWizard / src / org / tianocore / frameworkwizard / platform / ui / FpdFileContents.java
CommitLineData
a13899c5 1/** @file\r
2 Java class FpdFileContents is used to parse fpd xml file.\r
3 \r
4Copyright (c) 2006, Intel Corporation\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12**/\r
13package org.tianocore.frameworkwizard.platform.ui;\r
14\r
15import java.io.File;\r
16import java.io.IOException;\r
17import java.math.BigInteger;\r
18import java.util.ArrayList;\r
19import java.util.HashMap;\r
20import java.util.Iterator;\r
21import java.util.LinkedHashMap;\r
22import java.util.List;\r
23import java.util.ListIterator;\r
24import java.util.Map;\r
25import java.util.Set;\r
6a09eb19 26import java.util.Vector;\r
a13899c5 27\r
28import javax.xml.namespace.QName;\r
29\r
30import org.apache.xmlbeans.XmlCursor;\r
31import org.apache.xmlbeans.XmlObject;\r
32import org.apache.xmlbeans.XmlOptions;\r
33import org.tianocore.AntTaskDocument;\r
34import org.tianocore.BuildOptionsDocument;\r
35import org.tianocore.DynamicPcdBuildDefinitionsDocument;\r
6cba26e8 36import org.tianocore.EfiSectionType;\r
a13899c5 37import org.tianocore.FlashDefinitionFileDocument;\r
a13899c5 38import org.tianocore.FlashDocument;\r
39import org.tianocore.FrameworkModulesDocument;\r
6a09eb19 40import org.tianocore.IntermediateOutputType;\r
a13899c5 41import org.tianocore.LibrariesDocument;\r
42import org.tianocore.ModuleSADocument;\r
8f55ea73 43import org.tianocore.ModuleSaBuildOptionsDocument;\r
a13899c5 44import org.tianocore.ModuleSurfaceAreaDocument;\r
45import org.tianocore.OptionDocument;\r
46import org.tianocore.OptionsDocument;\r
47import org.tianocore.PcdBuildDefinitionDocument;\r
48import org.tianocore.PcdCodedDocument;\r
49import org.tianocore.PcdDataTypes;\r
50import org.tianocore.PcdDeclarationsDocument;\r
51import org.tianocore.PcdItemTypes;\r
52import org.tianocore.PlatformDefinitionsDocument;\r
53import org.tianocore.PlatformSurfaceAreaDocument;\r
54import org.tianocore.FvImageTypes;\r
55import org.tianocore.FvImagesDocument;\r
56import org.tianocore.LicenseDocument;\r
57import org.tianocore.PlatformHeaderDocument;\r
58import org.tianocore.SkuInfoDocument;\r
59import org.tianocore.UserDefinedAntTasksDocument;\r
1bf9fa5a 60import org.tianocore.UserExtensionsDocument;\r
61import org.tianocore.frameworkwizard.platform.ui.global.WorkspaceProfile;\r
a13899c5 62import org.tianocore.frameworkwizard.platform.ui.global.SurfaceAreaQuery;\r
3658f95e 63import org.tianocore.frameworkwizard.module.Identifications.ModuleIdentification;\r
64import 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
70public 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
98c20797 991 }\r
992 else {\r
993 saa[i][4] = "";\r
1800d80f 994 }\r
bf5abaff 995 \r
1800d80f 996 saa[i][5] = opt.getStringValue();\r
997 \r
998 ++i;\r
999 }\r
1000 }\r
1001 \r
1002 public int getModuleSAOptionsCount(String moduleKey){\r
1003 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
e232295e 1004 if (msa == null || msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null\r
1800d80f 1005 || msa.getModuleSaBuildOptions().getOptions().getOptionList() == null) {\r
1006 return 0;\r
1007 }\r
1008 return msa.getModuleSaBuildOptions().getOptions().getOptionList().size();\r
1009 }\r
1010 \r
1011 public void genModuleSAOptionsOpt(String moduleKey, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
1012 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
1013 if (msa.getModuleSaBuildOptions() == null) {\r
1014 msa.addNewModuleSaBuildOptions();\r
1015 }\r
1016 if (msa.getModuleSaBuildOptions().getOptions() == null){\r
1017 msa.getModuleSaBuildOptions().addNewOptions();\r
1018 }\r
1019 OptionDocument.Option opt = msa.getModuleSaBuildOptions().getOptions().addNewOption();\r
1020 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
1021 }\r
1022 \r
1023 public void removeModuleSAOptionsOpt(String moduleKey, int i) {\r
1024 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
1025 if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r
1026 return ;\r
1027 }\r
1028 OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r
1029 XmlCursor cursor = opts.newCursor();\r
1030 if (cursor.toFirstChild()) {\r
1031 for (int j = 0; j < i; ++j){\r
1032 cursor.toNextSibling();\r
1033 }\r
1034 cursor.removeXml();\r
1035 }\r
1036 cursor.dispose();\r
1037 }\r
1038 \r
1039 public void updateModuleSAOptionsOpt(String moduleKey, int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
1040 ModuleSADocument.ModuleSA msa = getModuleSA(moduleKey);\r
1041 if (msa.getModuleSaBuildOptions() == null || msa.getModuleSaBuildOptions().getOptions() == null) {\r
1042 return ;\r
1043 }\r
1044 OptionsDocument.Options opts = msa.getModuleSaBuildOptions().getOptions();\r
1045 XmlCursor cursor = opts.newCursor();\r
1046 if (cursor.toFirstChild()) {\r
1047 for (int j = 0; j < i; ++j){\r
1048 cursor.toNextSibling();\r
1049 }\r
1050 OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r
1051 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
1052 }\r
1053 cursor.dispose();\r
1054 }\r
1055 \r
a13899c5 1056 /**add pcd information of module mi to a ModuleSA. \r
1057 * @param mi\r
1058 * @param moduleSa if null, generate a new ModuleSA.\r
1059 */\r
bf5abaff 1060 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi, String arch, ModuleSADocument.ModuleSA moduleSa) throws Exception {\r
a13899c5 1061 //ToDo add Arch filter\r
1062 \r
1063 try {\r
af25df16 1064 if (moduleSa == null) {\r
bf5abaff 1065 moduleSa = genModuleSA(mi, arch);\r
af25df16 1066 }\r
1067 \r
1bf9fa5a 1068 ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = (ModuleSurfaceAreaDocument.ModuleSurfaceArea)WorkspaceProfile.getModuleXmlObject(mi);\r
a13899c5 1069 if (msa.getPcdCoded() == null) {\r
1070 return;\r
1071 }\r
af25df16 1072 \r
a13899c5 1073 Map<String, XmlObject> m = new HashMap<String, XmlObject>();\r
1074 m.put("ModuleSurfaceArea", msa);\r
1075 SurfaceAreaQuery.setDoc(m);\r
daa4663b 1076 PackageIdentification[] depPkgs = SurfaceAreaQuery.getDependencePkg(null, mi);\r
a13899c5 1077 //\r
1078 // Implementing InitializePlatformPcdBuildDefinitions\r
1079 //\r
1080 List<PcdCodedDocument.PcdCoded.PcdEntry> l = msa.getPcdCoded().getPcdEntryList();\r
1081 ListIterator li = l.listIterator();\r
1082 while(li.hasNext()) {\r
1083 PcdCodedDocument.PcdCoded.PcdEntry msaPcd = (PcdCodedDocument.PcdCoded.PcdEntry)li.next();\r
1084 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = LookupPcdDeclaration(msaPcd, depPkgs);\r
1085 if (spdPcd == null) {\r
1086 //\r
1087 // ToDo Error \r
1088 //\r
34c614e1 1089 throw new PcdDeclNotFound("No Declaration for PCD Entry " + msaPcd.getCName() + " in Module " + mi.getName());\r
a13899c5 1090 }\r
1091 //\r
1092 // AddItem to ModuleSA PcdBuildDefinitions\r
1093 //\r
1094 String defaultVal = msaPcd.getDefaultValue() == null ? spdPcd.getDefaultValue() : msaPcd.getDefaultValue();\r
908b1c05 1095 \r
a13899c5 1096 genPcdData(msaPcd.getCName(), spdPcd.getToken(), msaPcd.getTokenSpaceGuidCName(), msaPcd.getPcdItemType().toString(), spdPcd.getDatumType()+"", defaultVal, moduleSa);\r
1097 }\r
1098 \r
1099 }\r
1100 catch (Exception e){\r
34c614e1 1101 \r
82961247 1102 throw e; \r
a13899c5 1103 }\r
1104 \r
1105 }\r
1106 \r
1107 private PcdDeclarationsDocument.PcdDeclarations.PcdEntry LookupPcdDeclaration (PcdCodedDocument.PcdCoded.PcdEntry msaPcd, PackageIdentification[] depPkgs) {\r
1108 \r
a13899c5 1109 PcdDeclarationsDocument.PcdDeclarations.PcdEntry spdPcd = null;\r
1110 for (int i = 0; i < depPkgs.length; ++i) {\r
3658f95e 1111\r
1112 XmlObject[] xo = SurfaceAreaQuery.getSpdPcdDeclarations(depPkgs[i]);\r
a13899c5 1113 if (xo == null) {\r
1114 continue;\r
1115 }\r
1116 for (int j = 0; j < xo.length; ++j) {\r
1117 spdPcd = (PcdDeclarationsDocument.PcdDeclarations.PcdEntry)xo[j];\r
1118 if (msaPcd.getTokenSpaceGuidCName() == null) {\r
1119 if (spdPcd.getCName().equals(msaPcd.getCName())) {\r
1120 return spdPcd;\r
1121 }\r
1122 }\r
1123 else{\r
1124 if (spdPcd.getCName().equals(msaPcd.getCName()) && spdPcd.getTokenSpaceGuidCName().equals(msaPcd.getTokenSpaceGuidCName())) {\r
1125 return spdPcd;\r
1126 }\r
1127 }\r
1128 \r
1129 }\r
1130 \r
1131 }\r
1132 return null;\r
1133 }\r
1134 \r
bf5abaff 1135 private ModuleSADocument.ModuleSA genModuleSA (ModuleIdentification mi, String arch) {\r
1bf9fa5a 1136 PackageIdentification pi = WorkspaceProfile.getPackageForModule(mi);\r
a13899c5 1137 ModuleSADocument.ModuleSA msa = getfpdFrameworkModules().addNewModuleSA();\r
82dcbb45 1138 XmlCursor cursor = msa.newCursor();\r
1139 try{\r
3658f95e 1140 String comment = "Mod: " + mi.getName() + " Type: " + SurfaceAreaQuery.getModuleType(mi) + " Path: "\r
1141 + mi.getPath().substring(System.getenv("WORKSPACE").length() + 1);\r
82dcbb45 1142 cursor.insertComment(comment);\r
1143 }\r
1144 catch(Exception e){\r
1145 e.printStackTrace();\r
1146 }\r
1147 finally { \r
1148 cursor.dispose();\r
1149 }\r
a13899c5 1150 msa.setModuleGuid(mi.getGuid());\r
1151 msa.setModuleVersion(mi.getVersion());\r
1152 msa.setPackageGuid(pi.getGuid());\r
1153 msa.setPackageVersion(pi.getVersion());\r
bf5abaff 1154 if (arch != null) {\r
1155 Vector<String> v = new Vector<String>();\r
1156 v.add(arch);\r
1157 msa.setSupArchList(v); \r
1158 }\r
a13899c5 1159 \r
1160 return msa;\r
1161 }\r
1162 \r
82961247 1163 private void genPcdData (String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal, ModuleSADocument.ModuleSA moduleSa) \r
1164 throws PcdItemTypeConflictException, PcdValueMalFormed{\r
a13899c5 1165 if (moduleSa.getPcdBuildDefinition() == null){\r
1166 moduleSa.addNewPcdBuildDefinition();\r
1167 }\r
1168 //\r
1169 // constructe pcd to modulesa mapping first.\r
1170 // Attention : for any error condition, remove from map this pcd.\r
1171 //\r
1172 ArrayList<String> pcdConsumer = LookupPlatformPcdData(cName + " " + tsGuid);\r
1173 if (pcdConsumer == null) {\r
1174 pcdConsumer = new ArrayList<String>();\r
1175 }\r
1bf9fa5a 1176 //\r
1177 // Using existing Pcd type, if this pcd already exists in other ModuleSA\r
1178 //\r
1179 if (pcdConsumer.size() > 0) {\r
1180 String[] valPart = pcdConsumer.get(0).split(" ");\r
1181 itemType = valPart[5];\r
1182 }\r
a13899c5 1183 String listValue = moduleSa.getModuleGuid() + " " + moduleSa.getModuleVersion() \r
bf5abaff 1184 + " " + moduleSa.getPackageGuid() + " " + moduleSa.getPackageVersion() + " " + listToString(moduleSa.getSupArchList())\r
a13899c5 1185 + " " + itemType;\r
1186 pcdConsumer.add(listValue);\r
1187 dynPcdMap.put(cName + " " + tsGuid, pcdConsumer);\r
1bf9fa5a 1188 \r
a13899c5 1189 PcdBuildDefinitionDocument.PcdBuildDefinition.PcdData fpdPcd = moduleSa.getPcdBuildDefinition().addNewPcdData();\r
1190 fpdPcd.setCName(cName);\r
1191 fpdPcd.setToken(token);\r
1192 fpdPcd.setTokenSpaceGuidCName(tsGuid);\r
1193 fpdPcd.setDatumType(PcdDataTypes.Enum.forString(dataType));\r
1194 fpdPcd.setItemType(PcdItemTypes.Enum.forString(itemType));\r
a390c35d 1195 \r
1196 if (defaultVal != null){\r
1197 fpdPcd.setValue(defaultVal);\r
1198 }\r
1199 else {\r
1200 if (dataType.equals("UINT8") || dataType.equals("UINT16") || dataType.equals("UINT32") || dataType.equals("UINT64")) {\r
1201 fpdPcd.setValue("0");\r
1202 }\r
1203 if (dataType.equals("BOOLEAN")){\r
b3151273 1204 fpdPcd.setValue("FALSE");\r
a390c35d 1205 }\r
1206 if (dataType.equals("VOID*")) {\r
1207 fpdPcd.setValue("");\r
1208 }\r
1209 }\r
1bf9fa5a 1210 //\r
1211 // Using existing pcd value, if this pcd already exists in other moduleSa.\r
1212 //\r
1213 if (defaultPcdValue.get(cName + " " + tsGuid) == null) {\r
1214 defaultPcdValue.put(cName + " " + tsGuid, fpdPcd.getValue());\r
1215 }\r
1216 else {\r
1217 fpdPcd.setValue(defaultPcdValue.get(cName + " " + tsGuid));\r
1218 }\r
1219 \r
802e0055 1220 if (dataType.equals("UINT8")){\r
1221 fpdPcd.setMaxDatumSize(1);\r
1222 }\r
1223 if (dataType.equals("UINT16")) {\r
1224 fpdPcd.setMaxDatumSize(2);\r
1225 }\r
1226 if (dataType.equals("UINT32")) {\r
1227 fpdPcd.setMaxDatumSize(4);\r
1228 }\r
1229 if (dataType.equals("UINT64")){\r
1230 fpdPcd.setMaxDatumSize(8);\r
1231 }\r
1232 if (dataType.equals("BOOLEAN")){\r
1233 fpdPcd.setMaxDatumSize(1);\r
1234 }\r
1235 if (dataType.equals("VOID*")) {\r
1236 int maxSize = setMaxSizeForPointer(fpdPcd.getValue());\r
1237 fpdPcd.setMaxDatumSize(maxSize);\r
1238 }\r
a13899c5 1239 \r
a390c35d 1240 \r
a13899c5 1241 if (itemType.equals("DYNAMIC") || itemType.equals("DYNAMIC_EX")) {\r
1242 ArrayList<String> al = LookupDynamicPcdBuildDefinition(cName + " " + tsGuid);\r
1243 //\r
1244 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.\r
1245 // so need to add one dyn pcd.\r
1246 //\r
1247 if (al.size() == 1) {\r
1248 addDynamicPcdBuildData(cName, token, tsGuid, itemType, dataType, defaultVal);\r
1249 }\r
1250 }\r
1bf9fa5a 1251 \r
a13899c5 1252 }\r
1253 \r
908b1c05 1254 public int setMaxSizeForPointer(String datum) throws PcdValueMalFormed{\r
a13899c5 1255 if (datum == null) {\r
1256 return 0;\r
1257 }\r
1258 char ch = datum.charAt(0);\r
1259 int start, end;\r
1260 String strValue;\r
1261 //\r
1262 // For void* type PCD, only three datum is support:\r
1263 // 1) Unicode: string with start char is "L"\r
1264 // 2) Ansci: String is ""\r
1265 // 3) byte array: String start char "{"\r
1266 // \r
1267 if (ch == 'L') {\r
1268 start = datum.indexOf('\"');\r
1269 end = datum.lastIndexOf('\"');\r
1270 if ((start > end) || \r
1271 (end > datum.length())||\r
1272 ((start == end) && (datum.length() > 0))) {\r
1273 //ToDo Error handling here\r
82961247 1274 throw new PcdValueMalFormed (datum);\r
a13899c5 1275 }\r
1276\r
1277 strValue = datum.substring(start + 1, end);\r
1278 return strValue.length() * 2;\r
1279 } else if (ch == '\"'){\r
1280 start = datum.indexOf('\"');\r
1281 end = datum.lastIndexOf('\"');\r
1282 if ((start > end) || \r
1283 (end > datum.length())||\r
1284 ((start == end) && (datum.length() > 0))) {\r
82961247 1285 throw new PcdValueMalFormed (datum);\r
a13899c5 1286 }\r
1287 strValue = datum.substring(start + 1, end);\r
1288 return strValue.length();\r
1289 } else if (ch =='{') {\r
1290 String[] strValueArray;\r
1291\r
1292 start = datum.indexOf('{');\r
1293 end = datum.lastIndexOf('}');\r
1294 strValue = datum.substring(start + 1, end);\r
1295 strValue = strValue.trim();\r
1296 if (strValue.length() == 0) {\r
1297 return 0;\r
1298 }\r
1299 strValueArray = strValue.split(",");\r
1300 for (int index = 0; index < strValueArray.length; index ++) {\r
1301 Integer value = Integer.decode(strValueArray[index].trim());\r
1302 \r
1303 if (value > 0xFF) {\r
1304// "[FPD file error] The datum type of PCD %s in %s is VOID*, "+\r
a70d444e 1305// "it must be a byte array. But the element of %s exceed the byte range",\r
82961247 1306 throw new PcdValueMalFormed (datum); \r
a13899c5 1307 }\r
1308 }\r
1309 return strValueArray.length;\r
1310\r
1311\r
1312 } else {\r
1313// "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+\r
1314// "1) UNICODE string: like L\"xxxx\";\r\n"+\r
1315// "2) ANSIC string: like \"xxx\";\r\n"+\r
1316// "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+\r
1317// "but the datum in seems does not following above format!",\r
82961247 1318 throw new PcdValueMalFormed (datum);\r
a13899c5 1319 \r
1320 }\r
1321 }\r
1322 \r
1323 private ArrayList<String> LookupDynamicPcdBuildDefinition(String dynPcdKey) {\r
1324 ArrayList<String> al = dynPcdMap.get(dynPcdKey);\r
1325 \r
1326 return al;\r
1327 }\r
1328 \r
1329 private ArrayList<String> LookupPlatformPcdData(String pcdKey) {\r
1330 \r
34c614e1 1331 return dynPcdMap.get(pcdKey);\r
a13899c5 1332 }\r
1333 \r
1334 public int getDynamicPcdBuildDataCount() {\r
5af6b67f 1335 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1336 removeElement(getfpdDynPcdBuildDefs());\r
1337 fpdDynPcdBuildDefs = null;\r
a13899c5 1338 return 0;\r
1339 }\r
1340 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();\r
1341 }\r
1342 \r
1343 public void getDynamicPcdBuildData(String[][] saa) {\r
5af6b67f 1344 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1345 removeElement(getfpdDynPcdBuildDefs());\r
1346 fpdDynPcdBuildDefs = null;\r
a13899c5 1347 return ;\r
1348 }\r
1349 List<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> l = getfpdDynPcdBuildDefs().getPcdBuildDataList();\r
1350 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData> li = l.listIterator();\r
1351 int i = 0;\r
1352 while(li.hasNext()) {\r
1353 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcd = li.next();\r
1354 saa[i][0] = dynPcd.getCName();\r
1355 saa[i][1] = dynPcd.getToken().toString();\r
1356 saa[i][2] = dynPcd.getTokenSpaceGuidCName();\r
1357 saa[i][3] = dynPcd.getMaxDatumSize()+"";\r
1358 saa[i][4] = dynPcd.getDatumType().toString();\r
1359 \r
1360 ++i;\r
1361 }\r
1362 }\r
1363 \r
908b1c05 1364 public void addDynamicPcdBuildData(String cName, Object token, String tsGuid, String itemType, String dataType, String defaultVal) \r
82961247 1365 throws PcdValueMalFormed{\r
a13899c5 1366 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData dynPcdData = getfpdDynPcdBuildDefs().addNewPcdBuildData();\r
1367 dynPcdData.setItemType(PcdItemTypes.Enum.forString(itemType));\r
1368 dynPcdData.setCName(cName);\r
1369 dynPcdData.setToken(token);\r
1370 dynPcdData.setTokenSpaceGuidCName(tsGuid);\r
1371 dynPcdData.setDatumType(PcdDataTypes.Enum.forString(dataType));\r
1372 \r
1373 BigInteger bigInt = new BigInteger("0");\r
1374 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = dynPcdData.addNewSkuInfo();\r
1375 skuInfo.setSkuId(bigInt);\r
1376 if (defaultVal != null){\r
1377 skuInfo.setValue(defaultVal);\r
1378 }\r
1379 else {\r
1380 if (dataType.equals("UINT8")){\r
1381 skuInfo.setValue("0");\r
1382 }\r
1383 if (dataType.equals("UINT16")) {\r
1384 skuInfo.setValue("0");\r
1385 }\r
1386 if (dataType.equals("UINT32")) {\r
1387 skuInfo.setValue("0");\r
1388 }\r
1389 if (dataType.equals("UINT64")){\r
1390 skuInfo.setValue("0");\r
1391 }\r
1392 if (dataType.equals("BOOLEAN")){\r
1393 skuInfo.setValue("false");\r
1394 }\r
1395 if (dataType.equals("VOID*")) {\r
1396 skuInfo.setValue("");\r
1397 }\r
1398 }\r
1399 if (dataType.equals("UINT8")){\r
1400 dynPcdData.setMaxDatumSize(1);\r
1401 }\r
1402 if (dataType.equals("UINT16")) {\r
1403 dynPcdData.setMaxDatumSize(2);\r
1404 }\r
1405 if (dataType.equals("UINT32")) {\r
1406 dynPcdData.setMaxDatumSize(4);\r
1407 }\r
1408 if (dataType.equals("UINT64")){\r
1409 dynPcdData.setMaxDatumSize(8);\r
1410 }\r
1411 if (dataType.equals("BOOLEAN")){\r
1412 dynPcdData.setMaxDatumSize(1);\r
1413 }\r
1414 if (dataType.equals("VOID*")) {\r
1415 int maxSize = setMaxSizeForPointer(defaultVal);\r
1416 dynPcdData.setMaxDatumSize(maxSize);\r
1417 }\r
1418 }\r
1419 \r
908b1c05 1420 public void removeDynamicPcdBuildData(String cName, String tsGuid) {\r
e232295e 1421 XmlObject o = fpdRoot.getDynamicPcdBuildDefinitions();\r
1422 if (o == null) {\r
1423 return;\r
1424 }\r
a13899c5 1425 \r
1426 XmlCursor cursor = o.newCursor();\r
1427 if (cursor.toFirstChild()) {\r
af25df16 1428 do {\r
1429 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdBuildData = \r
1430 (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
908b1c05 1431 if (pcdBuildData.getCName().equals(cName) && pcdBuildData.getTokenSpaceGuidCName().equals(tsGuid)) {\r
add40ab2 1432 \r
1433 if (getDynamicPcdBuildDataCount() == 1) {\r
af25df16 1434 cursor.toParent();\r
af25df16 1435 }\r
add40ab2 1436 cursor.removeXml();\r
908b1c05 1437 cursor.dispose();\r
1438 return;\r
1439 }\r
a13899c5 1440 }\r
af25df16 1441 while (cursor.toNextSibling());\r
a13899c5 1442 }\r
1443 cursor.dispose();\r
1444 }\r
1445 //\r
1446 // Get the Sku Info count of ith dyn pcd element.\r
1447 //\r
1448 public int getDynamicPcdSkuInfoCount(int i){\r
e232295e 1449 if (fpdRoot.getDynamicPcdBuildDefinitions() == null || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList() == null \r
1450 || fpdRoot.getDynamicPcdBuildDefinitions().getPcdBuildDataList().size() == 0) {\r
a13899c5 1451 return 0;\r
1452 }\r
1453 \r
1454 int skuInfoCount = 0;\r
1455 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1456 if (cursor.toFirstChild()) {\r
1457 for (int j = 0; j < i; ++j) {\r
1458 cursor.toNextSibling();\r
1459 }\r
1460 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1461 if (pcdData.getSkuInfoList() == null) {\r
1462 skuInfoCount = 0;\r
1463 }\r
1464 else {\r
1465 skuInfoCount = pcdData.getSkuInfoList().size();\r
1466 }\r
1467 }\r
1468 cursor.dispose();\r
1469 return skuInfoCount;\r
1470 }\r
1471 \r
1472 public void getDynamicPcdSkuInfos(int i, String[][] saa){\r
1473 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1474 removeElement(getfpdDynPcdBuildDefs());\r
1475 fpdDynPcdBuildDefs = null;\r
a13899c5 1476 return;\r
1477 }\r
1478 \r
1479 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1480 if (cursor.toFirstChild()) {\r
1481 for (int j = 0; j < i; ++j) {\r
1482 cursor.toNextSibling();\r
1483 }\r
1484 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1485 if (pcdData.getSkuInfoList() == null) {\r
1486 cursor.dispose();\r
1487 return;\r
1488 }\r
1489 else {\r
1490 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r
1491 int k = 0;\r
1492 while (li.hasNext()) {\r
1493 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r
1494 saa[k][0] = skuInfo.getSkuId()+"";\r
1495 saa[k][1] = skuInfo.getVariableName();\r
1496 saa[k][2] = skuInfo.getVariableGuid();\r
1497 saa[k][3] = skuInfo.getVariableOffset();\r
1498 saa[k][4] = skuInfo.getHiiDefaultValue();\r
1499 saa[k][5] = skuInfo.getVpdOffset();\r
1500 saa[k][6] = skuInfo.getValue();\r
1501 ++k;\r
1502 }\r
1503 \r
1504 }\r
1505 }\r
1506 cursor.dispose();\r
1507 \r
1508 }\r
1509 \r
1510 public String getDynamicPcdBuildDataValue(int i){\r
1511 String value = null;\r
1512 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1513 removeElement(getfpdDynPcdBuildDefs());\r
1514 fpdDynPcdBuildDefs = null;\r
a13899c5 1515 return value;\r
1516 }\r
1517 \r
1518 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1519 if (cursor.toFirstChild()) {\r
1520 for (int j = 0; j < i; ++j) {\r
1521 cursor.toNextSibling();\r
1522 }\r
1523 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1524 if (pcdData.getSkuInfoList() == null) {\r
1525 value = null;\r
1526 }\r
1527 else {\r
1528 value = pcdData.getSkuInfoArray(0).getValue();\r
1529 }\r
1530 }\r
1531 cursor.dispose();\r
1532 return value;\r
1533 }\r
1534 \r
1535 public String getDynamicPcdBuildDataVpdOffset(int i){\r
1536 String vpdOffset = null;\r
1537 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1538 removeElement(getfpdDynPcdBuildDefs());\r
1539 fpdDynPcdBuildDefs = null;\r
a13899c5 1540 return vpdOffset;\r
1541 }\r
1542 \r
1543 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1544 if (cursor.toFirstChild()) {\r
1545 for (int j = 0; j < i; ++j) {\r
1546 cursor.toNextSibling();\r
1547 }\r
1548 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1549 if (pcdData.getSkuInfoList() == null) {\r
1550 vpdOffset = null;\r
1551 }\r
1552 else {\r
1553 vpdOffset = pcdData.getSkuInfoArray(0).getVpdOffset();\r
1554 }\r
1555 }\r
1556 cursor.dispose();\r
1557 return vpdOffset;\r
1558 }\r
1559 \r
1560 public void removeDynamicPcdBuildDataSkuInfo(int i) {\r
1561 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
e232295e 1562 removeElement(getfpdDynPcdBuildDefs());\r
1563 fpdDynPcdBuildDefs = null;\r
a13899c5 1564 return;\r
1565 }\r
1566 \r
1567 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1568 if (cursor.toFirstChild()) {\r
1569 for (int j = 0; j < i; ++j) {\r
1570 cursor.toNextSibling();\r
1571 }\r
1572 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1573 if (pcdData.getSkuInfoList() == null) {\r
1574 cursor.dispose();\r
1575 return;\r
1576 }\r
1577 else {\r
1578 QName qSkuInfo = new QName(xmlNs, "SkuInfo");\r
1579 cursor.toChild(qSkuInfo);\r
1580 cursor.removeXml();\r
1581 }\r
1582 }\r
1583 cursor.dispose();\r
1584 }\r
1585 //\r
1586 // generate sku info for ith dyn pcd build data.\r
1587 //\r
1588 public void genDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r
1589 String hiiDefault, String vpdOffset, String value, int i) {\r
e232295e 1590// if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
1591// return;\r
1592// }\r
a13899c5 1593 \r
1594 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1595 if (cursor.toFirstChild()) {\r
1596 for (int j = 0; j < i; ++j) {\r
1597 cursor.toNextSibling();\r
1598 }\r
1599 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1600 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = pcdData.addNewSkuInfo();\r
1601 skuInfo.setSkuId(new BigInteger(id));\r
1602 if (varName != null){\r
1603 skuInfo.setVariableName(varName);\r
1604 skuInfo.setVariableGuid(varGuid);\r
1605 skuInfo.setVariableOffset(varOffset);\r
1606 skuInfo.setHiiDefaultValue(hiiDefault);\r
1607 }\r
1608 else if (vpdOffset != null){\r
1609 skuInfo.setVpdOffset(vpdOffset);\r
1610 }\r
1611 else{\r
1612 skuInfo.setValue(value);\r
1613 }\r
1614 }\r
1615 }\r
1616 \r
1617 public void updateDynamicPcdBuildDataSkuInfo(String id, String varName, String varGuid, String varOffset, \r
1618 String hiiDefault, String vpdOffset, String value, int i){\r
e232295e 1619// if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {\r
1620// return;\r
1621// }\r
a13899c5 1622 \r
1623 XmlCursor cursor = getfpdDynPcdBuildDefs().newCursor();\r
1624 if (cursor.toFirstChild()) {\r
1625 for (int j = 0; j < i; ++j) {\r
1626 cursor.toNextSibling();\r
1627 }\r
1628 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData pcdData = (DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData)cursor.getObject();\r
1629 ListIterator<DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo> li = pcdData.getSkuInfoList().listIterator();\r
1630 while (li.hasNext()) {\r
1631 DynamicPcdBuildDefinitionsDocument.DynamicPcdBuildDefinitions.PcdBuildData.SkuInfo skuInfo = li.next();\r
1632 if (skuInfo.getSkuId().toString().equals(id)){\r
1633 if (varName != null){\r
1634 skuInfo.setVariableName(varName);\r
1635 skuInfo.setVariableGuid(varGuid);\r
1636 skuInfo.setVariableOffset(varOffset);\r
1637 skuInfo.setHiiDefaultValue(hiiDefault);\r
1638 }\r
1639 else if (vpdOffset != null){\r
1640 skuInfo.setVpdOffset(vpdOffset);\r
1641 }\r
1642 else{\r
1643 skuInfo.setValue(value);\r
1644 }\r
1645 break;\r
1646 }\r
1647 }\r
1648 }\r
1649 }\r
1650 \r
a13899c5 1651 public BuildOptionsDocument.BuildOptions getfpdBuildOpts() {\r
1652 if (fpdBuildOpts == null) {\r
1653 fpdBuildOpts = fpdRoot.addNewBuildOptions();\r
1654 }\r
1655 return fpdBuildOpts;\r
1656 }\r
1657 \r
2b70a636 1658 public void genBuildOptionsUserExtensions(String fvName, String outputFileName, Vector<String[]> includeModules) {\r
eb8ea829 1659 QName elementFvName = new QName (xmlNs, "FvName");\r
1660 QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r
1661 QName elementInfFileName = new QName(xmlNs, "InfFileName");\r
1662 QName elementModule = new QName(xmlNs, "Module");\r
1663 \r
1bf9fa5a 1664 UserExtensionsDocument.UserExtensions userExts = getfpdBuildOpts().addNewUserExtensions();\r
1665 userExts.setUserID("IMAGES");\r
1666 userExts.setIdentifier(new BigInteger("1"));\r
1667 XmlCursor cursor = userExts.newCursor();\r
1668 cursor.toEndToken();\r
1669 \r
eb8ea829 1670 cursor.beginElement(elementFvName);\r
1bf9fa5a 1671 cursor.insertChars(fvName);\r
1672 cursor.toNextToken();\r
1673 \r
eb8ea829 1674 cursor.beginElement(elementInfFileName);\r
61919f8c 1675 cursor.insertChars(fvName + ".inf");\r
1bf9fa5a 1676 cursor.toNextToken();\r
1677 \r
eb8ea829 1678 cursor.beginElement(elementIncludeModules);\r
2b70a636 1679 for (int i = 0; i < includeModules.size(); ++i) {\r
eb8ea829 1680 cursor.beginElement(elementModule);\r
2b70a636 1681 cursor.insertAttributeWithValue("ModuleGuid", includeModules.get(i)[0]);\r
1682 cursor.insertAttributeWithValue("BaseName", includeModules.get(i)[1]);\r
1bf9fa5a 1683 cursor.toEndToken();\r
1684 cursor.toNextToken();\r
1685 }\r
1686 cursor.dispose();\r
1687 }\r
1688 \r
1689 public int getUserExtsIncModCount (String fvName) {\r
1690 if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
1691 return -1;\r
1692 }\r
1693 ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
eb8ea829 1694 QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r
1bf9fa5a 1695 while (li.hasNext()) {\r
1696 UserExtensionsDocument.UserExtensions ues = li.next();\r
1697 if (!ues.getUserID().equals("IMAGES")) {\r
1698 continue;\r
1699 }\r
1700 XmlCursor cursor = ues.newCursor();\r
1701 cursor.toFirstChild();\r
1702 String elementName = cursor.getTextValue();\r
1703 if (elementName.equals(fvName)) {\r
eb8ea829 1704 cursor.toNextSibling(elementIncludeModules);\r
1bf9fa5a 1705 if (cursor.toFirstChild()) {\r
1706 int i = 1;\r
1707 for (i = 1; cursor.toNextSibling(); ++i);\r
1708 cursor.dispose();\r
1709 return i;\r
1710 }\r
1711 cursor.dispose();\r
1712 return 0;\r
1713 }\r
1714 cursor.dispose();\r
1715 }\r
1716 return -1;\r
1717 }\r
1718 \r
1719 public void getUserExtsIncMods(String fvName, String[][] saa) {\r
1720 if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
1721 return;\r
1722 }\r
eb8ea829 1723 \r
1724 XmlCursor cursor = getfpdBuildOpts().newCursor();\r
1725 QName elementUserExts = new QName (xmlNs, "UserExtensions");\r
1726 QName attribUserId = new QName ("UserID");\r
1727 QName elementFvName = new QName (xmlNs, "FvName");\r
1728 QName elementIncludeModules = new QName(xmlNs, "IncludeModules");\r
1729 QName attribModuleGuid = new QName("ModuleGuid");\r
1730 QName attribBaseName = new QName("BaseName");\r
1731 \r
1732 if (cursor.toChild(elementUserExts)) {\r
1733 do {\r
1734 cursor.push();\r
1735 if (cursor.getAttributeText(attribUserId).equals("IMAGES")) {\r
1736 cursor.toChild(elementFvName);\r
1737 String elementName = cursor.getTextValue();\r
1738 if (elementName.equals(fvName)) {\r
1739 cursor.toNextSibling(elementIncludeModules);\r
1740 if (cursor.toFirstChild()) {\r
1741 int i = 0;\r
1742 do {\r
1743 saa[i][0] = cursor.getAttributeText(attribModuleGuid);\r
1744 saa[i][1] = cursor.getAttributeText(attribBaseName);\r
1745 ++i;\r
1746 }while (cursor.toNextSibling());\r
1747 }\r
1748 break;\r
1749 }\r
1750 }\r
1751 cursor.pop();\r
1752 }while (cursor.toNextSibling(elementUserExts));\r
1753 }\r
1754 cursor.dispose();\r
1755 \r
1756 }\r
1757 \r
1758 public void updateBuildOptionsUserExtensions (String oldFvName, String newFvName) {\r
1759 if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
1760 return;\r
1761 }\r
1bf9fa5a 1762 ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
1763 while (li.hasNext()) {\r
1764 UserExtensionsDocument.UserExtensions ues = li.next();\r
1765 if (!ues.getUserID().equals("IMAGES")) {\r
1766 continue;\r
1767 }\r
1768 XmlCursor cursor = ues.newCursor();\r
1769 cursor.toFirstChild();\r
1770 String elementName = cursor.getTextValue();\r
eb8ea829 1771 if (elementName.equals(oldFvName)) {\r
1772 cursor.setTextValue(newFvName);\r
1bf9fa5a 1773 }\r
1774 cursor.dispose();\r
1775 }\r
1776 \r
1777 }\r
1778 \r
61919f8c 1779 public void removeBuildOptionsUserExtensions (String fvName) {\r
1780 if (getfpdBuildOpts().getUserExtensionsList() == null) {\r
1781 return;\r
1782 }\r
1783 \r
1784 ListIterator<UserExtensionsDocument.UserExtensions> li = getfpdBuildOpts().getUserExtensionsList().listIterator();\r
1785 while (li.hasNext()) {\r
1786 UserExtensionsDocument.UserExtensions ues = li.next();\r
1787 if (!ues.getUserID().equals("IMAGES")) {\r
1788 continue;\r
1789 }\r
1790 XmlCursor cursor = ues.newCursor();\r
1791 cursor.toFirstChild();\r
1792 String elementName = cursor.getTextValue();\r
1793 if (elementName.equals(fvName)) {\r
1794 cursor.toParent();\r
1795 cursor.removeXml();\r
1796 cursor.dispose();\r
1797 return;\r
1798 }\r
1799 cursor.dispose();\r
1800 }\r
1801 \r
1802 }\r
1803 \r
1804 \r
a13899c5 1805 public void genBuildOptionsUserDefAntTask (String id, String fileName, String execOrder) {\r
1806 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
1807 if (udats == null) {\r
1808 udats = getfpdBuildOpts().addNewUserDefinedAntTasks();\r
1809 }\r
1810 \r
1811 AntTaskDocument.AntTask at = udats.addNewAntTask();\r
1812 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r
1813 }\r
1814 \r
1815 private void setBuildOptionsUserDefAntTask(String id, String fileName, String execOrder, AntTaskDocument.AntTask at) {\r
1816 at.setId(new Integer(id));\r
bf5abaff 1817 XmlCursor cursor = at.newCursor();\r
a13899c5 1818 if (fileName != null){\r
1819 at.setFilename(fileName);\r
1820 }\r
bf5abaff 1821 else if (cursor.toChild(xmlNs, "Filename")) {\r
1822 cursor.removeXml();\r
1823 }\r
202c4f38 1824 if (execOrder != null) {\r
a13899c5 1825 at.setAntCmdOptions(execOrder);\r
1826 }\r
bf5abaff 1827 else if (cursor.toChild(xmlNs, "AntCmdOptions")) {\r
1828 cursor.removeXml();\r
1829 }\r
1830 cursor.dispose();\r
a13899c5 1831 }\r
1832 \r
1833 public void removeBuildOptionsUserDefAntTask(int i) {\r
1834 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r
1835 if (o == null) {\r
1836 return;\r
1837 }\r
1838 XmlCursor cursor = o.newCursor();\r
1839 if (cursor.toFirstChild()) {\r
1840 for (int j = 0; j < i; ++j) {\r
1841 cursor.toNextSibling();\r
1842 }\r
1843 cursor.removeXml();\r
af25df16 1844 if (getBuildOptionsUserDefAntTaskCount() == 0) {\r
1845 cursor.toParent();\r
1846 cursor.removeXml();\r
1847 }\r
a13899c5 1848 }\r
1849 cursor.dispose();\r
1850 }\r
1851 \r
1852 public void updateBuildOptionsUserDefAntTask(int i, String id, String fileName, String execOrder){\r
1853 XmlObject o = getfpdBuildOpts().getUserDefinedAntTasks();\r
1854 if (o == null) {\r
1855 return;\r
1856 }\r
1857 XmlCursor cursor = o.newCursor();\r
1858 if (cursor.toFirstChild()) {\r
1859 for (int j = 0; j < i; ++j) {\r
1860 cursor.toNextSibling();\r
1861 }\r
1862 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)cursor.getObject();\r
1863 setBuildOptionsUserDefAntTask(id, fileName, execOrder, at);\r
1864 }\r
1865 cursor.dispose();\r
1866 }\r
1867 \r
1868 public int getBuildOptionsUserDefAntTaskCount() {\r
1869 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
1870 if (udats == null || udats.getAntTaskList() == null) {\r
1871 return 0;\r
1872 }\r
1873 \r
1874 return udats.getAntTaskList().size();\r
1875 }\r
1876 \r
1877 public void getBuildOptionsUserDefAntTasks(String[][] saa) {\r
1878 UserDefinedAntTasksDocument.UserDefinedAntTasks udats = getfpdBuildOpts().getUserDefinedAntTasks();\r
1879 if (udats == null || udats.getAntTaskList() == null) {\r
1880 return ;\r
1881 }\r
1882 \r
1883 List<AntTaskDocument.AntTask> l = udats.getAntTaskList();\r
1884 ListIterator li = l.listIterator();\r
1885 int i = 0;\r
1886 while (li.hasNext()) {\r
1887 AntTaskDocument.AntTask at = (AntTaskDocument.AntTask)li.next();\r
1888 saa[i][0] = at.getId() + "";\r
1889 saa[i][1] = saa[i][2] = "";\r
1890 if (at.getFilename() != null){\r
1891 saa[i][1] = at.getFilename();\r
1892 }\r
1893 if (at.getAntCmdOptions() != null) {\r
1894 saa[i][2] = at.getAntCmdOptions();\r
1895 }\r
1896 ++i;\r
1897 }\r
1898 }\r
1800d80f 1899 public void genBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
a13899c5 1900 OptionsDocument.Options opts = getfpdBuildOpts().getOptions();\r
1901 if (opts == null) {\r
1902 opts = getfpdBuildOpts().addNewOptions();\r
1903 }\r
1904 OptionDocument.Option opt = opts.addNewOption();\r
1905 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
1906 }\r
1907 \r
1800d80f 1908 private void setBuildOptionsOpt(Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents, OptionDocument.Option opt){\r
a13899c5 1909 opt.setStringValue(contents);\r
1800d80f 1910 \r
1911 opt.setBuildTargets(buildTargets);\r
a13899c5 1912 opt.setToolChainFamily(toolChain);\r
1913 opt.setTagName(tagName);\r
1914 opt.setToolCode(toolCmd);\r
1800d80f 1915 \r
bf5abaff 1916 if (archList != null) {\r
1917 opt.setSupArchList(archList);\r
1918 }\r
1919 else {\r
1920 if (opt.isSetSupArchList()) {\r
1921 opt.unsetSupArchList();\r
1922 }\r
1923 }\r
a13899c5 1924 }\r
1925 \r
1926 public void removeBuildOptionsOpt(int i){\r
1927 \r
1928 XmlObject o = getfpdBuildOpts().getOptions();\r
1929 if (o == null) {\r
1930 return;\r
1931 }\r
1932 \r
1933 XmlCursor cursor = o.newCursor();\r
1934 if (cursor.toFirstChild()) {\r
1935 for (int j = 0; j < i; ++j) {\r
1936 cursor.toNextSibling();\r
1937 }\r
1938 cursor.removeXml();\r
af25df16 1939 if (getBuildOptionsOptCount() == 0) {\r
1940 cursor.toParent();\r
1941 cursor.removeXml();\r
1942 }\r
a13899c5 1943 }\r
1944 cursor.dispose();\r
1945 }\r
1946 \r
1800d80f 1947 public void updateBuildOptionsOpt(int i, Vector<Object> buildTargets, String toolChain, String tagName, String toolCmd, Vector<Object> archList, String contents) {\r
a13899c5 1948 XmlObject o = getfpdBuildOpts().getOptions();\r
1949 if (o == null) {\r
1950 return;\r
1951 }\r
1952 \r
1953 XmlCursor cursor = o.newCursor();\r
1954 if (cursor.toFirstChild()) {\r
1955 for (int j = 0; j < i; ++j) {\r
1956 cursor.toNextSibling();\r
1957 }\r
1958 OptionDocument.Option opt = (OptionDocument.Option)cursor.getObject();\r
1959 setBuildOptionsOpt(buildTargets, toolChain, tagName, toolCmd, archList, contents, opt);\r
1960 }\r
1961 cursor.dispose();\r
1962 }\r
1963 \r
1964 public int getBuildOptionsOptCount(){\r
1965 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r
1966 return 0;\r
1967 }\r
1968 return getfpdBuildOpts().getOptions().getOptionList().size();\r
1969 }\r
1970 \r
1971 public void getBuildOptionsOpts(String[][] saa) {\r
1972 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {\r
1973 return ;\r
1974 }\r
1975 \r
1976 List<OptionDocument.Option> lOpt = getfpdBuildOpts().getOptions().getOptionList();\r
1977 ListIterator li = lOpt.listIterator();\r
1978 int i = 0;\r
1979 while(li.hasNext()) {\r
1980 OptionDocument.Option opt = (OptionDocument.Option)li.next();\r
6cba26e8 1981 if (opt.getBuildTargets() != null) {\r
1982 saa[i][0] = listToString(opt.getBuildTargets());\r
1983 }\r
a13899c5 1984 saa[i][1] = opt.getToolChainFamily();\r
1985 if (opt.getSupArchList() != null){\r
6cba26e8 1986 saa[i][2] = listToString(opt.getSupArchList());\r
1987\r
a13899c5 1988 }\r
1989 saa[i][3] = opt.getToolCode();\r
1990 saa[i][4] = opt.getTagName();\r
1991 saa[i][5] = opt.getStringValue();\r
1992 \r
1993 ++i;\r
1994 }\r
1995 }\r
1996 \r
6cba26e8 1997 public void genBuildOptionsFfs(String ffsKey, String type) {\r
1998 BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r
1999 ffs.setFfsKey(ffsKey);\r
2000 if (type != null) {\r
2001 ffs.addNewSections().setEncapsulationType(type);\r
2002 }\r
2003 }\r
2004 \r
3b405e9b 2005 public void updateBuildOptionsFfsSectionsType(int i, String type) {\r
2006 BuildOptionsDocument.BuildOptions.Ffs ffs = getfpdBuildOpts().addNewFfs();\r
2007 if (type != null) {\r
2008 ffs.addNewSections().setEncapsulationType(type);\r
2009 }\r
2010 }\r
2011 \r
6cba26e8 2012 public void genBuildOptionsFfsAttribute(int i, String name, String value) {\r
2013 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2014 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = ffs.addNewAttribute();\r
2015 attrib.setName(name);\r
2016 attrib.setValue(value);\r
2017 }\r
2018 \r
2019 /**update jth attribute of ith ffs.\r
2020 * @param i\r
2021 * @param j\r
2022 */\r
2023 public void updateBuildOptionsFfsAttribute(int i, int j, String name, String value){\r
2024 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2025 XmlCursor cursor = ffs.newCursor();\r
2026 QName qAttrib = new QName(xmlNs, "Attribute");\r
2027 if (cursor.toChild(qAttrib)) {\r
2028 for (int k = 0; k < j; ++k) {\r
2029 cursor.toNextSibling(qAttrib);\r
2030 }\r
2031 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = (BuildOptionsDocument.BuildOptions.Ffs.Attribute)cursor.getObject();\r
2032 attrib.setName(name);\r
2033 attrib.setValue(value);\r
2034 }\r
2035 cursor.dispose();\r
2036 }\r
2037 \r
2038 public void removeBuildOptionsFfsAttribute(int i, int j){\r
2039 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2040 XmlCursor cursor = ffs.newCursor();\r
2041 QName qAttrib = new QName(xmlNs, "Attribute");\r
2042 if (cursor.toChild(qAttrib)) {\r
2043 for (int k = 0; k < j; ++k) {\r
2044 cursor.toNextSibling(qAttrib);\r
2045 }\r
2046 cursor.removeXml();\r
2047 }\r
2048 cursor.dispose();\r
2049 }\r
2050 \r
2051 public void genBuildOptionsFfsSectionsSection(int i, String sectionType) {\r
2052 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2053 if (ffs == null) {\r
2054 return;\r
2055 }\r
2056 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2057 \r
2058 if (sections == null){\r
2059 sections = ffs.addNewSections();\r
2060 }\r
2061 sections.addNewSection().setSectionType(EfiSectionType.Enum.forString(sectionType));\r
2062 }\r
2063 \r
3b405e9b 2064 public void removeBuildOptionsFfsSectionsSection(int i, int j) {\r
2065 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2066 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2067 if (sections == null) {\r
2068 return;\r
2069 }\r
2070 XmlCursor cursor = sections.newCursor();\r
2071 QName qSection = new QName(xmlNs, "Section");\r
2072 if (cursor.toChild(qSection)) {\r
2073 for (int k = 0; k < j; ++k) {\r
2074 cursor.toNextSibling(qSection);\r
2075 }\r
2076 cursor.removeXml();\r
2077 }\r
2078 cursor.dispose();\r
2079 }\r
2080 \r
2081 public void updateBuildOptionsFfsSectionsSection(int i, int j, String type){\r
2082 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2083 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2084 if (sections == null) {\r
2085 return;\r
2086 }\r
2087 XmlCursor cursor = sections.newCursor();\r
2088 QName qSection = new QName(xmlNs, "Section");\r
2089 if (cursor.toChild(qSection)) {\r
2090 for (int k = 0; k < j; ++k) {\r
2091 cursor.toNextSibling(qSection);\r
2092 }\r
2093 BuildOptionsDocument.BuildOptions.Ffs.Sections.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Section)cursor.getObject();\r
2094 section.setSectionType(EfiSectionType.Enum.forString(type));\r
2095 }\r
2096 cursor.dispose();\r
2097 } \r
2098 \r
6cba26e8 2099 public void genBuildOptionsFfsSectionsSections(int i, String encapType) {\r
2100 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2101 if (ffs == null) {\r
2102 return;\r
2103 }\r
2104 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2105 \r
2106 if (sections == null){\r
2107 sections = ffs.addNewSections();\r
2108 }\r
2109 sections.addNewSections().setEncapsulationType(encapType);\r
2110 }\r
2111 \r
3b405e9b 2112 public void removeBuildOptionsFfsSectionsSections(int i, int j) {\r
2113 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2114 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2115 if (sections == null) {\r
2116 return;\r
2117 }\r
2118 XmlCursor cursor = sections.newCursor();\r
2119 QName qSections = new QName(xmlNs, "Sections");\r
2120 if (cursor.toChild(qSections)) {\r
2121 for (int k = 0; k < j; ++k) {\r
2122 cursor.toNextSibling(qSections);\r
2123 }\r
2124 cursor.removeXml();\r
2125 }\r
2126 cursor.dispose();\r
2127 }\r
2128 \r
2129 public void updateBuildOptionsFfsSectionsSections(int i, int j, String type) {\r
2130 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2131 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2132 if (sections == null) {\r
2133 return;\r
2134 }\r
2135 XmlCursor cursor = sections.newCursor();\r
2136 QName qSections = new QName(xmlNs, "Sections");\r
2137 if (cursor.toChild(qSections)) {\r
2138 for (int k = 0; k < j; ++k) {\r
2139 cursor.toNextSibling(qSections);\r
2140 }\r
2141 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r
2142 sections2.setEncapsulationType(type);\r
2143 }\r
2144 cursor.dispose();\r
2145 }\r
2146 \r
6cba26e8 2147 public void genBuildOptionsFfsSectionsSectionsSection(int i, int j, String type) {\r
2148 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2149 if (ffs == null) {\r
2150 return;\r
2151 }\r
2152 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2153 XmlCursor cursor = sections.newCursor();\r
2154 QName qSections = new QName(xmlNs, "Sections");\r
2155 if (cursor.toChild(qSections)){\r
2156 for (int k = 0; k < j; ++k) {\r
2157 cursor.toNextSibling(qSections);\r
2158 }\r
2159 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r
2160 sections2.addNewSection().setSectionType(EfiSectionType.Enum.forString(type));\r
2161 }\r
2162 cursor.dispose();\r
2163 }\r
2164 \r
3b405e9b 2165 public void removeBuildOptionsFfsSectionsSectionsSection(int i, int j, int k) {\r
2166 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2167 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2168 if (sections == null) {\r
2169 return;\r
2170 }\r
2171 XmlCursor cursor = sections.newCursor();\r
2172 QName qSections = new QName(xmlNs, "Sections");\r
2173 if (cursor.toChild(qSections)) {\r
2174 for (int l = 0; l < j; ++l) {\r
2175 cursor.toNextSibling(qSections);\r
2176 }\r
2177 if (cursor.toFirstChild()) {\r
af25df16 2178 int m = 0;\r
2179 for (; m < k; ++m) {\r
3b405e9b 2180 cursor.toNextSibling();\r
2181 }\r
2182 cursor.removeXml();\r
af25df16 2183 if (m == 0) {\r
2184 cursor.toParent();\r
2185 cursor.removeXml();\r
2186 }\r
3b405e9b 2187 }\r
2188 }\r
2189 cursor.dispose();\r
2190 }\r
2191 \r
2192 public void updateBuildOptionsFfsSectionsSectionsSection(int i, int j, int k, String type) {\r
2193 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2194 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2195 if (sections == null) {\r
2196 return;\r
2197 }\r
2198 XmlCursor cursor = sections.newCursor();\r
2199 QName qSections = new QName(xmlNs, "Sections");\r
2200 if (cursor.toChild(qSections)) {\r
2201 for (int l = 0; l < j; ++l) {\r
2202 cursor.toNextSibling(qSections);\r
2203 }\r
2204 if (cursor.toFirstChild()) {\r
2205 for (int m = 0; m < k; ++m) {\r
2206 cursor.toNextSibling();\r
2207 }\r
2208 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section)cursor.getObject();\r
2209 section.setSectionType(EfiSectionType.Enum.forString(type));\r
2210 }\r
2211 }\r
2212 cursor.dispose();\r
2213 }\r
2214 \r
6cba26e8 2215 public void getBuildOptionsFfsSectionsSectionsSection(int i, int j, ArrayList<String> al) {\r
2216 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2217 if (ffs == null) {\r
2218 return;\r
2219 }\r
2220 BuildOptionsDocument.BuildOptions.Ffs.Sections sections = ffs.getSections();\r
2221 XmlCursor cursor = sections.newCursor();\r
2222 QName qSections = new QName(xmlNs, "Sections");\r
2223 if (cursor.toChild(qSections)){\r
2224 for (int k = 0; k < j; ++k) {\r
2225 cursor.toNextSibling(qSections);\r
2226 }\r
2227 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2 sections2 = (BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2)cursor.getObject();\r
2228 if (sections2.getSectionList() == null){\r
2229 cursor.dispose();\r
2230 return;\r
2231 }\r
2232 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section> li = sections2.getSectionList().listIterator();\r
2233 while(li.hasNext()) {\r
2234 BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2.Section section = li.next();\r
3b405e9b 2235 if (section.isSetSectionType()) {\r
1800d80f 2236 al.add(section.getSectionType().toString());\r
2237 }\r
3b405e9b 2238 \r
2239 }\r
6cba26e8 2240 }\r
2241 cursor.dispose();\r
2242 \r
2243 }\r
2244 \r
2245 public int getBuildOptionsFfsCount(){\r
2246 if (getfpdBuildOpts().getFfsList() == null) {\r
2247 return 0;\r
2248 }\r
2249 return getfpdBuildOpts().getFfsList().size();\r
2250 }\r
2251 \r
2252 public void getBuildOptionsFfsKey(String[][] saa) {\r
2253 if (getfpdBuildOpts().getFfsList() == null) {\r
2254 return;\r
2255 }\r
2256 ListIterator<BuildOptionsDocument.BuildOptions.Ffs> li = getfpdBuildOpts().getFfsList().listIterator();\r
2257 int i = 0;\r
2258 while(li.hasNext()){\r
2259 BuildOptionsDocument.BuildOptions.Ffs ffs = li.next();\r
2260 saa[i][0] = ffs.getFfsKey();\r
2261 ++i;\r
2262 }\r
2263 }\r
2264 \r
3b405e9b 2265 public void updateBuildOptionsFfsKey(int i, String key) {\r
2266 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2267 ffs.setFfsKey(key);\r
2268 }\r
2269 \r
6cba26e8 2270 /**Get ith FFS key and contents.\r
2271 * @param saa\r
2272 */\r
2273 public void getBuildOptionsFfs(int i, String[] sa, LinkedHashMap<String, String> ffsAttribMap, ArrayList<String> firstLevelSections, ArrayList<String> firstLevelSection) {\r
2274 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2275 \r
2276 if (ffs != null) {\r
2277 \r
2278 sa[0] = ffs.getFfsKey();\r
2279 if (ffs.getSections() != null) {\r
2280 if(ffs.getSections().getEncapsulationType() != null){\r
2281 sa[1] = ffs.getSections().getEncapsulationType();\r
2282 }\r
2283 if (ffs.getSections().getSectionList() != null){\r
2284 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Section> li = ffs.getSections().getSectionList().listIterator();\r
2285 while (li.hasNext()) {\r
2286 firstLevelSection.add(li.next().getSectionType().toString());\r
2287 }\r
2288 }\r
2289 if (ffs.getSections().getSectionsList() != null) {\r
2290 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Sections.Sections2> li = ffs.getSections().getSectionsList().listIterator();\r
2291 while(li.hasNext()) {\r
2292 firstLevelSections.add(li.next().getEncapsulationType());\r
2293 }\r
2294 }\r
2295 }\r
2296 if (ffs.getAttributeList() != null) {\r
2297 ListIterator<BuildOptionsDocument.BuildOptions.Ffs.Attribute> li = ffs.getAttributeList().listIterator();\r
2298 while(li.hasNext()) {\r
2299 BuildOptionsDocument.BuildOptions.Ffs.Attribute attrib = li.next();\r
2300 ffsAttribMap.put(attrib.getName(), attrib.getValue());\r
2301 }\r
2302 \r
2303 }\r
2304 }\r
2305\r
2306 \r
2307 }\r
2308 \r
2309 private BuildOptionsDocument.BuildOptions.Ffs getFfs(int i) {\r
2310 XmlObject o = getfpdBuildOpts();\r
2311 BuildOptionsDocument.BuildOptions.Ffs ffs = null;\r
2312 \r
2313 XmlCursor cursor = o.newCursor();\r
2314 QName qFfs = new QName(xmlNs, "Ffs");\r
2315 if (cursor.toChild(qFfs)) {\r
2316 for (int j = 0; j < i; ++j) {\r
2317 cursor.toNextSibling(qFfs);\r
2318 }\r
2319 ffs = (BuildOptionsDocument.BuildOptions.Ffs)cursor.getObject();\r
2320 }\r
2321 cursor.dispose();\r
2322 return ffs;\r
2323 }\r
2324 \r
2325 public void removeBuildOptionsFfs(int i) {\r
2326 BuildOptionsDocument.BuildOptions.Ffs ffs = getFfs(i);\r
2327 if (ffs == null){\r
2328 return;\r
2329 }\r
2330 \r
2331 XmlCursor cursor = ffs.newCursor();\r
2332 cursor.removeXml();\r
2333 cursor.dispose();\r
2334 }\r
2335 \r
3b405e9b 2336 \r
2337 \r
a13899c5 2338 public PlatformDefinitionsDocument.PlatformDefinitions getfpdPlatformDefs(){\r
2339 if (fpdPlatformDefs == null){\r
2340 fpdPlatformDefs = fpdRoot.addNewPlatformDefinitions();\r
2341 }\r
2342 return fpdPlatformDefs;\r
2343 }\r
2344 \r
6a09eb19 2345 public void getPlatformDefsSupportedArchs(Vector<Object> archs){\r
2346 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {\r
2347 return;\r
2348 }\r
2349 ListIterator li = getfpdPlatformDefs().getSupportedArchitectures().listIterator();\r
2350 while(li.hasNext()) {\r
2351 archs.add(li.next());\r
2352 }\r
2353 }\r
2354 \r
2355 public void setPlatformDefsSupportedArchs(Vector<Object> archs) {\r
bf5abaff 2356 if (archs != null) {\r
2357 getfpdPlatformDefs().setSupportedArchitectures(archs);\r
2358 }\r
2359// else {\r
2360// XmlCursor cursor = getfpdPlatformDefs().newCursor();\r
2361// if (cursor.toChild(xmlNs, "SupportedArchitectures")) {\r
2362// cursor.removeXml();\r
2363// }\r
2364// cursor.dispose();\r
2365// }\r
6a09eb19 2366 }\r
2367 \r
2368 public void getPlatformDefsBuildTargets(Vector<Object> targets) {\r
2369 if (getfpdPlatformDefs().getBuildTargets() == null) {\r
2370 return;\r
2371 }\r
2372 ListIterator li = getfpdPlatformDefs().getBuildTargets().listIterator();\r
2373 while(li.hasNext()) {\r
2374 targets.add(li.next());\r
2375 }\r
2376 }\r
2377 \r
2378 public void setPlatformDefsBuildTargets(Vector<Object> targets) {\r
2379 getfpdPlatformDefs().setBuildTargets(targets);\r
2380 }\r
2381 \r
2382 public void genPlatformDefsSkuInfo(String id, String name) {\r
2383 SkuInfoDocument.SkuInfo skuInfo = null;\r
2384 if (getfpdPlatformDefs().getSkuInfo() == null) {\r
2385 skuInfo = getfpdPlatformDefs().addNewSkuInfo();\r
2386 }\r
2387 skuInfo = getfpdPlatformDefs().getSkuInfo();\r
2388 if (skuInfo.getUiSkuNameList() == null || skuInfo.getUiSkuNameList().size() == 0) {\r
2389 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r
2390 skuName.setSkuID(new BigInteger("0"));\r
2391 skuName.setStringValue("DEFAULT");\r
2392 }\r
2393 if (id.equals("0")) {\r
2394 return;\r
2395 }\r
2396 SkuInfoDocument.SkuInfo.UiSkuName skuName = skuInfo.addNewUiSkuName();\r
2397 skuName.setSkuID(new BigInteger(id));\r
2398 skuName.setStringValue(name);\r
2399 }\r
2400 \r
2401 public int getPlatformDefsSkuInfoCount(){\r
2402 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r
2403 return 0;\r
2404 }\r
2405 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();\r
2406 }\r
2407 \r
2408 public void getPlatformDefsSkuInfos(String[][] saa){\r
2409 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {\r
5af6b67f 2410 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {\r
2411 removeElement(getfpdDynPcdBuildDefs());\r
2412 fpdDynPcdBuildDefs = null;\r
2413 }\r
6a09eb19 2414 return ;\r
2415 }\r
2416 \r
2417 List<SkuInfoDocument.SkuInfo.UiSkuName> l = getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();\r
2418 ListIterator<SkuInfoDocument.SkuInfo.UiSkuName> li = l.listIterator();\r
2419 int i = 0;\r
2420 while(li.hasNext()) {\r
2421 SkuInfoDocument.SkuInfo.UiSkuName sku = li.next();\r
2422 saa[i][0] = sku.getSkuID()+"";\r
2423 saa[i][1] = sku.getStringValue();\r
2424 ++i;\r
2425 }\r
2426 }\r
2427 \r
2428 public void removePlatformDefsSkuInfo(int i) {\r
2429 SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r
2430 if (skuInfo == null || i == 0) {\r
2431 return ;\r
2432 }\r
2433 \r
2434 XmlCursor cursor = skuInfo.newCursor();\r
2435 if (cursor.toFirstChild()) {\r
2436 for (int j = 0; j < i; ++j) {\r
2437 cursor.toNextSibling();\r
2438 }\r
2439 cursor.removeXml();\r
2440 }\r
2441 cursor.dispose();\r
2442 }\r
2443 \r
2444 public void updatePlatformDefsSkuInfo(int i, String id, String name) {\r
2445 SkuInfoDocument.SkuInfo skuInfo = getfpdPlatformDefs().getSkuInfo();\r
2446 if (skuInfo == null || i == 0) {\r
2447 return ;\r
2448 }\r
2449 \r
2450 XmlCursor cursor = skuInfo.newCursor();\r
2451 if (cursor.toFirstChild()) {\r
2452 for (int j = 0; j < i; ++j) {\r
2453 cursor.toNextSibling();\r
2454 }\r
2455 SkuInfoDocument.SkuInfo.UiSkuName sku = (SkuInfoDocument.SkuInfo.UiSkuName)cursor.getObject();\r
2456 sku.setSkuID(new BigInteger(id));\r
2457 sku.setStringValue(name);\r
2458 }\r
2459 cursor.dispose();\r
2460 }\r
2461 \r
2462 public String getPlatformDefsInterDir(){\r
2463 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {\r
2464 return null;\r
2465 }\r
2466 return getfpdPlatformDefs().getIntermediateDirectories().toString();\r
2467 }\r
2468 \r
2469 public void setPlatformDefsInterDir(String interDir){\r
2470 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType.Enum.forString(interDir));\r
2471 }\r
2472 \r
2473 public String getPlatformDefsOutputDir() {\r
2474 return getfpdPlatformDefs().getOutputDirectory();\r
2475 }\r
2476 \r
2477 public void setPlatformDefsOutputDir(String outputDir) {\r
af25df16 2478 if (outputDir != null && outputDir.length() > 0) {\r
2479 getfpdPlatformDefs().setOutputDirectory(outputDir);\r
2480 }\r
2481 else{\r
2482 XmlCursor cursor = getfpdPlatformDefs().newCursor();\r
2483 if (cursor.toChild(new QName(xmlNs, "OutputDirectory"))) {\r
2484 cursor.removeXml();\r
2485 }\r
2486 cursor.dispose();\r
2487 }\r
6a09eb19 2488 }\r
2489 \r
a13899c5 2490 public FlashDocument.Flash getfpdFlash() {\r
2491 if (fpdFlash == null) {\r
2492 fpdFlash = fpdRoot.addNewFlash();\r
2493 }\r
2494 return fpdFlash;\r
2495 }\r
2496 \r
2497 public void genFlashDefinitionFile(String file) {\r
2498 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r
2499 if (fdf == null) {\r
2500 fdf = getfpdFlash().addNewFlashDefinitionFile();\r
2501 }\r
2502 \r
2503 fdf.setStringValue(file);\r
2504 }\r
2505 \r
2506 public String getFlashDefinitionFile() {\r
2507 FlashDefinitionFileDocument.FlashDefinitionFile fdf = getfpdFlash().getFlashDefinitionFile();\r
2508 if (fdf == null) {\r
2509 return "";\r
2510 }\r
2511 \r
2512 return fdf.getStringValue();\r
2513 }\r
2514 \r
a13899c5 2515 public void genFvImagesNameValue(String name, String value) {\r
2516 \r
2517 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r
2518 if (fi == null) {\r
2519 fi = getfpdFlash().addNewFvImages();\r
2520 }\r
2521 \r
2522 FvImagesDocument.FvImages.NameValue nv = fi.addNewNameValue();\r
2523 nv.setName(name);\r
2524 nv.setValue(value);\r
2525 }\r
2526 \r
2527 public void removeFvImagesNameValue(int i){\r
2528 \r
2529 XmlObject o = getfpdFlash().getFvImages();\r
2530 if (o == null) {\r
2531 return;\r
2532 }\r
2533 \r
2534 QName qNameValue = new QName(xmlNs, "NameValue");\r
2535 XmlCursor cursor = o.newCursor();\r
2536 if (cursor.toChild(qNameValue)) {\r
2537 for (int j = 0; j < i; ++j) {\r
2538 cursor.toNextSibling(qNameValue);\r
2539 }\r
2540 cursor.removeXml();\r
2541 }\r
2542 cursor.dispose();\r
2543 }\r
2544 \r
2545 public void updateFvImagesNameValue(int i, String name, String value){\r
2546 \r
2547 XmlObject o = getfpdFlash().getFvImages();\r
2548 if (o == null) {\r
2549 return;\r
2550 }\r
2551 \r
2552 QName qNameValue = new QName(xmlNs, "NameValue");\r
2553 XmlCursor cursor = o.newCursor();\r
2554 if (cursor.toChild(qNameValue)) {\r
2555 for (int j = 0; j < i; ++j) {\r
2556 cursor.toNextSibling(qNameValue);\r
2557 }\r
2558 FvImagesDocument.FvImages.NameValue nv = (FvImagesDocument.FvImages.NameValue)cursor.getObject();\r
2559 nv.setName(name);\r
2560 nv.setValue(value);\r
2561 }\r
2562 cursor.dispose();\r
2563 }\r
2564 \r
2565 public int getFvImagesNameValueCount() {\r
2566 \r
2567 FvImagesDocument.FvImages fi = null;\r
2568 if ((fi = getfpdFlash().getFvImages()) == null || fi.getNameValueList() == null) {\r
2569 return 0;\r
2570 }\r
2571 return fi.getNameValueList().size();\r
2572 }\r
2573 \r
2574 public void getFvImagesNameValues(String[][] nv) {\r
2575 \r
2576 FvImagesDocument.FvImages fi = getfpdFlash().getFvImages();\r
2577 if (fi == null){\r
2578 return;\r
2579 }\r
2580 List<FvImagesDocument.FvImages.NameValue> l = fi.getNameValueList();\r
2581 int i = 0;\r
2582 ListIterator li = l.listIterator();\r
2583 while (li.hasNext()) {\r
2584 FvImagesDocument.FvImages.NameValue e = (FvImagesDocument.FvImages.NameValue) li\r
2585 .next();\r
2586 nv[i][0] = e.getName();\r
2587 nv[i][1] = e.getValue();\r
2588 \r
2589 i++;\r
2590 }\r
2591 }\r
2592 \r
eb8ea829 2593 public void getFvImagesFvImageFvImageNames (Vector<String> vImageNames) {\r