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])) {
222 // if (s[1] != null) {
226 // if (msa.getPackageVersion() != null) {
227 // if (!msa.getPackageVersion().equals(s[3])) {
232 // if (s[3] != null) {
241 public void removeModuleSA(int i
) {
242 XmlObject o
= getfpdFrameworkModules();
247 XmlCursor cursor
= o
.newCursor();
248 if (cursor
.toFirstChild()) {
249 for (int j
= 0; j
< i
; ++j
) {
250 cursor
.toNextSibling();
253 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
255 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
256 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
257 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion();
258 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
259 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
260 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
261 while(li
.hasNext()) {
262 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
263 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
271 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
273 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
277 String
[] s
= moduleInfo
.split(" ");
278 for(int i
= 0; i
< al
.size(); ++i
){
279 String consumer
= al
.get(i
);
280 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
286 if (al
.size() == 0) {
287 dynPcdMap
.remove(pcdKey
);
288 String
[] s1
= pcdKey
.split(" ");
289 removeDynamicPcdBuildData(s1
[0], s1
[1]);
294 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
296 public int getPcdDataCount(String key
){
297 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
298 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
301 return msa
.getPcdBuildDefinition().getPcdDataList().size();
304 public void getPcdData(String key
, String
[][] saa
) {
305 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
306 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
309 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
310 for (int i
= 0; i
< saa
.length
; ++i
) {
311 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
312 saa
[i
][0] = pcdData
.getCName();
313 saa
[i
][1] = pcdData
.getTokenSpaceGuidCName();
314 saa
[i
][2] = pcdData
.getItemType()+"";
315 saa
[i
][3] = pcdData
.getToken().toString();
316 saa
[i
][4] = pcdData
.getMaxDatumSize()+"";
317 saa
[i
][5] = pcdData
.getDatumType()+"";
318 saa
[i
][6] = pcdData
.getValue();
323 public void updatePcdData(String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
324 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
325 if (msa
== null || msa
.getPcdBuildDefinition() == null){
329 XmlCursor cursor
= msa
.getPcdBuildDefinition().newCursor();
330 if (cursor
.toFirstChild()){
332 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
333 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
334 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
335 if(pcdData
.getDatumType().equals("VOID*")) {
336 pcdData
.setMaxDatumSize(new Integer(maxSize
));
338 pcdData
.setValue(value
);
342 while(cursor
.toNextSibling());
347 /**Get original Pcd info from MSA & SPD files.
348 * @param mi ModuleIdentification from which MSA & SPD come
349 * @param cName PCD cName
350 * @param sa Results: HelpText, Original item type.
353 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String
[] sa
) throws Exception
{
356 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
357 if (msa
.getPcdCoded() == null) {
361 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
362 m
.put("ModuleSurfaceArea", msa
);
363 SurfaceAreaQuery
.setDoc(m
);
364 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
366 // First look through MSA pcd entries.
368 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
369 ListIterator li
= l
.listIterator();
370 while(li
.hasNext()) {
371 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
372 if (!msaPcd
.getCName().equals(cName
)) {
375 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
376 if (spdPcd
== null) {
380 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
383 // Get Pcd help text and original item type.
385 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
386 sa
[1] = msaPcd
.getPcdItemType()+"";
400 /**Remove PCDBuildDefinition entries from ModuleSA
401 * @param moduleKey identifier of ModuleSA.
402 * @param consumer where these entries come from.
404 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
406 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(consumer
);
407 if (msa
.getPcdCoded() == null) {
411 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
412 ListIterator li
= l
.listIterator();
414 while(li
.hasNext()) {
415 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
416 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
417 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
418 if (cursor
.toFirstChild()) {
419 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
420 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
422 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
426 while (cursor
.toNextSibling()) {
427 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
428 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
429 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
445 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
447 public int getLibraryInstancesCount(String key
) {
448 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
449 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
452 return msa
.getLibraries().getInstanceList().size();
455 public void getLibraryInstances(String key
, String
[][] saa
){
456 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
457 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
461 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
462 for (int i
= 0; i
< saa
.length
; ++i
) {
463 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
464 saa
[i
][1] = instance
.getModuleGuid();
465 saa
[i
][2] = instance
.getModuleVersion();
466 saa
[i
][3] = instance
.getPackageGuid();
467 saa
[i
][4] = instance
.getPackageVersion();
471 public void removeLibraryInstance(String key
, int i
) {
472 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
473 if (msa
== null || msa
.getLibraries() == null){
477 XmlCursor cursor
= msa
.getLibraries().newCursor();
478 if (cursor
.toFirstChild()) {
479 for (int j
= 0; j
< i
; ++j
) {
480 cursor
.toNextSibling();
488 public void genLibraryInstance(String mg
, String mv
, String pg
, String pv
, String key
) {
489 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
491 msa
= getfpdFrameworkModules().addNewModuleSA();
493 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
495 libs
= msa
.addNewLibraries();
498 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
499 instance
.setModuleGuid(mg
);
500 instance
.setModuleVersion(mv
);
501 instance
.setPackageGuid(pg
);
502 instance
.setPackageVersion(pv
);
506 public String
getFvBinding(String moduleKey
){
507 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
508 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
511 return msa
.getModuleSaBuildOptions().getFvBinding();
514 public void setFvBinding(String moduleKey
, String fvBinding
){
515 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
519 if(msa
.getModuleSaBuildOptions() == null){
520 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
523 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
526 public String
getFfsFileNameGuid(String moduleKey
){
527 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
528 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
531 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
534 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
535 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
539 if(msa
.getModuleSaBuildOptions() == null){
540 msa
.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
543 msa
.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
546 public String
getFfsFormatKey(String moduleKey
){
547 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
548 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
551 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
554 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
555 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
559 if(msa
.getModuleSaBuildOptions() == null){
560 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
563 msa
.getModuleSaBuildOptions().setFvBinding(ffsKey
);
566 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
567 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
568 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
569 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
573 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
574 ListIterator li
= lOpt
.listIterator();
576 while(li
.hasNext()) {
577 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
578 if (opt
.getBuildTargets() != null) {
579 saa
[i
][0] = listToString(opt
.getBuildTargets());
581 saa
[i
][1] = opt
.getToolChainFamily();
582 if (opt
.getSupArchList() != null){
583 saa
[i
][2] = listToString(opt
.getSupArchList());
586 saa
[i
][3] = opt
.getToolCode();
587 saa
[i
][4] = opt
.getTagName();
588 saa
[i
][5] = opt
.getStringValue();
594 public int getModuleSAOptionsCount(String moduleKey
){
595 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
596 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
597 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
600 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
603 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
604 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
605 if (msa
.getModuleSaBuildOptions() == null) {
606 msa
.addNewModuleSaBuildOptions();
608 if (msa
.getModuleSaBuildOptions().getOptions() == null){
609 msa
.getModuleSaBuildOptions().addNewOptions();
611 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
612 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
615 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
616 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
617 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
620 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
621 XmlCursor cursor
= opts
.newCursor();
622 if (cursor
.toFirstChild()) {
623 for (int j
= 0; j
< i
; ++j
){
624 cursor
.toNextSibling();
631 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
632 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
633 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
636 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
637 XmlCursor cursor
= opts
.newCursor();
638 if (cursor
.toFirstChild()) {
639 for (int j
= 0; j
< i
; ++j
){
640 cursor
.toNextSibling();
642 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
643 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
648 /**add pcd information of module mi to a ModuleSA.
650 * @param moduleSa if null, generate a new ModuleSA.
652 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
653 //ToDo add Arch filter
656 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
657 if (msa
.getPcdCoded() == null) {
660 if (moduleSa
== null) {
661 moduleSa
= genModuleSA(mi
);
663 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
664 m
.put("ModuleSurfaceArea", msa
);
665 SurfaceAreaQuery
.setDoc(m
);
666 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
668 // Implementing InitializePlatformPcdBuildDefinitions
670 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
671 ListIterator li
= l
.listIterator();
672 while(li
.hasNext()) {
673 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
674 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
675 if (spdPcd
== null) {
679 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
682 // AddItem to ModuleSA PcdBuildDefinitions
684 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
686 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
697 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
699 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
700 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
701 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
702 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
703 SurfaceAreaQuery
.setDoc(m
);
704 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
708 for (int j
= 0; j
< xo
.length
; ++j
) {
709 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
710 if (msaPcd
.getTokenSpaceGuidCName() == null) {
711 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
716 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
727 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
) {
728 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
729 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
730 msa
.setModuleGuid(mi
.getGuid());
731 msa
.setModuleVersion(mi
.getVersion());
732 msa
.setPackageGuid(pi
.getGuid());
733 msa
.setPackageVersion(pi
.getVersion());
738 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
739 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
740 if (moduleSa
.getPcdBuildDefinition() == null){
741 moduleSa
.addNewPcdBuildDefinition();
744 // constructe pcd to modulesa mapping first.
745 // Attention : for any error condition, remove from map this pcd.
747 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
748 if (pcdConsumer
== null) {
749 pcdConsumer
= new ArrayList
<String
>();
751 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
752 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion()
754 pcdConsumer
.add(listValue
);
755 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
757 // Special dynamic type, if this pcd already exists in other ModuleSA
759 if (itemType
.equals("DYNAMIC")) {
761 ListIterator li
= pcdConsumer
.listIterator();
762 while(li
.hasNext()) {
763 String value
= li
.next().toString();
764 String
[] valuePart
= value
.split(" ");
765 if (!valuePart
[4].equals("DYNAMIC")) {
766 //ToDo error for same pcd, other type than dynamic
767 pcdConsumer
.remove(listValue
);
768 throw new PcdItemTypeConflictException(value
);
773 ListIterator li
= pcdConsumer
.listIterator();
774 while(li
.hasNext()) {
775 String value
= li
.next().toString();
776 String
[] valuePart
= value
.split(" ");
777 if (valuePart
[4].equals("DYNAMIC")) {
778 //ToDo error for same pcd, other type than non-dynamic
779 pcdConsumer
.remove(listValue
);
780 throw new PcdItemTypeConflictException(value
);
785 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
786 fpdPcd
.setCName(cName
);
787 fpdPcd
.setToken(token
);
788 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
789 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
790 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
792 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
793 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
795 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
796 // so need to add one dyn pcd.
798 if (al
.size() == 1) {
799 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
803 if (defaultVal
!= null){
804 fpdPcd
.setValue(defaultVal
);
807 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
808 fpdPcd
.setValue("0");
810 if (dataType
.equals("BOOLEAN")){
811 fpdPcd
.setValue("false");
813 if (dataType
.equals("VOID*")) {
817 if (dataType
.equals("UINT8")){
818 fpdPcd
.setMaxDatumSize(1);
820 if (dataType
.equals("UINT16")) {
821 fpdPcd
.setMaxDatumSize(2);
823 if (dataType
.equals("UINT32")) {
824 fpdPcd
.setMaxDatumSize(4);
826 if (dataType
.equals("UINT64")){
827 fpdPcd
.setMaxDatumSize(8);
829 if (dataType
.equals("BOOLEAN")){
830 fpdPcd
.setMaxDatumSize(1);
832 if (dataType
.equals("VOID*")) {
833 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
834 fpdPcd
.setMaxDatumSize(maxSize
);
839 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
843 char ch
= datum
.charAt(0);
847 // For void* type PCD, only three datum is support:
848 // 1) Unicode: string with start char is "L"
849 // 2) Ansci: String is ""
850 // 3) byte array: String start char "{"
853 start
= datum
.indexOf('\"');
854 end
= datum
.lastIndexOf('\"');
856 (end
> datum
.length())||
857 ((start
== end
) && (datum
.length() > 0))) {
858 //ToDo Error handling here
859 throw new PcdValueMalFormed (datum
);
862 strValue
= datum
.substring(start
+ 1, end
);
863 return strValue
.length() * 2;
864 } else if (ch
== '\"'){
865 start
= datum
.indexOf('\"');
866 end
= datum
.lastIndexOf('\"');
868 (end
> datum
.length())||
869 ((start
== end
) && (datum
.length() > 0))) {
870 throw new PcdValueMalFormed (datum
);
872 strValue
= datum
.substring(start
+ 1, end
);
873 return strValue
.length();
874 } else if (ch
=='{') {
875 String
[] strValueArray
;
877 start
= datum
.indexOf('{');
878 end
= datum
.lastIndexOf('}');
879 strValue
= datum
.substring(start
+ 1, end
);
880 strValue
= strValue
.trim();
881 if (strValue
.length() == 0) {
884 strValueArray
= strValue
.split(",");
885 for (int index
= 0; index
< strValueArray
.length
; index
++) {
886 Integer value
= Integer
.decode(strValueArray
[index
].trim());
889 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
890 // "it is byte array in fact. But the element of %s exceed the byte range",
891 throw new PcdValueMalFormed (datum
);
894 return strValueArray
.length
;
898 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
899 // "1) UNICODE string: like L\"xxxx\";\r\n"+
900 // "2) ANSIC string: like \"xxx\";\r\n"+
901 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
902 // "but the datum in seems does not following above format!",
903 throw new PcdValueMalFormed (datum
);
908 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
909 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
914 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
916 return dynPcdMap
.get("pcdKey");
919 public int getDynamicPcdBuildDataCount() {
920 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
923 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
926 public void getDynamicPcdBuildData(String
[][] saa
) {
927 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
930 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
931 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
933 while(li
.hasNext()) {
934 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
935 saa
[i
][0] = dynPcd
.getCName();
936 saa
[i
][1] = dynPcd
.getToken().toString();
937 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
938 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
939 saa
[i
][4] = dynPcd
.getDatumType().toString();
945 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
946 throws PcdValueMalFormed
{
947 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
948 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
949 dynPcdData
.setCName(cName
);
950 dynPcdData
.setToken(token
);
951 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
952 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
954 BigInteger bigInt
= new BigInteger("0");
955 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
956 skuInfo
.setSkuId(bigInt
);
957 if (defaultVal
!= null){
958 skuInfo
.setValue(defaultVal
);
961 if (dataType
.equals("UINT8")){
962 skuInfo
.setValue("0");
964 if (dataType
.equals("UINT16")) {
965 skuInfo
.setValue("0");
967 if (dataType
.equals("UINT32")) {
968 skuInfo
.setValue("0");
970 if (dataType
.equals("UINT64")){
971 skuInfo
.setValue("0");
973 if (dataType
.equals("BOOLEAN")){
974 skuInfo
.setValue("false");
976 if (dataType
.equals("VOID*")) {
977 skuInfo
.setValue("");
980 if (dataType
.equals("UINT8")){
981 dynPcdData
.setMaxDatumSize(1);
983 if (dataType
.equals("UINT16")) {
984 dynPcdData
.setMaxDatumSize(2);
986 if (dataType
.equals("UINT32")) {
987 dynPcdData
.setMaxDatumSize(4);
989 if (dataType
.equals("UINT64")){
990 dynPcdData
.setMaxDatumSize(8);
992 if (dataType
.equals("BOOLEAN")){
993 dynPcdData
.setMaxDatumSize(1);
995 if (dataType
.equals("VOID*")) {
996 int maxSize
= setMaxSizeForPointer(defaultVal
);
997 dynPcdData
.setMaxDatumSize(maxSize
);
1001 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1002 XmlObject o
= getfpdDynPcdBuildDefs();
1004 XmlCursor cursor
= o
.newCursor();
1005 if (cursor
.toFirstChild()) {
1006 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1007 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1008 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1013 while (cursor
.toNextSibling()) {
1015 pcdBuildData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1016 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1026 // Get the Sku Info count of ith dyn pcd element.
1028 public int getDynamicPcdSkuInfoCount(int i
){
1029 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1033 int skuInfoCount
= 0;
1034 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1035 if (cursor
.toFirstChild()) {
1036 for (int j
= 0; j
< i
; ++j
) {
1037 cursor
.toNextSibling();
1039 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1040 if (pcdData
.getSkuInfoList() == null) {
1044 skuInfoCount
= pcdData
.getSkuInfoList().size();
1048 return skuInfoCount
;
1051 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1052 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1056 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1057 if (cursor
.toFirstChild()) {
1058 for (int j
= 0; j
< i
; ++j
) {
1059 cursor
.toNextSibling();
1061 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1062 if (pcdData
.getSkuInfoList() == null) {
1067 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1069 while (li
.hasNext()) {
1070 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1071 saa
[k
][0] = skuInfo
.getSkuId()+"";
1072 saa
[k
][1] = skuInfo
.getVariableName();
1073 saa
[k
][2] = skuInfo
.getVariableGuid();
1074 saa
[k
][3] = skuInfo
.getVariableOffset();
1075 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1076 saa
[k
][5] = skuInfo
.getVpdOffset();
1077 saa
[k
][6] = skuInfo
.getValue();
1087 public String
getDynamicPcdBuildDataValue(int i
){
1088 String value
= null;
1089 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1093 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1094 if (cursor
.toFirstChild()) {
1095 for (int j
= 0; j
< i
; ++j
) {
1096 cursor
.toNextSibling();
1098 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1099 if (pcdData
.getSkuInfoList() == null) {
1103 value
= pcdData
.getSkuInfoArray(0).getValue();
1110 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1111 String vpdOffset
= null;
1112 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1116 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1117 if (cursor
.toFirstChild()) {
1118 for (int j
= 0; j
< i
; ++j
) {
1119 cursor
.toNextSibling();
1121 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1122 if (pcdData
.getSkuInfoList() == null) {
1126 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1133 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1134 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1138 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1139 if (cursor
.toFirstChild()) {
1140 for (int j
= 0; j
< i
; ++j
) {
1141 cursor
.toNextSibling();
1143 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1144 if (pcdData
.getSkuInfoList() == null) {
1149 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1150 cursor
.toChild(qSkuInfo
);
1157 // generate sku info for ith dyn pcd build data.
1159 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1160 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1161 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1165 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1166 if (cursor
.toFirstChild()) {
1167 for (int j
= 0; j
< i
; ++j
) {
1168 cursor
.toNextSibling();
1170 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1171 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1172 skuInfo
.setSkuId(new BigInteger(id
));
1173 if (varName
!= null){
1174 skuInfo
.setVariableName(varName
);
1175 skuInfo
.setVariableGuid(varGuid
);
1176 skuInfo
.setVariableOffset(varOffset
);
1177 skuInfo
.setHiiDefaultValue(hiiDefault
);
1179 else if (vpdOffset
!= null){
1180 skuInfo
.setVpdOffset(vpdOffset
);
1183 skuInfo
.setValue(value
);
1188 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1189 String hiiDefault
, String vpdOffset
, String value
, int i
){
1190 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1194 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1195 if (cursor
.toFirstChild()) {
1196 for (int j
= 0; j
< i
; ++j
) {
1197 cursor
.toNextSibling();
1199 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1200 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1201 while (li
.hasNext()) {
1202 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1203 if (skuInfo
.getSkuId().toString().equals(id
)){
1204 if (varName
!= null){
1205 skuInfo
.setVariableName(varName
);
1206 skuInfo
.setVariableGuid(varGuid
);
1207 skuInfo
.setVariableOffset(varOffset
);
1208 skuInfo
.setHiiDefaultValue(hiiDefault
);
1210 else if (vpdOffset
!= null){
1211 skuInfo
.setVpdOffset(vpdOffset
);
1214 skuInfo
.setValue(value
);
1222 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1223 if (fpdBuildOpts
== null) {
1224 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1226 return fpdBuildOpts
;
1229 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1230 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1231 if (udats
== null) {
1232 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1235 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1236 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1239 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1240 at
.setId(new Integer(id
));
1241 if (fileName
!= null){
1242 at
.setFilename(fileName
);
1244 if (execOrder
!= null) {
1245 at
.setAntCmdOptions(execOrder
);
1249 public void removeBuildOptionsUserDefAntTask(int i
) {
1250 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1254 XmlCursor cursor
= o
.newCursor();
1255 if (cursor
.toFirstChild()) {
1256 for (int j
= 0; j
< i
; ++j
) {
1257 cursor
.toNextSibling();
1264 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1265 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1269 XmlCursor cursor
= o
.newCursor();
1270 if (cursor
.toFirstChild()) {
1271 for (int j
= 0; j
< i
; ++j
) {
1272 cursor
.toNextSibling();
1274 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1275 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1280 public int getBuildOptionsUserDefAntTaskCount() {
1281 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1282 if (udats
== null || udats
.getAntTaskList() == null) {
1286 return udats
.getAntTaskList().size();
1289 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1290 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1291 if (udats
== null || udats
.getAntTaskList() == null) {
1295 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1296 ListIterator li
= l
.listIterator();
1298 while (li
.hasNext()) {
1299 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1300 saa
[i
][0] = at
.getId() + "";
1301 saa
[i
][1] = saa
[i
][2] = "";
1302 if (at
.getFilename() != null){
1303 saa
[i
][1] = at
.getFilename();
1305 if (at
.getAntCmdOptions() != null) {
1306 saa
[i
][2] = at
.getAntCmdOptions();
1311 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1312 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1314 opts
= getfpdBuildOpts().addNewOptions();
1316 OptionDocument
.Option opt
= opts
.addNewOption();
1317 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1320 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1321 opt
.setStringValue(contents
);
1323 opt
.setBuildTargets(buildTargets
);
1324 opt
.setToolChainFamily(toolChain
);
1325 opt
.setTagName(tagName
);
1326 opt
.setToolCode(toolCmd
);
1328 opt
.setSupArchList(archList
);
1331 public void removeBuildOptionsOpt(int i
){
1333 XmlObject o
= getfpdBuildOpts().getOptions();
1338 XmlCursor cursor
= o
.newCursor();
1339 if (cursor
.toFirstChild()) {
1340 for (int j
= 0; j
< i
; ++j
) {
1341 cursor
.toNextSibling();
1348 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1349 XmlObject o
= getfpdBuildOpts().getOptions();
1354 XmlCursor cursor
= o
.newCursor();
1355 if (cursor
.toFirstChild()) {
1356 for (int j
= 0; j
< i
; ++j
) {
1357 cursor
.toNextSibling();
1359 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1360 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1365 public int getBuildOptionsOptCount(){
1366 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1369 return getfpdBuildOpts().getOptions().getOptionList().size();
1372 public void getBuildOptionsOpts(String
[][] saa
) {
1373 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1377 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1378 ListIterator li
= lOpt
.listIterator();
1380 while(li
.hasNext()) {
1381 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1382 if (opt
.getBuildTargets() != null) {
1383 saa
[i
][0] = listToString(opt
.getBuildTargets());
1385 saa
[i
][1] = opt
.getToolChainFamily();
1386 if (opt
.getSupArchList() != null){
1387 saa
[i
][2] = listToString(opt
.getSupArchList());
1390 saa
[i
][3] = opt
.getToolCode();
1391 saa
[i
][4] = opt
.getTagName();
1392 saa
[i
][5] = opt
.getStringValue();
1398 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1399 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1400 ffs
.setFfsKey(ffsKey
);
1402 ffs
.addNewSections().setEncapsulationType(type
);
1406 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1407 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1409 ffs
.addNewSections().setEncapsulationType(type
);
1413 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1414 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1415 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1416 attrib
.setName(name
);
1417 attrib
.setValue(value
);
1420 /**update jth attribute of ith ffs.
1424 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1425 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1426 XmlCursor cursor
= ffs
.newCursor();
1427 QName qAttrib
= new QName(xmlNs
, "Attribute");
1428 if (cursor
.toChild(qAttrib
)) {
1429 for (int k
= 0; k
< j
; ++k
) {
1430 cursor
.toNextSibling(qAttrib
);
1432 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1433 attrib
.setName(name
);
1434 attrib
.setValue(value
);
1439 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1440 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1441 XmlCursor cursor
= ffs
.newCursor();
1442 QName qAttrib
= new QName(xmlNs
, "Attribute");
1443 if (cursor
.toChild(qAttrib
)) {
1444 for (int k
= 0; k
< j
; ++k
) {
1445 cursor
.toNextSibling(qAttrib
);
1452 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1453 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1457 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1459 if (sections
== null){
1460 sections
= ffs
.addNewSections();
1462 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1465 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1466 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1467 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1468 if (sections
== null) {
1471 XmlCursor cursor
= sections
.newCursor();
1472 QName qSection
= new QName(xmlNs
, "Section");
1473 if (cursor
.toChild(qSection
)) {
1474 for (int k
= 0; k
< j
; ++k
) {
1475 cursor
.toNextSibling(qSection
);
1482 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1483 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1484 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1485 if (sections
== null) {
1488 XmlCursor cursor
= sections
.newCursor();
1489 QName qSection
= new QName(xmlNs
, "Section");
1490 if (cursor
.toChild(qSection
)) {
1491 for (int k
= 0; k
< j
; ++k
) {
1492 cursor
.toNextSibling(qSection
);
1494 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1495 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1500 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1501 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1505 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1507 if (sections
== null){
1508 sections
= ffs
.addNewSections();
1510 sections
.addNewSections().setEncapsulationType(encapType
);
1513 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1514 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1515 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1516 if (sections
== null) {
1519 XmlCursor cursor
= sections
.newCursor();
1520 QName qSections
= new QName(xmlNs
, "Sections");
1521 if (cursor
.toChild(qSections
)) {
1522 for (int k
= 0; k
< j
; ++k
) {
1523 cursor
.toNextSibling(qSections
);
1530 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1531 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1532 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1533 if (sections
== null) {
1536 XmlCursor cursor
= sections
.newCursor();
1537 QName qSections
= new QName(xmlNs
, "Sections");
1538 if (cursor
.toChild(qSections
)) {
1539 for (int k
= 0; k
< j
; ++k
) {
1540 cursor
.toNextSibling(qSections
);
1542 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1543 sections2
.setEncapsulationType(type
);
1548 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1549 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1553 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1554 XmlCursor cursor
= sections
.newCursor();
1555 QName qSections
= new QName(xmlNs
, "Sections");
1556 if (cursor
.toChild(qSections
)){
1557 for (int k
= 0; k
< j
; ++k
) {
1558 cursor
.toNextSibling(qSections
);
1560 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1561 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1566 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1567 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1568 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1569 if (sections
== null) {
1572 XmlCursor cursor
= sections
.newCursor();
1573 QName qSections
= new QName(xmlNs
, "Sections");
1574 if (cursor
.toChild(qSections
)) {
1575 for (int l
= 0; l
< j
; ++l
) {
1576 cursor
.toNextSibling(qSections
);
1578 if (cursor
.toFirstChild()) {
1579 for (int m
= 0; m
< k
; ++m
) {
1580 cursor
.toNextSibling();
1588 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1589 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1590 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1591 if (sections
== null) {
1594 XmlCursor cursor
= sections
.newCursor();
1595 QName qSections
= new QName(xmlNs
, "Sections");
1596 if (cursor
.toChild(qSections
)) {
1597 for (int l
= 0; l
< j
; ++l
) {
1598 cursor
.toNextSibling(qSections
);
1600 if (cursor
.toFirstChild()) {
1601 for (int m
= 0; m
< k
; ++m
) {
1602 cursor
.toNextSibling();
1604 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1605 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1611 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1612 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1616 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1617 XmlCursor cursor
= sections
.newCursor();
1618 QName qSections
= new QName(xmlNs
, "Sections");
1619 if (cursor
.toChild(qSections
)){
1620 for (int k
= 0; k
< j
; ++k
) {
1621 cursor
.toNextSibling(qSections
);
1623 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1624 if (sections2
.getSectionList() == null){
1628 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1629 while(li
.hasNext()) {
1630 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1631 if (section
.isSetSectionType()) {
1632 al
.add(section
.getSectionType().toString());
1641 public int getBuildOptionsFfsCount(){
1642 if (getfpdBuildOpts().getFfsList() == null) {
1645 return getfpdBuildOpts().getFfsList().size();
1648 public void getBuildOptionsFfsKey(String
[][] saa
) {
1649 if (getfpdBuildOpts().getFfsList() == null) {
1652 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1654 while(li
.hasNext()){
1655 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1656 saa
[i
][0] = ffs
.getFfsKey();
1661 public void updateBuildOptionsFfsKey(int i
, String key
) {
1662 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1666 /**Get ith FFS key and contents.
1669 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
1670 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1674 sa
[0] = ffs
.getFfsKey();
1675 if (ffs
.getSections() != null) {
1676 if(ffs
.getSections().getEncapsulationType() != null){
1677 sa
[1] = ffs
.getSections().getEncapsulationType();
1679 if (ffs
.getSections().getSectionList() != null){
1680 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
1681 while (li
.hasNext()) {
1682 firstLevelSection
.add(li
.next().getSectionType().toString());
1685 if (ffs
.getSections().getSectionsList() != null) {
1686 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
1687 while(li
.hasNext()) {
1688 firstLevelSections
.add(li
.next().getEncapsulationType());
1692 if (ffs
.getAttributeList() != null) {
1693 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
1694 while(li
.hasNext()) {
1695 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
1696 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
1705 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
1706 XmlObject o
= getfpdBuildOpts();
1707 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
1709 XmlCursor cursor
= o
.newCursor();
1710 QName qFfs
= new QName(xmlNs
, "Ffs");
1711 if (cursor
.toChild(qFfs
)) {
1712 for (int j
= 0; j
< i
; ++j
) {
1713 cursor
.toNextSibling(qFfs
);
1715 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
1721 public void removeBuildOptionsFfs(int i
) {
1722 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1727 XmlCursor cursor
= ffs
.newCursor();
1734 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
1735 if (fpdPlatformDefs
== null){
1736 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
1738 return fpdPlatformDefs
;
1741 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
1742 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1745 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1746 while(li
.hasNext()) {
1747 archs
.add(li
.next());
1751 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
1752 getfpdPlatformDefs().setSupportedArchitectures(archs
);
1755 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1756 if (getfpdPlatformDefs().getBuildTargets() == null) {
1759 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
1760 while(li
.hasNext()) {
1761 targets
.add(li
.next());
1765 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1766 getfpdPlatformDefs().setBuildTargets(targets
);
1769 public void genPlatformDefsSkuInfo(String id
, String name
) {
1770 SkuInfoDocument
.SkuInfo skuInfo
= null;
1771 if (getfpdPlatformDefs().getSkuInfo() == null) {
1772 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
1774 skuInfo
= getfpdPlatformDefs().getSkuInfo();
1775 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
1776 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1777 skuName
.setSkuID(new BigInteger("0"));
1778 skuName
.setStringValue("DEFAULT");
1780 if (id
.equals("0")) {
1783 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1784 skuName
.setSkuID(new BigInteger(id
));
1785 skuName
.setStringValue(name
);
1788 public int getPlatformDefsSkuInfoCount(){
1789 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1792 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1795 public void getPlatformDefsSkuInfos(String
[][] saa
){
1796 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1800 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1801 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
1803 while(li
.hasNext()) {
1804 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
1805 saa
[i
][0] = sku
.getSkuID()+"";
1806 saa
[i
][1] = sku
.getStringValue();
1811 public void removePlatformDefsSkuInfo(int i
) {
1812 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1813 if (skuInfo
== null || i
== 0) {
1817 XmlCursor cursor
= skuInfo
.newCursor();
1818 if (cursor
.toFirstChild()) {
1819 for (int j
= 0; j
< i
; ++j
) {
1820 cursor
.toNextSibling();
1827 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
1828 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1829 if (skuInfo
== null || i
== 0) {
1833 XmlCursor cursor
= skuInfo
.newCursor();
1834 if (cursor
.toFirstChild()) {
1835 for (int j
= 0; j
< i
; ++j
) {
1836 cursor
.toNextSibling();
1838 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
1839 sku
.setSkuID(new BigInteger(id
));
1840 sku
.setStringValue(name
);
1845 public String
getPlatformDefsInterDir(){
1846 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
1849 return getfpdPlatformDefs().getIntermediateDirectories().toString();
1852 public void setPlatformDefsInterDir(String interDir
){
1853 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
1856 public String
getPlatformDefsOutputDir() {
1857 return getfpdPlatformDefs().getOutputDirectory();
1860 public void setPlatformDefsOutputDir(String outputDir
) {
1861 getfpdPlatformDefs().setOutputDirectory(outputDir
);
1864 public FlashDocument
.Flash
getfpdFlash() {
1865 if (fpdFlash
== null) {
1866 fpdFlash
= fpdRoot
.addNewFlash();
1871 public void genFlashDefinitionFile(String file
) {
1872 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1874 fdf
= getfpdFlash().addNewFlashDefinitionFile();
1877 fdf
.setStringValue(file
);
1880 public String
getFlashDefinitionFile() {
1881 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1886 return fdf
.getStringValue();
1889 public void genFvImagesNameValue(String name
, String value
) {
1891 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1893 fi
= getfpdFlash().addNewFvImages();
1896 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
1901 public void removeFvImagesNameValue(int i
){
1903 XmlObject o
= getfpdFlash().getFvImages();
1908 QName qNameValue
= new QName(xmlNs
, "NameValue");
1909 XmlCursor cursor
= o
.newCursor();
1910 if (cursor
.toChild(qNameValue
)) {
1911 for (int j
= 0; j
< i
; ++j
) {
1912 cursor
.toNextSibling(qNameValue
);
1919 public void updateFvImagesNameValue(int i
, String name
, String value
){
1921 XmlObject o
= getfpdFlash().getFvImages();
1926 QName qNameValue
= new QName(xmlNs
, "NameValue");
1927 XmlCursor cursor
= o
.newCursor();
1928 if (cursor
.toChild(qNameValue
)) {
1929 for (int j
= 0; j
< i
; ++j
) {
1930 cursor
.toNextSibling(qNameValue
);
1932 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
1939 public int getFvImagesNameValueCount() {
1941 FvImagesDocument
.FvImages fi
= null;
1942 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
1945 return fi
.getNameValueList().size();
1948 public void getFvImagesNameValues(String
[][] nv
) {
1950 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1954 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
1956 ListIterator li
= l
.listIterator();
1957 while (li
.hasNext()) {
1958 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
1960 nv
[i
][0] = e
.getName();
1961 nv
[i
][1] = e
.getValue();
1967 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
1969 FvImagesDocument
.FvImages fis
= null;
1970 if ((fis
= getfpdFlash().getFvImages()) == null) {
1971 fis
= getfpdFlash().addNewFvImages();
1975 //gen FvImage with FvImageNames array
1977 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
1978 for (int i
= 0; i
< names
.length
; ++i
) {
1979 fi
.addFvImageNames(names
[i
]);
1981 fi
.setType(FvImageTypes
.Enum
.forString(types
));
1982 if (options
!= null){
1983 setFvImagesFvImageFvImageOptions(options
, fi
);
1987 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
1988 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
1990 fio
= fi
.addNewFvImageOptions();
1993 Set
<String
> key
= options
.keySet();
1994 Iterator
<String
> i
= key
.iterator();
1995 while (i
.hasNext()) {
1997 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
1998 String k
= (String
)i
.next();
2001 nv
.setValue((String
)options
.get(k
));
2008 public void removeFvImagesFvImage(int i
) {
2010 XmlObject o
= getfpdFlash().getFvImages();
2015 QName qFvImage
= new QName(xmlNs
, "FvImage");
2016 XmlCursor cursor
= o
.newCursor();
2017 if (cursor
.toChild(qFvImage
)) {
2018 for (int j
= 0; j
< i
; ++j
) {
2019 cursor
.toNextSibling(qFvImage
);
2026 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2028 XmlObject o
= getfpdFlash().getFvImages();
2032 XmlCursor cursor
= o
.newCursor();
2033 QName qFvImage
= new QName(xmlNs
, "FvImage");
2034 if (cursor
.toChild(qFvImage
)) {
2035 for (int j
= 0; j
< i
; ++j
) {
2036 cursor
.toNextSibling(qFvImage
);
2038 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2039 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2042 // remove old FvImageNames before adding new ones
2044 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2045 cursor
.toChild(qFvImageNames
);
2047 while (cursor
.toNextSibling(qFvImageNames
)) {
2051 for (int k
= 0; k
< names
.length
; ++k
) {
2052 fi
.addFvImageNames(names
[k
]);
2055 // remove old FvImageOptions before adding new options
2057 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2058 cursor
.toNextSibling(qFvImageOptions
);
2061 setFvImagesFvImageFvImageOptions(options
, fi
);
2066 public int getFvImagesFvImageCount() {
2068 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2071 return getfpdFlash().getFvImages().getFvImageList().size();
2074 /**Only Get Fv image setting - name and type.
2077 public void getFvImagesFvImages(String
[][] saa
) {
2079 if (getfpdFlash().getFvImages() == null) {
2082 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2086 ListIterator li
= l
.listIterator();
2088 while(li
.hasNext()) {
2089 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2091 // get FvImageNames array, space separated
2093 List
<String
> lfn
= fi
.getFvImageNamesList();
2094 ListIterator lfni
= lfn
.listIterator();
2096 while (lfni
.hasNext()) {
2097 saa
[i
][0] += (String
)lfni
.next();
2100 saa
[i
][0] = saa
[i
][0].trim();
2102 saa
[i
][1] = fi
.getType()+"";
2108 /**Get FvImage Options for FvImage i
2109 * @param i the ith FvImage
2111 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2112 XmlObject o
= getfpdFlash().getFvImages();
2116 XmlCursor cursor
= o
.newCursor();
2117 QName qFvImage
= new QName(xmlNs
, "FvImage");
2118 if (cursor
.toChild(qFvImage
)) {
2119 for (int j
= 0; j
< i
; ++j
) {
2120 cursor
.toNextSibling(qFvImage
);
2122 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2123 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2126 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2127 while(li
.hasNext()){
2128 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2129 m
.put(nv
.getName(), nv
.getValue());
2135 Get platform header element
2136 @return PlatformHeaderDocument.PlatformHeader
2138 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2139 if (fpdHdr
== null) {
2140 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2142 genPlatformDefsSkuInfo("0", "DEFAULT");
2146 public String
getFpdHdrPlatformName() {
2147 return getFpdHdr().getPlatformName();
2150 public String
getFpdHdrGuidValue() {
2151 return getFpdHdr().getGuidValue();
2154 public String
getFpdHdrVer() {
2155 return getFpdHdr().getVersion();
2158 public String
getFpdHdrAbs() {
2159 return getFpdHdr().getAbstract();
2162 public String
getFpdHdrDescription() {
2163 return getFpdHdr().getDescription();
2166 public String
getFpdHdrCopyright() {
2167 return getFpdHdr().getCopyright();
2170 public String
getFpdHdrLicense() {
2171 LicenseDocument
.License l
= getFpdHdr().getLicense();
2175 return l
.getStringValue();
2178 public String
getFpdHdrUrl() {
2179 LicenseDocument
.License l
= getFpdHdr().getLicense();
2186 public String
getFpdHdrSpec() {
2188 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2189 // return getFpdHdr().getSpecification();
2192 public void setFpdHdrPlatformName(String name
){
2193 getFpdHdr().setPlatformName(name
);
2196 public void setFpdHdrGuidValue(String guid
){
2197 getFpdHdr().setGuidValue(guid
);
2200 public void setFpdHdrVer(String v
){
2201 getFpdHdr().setVersion(v
);
2204 public void setFpdHdrAbs(String abs
) {
2205 getFpdHdr().setAbstract(abs
);
2208 public void setFpdHdrDescription(String desc
){
2209 getFpdHdr().setDescription(desc
);
2212 public void setFpdHdrCopyright(String cr
) {
2213 getFpdHdr().setCopyright(cr
);
2216 public void setFpdHdrLicense(String license
){
2217 LicenseDocument
.License l
= getFpdHdr().getLicense();
2219 getFpdHdr().addNewLicense().setStringValue(license
);
2222 l
.setStringValue(license
);
2226 public void setFpdHdrUrl(String url
){
2227 LicenseDocument
.License l
= getFpdHdr().getLicense();
2233 public void setFpdHdrSpec(String s
){
2234 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2235 getFpdHdr().setSpecification(s
);
2238 Save the processed xml contents to file
2240 @param fpdFile The file to save xml contents
2241 @throws IOException Exceptions during file operation
2243 public void saveAs(File fpdFile
) throws IOException
{
2245 XmlOptions options
= new XmlOptions();
2247 options
.setCharacterEncoding("UTF-8");
2248 options
.setSavePrettyPrint();
2249 options
.setSavePrettyPrintIndent(2);
2251 fpdd
.save(fpdFile
, options
);
2252 } catch (IOException e
) {
2253 e
.printStackTrace();
2258 private String
listToString(List l
) {
2263 ListIterator li
= l
.listIterator();
2264 while(li
.hasNext()) {
2272 class PcdItemTypeConflictException
extends Exception
{
2277 private static final long serialVersionUID
= 1L;
2278 private String details
= null;
2280 PcdItemTypeConflictException(String info
){
2284 public String
getMessage() {
2289 class PcdDeclNotFound
extends Exception
{
2294 private static final long serialVersionUID
= 1L;
2295 private String details
= null;
2297 PcdDeclNotFound(String info
) {
2301 public String
getMessage() {
2306 class PcdValueMalFormed
extends Exception
{
2311 private static final long serialVersionUID
= 1L;
2312 private String details
= null;
2314 PcdValueMalFormed(String info
) {
2318 public String
getMessage() {