2 Java class FpdFileContents is used to parse fpd xml file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
16 import java
.io
.IOException
;
17 import java
.math
.BigInteger
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashMap
;
22 import java
.util
.List
;
23 import java
.util
.ListIterator
;
26 import java
.util
.Vector
;
28 import javax
.xml
.namespace
.QName
;
30 import org
.apache
.xmlbeans
.XmlCursor
;
31 import org
.apache
.xmlbeans
.XmlObject
;
32 import org
.apache
.xmlbeans
.XmlOptions
;
33 import org
.tianocore
.AntTaskDocument
;
34 import org
.tianocore
.BuildOptionsDocument
;
35 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
;
36 import org
.tianocore
.EfiSectionType
;
37 import org
.tianocore
.FlashDefinitionFileDocument
;
38 import org
.tianocore
.FlashDocument
;
39 import org
.tianocore
.FrameworkModulesDocument
;
40 import org
.tianocore
.IntermediateOutputType
;
41 import org
.tianocore
.LibrariesDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSurfaceAreaDocument
;
44 import org
.tianocore
.OptionDocument
;
45 import org
.tianocore
.OptionsDocument
;
46 import org
.tianocore
.PcdBuildDefinitionDocument
;
47 import org
.tianocore
.PcdCodedDocument
;
48 import org
.tianocore
.PcdDataTypes
;
49 import org
.tianocore
.PcdDeclarationsDocument
;
50 import org
.tianocore
.PcdItemTypes
;
51 import org
.tianocore
.PlatformDefinitionsDocument
;
52 import org
.tianocore
.PlatformSurfaceAreaDocument
;
53 import org
.tianocore
.FvImageTypes
;
54 import org
.tianocore
.FvImagesDocument
;
55 import org
.tianocore
.LicenseDocument
;
56 import org
.tianocore
.PlatformHeaderDocument
;
57 import org
.tianocore
.SkuInfoDocument
;
58 import org
.tianocore
.UserDefinedAntTasksDocument
;
59 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.GlobalData
;
60 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.ModuleIdentification
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.PackageIdentification
;
65 This class processes fpd file contents such as add remove xml elements.
66 @since PackageEditor 1.0
68 public class FpdFileContents
{
70 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
72 private PlatformSurfaceAreaDocument fpdd
= null;
74 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
76 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
78 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
80 private FlashDocument
.Flash fpdFlash
= null;
82 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
84 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
86 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
88 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
91 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
93 public void initDynPcdMap() {
94 if (dynPcdMap
== null) {
95 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
96 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
100 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
101 while (li
.hasNext()) {
102 ModuleSADocument
.ModuleSA msa
= li
.next();
103 if (msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null) {
106 String ModuleInfo
= msa
.getModuleGuid() + " " + msa
.getModuleVersion() +
107 " " + msa
.getPackageGuid() + " " + msa
.getPackageVersion();
108 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= msa
.getPcdBuildDefinition().getPcdDataList();
109 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
110 while (lpi
.hasNext()) {
111 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
112 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
113 if (dynPcdMap
.get(pcdKey
) == null) {
114 ArrayList
<String
> al
= new ArrayList
<String
>();
115 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
116 dynPcdMap
.put(pcdKey
, al
);
119 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
126 public ArrayList
<String
> getDynPcdMapValue(String key
) {
127 return dynPcdMap
.get(key
);
130 Constructor to create a new spd file
132 public FpdFileContents() {
134 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
135 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
140 Constructor for existing document object
143 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
145 fpdHdr
= fpdRoot
.getPlatformHeader();
146 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
147 fpdBuildOpts
= fpdRoot
.getBuildOptions();
148 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
149 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
150 fpdFlash
= fpdRoot
.getFlash();
154 Constructor based on an existing spd file
156 @param f Existing spd file
158 public FpdFileContents(File f
) {
160 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
161 fpdRoot
= fpdd
.getPlatformSurfaceArea();
162 } catch (Exception e
) {
163 System
.out
.println(e
.toString());
167 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
168 if (fpdDynPcdBuildDefs
== null){
169 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
171 return fpdDynPcdBuildDefs
;
174 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
175 if (fpdFrameworkModules
== null){
176 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
178 return fpdFrameworkModules
;
181 public int getFrameworkModulesCount() {
182 if (getfpdFrameworkModules().getModuleSAList() == null){
185 return getfpdFrameworkModules().getModuleSAList().size();
188 public void getFrameworkModulesInfo(String
[][] saa
) {
189 if (getFrameworkModulesCount() == 0){
193 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
195 while(li
.hasNext()) {
196 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
197 saa
[i
][1] = msa
.getModuleGuid();
198 saa
[i
][2] = msa
.getModuleVersion();
200 saa
[i
][3] = msa
.getPackageGuid();
201 saa
[i
][4] = msa
.getPackageVersion();
202 // saa[i][4] = listToString(msa.getSupArchList());
207 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
208 String
[] s
= key
.split(" ");
209 if (getfpdFrameworkModules().getModuleSAList() == null) {
212 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
213 while(li
.hasNext()) {
214 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
215 if (msa
.getModuleGuid().equals(s
[0]) && msa
.getPackageGuid().equals(s
[2])) {
216 if (msa
.getModuleVersion() != null) {
217 if (!msa
.getModuleVersion().equals(s
[1])) {
221 if (msa
.getPackageVersion() != null) {
222 if (!msa
.getPackageVersion().equals(s
[3])) {
231 public void removeModuleSA(int i
) {
232 XmlObject o
= getfpdFrameworkModules();
237 XmlCursor cursor
= o
.newCursor();
238 if (cursor
.toFirstChild()) {
239 for (int j
= 0; j
< i
; ++j
) {
240 cursor
.toNextSibling();
243 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
245 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
246 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
247 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion();
248 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
249 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
250 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
251 while(li
.hasNext()) {
252 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
253 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
257 if (getFrameworkModulesCount() == 0) {
265 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
267 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
271 String
[] s
= moduleInfo
.split(" ");
272 for(int i
= 0; i
< al
.size(); ++i
){
273 String consumer
= al
.get(i
);
274 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
280 if (al
.size() == 0) {
281 dynPcdMap
.remove(pcdKey
);
282 String
[] s1
= pcdKey
.split(" ");
283 removeDynamicPcdBuildData(s1
[0], s1
[1]);
288 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
290 public int getPcdDataCount(int i
){
291 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
295 XmlCursor cursor
= getfpdFrameworkModules().newCursor();
296 ModuleSADocument
.ModuleSA msa
= null;
297 if (cursor
.toFirstChild()) {
298 for (int j
= 0; j
< i
; ++j
) {
299 cursor
.toNextSibling();
301 msa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
305 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
308 return msa
.getPcdBuildDefinition().getPcdDataList().size();
312 public void getPcdData(int i
, String
[][] saa
) {
313 if (getfpdFrameworkModules().getModuleSAList() == null || getfpdFrameworkModules().getModuleSAList().size() == 0) {
317 XmlCursor cursor
= getfpdFrameworkModules().newCursor();
318 ModuleSADocument
.ModuleSA msa
= null;
319 if (cursor
.toFirstChild()) {
320 for (int j
= 0; j
< i
; ++j
) {
321 cursor
.toNextSibling();
323 msa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
327 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
330 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
331 for (int k
= 0; k
< saa
.length
; ++k
) {
332 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
333 saa
[k
][0] = pcdData
.getCName();
334 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
335 saa
[k
][2] = pcdData
.getItemType()+"";
336 saa
[k
][3] = pcdData
.getToken().toString();
337 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
338 saa
[k
][5] = pcdData
.getDatumType()+"";
339 saa
[k
][6] = pcdData
.getValue();
344 public void updatePcdData(String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
345 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
346 if (msa
== null || msa
.getPcdBuildDefinition() == null){
350 XmlCursor cursor
= msa
.getPcdBuildDefinition().newCursor();
351 if (cursor
.toFirstChild()){
353 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
354 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
355 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
356 if(pcdData
.getDatumType().equals("VOID*")) {
357 pcdData
.setMaxDatumSize(new Integer(maxSize
));
359 pcdData
.setValue(value
);
363 while(cursor
.toNextSibling());
368 /**Get original Pcd info from MSA & SPD files.
369 * @param mi ModuleIdentification from which MSA & SPD come
370 * @param cName PCD cName
371 * @param sa Results: HelpText, Original item type.
374 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String
[] sa
) throws Exception
{
377 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
378 if (msa
.getPcdCoded() == null) {
382 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
383 m
.put("ModuleSurfaceArea", msa
);
384 SurfaceAreaQuery
.setDoc(m
);
385 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
387 // First look through MSA pcd entries.
389 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
390 ListIterator li
= l
.listIterator();
391 while(li
.hasNext()) {
392 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
393 if (!msaPcd
.getCName().equals(cName
)) {
396 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
397 if (spdPcd
== null) {
401 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
404 // Get Pcd help text and original item type.
406 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
407 sa
[1] = msaPcd
.getPcdItemType()+"";
414 // e.printStackTrace();
421 /**Remove PCDBuildDefinition entries from ModuleSA
422 * @param moduleKey identifier of ModuleSA.
423 * @param consumer where these entries come from.
425 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
427 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(consumer
);
428 if (msa
.getPcdCoded() == null) {
432 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
433 ListIterator li
= l
.listIterator();
435 while(li
.hasNext()) {
436 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
437 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
438 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
439 if (cursor
.toFirstChild()) {
440 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
441 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
443 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
447 while (cursor
.toNextSibling()) {
448 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
449 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
450 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
466 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
468 public int getLibraryInstancesCount(String key
) {
469 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
470 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
473 return msa
.getLibraries().getInstanceList().size();
476 public void getLibraryInstances(String key
, String
[][] saa
){
477 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
478 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
482 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
483 for (int i
= 0; i
< saa
.length
; ++i
) {
484 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
485 saa
[i
][1] = instance
.getModuleGuid();
486 saa
[i
][2] = instance
.getModuleVersion();
487 saa
[i
][3] = instance
.getPackageGuid();
488 saa
[i
][4] = instance
.getPackageVersion();
492 public void removeLibraryInstance(String key
, int i
) {
493 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
494 if (msa
== null || msa
.getLibraries() == null){
498 XmlCursor cursor
= msa
.getLibraries().newCursor();
499 if (cursor
.toFirstChild()) {
500 for (int j
= 0; j
< i
; ++j
) {
501 cursor
.toNextSibling();
509 public void genLibraryInstance(String mg
, String mv
, String pg
, String pv
, String key
) {
510 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
512 msa
= getfpdFrameworkModules().addNewModuleSA();
514 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
516 libs
= msa
.addNewLibraries();
519 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
520 instance
.setModuleGuid(mg
);
521 instance
.setModuleVersion(mv
);
522 instance
.setPackageGuid(pg
);
523 instance
.setPackageVersion(pv
);
527 public String
getFvBinding(String moduleKey
){
528 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
529 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
532 return msa
.getModuleSaBuildOptions().getFvBinding();
535 public void setFvBinding(String moduleKey
, String fvBinding
){
536 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
540 if(msa
.getModuleSaBuildOptions() == null){
541 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
544 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
547 public String
getFfsFileNameGuid(String moduleKey
){
548 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
549 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
552 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
555 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
556 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
560 if(msa
.getModuleSaBuildOptions() == null){
561 msa
.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
564 msa
.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
567 public String
getFfsFormatKey(String moduleKey
){
568 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
569 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
572 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
575 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
576 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
580 if(msa
.getModuleSaBuildOptions() == null){
581 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
584 msa
.getModuleSaBuildOptions().setFvBinding(ffsKey
);
587 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
588 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
589 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
590 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
594 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
595 ListIterator li
= lOpt
.listIterator();
597 while(li
.hasNext()) {
598 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
599 if (opt
.getBuildTargets() != null) {
600 saa
[i
][0] = listToString(opt
.getBuildTargets());
602 saa
[i
][1] = opt
.getToolChainFamily();
603 if (opt
.getSupArchList() != null){
604 saa
[i
][2] = listToString(opt
.getSupArchList());
607 saa
[i
][3] = opt
.getToolCode();
608 saa
[i
][4] = opt
.getTagName();
609 saa
[i
][5] = opt
.getStringValue();
615 public int getModuleSAOptionsCount(String moduleKey
){
616 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
617 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
618 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
621 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
624 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
625 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
626 if (msa
.getModuleSaBuildOptions() == null) {
627 msa
.addNewModuleSaBuildOptions();
629 if (msa
.getModuleSaBuildOptions().getOptions() == null){
630 msa
.getModuleSaBuildOptions().addNewOptions();
632 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
633 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
636 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
637 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
638 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
641 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
642 XmlCursor cursor
= opts
.newCursor();
643 if (cursor
.toFirstChild()) {
644 for (int j
= 0; j
< i
; ++j
){
645 cursor
.toNextSibling();
652 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
653 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
654 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
657 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
658 XmlCursor cursor
= opts
.newCursor();
659 if (cursor
.toFirstChild()) {
660 for (int j
= 0; j
< i
; ++j
){
661 cursor
.toNextSibling();
663 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
664 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
669 /**add pcd information of module mi to a ModuleSA.
671 * @param moduleSa if null, generate a new ModuleSA.
673 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
674 //ToDo add Arch filter
677 if (moduleSa
== null) {
678 moduleSa
= genModuleSA(mi
);
681 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
682 if (msa
.getPcdCoded() == null) {
686 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
687 m
.put("ModuleSurfaceArea", msa
);
688 SurfaceAreaQuery
.setDoc(m
);
689 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
691 // Implementing InitializePlatformPcdBuildDefinitions
693 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
694 ListIterator li
= l
.listIterator();
695 while(li
.hasNext()) {
696 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
697 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
698 if (spdPcd
== null) {
702 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
705 // AddItem to ModuleSA PcdBuildDefinitions
707 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
709 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
714 // e.printStackTrace();
720 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
722 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
723 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
724 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
725 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
726 SurfaceAreaQuery
.setDoc(m
);
727 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
731 for (int j
= 0; j
< xo
.length
; ++j
) {
732 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
733 if (msaPcd
.getTokenSpaceGuidCName() == null) {
734 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
739 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
750 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
) {
751 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
752 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
753 msa
.setModuleGuid(mi
.getGuid());
754 msa
.setModuleVersion(mi
.getVersion());
755 msa
.setPackageGuid(pi
.getGuid());
756 msa
.setPackageVersion(pi
.getVersion());
761 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
762 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
763 if (moduleSa
.getPcdBuildDefinition() == null){
764 moduleSa
.addNewPcdBuildDefinition();
767 // constructe pcd to modulesa mapping first.
768 // Attention : for any error condition, remove from map this pcd.
770 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
771 if (pcdConsumer
== null) {
772 pcdConsumer
= new ArrayList
<String
>();
774 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
775 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion()
777 pcdConsumer
.add(listValue
);
778 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
780 // Special dynamic type, if this pcd already exists in other ModuleSA
782 if (itemType
.equals("DYNAMIC")) {
784 ListIterator li
= pcdConsumer
.listIterator();
785 while(li
.hasNext()) {
786 String value
= li
.next().toString();
787 String
[] valuePart
= value
.split(" ");
788 if (!valuePart
[4].equals("DYNAMIC")) {
789 //ToDo error for same pcd, other type than dynamic
790 pcdConsumer
.remove(listValue
);
791 throw new PcdItemTypeConflictException(value
);
796 ListIterator li
= pcdConsumer
.listIterator();
797 while(li
.hasNext()) {
798 String value
= li
.next().toString();
799 String
[] valuePart
= value
.split(" ");
800 if (valuePart
[4].equals("DYNAMIC")) {
801 //ToDo error for same pcd, other type than non-dynamic
802 pcdConsumer
.remove(listValue
);
803 throw new PcdItemTypeConflictException(value
);
808 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
809 fpdPcd
.setCName(cName
);
810 fpdPcd
.setToken(token
);
811 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
812 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
813 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
815 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
816 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
818 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
819 // so need to add one dyn pcd.
821 if (al
.size() == 1) {
822 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
826 if (defaultVal
!= null){
827 fpdPcd
.setValue(defaultVal
);
830 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
831 fpdPcd
.setValue("0");
833 if (dataType
.equals("BOOLEAN")){
834 fpdPcd
.setValue("false");
836 if (dataType
.equals("VOID*")) {
840 if (dataType
.equals("UINT8")){
841 fpdPcd
.setMaxDatumSize(1);
843 if (dataType
.equals("UINT16")) {
844 fpdPcd
.setMaxDatumSize(2);
846 if (dataType
.equals("UINT32")) {
847 fpdPcd
.setMaxDatumSize(4);
849 if (dataType
.equals("UINT64")){
850 fpdPcd
.setMaxDatumSize(8);
852 if (dataType
.equals("BOOLEAN")){
853 fpdPcd
.setMaxDatumSize(1);
855 if (dataType
.equals("VOID*")) {
856 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
857 fpdPcd
.setMaxDatumSize(maxSize
);
862 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
866 char ch
= datum
.charAt(0);
870 // For void* type PCD, only three datum is support:
871 // 1) Unicode: string with start char is "L"
872 // 2) Ansci: String is ""
873 // 3) byte array: String start char "{"
876 start
= datum
.indexOf('\"');
877 end
= datum
.lastIndexOf('\"');
879 (end
> datum
.length())||
880 ((start
== end
) && (datum
.length() > 0))) {
881 //ToDo Error handling here
882 throw new PcdValueMalFormed (datum
);
885 strValue
= datum
.substring(start
+ 1, end
);
886 return strValue
.length() * 2;
887 } else if (ch
== '\"'){
888 start
= datum
.indexOf('\"');
889 end
= datum
.lastIndexOf('\"');
891 (end
> datum
.length())||
892 ((start
== end
) && (datum
.length() > 0))) {
893 throw new PcdValueMalFormed (datum
);
895 strValue
= datum
.substring(start
+ 1, end
);
896 return strValue
.length();
897 } else if (ch
=='{') {
898 String
[] strValueArray
;
900 start
= datum
.indexOf('{');
901 end
= datum
.lastIndexOf('}');
902 strValue
= datum
.substring(start
+ 1, end
);
903 strValue
= strValue
.trim();
904 if (strValue
.length() == 0) {
907 strValueArray
= strValue
.split(",");
908 for (int index
= 0; index
< strValueArray
.length
; index
++) {
909 Integer value
= Integer
.decode(strValueArray
[index
].trim());
912 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
913 // "it is byte array in fact. But the element of %s exceed the byte range",
914 throw new PcdValueMalFormed (datum
);
917 return strValueArray
.length
;
921 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
922 // "1) UNICODE string: like L\"xxxx\";\r\n"+
923 // "2) ANSIC string: like \"xxx\";\r\n"+
924 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
925 // "but the datum in seems does not following above format!",
926 throw new PcdValueMalFormed (datum
);
931 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
932 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
937 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
939 return dynPcdMap
.get("pcdKey");
942 public int getDynamicPcdBuildDataCount() {
943 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
946 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
949 public void getDynamicPcdBuildData(String
[][] saa
) {
950 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
953 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
954 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
956 while(li
.hasNext()) {
957 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
958 saa
[i
][0] = dynPcd
.getCName();
959 saa
[i
][1] = dynPcd
.getToken().toString();
960 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
961 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
962 saa
[i
][4] = dynPcd
.getDatumType().toString();
968 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
969 throws PcdValueMalFormed
{
970 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
971 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
972 dynPcdData
.setCName(cName
);
973 dynPcdData
.setToken(token
);
974 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
975 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
977 BigInteger bigInt
= new BigInteger("0");
978 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
979 skuInfo
.setSkuId(bigInt
);
980 if (defaultVal
!= null){
981 skuInfo
.setValue(defaultVal
);
984 if (dataType
.equals("UINT8")){
985 skuInfo
.setValue("0");
987 if (dataType
.equals("UINT16")) {
988 skuInfo
.setValue("0");
990 if (dataType
.equals("UINT32")) {
991 skuInfo
.setValue("0");
993 if (dataType
.equals("UINT64")){
994 skuInfo
.setValue("0");
996 if (dataType
.equals("BOOLEAN")){
997 skuInfo
.setValue("false");
999 if (dataType
.equals("VOID*")) {
1000 skuInfo
.setValue("");
1003 if (dataType
.equals("UINT8")){
1004 dynPcdData
.setMaxDatumSize(1);
1006 if (dataType
.equals("UINT16")) {
1007 dynPcdData
.setMaxDatumSize(2);
1009 if (dataType
.equals("UINT32")) {
1010 dynPcdData
.setMaxDatumSize(4);
1012 if (dataType
.equals("UINT64")){
1013 dynPcdData
.setMaxDatumSize(8);
1015 if (dataType
.equals("BOOLEAN")){
1016 dynPcdData
.setMaxDatumSize(1);
1018 if (dataType
.equals("VOID*")) {
1019 int maxSize
= setMaxSizeForPointer(defaultVal
);
1020 dynPcdData
.setMaxDatumSize(maxSize
);
1024 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1025 XmlObject o
= getfpdDynPcdBuildDefs();
1027 XmlCursor cursor
= o
.newCursor();
1028 if (cursor
.toFirstChild()) {
1030 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1031 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1032 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1034 if (getDynamicPcdBuildDataCount() == 0) {
1042 while (cursor
.toNextSibling());
1047 // Get the Sku Info count of ith dyn pcd element.
1049 public int getDynamicPcdSkuInfoCount(int i
){
1050 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1054 int skuInfoCount
= 0;
1055 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1056 if (cursor
.toFirstChild()) {
1057 for (int j
= 0; j
< i
; ++j
) {
1058 cursor
.toNextSibling();
1060 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1061 if (pcdData
.getSkuInfoList() == null) {
1065 skuInfoCount
= pcdData
.getSkuInfoList().size();
1069 return skuInfoCount
;
1072 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1073 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1077 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1078 if (cursor
.toFirstChild()) {
1079 for (int j
= 0; j
< i
; ++j
) {
1080 cursor
.toNextSibling();
1082 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1083 if (pcdData
.getSkuInfoList() == null) {
1088 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1090 while (li
.hasNext()) {
1091 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1092 saa
[k
][0] = skuInfo
.getSkuId()+"";
1093 saa
[k
][1] = skuInfo
.getVariableName();
1094 saa
[k
][2] = skuInfo
.getVariableGuid();
1095 saa
[k
][3] = skuInfo
.getVariableOffset();
1096 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1097 saa
[k
][5] = skuInfo
.getVpdOffset();
1098 saa
[k
][6] = skuInfo
.getValue();
1108 public String
getDynamicPcdBuildDataValue(int i
){
1109 String value
= null;
1110 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1114 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1115 if (cursor
.toFirstChild()) {
1116 for (int j
= 0; j
< i
; ++j
) {
1117 cursor
.toNextSibling();
1119 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1120 if (pcdData
.getSkuInfoList() == null) {
1124 value
= pcdData
.getSkuInfoArray(0).getValue();
1131 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1132 String vpdOffset
= null;
1133 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1137 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1138 if (cursor
.toFirstChild()) {
1139 for (int j
= 0; j
< i
; ++j
) {
1140 cursor
.toNextSibling();
1142 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1143 if (pcdData
.getSkuInfoList() == null) {
1147 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1154 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1155 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1159 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1160 if (cursor
.toFirstChild()) {
1161 for (int j
= 0; j
< i
; ++j
) {
1162 cursor
.toNextSibling();
1164 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1165 if (pcdData
.getSkuInfoList() == null) {
1170 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1171 cursor
.toChild(qSkuInfo
);
1178 // generate sku info for ith dyn pcd build data.
1180 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1181 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1182 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1186 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1187 if (cursor
.toFirstChild()) {
1188 for (int j
= 0; j
< i
; ++j
) {
1189 cursor
.toNextSibling();
1191 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1192 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1193 skuInfo
.setSkuId(new BigInteger(id
));
1194 if (varName
!= null){
1195 skuInfo
.setVariableName(varName
);
1196 skuInfo
.setVariableGuid(varGuid
);
1197 skuInfo
.setVariableOffset(varOffset
);
1198 skuInfo
.setHiiDefaultValue(hiiDefault
);
1200 else if (vpdOffset
!= null){
1201 skuInfo
.setVpdOffset(vpdOffset
);
1204 skuInfo
.setValue(value
);
1209 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1210 String hiiDefault
, String vpdOffset
, String value
, int i
){
1211 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1215 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1216 if (cursor
.toFirstChild()) {
1217 for (int j
= 0; j
< i
; ++j
) {
1218 cursor
.toNextSibling();
1220 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1221 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1222 while (li
.hasNext()) {
1223 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1224 if (skuInfo
.getSkuId().toString().equals(id
)){
1225 if (varName
!= null){
1226 skuInfo
.setVariableName(varName
);
1227 skuInfo
.setVariableGuid(varGuid
);
1228 skuInfo
.setVariableOffset(varOffset
);
1229 skuInfo
.setHiiDefaultValue(hiiDefault
);
1231 else if (vpdOffset
!= null){
1232 skuInfo
.setVpdOffset(vpdOffset
);
1235 skuInfo
.setValue(value
);
1243 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1244 if (fpdBuildOpts
== null) {
1245 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1247 return fpdBuildOpts
;
1250 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1251 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1252 if (udats
== null) {
1253 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1256 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1257 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1260 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1261 at
.setId(new Integer(id
));
1262 if (fileName
!= null){
1263 at
.setFilename(fileName
);
1265 if (execOrder
!= null) {
1266 at
.setAntCmdOptions(execOrder
);
1270 public void removeBuildOptionsUserDefAntTask(int i
) {
1271 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1275 XmlCursor cursor
= o
.newCursor();
1276 if (cursor
.toFirstChild()) {
1277 for (int j
= 0; j
< i
; ++j
) {
1278 cursor
.toNextSibling();
1281 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1289 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1290 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1294 XmlCursor cursor
= o
.newCursor();
1295 if (cursor
.toFirstChild()) {
1296 for (int j
= 0; j
< i
; ++j
) {
1297 cursor
.toNextSibling();
1299 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1300 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1305 public int getBuildOptionsUserDefAntTaskCount() {
1306 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1307 if (udats
== null || udats
.getAntTaskList() == null) {
1311 return udats
.getAntTaskList().size();
1314 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1315 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1316 if (udats
== null || udats
.getAntTaskList() == null) {
1320 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1321 ListIterator li
= l
.listIterator();
1323 while (li
.hasNext()) {
1324 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1325 saa
[i
][0] = at
.getId() + "";
1326 saa
[i
][1] = saa
[i
][2] = "";
1327 if (at
.getFilename() != null){
1328 saa
[i
][1] = at
.getFilename();
1330 if (at
.getAntCmdOptions() != null) {
1331 saa
[i
][2] = at
.getAntCmdOptions();
1336 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1337 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1339 opts
= getfpdBuildOpts().addNewOptions();
1341 OptionDocument
.Option opt
= opts
.addNewOption();
1342 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1345 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1346 opt
.setStringValue(contents
);
1348 opt
.setBuildTargets(buildTargets
);
1349 opt
.setToolChainFamily(toolChain
);
1350 opt
.setTagName(tagName
);
1351 opt
.setToolCode(toolCmd
);
1353 opt
.setSupArchList(archList
);
1356 public void removeBuildOptionsOpt(int i
){
1358 XmlObject o
= getfpdBuildOpts().getOptions();
1363 XmlCursor cursor
= o
.newCursor();
1364 if (cursor
.toFirstChild()) {
1365 for (int j
= 0; j
< i
; ++j
) {
1366 cursor
.toNextSibling();
1369 if (getBuildOptionsOptCount() == 0) {
1377 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1378 XmlObject o
= getfpdBuildOpts().getOptions();
1383 XmlCursor cursor
= o
.newCursor();
1384 if (cursor
.toFirstChild()) {
1385 for (int j
= 0; j
< i
; ++j
) {
1386 cursor
.toNextSibling();
1388 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1389 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1394 public int getBuildOptionsOptCount(){
1395 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1398 return getfpdBuildOpts().getOptions().getOptionList().size();
1401 public void getBuildOptionsOpts(String
[][] saa
) {
1402 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1406 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1407 ListIterator li
= lOpt
.listIterator();
1409 while(li
.hasNext()) {
1410 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1411 if (opt
.getBuildTargets() != null) {
1412 saa
[i
][0] = listToString(opt
.getBuildTargets());
1414 saa
[i
][1] = opt
.getToolChainFamily();
1415 if (opt
.getSupArchList() != null){
1416 saa
[i
][2] = listToString(opt
.getSupArchList());
1419 saa
[i
][3] = opt
.getToolCode();
1420 saa
[i
][4] = opt
.getTagName();
1421 saa
[i
][5] = opt
.getStringValue();
1427 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1428 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1429 ffs
.setFfsKey(ffsKey
);
1431 ffs
.addNewSections().setEncapsulationType(type
);
1435 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1436 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1438 ffs
.addNewSections().setEncapsulationType(type
);
1442 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1443 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1444 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1445 attrib
.setName(name
);
1446 attrib
.setValue(value
);
1449 /**update jth attribute of ith ffs.
1453 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1454 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1455 XmlCursor cursor
= ffs
.newCursor();
1456 QName qAttrib
= new QName(xmlNs
, "Attribute");
1457 if (cursor
.toChild(qAttrib
)) {
1458 for (int k
= 0; k
< j
; ++k
) {
1459 cursor
.toNextSibling(qAttrib
);
1461 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1462 attrib
.setName(name
);
1463 attrib
.setValue(value
);
1468 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1469 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1470 XmlCursor cursor
= ffs
.newCursor();
1471 QName qAttrib
= new QName(xmlNs
, "Attribute");
1472 if (cursor
.toChild(qAttrib
)) {
1473 for (int k
= 0; k
< j
; ++k
) {
1474 cursor
.toNextSibling(qAttrib
);
1481 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1482 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1486 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1488 if (sections
== null){
1489 sections
= ffs
.addNewSections();
1491 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1494 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1495 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1496 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1497 if (sections
== null) {
1500 XmlCursor cursor
= sections
.newCursor();
1501 QName qSection
= new QName(xmlNs
, "Section");
1502 if (cursor
.toChild(qSection
)) {
1503 for (int k
= 0; k
< j
; ++k
) {
1504 cursor
.toNextSibling(qSection
);
1511 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1512 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1513 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1514 if (sections
== null) {
1517 XmlCursor cursor
= sections
.newCursor();
1518 QName qSection
= new QName(xmlNs
, "Section");
1519 if (cursor
.toChild(qSection
)) {
1520 for (int k
= 0; k
< j
; ++k
) {
1521 cursor
.toNextSibling(qSection
);
1523 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1524 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1529 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1530 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1534 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1536 if (sections
== null){
1537 sections
= ffs
.addNewSections();
1539 sections
.addNewSections().setEncapsulationType(encapType
);
1542 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1543 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1544 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1545 if (sections
== null) {
1548 XmlCursor cursor
= sections
.newCursor();
1549 QName qSections
= new QName(xmlNs
, "Sections");
1550 if (cursor
.toChild(qSections
)) {
1551 for (int k
= 0; k
< j
; ++k
) {
1552 cursor
.toNextSibling(qSections
);
1559 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1560 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1561 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1562 if (sections
== null) {
1565 XmlCursor cursor
= sections
.newCursor();
1566 QName qSections
= new QName(xmlNs
, "Sections");
1567 if (cursor
.toChild(qSections
)) {
1568 for (int k
= 0; k
< j
; ++k
) {
1569 cursor
.toNextSibling(qSections
);
1571 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1572 sections2
.setEncapsulationType(type
);
1577 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1578 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1582 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1583 XmlCursor cursor
= sections
.newCursor();
1584 QName qSections
= new QName(xmlNs
, "Sections");
1585 if (cursor
.toChild(qSections
)){
1586 for (int k
= 0; k
< j
; ++k
) {
1587 cursor
.toNextSibling(qSections
);
1589 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1590 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1595 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1596 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1597 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1598 if (sections
== null) {
1601 XmlCursor cursor
= sections
.newCursor();
1602 QName qSections
= new QName(xmlNs
, "Sections");
1603 if (cursor
.toChild(qSections
)) {
1604 for (int l
= 0; l
< j
; ++l
) {
1605 cursor
.toNextSibling(qSections
);
1607 if (cursor
.toFirstChild()) {
1609 for (; m
< k
; ++m
) {
1610 cursor
.toNextSibling();
1622 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1623 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1624 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1625 if (sections
== null) {
1628 XmlCursor cursor
= sections
.newCursor();
1629 QName qSections
= new QName(xmlNs
, "Sections");
1630 if (cursor
.toChild(qSections
)) {
1631 for (int l
= 0; l
< j
; ++l
) {
1632 cursor
.toNextSibling(qSections
);
1634 if (cursor
.toFirstChild()) {
1635 for (int m
= 0; m
< k
; ++m
) {
1636 cursor
.toNextSibling();
1638 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1639 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1645 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1646 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1650 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1651 XmlCursor cursor
= sections
.newCursor();
1652 QName qSections
= new QName(xmlNs
, "Sections");
1653 if (cursor
.toChild(qSections
)){
1654 for (int k
= 0; k
< j
; ++k
) {
1655 cursor
.toNextSibling(qSections
);
1657 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1658 if (sections2
.getSectionList() == null){
1662 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1663 while(li
.hasNext()) {
1664 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1665 if (section
.isSetSectionType()) {
1666 al
.add(section
.getSectionType().toString());
1675 public int getBuildOptionsFfsCount(){
1676 if (getfpdBuildOpts().getFfsList() == null) {
1679 return getfpdBuildOpts().getFfsList().size();
1682 public void getBuildOptionsFfsKey(String
[][] saa
) {
1683 if (getfpdBuildOpts().getFfsList() == null) {
1686 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1688 while(li
.hasNext()){
1689 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1690 saa
[i
][0] = ffs
.getFfsKey();
1695 public void updateBuildOptionsFfsKey(int i
, String key
) {
1696 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1700 /**Get ith FFS key and contents.
1703 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
1704 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1708 sa
[0] = ffs
.getFfsKey();
1709 if (ffs
.getSections() != null) {
1710 if(ffs
.getSections().getEncapsulationType() != null){
1711 sa
[1] = ffs
.getSections().getEncapsulationType();
1713 if (ffs
.getSections().getSectionList() != null){
1714 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
1715 while (li
.hasNext()) {
1716 firstLevelSection
.add(li
.next().getSectionType().toString());
1719 if (ffs
.getSections().getSectionsList() != null) {
1720 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
1721 while(li
.hasNext()) {
1722 firstLevelSections
.add(li
.next().getEncapsulationType());
1726 if (ffs
.getAttributeList() != null) {
1727 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
1728 while(li
.hasNext()) {
1729 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
1730 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
1739 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
1740 XmlObject o
= getfpdBuildOpts();
1741 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
1743 XmlCursor cursor
= o
.newCursor();
1744 QName qFfs
= new QName(xmlNs
, "Ffs");
1745 if (cursor
.toChild(qFfs
)) {
1746 for (int j
= 0; j
< i
; ++j
) {
1747 cursor
.toNextSibling(qFfs
);
1749 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
1755 public void removeBuildOptionsFfs(int i
) {
1756 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1761 XmlCursor cursor
= ffs
.newCursor();
1768 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
1769 if (fpdPlatformDefs
== null){
1770 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
1772 return fpdPlatformDefs
;
1775 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
1776 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1779 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1780 while(li
.hasNext()) {
1781 archs
.add(li
.next());
1785 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
1786 getfpdPlatformDefs().setSupportedArchitectures(archs
);
1789 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1790 if (getfpdPlatformDefs().getBuildTargets() == null) {
1793 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
1794 while(li
.hasNext()) {
1795 targets
.add(li
.next());
1799 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1800 getfpdPlatformDefs().setBuildTargets(targets
);
1803 public void genPlatformDefsSkuInfo(String id
, String name
) {
1804 SkuInfoDocument
.SkuInfo skuInfo
= null;
1805 if (getfpdPlatformDefs().getSkuInfo() == null) {
1806 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
1808 skuInfo
= getfpdPlatformDefs().getSkuInfo();
1809 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
1810 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1811 skuName
.setSkuID(new BigInteger("0"));
1812 skuName
.setStringValue("DEFAULT");
1814 if (id
.equals("0")) {
1817 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1818 skuName
.setSkuID(new BigInteger(id
));
1819 skuName
.setStringValue(name
);
1822 public int getPlatformDefsSkuInfoCount(){
1823 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1826 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1829 public void getPlatformDefsSkuInfos(String
[][] saa
){
1830 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1834 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1835 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
1837 while(li
.hasNext()) {
1838 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
1839 saa
[i
][0] = sku
.getSkuID()+"";
1840 saa
[i
][1] = sku
.getStringValue();
1845 public void removePlatformDefsSkuInfo(int i
) {
1846 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1847 if (skuInfo
== null || i
== 0) {
1851 XmlCursor cursor
= skuInfo
.newCursor();
1852 if (cursor
.toFirstChild()) {
1853 for (int j
= 0; j
< i
; ++j
) {
1854 cursor
.toNextSibling();
1861 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
1862 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1863 if (skuInfo
== null || i
== 0) {
1867 XmlCursor cursor
= skuInfo
.newCursor();
1868 if (cursor
.toFirstChild()) {
1869 for (int j
= 0; j
< i
; ++j
) {
1870 cursor
.toNextSibling();
1872 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
1873 sku
.setSkuID(new BigInteger(id
));
1874 sku
.setStringValue(name
);
1879 public String
getPlatformDefsInterDir(){
1880 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
1883 return getfpdPlatformDefs().getIntermediateDirectories().toString();
1886 public void setPlatformDefsInterDir(String interDir
){
1887 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
1890 public String
getPlatformDefsOutputDir() {
1891 return getfpdPlatformDefs().getOutputDirectory();
1894 public void setPlatformDefsOutputDir(String outputDir
) {
1895 if (outputDir
!= null && outputDir
.length() > 0) {
1896 getfpdPlatformDefs().setOutputDirectory(outputDir
);
1899 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
1900 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
1907 public FlashDocument
.Flash
getfpdFlash() {
1908 if (fpdFlash
== null) {
1909 fpdFlash
= fpdRoot
.addNewFlash();
1914 public void genFlashDefinitionFile(String file
) {
1915 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1917 fdf
= getfpdFlash().addNewFlashDefinitionFile();
1920 fdf
.setStringValue(file
);
1923 public String
getFlashDefinitionFile() {
1924 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1929 return fdf
.getStringValue();
1932 public void genFvImagesNameValue(String name
, String value
) {
1934 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1936 fi
= getfpdFlash().addNewFvImages();
1939 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
1944 public void removeFvImagesNameValue(int i
){
1946 XmlObject o
= getfpdFlash().getFvImages();
1951 QName qNameValue
= new QName(xmlNs
, "NameValue");
1952 XmlCursor cursor
= o
.newCursor();
1953 if (cursor
.toChild(qNameValue
)) {
1954 for (int j
= 0; j
< i
; ++j
) {
1955 cursor
.toNextSibling(qNameValue
);
1962 public void updateFvImagesNameValue(int i
, String name
, String value
){
1964 XmlObject o
= getfpdFlash().getFvImages();
1969 QName qNameValue
= new QName(xmlNs
, "NameValue");
1970 XmlCursor cursor
= o
.newCursor();
1971 if (cursor
.toChild(qNameValue
)) {
1972 for (int j
= 0; j
< i
; ++j
) {
1973 cursor
.toNextSibling(qNameValue
);
1975 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
1982 public int getFvImagesNameValueCount() {
1984 FvImagesDocument
.FvImages fi
= null;
1985 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
1988 return fi
.getNameValueList().size();
1991 public void getFvImagesNameValues(String
[][] nv
) {
1993 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1997 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
1999 ListIterator li
= l
.listIterator();
2000 while (li
.hasNext()) {
2001 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2003 nv
[i
][0] = e
.getName();
2004 nv
[i
][1] = e
.getValue();
2010 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2012 FvImagesDocument
.FvImages fis
= null;
2013 if ((fis
= getfpdFlash().getFvImages()) == null) {
2014 fis
= getfpdFlash().addNewFvImages();
2018 //gen FvImage with FvImageNames array
2020 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2021 for (int i
= 0; i
< names
.length
; ++i
) {
2022 fi
.addFvImageNames(names
[i
]);
2024 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2025 if (options
!= null){
2026 setFvImagesFvImageFvImageOptions(options
, fi
);
2030 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2031 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2033 fio
= fi
.addNewFvImageOptions();
2036 Set
<String
> key
= options
.keySet();
2037 Iterator
<String
> i
= key
.iterator();
2038 while (i
.hasNext()) {
2040 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2041 String k
= (String
)i
.next();
2044 nv
.setValue((String
)options
.get(k
));
2051 public void removeFvImagesFvImage(int i
) {
2053 XmlObject o
= getfpdFlash().getFvImages();
2058 QName qFvImage
= new QName(xmlNs
, "FvImage");
2059 XmlCursor cursor
= o
.newCursor();
2060 if (cursor
.toChild(qFvImage
)) {
2061 for (int j
= 0; j
< i
; ++j
) {
2062 cursor
.toNextSibling(qFvImage
);
2069 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2071 XmlObject o
= getfpdFlash().getFvImages();
2075 XmlCursor cursor
= o
.newCursor();
2076 QName qFvImage
= new QName(xmlNs
, "FvImage");
2077 if (cursor
.toChild(qFvImage
)) {
2078 for (int j
= 0; j
< i
; ++j
) {
2079 cursor
.toNextSibling(qFvImage
);
2081 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2082 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2085 // remove old FvImageNames before adding new ones
2087 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2088 cursor
.toChild(qFvImageNames
);
2090 while (cursor
.toNextSibling(qFvImageNames
)) {
2094 for (int k
= 0; k
< names
.length
; ++k
) {
2095 fi
.addFvImageNames(names
[k
]);
2098 // remove old FvImageOptions before adding new options
2100 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2101 cursor
.toNextSibling(qFvImageOptions
);
2104 setFvImagesFvImageFvImageOptions(options
, fi
);
2109 public int getFvImagesFvImageCount() {
2111 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2114 return getfpdFlash().getFvImages().getFvImageList().size();
2117 /**Only Get Fv image setting - name and type.
2120 public void getFvImagesFvImages(String
[][] saa
) {
2122 if (getfpdFlash().getFvImages() == null) {
2125 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2129 ListIterator li
= l
.listIterator();
2131 while(li
.hasNext()) {
2132 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2134 // get FvImageNames array, space separated
2136 List
<String
> lfn
= fi
.getFvImageNamesList();
2137 ListIterator lfni
= lfn
.listIterator();
2139 while (lfni
.hasNext()) {
2140 saa
[i
][0] += (String
)lfni
.next();
2143 saa
[i
][0] = saa
[i
][0].trim();
2145 saa
[i
][1] = fi
.getType()+"";
2151 /**Get FvImage Options for FvImage i
2152 * @param i the ith FvImage
2154 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2155 XmlObject o
= getfpdFlash().getFvImages();
2159 XmlCursor cursor
= o
.newCursor();
2160 QName qFvImage
= new QName(xmlNs
, "FvImage");
2161 if (cursor
.toChild(qFvImage
)) {
2162 for (int j
= 0; j
< i
; ++j
) {
2163 cursor
.toNextSibling(qFvImage
);
2165 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2166 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2169 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2170 while(li
.hasNext()){
2171 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2172 m
.put(nv
.getName(), nv
.getValue());
2178 Get platform header element
2179 @return PlatformHeaderDocument.PlatformHeader
2181 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2182 if (fpdHdr
== null) {
2183 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2185 genPlatformDefsSkuInfo("0", "DEFAULT");
2189 public String
getFpdHdrPlatformName() {
2190 return getFpdHdr().getPlatformName();
2193 public String
getFpdHdrGuidValue() {
2194 return getFpdHdr().getGuidValue();
2197 public String
getFpdHdrVer() {
2198 return getFpdHdr().getVersion();
2201 public String
getFpdHdrAbs() {
2202 return getFpdHdr().getAbstract();
2205 public String
getFpdHdrDescription() {
2206 return getFpdHdr().getDescription();
2209 public String
getFpdHdrCopyright() {
2210 return getFpdHdr().getCopyright();
2213 public String
getFpdHdrLicense() {
2214 LicenseDocument
.License l
= getFpdHdr().getLicense();
2218 return l
.getStringValue();
2221 public String
getFpdHdrUrl() {
2222 LicenseDocument
.License l
= getFpdHdr().getLicense();
2229 public String
getFpdHdrSpec() {
2231 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2232 // return getFpdHdr().getSpecification();
2235 public void setFpdHdrPlatformName(String name
){
2236 getFpdHdr().setPlatformName(name
);
2239 public void setFpdHdrGuidValue(String guid
){
2240 getFpdHdr().setGuidValue(guid
);
2243 public void setFpdHdrVer(String v
){
2244 getFpdHdr().setVersion(v
);
2247 public void setFpdHdrAbs(String abs
) {
2248 getFpdHdr().setAbstract(abs
);
2251 public void setFpdHdrDescription(String desc
){
2252 getFpdHdr().setDescription(desc
);
2255 public void setFpdHdrCopyright(String cr
) {
2256 getFpdHdr().setCopyright(cr
);
2259 public void setFpdHdrLicense(String license
){
2260 LicenseDocument
.License l
= getFpdHdr().getLicense();
2262 getFpdHdr().addNewLicense().setStringValue(license
);
2265 l
.setStringValue(license
);
2269 public void setFpdHdrUrl(String url
){
2270 LicenseDocument
.License l
= getFpdHdr().getLicense();
2276 public void setFpdHdrSpec(String s
){
2277 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2278 getFpdHdr().setSpecification(s
);
2281 Save the processed xml contents to file
2283 @param fpdFile The file to save xml contents
2284 @throws IOException Exceptions during file operation
2286 public void saveAs(File fpdFile
) throws IOException
{
2288 XmlOptions options
= new XmlOptions();
2290 options
.setCharacterEncoding("UTF-8");
2291 options
.setSavePrettyPrint();
2292 options
.setSavePrettyPrintIndent(2);
2294 fpdd
.save(fpdFile
, options
);
2295 } catch (IOException e
) {
2296 e
.printStackTrace();
2301 private String
listToString(List l
) {
2306 ListIterator li
= l
.listIterator();
2307 while(li
.hasNext()) {
2315 class PcdItemTypeConflictException
extends Exception
{
2320 private static final long serialVersionUID
= 1L;
2321 private String details
= null;
2323 PcdItemTypeConflictException(String info
){
2327 public String
getMessage() {
2332 class PcdDeclNotFound
extends Exception
{
2337 private static final long serialVersionUID
= 1L;
2338 private String details
= null;
2340 PcdDeclNotFound(String info
) {
2344 public String
getMessage() {
2349 class PcdValueMalFormed
extends Exception
{
2354 private static final long serialVersionUID
= 1L;
2355 private String details
= null;
2357 PcdValueMalFormed(String info
) {
2361 public String
getMessage() {