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() + " " + listToString(msa
.getSupArchList());
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
][0] = msa
.getModuleGuid();
198 saa
[i
][1] = msa
.getModuleVersion();
200 saa
[i
][2] = msa
.getPackageGuid();
201 saa
[i
][3] = msa
.getPackageVersion();
202 saa
[i
][4] = listToString(msa
.getSupArchList());
207 public void getFrameworkModuleInfo(int i
, String
[] sa
) {
208 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
212 sa
[0] = msa
.getModuleGuid();
213 sa
[1] = msa
.getModuleVersion();
214 sa
[2] = msa
.getPackageGuid();
215 sa
[3] = msa
.getPackageVersion();
216 sa
[4] = listToString(msa
.getSupArchList());
219 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
220 String
[] s
= key
.split(" ");
221 if (getfpdFrameworkModules().getModuleSAList() == null) {
224 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
225 while(li
.hasNext()) {
226 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
227 if (msa
.getModuleGuid().equals(s
[0]) && msa
.getPackageGuid().equals(s
[2])) {
228 if (msa
.getModuleVersion() != null) {
229 if (!msa
.getModuleVersion().equals(s
[1])) {
233 if (msa
.getPackageVersion() != null) {
234 if (!msa
.getPackageVersion().equals(s
[3])) {
238 //ToDo add arch check for s[4]
239 if (msa
.getSupArchList() != null) {
240 if (!listToString(msa
.getSupArchList()).equals(s
[4])) {
250 private ModuleSADocument
.ModuleSA
getModuleSA(int i
) {
251 ModuleSADocument
.ModuleSA msa
= null;
252 XmlCursor cursor
= getfpdFrameworkModules().newCursor();
253 if (cursor
.toFirstChild()) {
254 for (int j
= 0; j
< i
; ++j
) {
255 cursor
.toNextSibling();
257 msa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
263 public void removeModuleSA(int i
) {
264 XmlObject o
= getfpdFrameworkModules();
269 XmlCursor cursor
= o
.newCursor();
270 if (cursor
.toFirstChild()) {
271 for (int j
= 0; j
< i
; ++j
) {
272 cursor
.toNextSibling();
275 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
277 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
278 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
279 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList());
280 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
281 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
282 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
283 while(li
.hasNext()) {
284 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
285 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
289 if (getFrameworkModulesCount() == 0) {
297 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
299 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
303 String
[] s
= moduleInfo
.split(" ");
304 for(int i
= 0; i
< al
.size(); ++i
){
305 String consumer
= al
.get(i
);
306 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
307 String
[] consumerPart
= consumer
.split(" ");
308 if (!consumerPart
[4].equals(s
[4])) {
316 if (al
.size() == 0) {
317 dynPcdMap
.remove(pcdKey
);
318 String
[] s1
= pcdKey
.split(" ");
319 removeDynamicPcdBuildData(s1
[0], s1
[1]);
324 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
326 public int getPcdDataCount(int i
){
327 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
329 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
332 return msa
.getPcdBuildDefinition().getPcdDataList().size();
336 public void getPcdData(int i
, String
[][] saa
) {
337 ModuleSADocument
.ModuleSA msa
= getModuleSA(i
);
339 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
342 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
343 for (int k
= 0; k
< saa
.length
; ++k
) {
344 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
345 saa
[k
][0] = pcdData
.getCName();
346 saa
[k
][1] = pcdData
.getTokenSpaceGuidCName();
347 saa
[k
][2] = pcdData
.getItemType()+"";
348 saa
[k
][3] = pcdData
.getToken().toString();
349 saa
[k
][4] = pcdData
.getMaxDatumSize()+"";
350 saa
[k
][5] = pcdData
.getDatumType()+"";
351 saa
[k
][6] = pcdData
.getValue();
356 public void updatePcdData(String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
357 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
358 if (msa
== null || msa
.getPcdBuildDefinition() == null){
362 XmlCursor cursor
= msa
.getPcdBuildDefinition().newCursor();
363 if (cursor
.toFirstChild()){
365 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
366 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
367 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
368 if(pcdData
.getDatumType().equals("VOID*")) {
369 pcdData
.setMaxDatumSize(new Integer(maxSize
));
371 pcdData
.setValue(value
);
375 while(cursor
.toNextSibling());
380 /**Get original Pcd info from MSA & SPD files.
381 * @param mi ModuleIdentification from which MSA & SPD come
382 * @param cName PCD cName
383 * @param sa Results: HelpText, Original item type.
386 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String
[] sa
) throws Exception
{
389 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
390 if (msa
.getPcdCoded() == null) {
394 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
395 m
.put("ModuleSurfaceArea", msa
);
396 SurfaceAreaQuery
.setDoc(m
);
397 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
399 // First look through MSA pcd entries.
401 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
402 ListIterator li
= l
.listIterator();
403 while(li
.hasNext()) {
404 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
405 if (!msaPcd
.getCName().equals(cName
)) {
408 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
409 if (spdPcd
== null) {
413 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
416 // Get Pcd help text and original item type.
418 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
419 sa
[1] = msaPcd
.getPcdItemType()+"";
426 // e.printStackTrace();
433 /**Remove PCDBuildDefinition entries from ModuleSA
434 * @param moduleKey identifier of ModuleSA.
435 * @param consumer where these entries come from.
437 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
439 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(consumer
);
440 if (msa
.getPcdCoded() == null) {
444 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
445 ListIterator li
= l
.listIterator();
447 while(li
.hasNext()) {
448 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
449 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
450 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
451 if (cursor
.toFirstChild()) {
452 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
453 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
455 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
459 while (cursor
.toNextSibling()) {
460 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
461 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
462 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
478 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer Arch"
480 public int getLibraryInstancesCount(String key
) {
481 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
482 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
485 return msa
.getLibraries().getInstanceList().size();
488 public void getLibraryInstances(String key
, String
[][] saa
){
489 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
490 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
494 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
495 for (int i
= 0; i
< saa
.length
; ++i
) {
496 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
497 saa
[i
][1] = instance
.getModuleGuid();
498 saa
[i
][2] = instance
.getModuleVersion();
499 saa
[i
][3] = instance
.getPackageGuid();
500 saa
[i
][4] = instance
.getPackageVersion();
504 public void removeLibraryInstance(String key
, int i
) {
505 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
506 if (msa
== null || msa
.getLibraries() == null){
510 XmlCursor cursor
= msa
.getLibraries().newCursor();
511 if (cursor
.toFirstChild()) {
512 for (int j
= 0; j
< i
; ++j
) {
513 cursor
.toNextSibling();
521 public void genLibraryInstance(String mg
, String mv
, String pg
, String pv
, String key
) {
522 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
524 msa
= getfpdFrameworkModules().addNewModuleSA();
526 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
528 libs
= msa
.addNewLibraries();
531 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
532 instance
.setModuleGuid(mg
);
533 instance
.setModuleVersion(mv
);
534 instance
.setPackageGuid(pg
);
535 instance
.setPackageVersion(pv
);
539 public String
getFvBinding(String moduleKey
){
540 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
541 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
544 return msa
.getModuleSaBuildOptions().getFvBinding();
547 public void setFvBinding(String moduleKey
, String fvBinding
){
548 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
552 if(msa
.getModuleSaBuildOptions() == null){
553 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
556 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
559 public String
getFfsFileNameGuid(String moduleKey
){
560 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
561 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
564 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
567 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
568 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
572 if(msa
.getModuleSaBuildOptions() == null){
573 msa
.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
576 msa
.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
579 public String
getFfsFormatKey(String moduleKey
){
580 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
581 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
584 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
587 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
588 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
592 if(msa
.getModuleSaBuildOptions() == null){
593 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
596 msa
.getModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
599 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
600 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
601 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
602 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
606 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
607 ListIterator li
= lOpt
.listIterator();
609 while(li
.hasNext()) {
610 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
611 if (opt
.getBuildTargets() != null) {
612 saa
[i
][0] = listToString(opt
.getBuildTargets());
614 saa
[i
][1] = opt
.getToolChainFamily();
615 saa
[i
][2] = opt
.getTagName();
616 saa
[i
][3] = opt
.getToolCode();
618 if (opt
.getSupArchList() != null){
619 saa
[i
][4] = listToString(opt
.getSupArchList());
623 saa
[i
][5] = opt
.getStringValue();
629 public int getModuleSAOptionsCount(String moduleKey
){
630 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
631 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
632 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
635 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
638 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
639 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
640 if (msa
.getModuleSaBuildOptions() == null) {
641 msa
.addNewModuleSaBuildOptions();
643 if (msa
.getModuleSaBuildOptions().getOptions() == null){
644 msa
.getModuleSaBuildOptions().addNewOptions();
646 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
647 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
650 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
651 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
652 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
655 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
656 XmlCursor cursor
= opts
.newCursor();
657 if (cursor
.toFirstChild()) {
658 for (int j
= 0; j
< i
; ++j
){
659 cursor
.toNextSibling();
666 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
667 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
668 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
671 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
672 XmlCursor cursor
= opts
.newCursor();
673 if (cursor
.toFirstChild()) {
674 for (int j
= 0; j
< i
; ++j
){
675 cursor
.toNextSibling();
677 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
678 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
683 /**add pcd information of module mi to a ModuleSA.
685 * @param moduleSa if null, generate a new ModuleSA.
687 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, String arch
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
688 //ToDo add Arch filter
691 if (moduleSa
== null) {
692 moduleSa
= genModuleSA(mi
, arch
);
695 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
696 if (msa
.getPcdCoded() == null) {
700 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
701 m
.put("ModuleSurfaceArea", msa
);
702 SurfaceAreaQuery
.setDoc(m
);
703 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
705 // Implementing InitializePlatformPcdBuildDefinitions
707 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
708 ListIterator li
= l
.listIterator();
709 while(li
.hasNext()) {
710 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
711 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
712 if (spdPcd
== null) {
716 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
719 // AddItem to ModuleSA PcdBuildDefinitions
721 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
723 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
728 // e.printStackTrace();
734 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
736 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
737 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
738 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
739 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
740 SurfaceAreaQuery
.setDoc(m
);
741 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
745 for (int j
= 0; j
< xo
.length
; ++j
) {
746 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
747 if (msaPcd
.getTokenSpaceGuidCName() == null) {
748 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
753 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
764 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
, String arch
) {
765 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
766 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
767 msa
.setModuleGuid(mi
.getGuid());
768 msa
.setModuleVersion(mi
.getVersion());
769 msa
.setPackageGuid(pi
.getGuid());
770 msa
.setPackageVersion(pi
.getVersion());
772 Vector
<String
> v
= new Vector
<String
>();
774 msa
.setSupArchList(v
);
780 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
781 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
782 if (moduleSa
.getPcdBuildDefinition() == null){
783 moduleSa
.addNewPcdBuildDefinition();
786 // constructe pcd to modulesa mapping first.
787 // Attention : for any error condition, remove from map this pcd.
789 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
790 if (pcdConsumer
== null) {
791 pcdConsumer
= new ArrayList
<String
>();
793 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
794 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion() + " " + listToString(moduleSa
.getSupArchList())
796 pcdConsumer
.add(listValue
);
797 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
799 // Special dynamic type, if this pcd already exists in other ModuleSA
801 if (itemType
.equals("DYNAMIC")) {
803 ListIterator li
= pcdConsumer
.listIterator();
804 while(li
.hasNext()) {
805 String value
= li
.next().toString();
806 String
[] valuePart
= value
.split(" ");
807 if (!valuePart
[4].equals("DYNAMIC")) {
808 //ToDo error for same pcd, other type than dynamic
809 pcdConsumer
.remove(listValue
);
810 throw new PcdItemTypeConflictException(value
);
815 ListIterator li
= pcdConsumer
.listIterator();
816 while(li
.hasNext()) {
817 String value
= li
.next().toString();
818 String
[] valuePart
= value
.split(" ");
819 if (valuePart
[4].equals("DYNAMIC")) {
820 //ToDo error for same pcd, other type than non-dynamic
821 pcdConsumer
.remove(listValue
);
822 throw new PcdItemTypeConflictException(value
);
827 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
828 fpdPcd
.setCName(cName
);
829 fpdPcd
.setToken(token
);
830 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
831 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
832 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
834 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
835 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
837 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
838 // so need to add one dyn pcd.
840 if (al
.size() == 1) {
841 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
845 if (defaultVal
!= null){
846 fpdPcd
.setValue(defaultVal
);
849 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
850 fpdPcd
.setValue("0");
852 if (dataType
.equals("BOOLEAN")){
853 fpdPcd
.setValue("false");
855 if (dataType
.equals("VOID*")) {
859 if (dataType
.equals("UINT8")){
860 fpdPcd
.setMaxDatumSize(1);
862 if (dataType
.equals("UINT16")) {
863 fpdPcd
.setMaxDatumSize(2);
865 if (dataType
.equals("UINT32")) {
866 fpdPcd
.setMaxDatumSize(4);
868 if (dataType
.equals("UINT64")){
869 fpdPcd
.setMaxDatumSize(8);
871 if (dataType
.equals("BOOLEAN")){
872 fpdPcd
.setMaxDatumSize(1);
874 if (dataType
.equals("VOID*")) {
875 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
876 fpdPcd
.setMaxDatumSize(maxSize
);
881 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
885 char ch
= datum
.charAt(0);
889 // For void* type PCD, only three datum is support:
890 // 1) Unicode: string with start char is "L"
891 // 2) Ansci: String is ""
892 // 3) byte array: String start char "{"
895 start
= datum
.indexOf('\"');
896 end
= datum
.lastIndexOf('\"');
898 (end
> datum
.length())||
899 ((start
== end
) && (datum
.length() > 0))) {
900 //ToDo Error handling here
901 throw new PcdValueMalFormed (datum
);
904 strValue
= datum
.substring(start
+ 1, end
);
905 return strValue
.length() * 2;
906 } else if (ch
== '\"'){
907 start
= datum
.indexOf('\"');
908 end
= datum
.lastIndexOf('\"');
910 (end
> datum
.length())||
911 ((start
== end
) && (datum
.length() > 0))) {
912 throw new PcdValueMalFormed (datum
);
914 strValue
= datum
.substring(start
+ 1, end
);
915 return strValue
.length();
916 } else if (ch
=='{') {
917 String
[] strValueArray
;
919 start
= datum
.indexOf('{');
920 end
= datum
.lastIndexOf('}');
921 strValue
= datum
.substring(start
+ 1, end
);
922 strValue
= strValue
.trim();
923 if (strValue
.length() == 0) {
926 strValueArray
= strValue
.split(",");
927 for (int index
= 0; index
< strValueArray
.length
; index
++) {
928 Integer value
= Integer
.decode(strValueArray
[index
].trim());
931 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
932 // "it is byte array in fact. But the element of %s exceed the byte range",
933 throw new PcdValueMalFormed (datum
);
936 return strValueArray
.length
;
940 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
941 // "1) UNICODE string: like L\"xxxx\";\r\n"+
942 // "2) ANSIC string: like \"xxx\";\r\n"+
943 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
944 // "but the datum in seems does not following above format!",
945 throw new PcdValueMalFormed (datum
);
950 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
951 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
956 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
958 return dynPcdMap
.get("pcdKey");
961 public int getDynamicPcdBuildDataCount() {
962 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
965 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
968 public void getDynamicPcdBuildData(String
[][] saa
) {
969 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
972 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
973 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
975 while(li
.hasNext()) {
976 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
977 saa
[i
][0] = dynPcd
.getCName();
978 saa
[i
][1] = dynPcd
.getToken().toString();
979 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
980 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
981 saa
[i
][4] = dynPcd
.getDatumType().toString();
987 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
988 throws PcdValueMalFormed
{
989 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
990 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
991 dynPcdData
.setCName(cName
);
992 dynPcdData
.setToken(token
);
993 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
994 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
996 BigInteger bigInt
= new BigInteger("0");
997 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
998 skuInfo
.setSkuId(bigInt
);
999 if (defaultVal
!= null){
1000 skuInfo
.setValue(defaultVal
);
1003 if (dataType
.equals("UINT8")){
1004 skuInfo
.setValue("0");
1006 if (dataType
.equals("UINT16")) {
1007 skuInfo
.setValue("0");
1009 if (dataType
.equals("UINT32")) {
1010 skuInfo
.setValue("0");
1012 if (dataType
.equals("UINT64")){
1013 skuInfo
.setValue("0");
1015 if (dataType
.equals("BOOLEAN")){
1016 skuInfo
.setValue("false");
1018 if (dataType
.equals("VOID*")) {
1019 skuInfo
.setValue("");
1022 if (dataType
.equals("UINT8")){
1023 dynPcdData
.setMaxDatumSize(1);
1025 if (dataType
.equals("UINT16")) {
1026 dynPcdData
.setMaxDatumSize(2);
1028 if (dataType
.equals("UINT32")) {
1029 dynPcdData
.setMaxDatumSize(4);
1031 if (dataType
.equals("UINT64")){
1032 dynPcdData
.setMaxDatumSize(8);
1034 if (dataType
.equals("BOOLEAN")){
1035 dynPcdData
.setMaxDatumSize(1);
1037 if (dataType
.equals("VOID*")) {
1038 int maxSize
= setMaxSizeForPointer(defaultVal
);
1039 dynPcdData
.setMaxDatumSize(maxSize
);
1043 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
1044 XmlObject o
= getfpdDynPcdBuildDefs();
1046 XmlCursor cursor
= o
.newCursor();
1047 if (cursor
.toFirstChild()) {
1049 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1050 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1051 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1053 if (getDynamicPcdBuildDataCount() == 0) {
1061 while (cursor
.toNextSibling());
1066 // Get the Sku Info count of ith dyn pcd element.
1068 public int getDynamicPcdSkuInfoCount(int i
){
1069 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1073 int skuInfoCount
= 0;
1074 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1075 if (cursor
.toFirstChild()) {
1076 for (int j
= 0; j
< i
; ++j
) {
1077 cursor
.toNextSibling();
1079 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1080 if (pcdData
.getSkuInfoList() == null) {
1084 skuInfoCount
= pcdData
.getSkuInfoList().size();
1088 return skuInfoCount
;
1091 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1092 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1096 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1097 if (cursor
.toFirstChild()) {
1098 for (int j
= 0; j
< i
; ++j
) {
1099 cursor
.toNextSibling();
1101 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1102 if (pcdData
.getSkuInfoList() == null) {
1107 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1109 while (li
.hasNext()) {
1110 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1111 saa
[k
][0] = skuInfo
.getSkuId()+"";
1112 saa
[k
][1] = skuInfo
.getVariableName();
1113 saa
[k
][2] = skuInfo
.getVariableGuid();
1114 saa
[k
][3] = skuInfo
.getVariableOffset();
1115 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1116 saa
[k
][5] = skuInfo
.getVpdOffset();
1117 saa
[k
][6] = skuInfo
.getValue();
1127 public String
getDynamicPcdBuildDataValue(int i
){
1128 String value
= null;
1129 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1133 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1134 if (cursor
.toFirstChild()) {
1135 for (int j
= 0; j
< i
; ++j
) {
1136 cursor
.toNextSibling();
1138 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1139 if (pcdData
.getSkuInfoList() == null) {
1143 value
= pcdData
.getSkuInfoArray(0).getValue();
1150 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1151 String vpdOffset
= null;
1152 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1156 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1157 if (cursor
.toFirstChild()) {
1158 for (int j
= 0; j
< i
; ++j
) {
1159 cursor
.toNextSibling();
1161 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1162 if (pcdData
.getSkuInfoList() == null) {
1166 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1173 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1174 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1178 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1179 if (cursor
.toFirstChild()) {
1180 for (int j
= 0; j
< i
; ++j
) {
1181 cursor
.toNextSibling();
1183 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1184 if (pcdData
.getSkuInfoList() == null) {
1189 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1190 cursor
.toChild(qSkuInfo
);
1197 // generate sku info for ith dyn pcd build data.
1199 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1200 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1201 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1205 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1206 if (cursor
.toFirstChild()) {
1207 for (int j
= 0; j
< i
; ++j
) {
1208 cursor
.toNextSibling();
1210 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1211 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1212 skuInfo
.setSkuId(new BigInteger(id
));
1213 if (varName
!= null){
1214 skuInfo
.setVariableName(varName
);
1215 skuInfo
.setVariableGuid(varGuid
);
1216 skuInfo
.setVariableOffset(varOffset
);
1217 skuInfo
.setHiiDefaultValue(hiiDefault
);
1219 else if (vpdOffset
!= null){
1220 skuInfo
.setVpdOffset(vpdOffset
);
1223 skuInfo
.setValue(value
);
1228 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1229 String hiiDefault
, String vpdOffset
, String value
, int i
){
1230 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1234 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1235 if (cursor
.toFirstChild()) {
1236 for (int j
= 0; j
< i
; ++j
) {
1237 cursor
.toNextSibling();
1239 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1240 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1241 while (li
.hasNext()) {
1242 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1243 if (skuInfo
.getSkuId().toString().equals(id
)){
1244 if (varName
!= null){
1245 skuInfo
.setVariableName(varName
);
1246 skuInfo
.setVariableGuid(varGuid
);
1247 skuInfo
.setVariableOffset(varOffset
);
1248 skuInfo
.setHiiDefaultValue(hiiDefault
);
1250 else if (vpdOffset
!= null){
1251 skuInfo
.setVpdOffset(vpdOffset
);
1254 skuInfo
.setValue(value
);
1262 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1263 if (fpdBuildOpts
== null) {
1264 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1266 return fpdBuildOpts
;
1269 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1270 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1271 if (udats
== null) {
1272 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1275 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1276 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1279 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1280 at
.setId(new Integer(id
));
1281 XmlCursor cursor
= at
.newCursor();
1282 if (fileName
!= null){
1283 at
.setFilename(fileName
);
1285 else if (cursor
.toChild(xmlNs
, "Filename")) {
1288 if (execOrder
!= null) {
1289 at
.setAntCmdOptions(execOrder
);
1291 else if (cursor
.toChild(xmlNs
, "AntCmdOptions")) {
1297 public void removeBuildOptionsUserDefAntTask(int i
) {
1298 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1302 XmlCursor cursor
= o
.newCursor();
1303 if (cursor
.toFirstChild()) {
1304 for (int j
= 0; j
< i
; ++j
) {
1305 cursor
.toNextSibling();
1308 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1316 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1317 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1321 XmlCursor cursor
= o
.newCursor();
1322 if (cursor
.toFirstChild()) {
1323 for (int j
= 0; j
< i
; ++j
) {
1324 cursor
.toNextSibling();
1326 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1327 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1332 public int getBuildOptionsUserDefAntTaskCount() {
1333 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1334 if (udats
== null || udats
.getAntTaskList() == null) {
1338 return udats
.getAntTaskList().size();
1341 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1342 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1343 if (udats
== null || udats
.getAntTaskList() == null) {
1347 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1348 ListIterator li
= l
.listIterator();
1350 while (li
.hasNext()) {
1351 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1352 saa
[i
][0] = at
.getId() + "";
1353 saa
[i
][1] = saa
[i
][2] = "";
1354 if (at
.getFilename() != null){
1355 saa
[i
][1] = at
.getFilename();
1357 if (at
.getAntCmdOptions() != null) {
1358 saa
[i
][2] = at
.getAntCmdOptions();
1363 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1364 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1366 opts
= getfpdBuildOpts().addNewOptions();
1368 OptionDocument
.Option opt
= opts
.addNewOption();
1369 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1372 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1373 opt
.setStringValue(contents
);
1375 opt
.setBuildTargets(buildTargets
);
1376 opt
.setToolChainFamily(toolChain
);
1377 opt
.setTagName(tagName
);
1378 opt
.setToolCode(toolCmd
);
1380 if (archList
!= null) {
1381 opt
.setSupArchList(archList
);
1384 if (opt
.isSetSupArchList()) {
1385 opt
.unsetSupArchList();
1390 public void removeBuildOptionsOpt(int i
){
1392 XmlObject o
= getfpdBuildOpts().getOptions();
1397 XmlCursor cursor
= o
.newCursor();
1398 if (cursor
.toFirstChild()) {
1399 for (int j
= 0; j
< i
; ++j
) {
1400 cursor
.toNextSibling();
1403 if (getBuildOptionsOptCount() == 0) {
1411 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1412 XmlObject o
= getfpdBuildOpts().getOptions();
1417 XmlCursor cursor
= o
.newCursor();
1418 if (cursor
.toFirstChild()) {
1419 for (int j
= 0; j
< i
; ++j
) {
1420 cursor
.toNextSibling();
1422 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1423 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1428 public int getBuildOptionsOptCount(){
1429 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1432 return getfpdBuildOpts().getOptions().getOptionList().size();
1435 public void getBuildOptionsOpts(String
[][] saa
) {
1436 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1440 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1441 ListIterator li
= lOpt
.listIterator();
1443 while(li
.hasNext()) {
1444 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1445 if (opt
.getBuildTargets() != null) {
1446 saa
[i
][0] = listToString(opt
.getBuildTargets());
1448 saa
[i
][1] = opt
.getToolChainFamily();
1449 if (opt
.getSupArchList() != null){
1450 saa
[i
][2] = listToString(opt
.getSupArchList());
1453 saa
[i
][3] = opt
.getToolCode();
1454 saa
[i
][4] = opt
.getTagName();
1455 saa
[i
][5] = opt
.getStringValue();
1461 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1462 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1463 ffs
.setFfsKey(ffsKey
);
1465 ffs
.addNewSections().setEncapsulationType(type
);
1469 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1470 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1472 ffs
.addNewSections().setEncapsulationType(type
);
1476 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1477 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1478 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1479 attrib
.setName(name
);
1480 attrib
.setValue(value
);
1483 /**update jth attribute of ith ffs.
1487 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1488 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1489 XmlCursor cursor
= ffs
.newCursor();
1490 QName qAttrib
= new QName(xmlNs
, "Attribute");
1491 if (cursor
.toChild(qAttrib
)) {
1492 for (int k
= 0; k
< j
; ++k
) {
1493 cursor
.toNextSibling(qAttrib
);
1495 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1496 attrib
.setName(name
);
1497 attrib
.setValue(value
);
1502 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1503 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1504 XmlCursor cursor
= ffs
.newCursor();
1505 QName qAttrib
= new QName(xmlNs
, "Attribute");
1506 if (cursor
.toChild(qAttrib
)) {
1507 for (int k
= 0; k
< j
; ++k
) {
1508 cursor
.toNextSibling(qAttrib
);
1515 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1516 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1520 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1522 if (sections
== null){
1523 sections
= ffs
.addNewSections();
1525 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1528 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1529 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1530 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1531 if (sections
== null) {
1534 XmlCursor cursor
= sections
.newCursor();
1535 QName qSection
= new QName(xmlNs
, "Section");
1536 if (cursor
.toChild(qSection
)) {
1537 for (int k
= 0; k
< j
; ++k
) {
1538 cursor
.toNextSibling(qSection
);
1545 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1546 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1547 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1548 if (sections
== null) {
1551 XmlCursor cursor
= sections
.newCursor();
1552 QName qSection
= new QName(xmlNs
, "Section");
1553 if (cursor
.toChild(qSection
)) {
1554 for (int k
= 0; k
< j
; ++k
) {
1555 cursor
.toNextSibling(qSection
);
1557 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1558 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1563 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1564 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1568 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1570 if (sections
== null){
1571 sections
= ffs
.addNewSections();
1573 sections
.addNewSections().setEncapsulationType(encapType
);
1576 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1577 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1578 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1579 if (sections
== null) {
1582 XmlCursor cursor
= sections
.newCursor();
1583 QName qSections
= new QName(xmlNs
, "Sections");
1584 if (cursor
.toChild(qSections
)) {
1585 for (int k
= 0; k
< j
; ++k
) {
1586 cursor
.toNextSibling(qSections
);
1593 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1594 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1595 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1596 if (sections
== null) {
1599 XmlCursor cursor
= sections
.newCursor();
1600 QName qSections
= new QName(xmlNs
, "Sections");
1601 if (cursor
.toChild(qSections
)) {
1602 for (int k
= 0; k
< j
; ++k
) {
1603 cursor
.toNextSibling(qSections
);
1605 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1606 sections2
.setEncapsulationType(type
);
1611 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
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 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1629 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1630 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1631 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1632 if (sections
== null) {
1635 XmlCursor cursor
= sections
.newCursor();
1636 QName qSections
= new QName(xmlNs
, "Sections");
1637 if (cursor
.toChild(qSections
)) {
1638 for (int l
= 0; l
< j
; ++l
) {
1639 cursor
.toNextSibling(qSections
);
1641 if (cursor
.toFirstChild()) {
1643 for (; m
< k
; ++m
) {
1644 cursor
.toNextSibling();
1656 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1657 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1658 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1659 if (sections
== null) {
1662 XmlCursor cursor
= sections
.newCursor();
1663 QName qSections
= new QName(xmlNs
, "Sections");
1664 if (cursor
.toChild(qSections
)) {
1665 for (int l
= 0; l
< j
; ++l
) {
1666 cursor
.toNextSibling(qSections
);
1668 if (cursor
.toFirstChild()) {
1669 for (int m
= 0; m
< k
; ++m
) {
1670 cursor
.toNextSibling();
1672 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1673 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1679 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1680 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1684 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1685 XmlCursor cursor
= sections
.newCursor();
1686 QName qSections
= new QName(xmlNs
, "Sections");
1687 if (cursor
.toChild(qSections
)){
1688 for (int k
= 0; k
< j
; ++k
) {
1689 cursor
.toNextSibling(qSections
);
1691 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1692 if (sections2
.getSectionList() == null){
1696 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1697 while(li
.hasNext()) {
1698 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1699 if (section
.isSetSectionType()) {
1700 al
.add(section
.getSectionType().toString());
1709 public int getBuildOptionsFfsCount(){
1710 if (getfpdBuildOpts().getFfsList() == null) {
1713 return getfpdBuildOpts().getFfsList().size();
1716 public void getBuildOptionsFfsKey(String
[][] saa
) {
1717 if (getfpdBuildOpts().getFfsList() == null) {
1720 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1722 while(li
.hasNext()){
1723 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1724 saa
[i
][0] = ffs
.getFfsKey();
1729 public void updateBuildOptionsFfsKey(int i
, String key
) {
1730 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1734 /**Get ith FFS key and contents.
1737 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
1738 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1742 sa
[0] = ffs
.getFfsKey();
1743 if (ffs
.getSections() != null) {
1744 if(ffs
.getSections().getEncapsulationType() != null){
1745 sa
[1] = ffs
.getSections().getEncapsulationType();
1747 if (ffs
.getSections().getSectionList() != null){
1748 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
1749 while (li
.hasNext()) {
1750 firstLevelSection
.add(li
.next().getSectionType().toString());
1753 if (ffs
.getSections().getSectionsList() != null) {
1754 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
1755 while(li
.hasNext()) {
1756 firstLevelSections
.add(li
.next().getEncapsulationType());
1760 if (ffs
.getAttributeList() != null) {
1761 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
1762 while(li
.hasNext()) {
1763 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
1764 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
1773 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
1774 XmlObject o
= getfpdBuildOpts();
1775 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
1777 XmlCursor cursor
= o
.newCursor();
1778 QName qFfs
= new QName(xmlNs
, "Ffs");
1779 if (cursor
.toChild(qFfs
)) {
1780 for (int j
= 0; j
< i
; ++j
) {
1781 cursor
.toNextSibling(qFfs
);
1783 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
1789 public void removeBuildOptionsFfs(int i
) {
1790 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1795 XmlCursor cursor
= ffs
.newCursor();
1802 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
1803 if (fpdPlatformDefs
== null){
1804 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
1806 return fpdPlatformDefs
;
1809 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
1810 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1813 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1814 while(li
.hasNext()) {
1815 archs
.add(li
.next());
1819 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
1820 if (archs
!= null) {
1821 getfpdPlatformDefs().setSupportedArchitectures(archs
);
1824 // XmlCursor cursor = getfpdPlatformDefs().newCursor();
1825 // if (cursor.toChild(xmlNs, "SupportedArchitectures")) {
1826 // cursor.removeXml();
1828 // cursor.dispose();
1832 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1833 if (getfpdPlatformDefs().getBuildTargets() == null) {
1836 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
1837 while(li
.hasNext()) {
1838 targets
.add(li
.next());
1842 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1843 getfpdPlatformDefs().setBuildTargets(targets
);
1846 public void genPlatformDefsSkuInfo(String id
, String name
) {
1847 SkuInfoDocument
.SkuInfo skuInfo
= null;
1848 if (getfpdPlatformDefs().getSkuInfo() == null) {
1849 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
1851 skuInfo
= getfpdPlatformDefs().getSkuInfo();
1852 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
1853 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1854 skuName
.setSkuID(new BigInteger("0"));
1855 skuName
.setStringValue("DEFAULT");
1857 if (id
.equals("0")) {
1860 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1861 skuName
.setSkuID(new BigInteger(id
));
1862 skuName
.setStringValue(name
);
1865 public int getPlatformDefsSkuInfoCount(){
1866 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1869 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1872 public void getPlatformDefsSkuInfos(String
[][] saa
){
1873 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1877 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1878 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
1880 while(li
.hasNext()) {
1881 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
1882 saa
[i
][0] = sku
.getSkuID()+"";
1883 saa
[i
][1] = sku
.getStringValue();
1888 public void removePlatformDefsSkuInfo(int i
) {
1889 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1890 if (skuInfo
== null || i
== 0) {
1894 XmlCursor cursor
= skuInfo
.newCursor();
1895 if (cursor
.toFirstChild()) {
1896 for (int j
= 0; j
< i
; ++j
) {
1897 cursor
.toNextSibling();
1904 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
1905 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1906 if (skuInfo
== null || i
== 0) {
1910 XmlCursor cursor
= skuInfo
.newCursor();
1911 if (cursor
.toFirstChild()) {
1912 for (int j
= 0; j
< i
; ++j
) {
1913 cursor
.toNextSibling();
1915 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
1916 sku
.setSkuID(new BigInteger(id
));
1917 sku
.setStringValue(name
);
1922 public String
getPlatformDefsInterDir(){
1923 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
1926 return getfpdPlatformDefs().getIntermediateDirectories().toString();
1929 public void setPlatformDefsInterDir(String interDir
){
1930 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
1933 public String
getPlatformDefsOutputDir() {
1934 return getfpdPlatformDefs().getOutputDirectory();
1937 public void setPlatformDefsOutputDir(String outputDir
) {
1938 if (outputDir
!= null && outputDir
.length() > 0) {
1939 getfpdPlatformDefs().setOutputDirectory(outputDir
);
1942 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
1943 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
1950 public FlashDocument
.Flash
getfpdFlash() {
1951 if (fpdFlash
== null) {
1952 fpdFlash
= fpdRoot
.addNewFlash();
1957 public void genFlashDefinitionFile(String file
) {
1958 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1960 fdf
= getfpdFlash().addNewFlashDefinitionFile();
1963 fdf
.setStringValue(file
);
1966 public String
getFlashDefinitionFile() {
1967 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1972 return fdf
.getStringValue();
1975 public void genFvImagesNameValue(String name
, String value
) {
1977 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1979 fi
= getfpdFlash().addNewFvImages();
1982 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
1987 public void removeFvImagesNameValue(int i
){
1989 XmlObject o
= getfpdFlash().getFvImages();
1994 QName qNameValue
= new QName(xmlNs
, "NameValue");
1995 XmlCursor cursor
= o
.newCursor();
1996 if (cursor
.toChild(qNameValue
)) {
1997 for (int j
= 0; j
< i
; ++j
) {
1998 cursor
.toNextSibling(qNameValue
);
2005 public void updateFvImagesNameValue(int i
, String name
, String value
){
2007 XmlObject o
= getfpdFlash().getFvImages();
2012 QName qNameValue
= new QName(xmlNs
, "NameValue");
2013 XmlCursor cursor
= o
.newCursor();
2014 if (cursor
.toChild(qNameValue
)) {
2015 for (int j
= 0; j
< i
; ++j
) {
2016 cursor
.toNextSibling(qNameValue
);
2018 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
2025 public int getFvImagesNameValueCount() {
2027 FvImagesDocument
.FvImages fi
= null;
2028 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
2031 return fi
.getNameValueList().size();
2034 public void getFvImagesNameValues(String
[][] nv
) {
2036 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
2040 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
2042 ListIterator li
= l
.listIterator();
2043 while (li
.hasNext()) {
2044 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
2046 nv
[i
][0] = e
.getName();
2047 nv
[i
][1] = e
.getValue();
2053 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
2055 FvImagesDocument
.FvImages fis
= null;
2056 if ((fis
= getfpdFlash().getFvImages()) == null) {
2057 fis
= getfpdFlash().addNewFvImages();
2061 //gen FvImage with FvImageNames array
2063 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
2064 for (int i
= 0; i
< names
.length
; ++i
) {
2065 fi
.addFvImageNames(names
[i
]);
2067 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2068 if (options
!= null){
2069 setFvImagesFvImageFvImageOptions(options
, fi
);
2073 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2074 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2076 fio
= fi
.addNewFvImageOptions();
2079 Set
<String
> key
= options
.keySet();
2080 Iterator
<String
> i
= key
.iterator();
2081 while (i
.hasNext()) {
2083 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2084 String k
= (String
)i
.next();
2087 nv
.setValue((String
)options
.get(k
));
2094 public void removeFvImagesFvImage(int i
) {
2096 XmlObject o
= getfpdFlash().getFvImages();
2101 QName qFvImage
= new QName(xmlNs
, "FvImage");
2102 XmlCursor cursor
= o
.newCursor();
2103 if (cursor
.toChild(qFvImage
)) {
2104 for (int j
= 0; j
< i
; ++j
) {
2105 cursor
.toNextSibling(qFvImage
);
2112 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2114 XmlObject o
= getfpdFlash().getFvImages();
2118 XmlCursor cursor
= o
.newCursor();
2119 QName qFvImage
= new QName(xmlNs
, "FvImage");
2120 if (cursor
.toChild(qFvImage
)) {
2121 for (int j
= 0; j
< i
; ++j
) {
2122 cursor
.toNextSibling(qFvImage
);
2124 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2125 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2128 // remove old FvImageNames before adding new ones
2130 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2131 cursor
.toChild(qFvImageNames
);
2133 while (cursor
.toNextSibling(qFvImageNames
)) {
2137 for (int k
= 0; k
< names
.length
; ++k
) {
2138 fi
.addFvImageNames(names
[k
]);
2141 // remove old FvImageOptions before adding new options
2143 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2144 cursor
.toNextSibling(qFvImageOptions
);
2147 setFvImagesFvImageFvImageOptions(options
, fi
);
2152 public int getFvImagesFvImageCount() {
2154 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2157 return getfpdFlash().getFvImages().getFvImageList().size();
2160 /**Only Get Fv image setting - name and type.
2163 public void getFvImagesFvImages(String
[][] saa
) {
2165 if (getfpdFlash().getFvImages() == null) {
2168 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2172 ListIterator li
= l
.listIterator();
2174 while(li
.hasNext()) {
2175 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2177 // get FvImageNames array, space separated
2179 List
<String
> lfn
= fi
.getFvImageNamesList();
2180 ListIterator lfni
= lfn
.listIterator();
2182 while (lfni
.hasNext()) {
2183 saa
[i
][0] += (String
)lfni
.next();
2186 saa
[i
][0] = saa
[i
][0].trim();
2188 saa
[i
][1] = fi
.getType()+"";
2194 /**Get FvImage Options for FvImage i
2195 * @param i the ith FvImage
2197 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2198 XmlObject o
= getfpdFlash().getFvImages();
2202 XmlCursor cursor
= o
.newCursor();
2203 QName qFvImage
= new QName(xmlNs
, "FvImage");
2204 if (cursor
.toChild(qFvImage
)) {
2205 for (int j
= 0; j
< i
; ++j
) {
2206 cursor
.toNextSibling(qFvImage
);
2208 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2209 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2212 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2213 while(li
.hasNext()){
2214 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2215 m
.put(nv
.getName(), nv
.getValue());
2221 Get platform header element
2222 @return PlatformHeaderDocument.PlatformHeader
2224 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2225 if (fpdHdr
== null) {
2226 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2228 genPlatformDefsSkuInfo("0", "DEFAULT");
2232 public String
getFpdHdrPlatformName() {
2233 return getFpdHdr().getPlatformName();
2236 public String
getFpdHdrGuidValue() {
2237 return getFpdHdr().getGuidValue();
2240 public String
getFpdHdrVer() {
2241 return getFpdHdr().getVersion();
2244 public String
getFpdHdrAbs() {
2245 return getFpdHdr().getAbstract();
2248 public String
getFpdHdrDescription() {
2249 return getFpdHdr().getDescription();
2252 public String
getFpdHdrCopyright() {
2253 return getFpdHdr().getCopyright();
2256 public String
getFpdHdrLicense() {
2257 LicenseDocument
.License l
= getFpdHdr().getLicense();
2261 return l
.getStringValue();
2264 public String
getFpdHdrUrl() {
2265 LicenseDocument
.License l
= getFpdHdr().getLicense();
2272 public String
getFpdHdrSpec() {
2274 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2275 // return getFpdHdr().getSpecification();
2278 public void setFpdHdrPlatformName(String name
){
2279 getFpdHdr().setPlatformName(name
);
2282 public void setFpdHdrGuidValue(String guid
){
2283 getFpdHdr().setGuidValue(guid
);
2286 public void setFpdHdrVer(String v
){
2287 getFpdHdr().setVersion(v
);
2290 public void setFpdHdrAbs(String abs
) {
2291 getFpdHdr().setAbstract(abs
);
2294 public void setFpdHdrDescription(String desc
){
2295 getFpdHdr().setDescription(desc
);
2298 public void setFpdHdrCopyright(String cr
) {
2299 getFpdHdr().setCopyright(cr
);
2302 public void setFpdHdrLicense(String license
){
2303 LicenseDocument
.License l
= getFpdHdr().getLicense();
2305 getFpdHdr().addNewLicense().setStringValue(license
);
2308 l
.setStringValue(license
);
2312 public void setFpdHdrUrl(String url
){
2313 LicenseDocument
.License l
= getFpdHdr().getLicense();
2319 public void setFpdHdrSpec(String s
){
2320 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2321 getFpdHdr().setSpecification(s
);
2324 Save the processed xml contents to file
2326 @param fpdFile The file to save xml contents
2327 @throws IOException Exceptions during file operation
2329 public void saveAs(File fpdFile
) throws IOException
{
2331 XmlOptions options
= new XmlOptions();
2333 options
.setCharacterEncoding("UTF-8");
2334 options
.setSavePrettyPrint();
2335 options
.setSavePrettyPrintIndent(2);
2337 fpdd
.save(fpdFile
, options
);
2338 } catch (IOException e
) {
2339 e
.printStackTrace();
2344 private String
listToString(List l
) {
2349 ListIterator li
= l
.listIterator();
2350 while(li
.hasNext()) {
2358 class PcdItemTypeConflictException
extends Exception
{
2363 private static final long serialVersionUID
= 1L;
2364 private String details
= null;
2366 PcdItemTypeConflictException(String info
){
2370 public String
getMessage() {
2375 class PcdDeclNotFound
extends Exception
{
2380 private static final long serialVersionUID
= 1L;
2381 private String details
= null;
2383 PcdDeclNotFound(String info
) {
2387 public String
getMessage() {
2392 class PcdValueMalFormed
extends Exception
{
2397 private static final long serialVersionUID
= 1L;
2398 private String details
= null;
2400 PcdValueMalFormed(String info
) {
2404 public String
getMessage() {