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