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