2 Java class FpdFileContents is used to parse fpd xml file.
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 package org
.tianocore
.frameworkwizard
.platform
.ui
;
16 import java
.io
.IOException
;
17 import java
.math
.BigInteger
;
18 import java
.util
.ArrayList
;
19 import java
.util
.HashMap
;
20 import java
.util
.Iterator
;
21 import java
.util
.LinkedHashMap
;
22 import java
.util
.List
;
23 import java
.util
.ListIterator
;
26 import java
.util
.Vector
;
28 import javax
.xml
.namespace
.QName
;
30 import org
.apache
.xmlbeans
.XmlCursor
;
31 import org
.apache
.xmlbeans
.XmlObject
;
32 import org
.apache
.xmlbeans
.XmlOptions
;
33 import org
.tianocore
.AntTaskDocument
;
34 import org
.tianocore
.BuildOptionsDocument
;
35 import org
.tianocore
.DynamicPcdBuildDefinitionsDocument
;
36 import org
.tianocore
.EfiSectionType
;
37 import org
.tianocore
.FlashDefinitionFileDocument
;
38 import org
.tianocore
.FlashDocument
;
39 import org
.tianocore
.FrameworkModulesDocument
;
40 import org
.tianocore
.IntermediateOutputType
;
41 import org
.tianocore
.LibrariesDocument
;
42 import org
.tianocore
.ModuleSADocument
;
43 import org
.tianocore
.ModuleSurfaceAreaDocument
;
44 import org
.tianocore
.OptionDocument
;
45 import org
.tianocore
.OptionsDocument
;
46 import org
.tianocore
.PcdBuildDefinitionDocument
;
47 import org
.tianocore
.PcdCodedDocument
;
48 import org
.tianocore
.PcdDataTypes
;
49 import org
.tianocore
.PcdDeclarationsDocument
;
50 import org
.tianocore
.PcdItemTypes
;
51 import org
.tianocore
.PlatformDefinitionsDocument
;
52 import org
.tianocore
.PlatformSurfaceAreaDocument
;
53 import org
.tianocore
.FvImageTypes
;
54 import org
.tianocore
.FvImagesDocument
;
55 import org
.tianocore
.LicenseDocument
;
56 import org
.tianocore
.PlatformHeaderDocument
;
57 import org
.tianocore
.SkuInfoDocument
;
58 import org
.tianocore
.UserDefinedAntTasksDocument
;
59 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.GlobalData
;
60 import org
.tianocore
.frameworkwizard
.platform
.ui
.global
.SurfaceAreaQuery
;
61 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.ModuleIdentification
;
62 import org
.tianocore
.frameworkwizard
.platform
.ui
.id
.PackageIdentification
;
65 This class processes fpd file contents such as add remove xml elements.
66 @since PackageEditor 1.0
68 public class FpdFileContents
{
70 static final String xmlNs
= "http://www.TianoCore.org/2006/Edk2.0";
72 private PlatformSurfaceAreaDocument fpdd
= null;
74 private PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpdRoot
= null;
76 private PlatformHeaderDocument
.PlatformHeader fpdHdr
= null;
78 private PlatformDefinitionsDocument
.PlatformDefinitions fpdPlatformDefs
= null;
80 private FlashDocument
.Flash fpdFlash
= null;
82 private BuildOptionsDocument
.BuildOptions fpdBuildOpts
= null;
84 private FrameworkModulesDocument
.FrameworkModules fpdFrameworkModules
= null;
86 private DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions fpdDynPcdBuildDefs
= null;
88 private HashMap
<String
, ArrayList
<String
>> dynPcdMap
= null;
91 * look through all pcd data in all ModuleSA, create pcd -> ModuleSA mappings.
93 public void initDynPcdMap() {
94 if (dynPcdMap
== null) {
95 dynPcdMap
= new HashMap
<String
, ArrayList
<String
>>();
96 List
<ModuleSADocument
.ModuleSA
> l
= getfpdFrameworkModules().getModuleSAList();
100 ListIterator
<ModuleSADocument
.ModuleSA
> li
= l
.listIterator();
101 while (li
.hasNext()) {
102 ModuleSADocument
.ModuleSA msa
= li
.next();
103 if (msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null) {
106 String ModuleInfo
= msa
.getModuleGuid() + " " + msa
.getModuleVersion() +
107 " " + msa
.getPackageGuid() + " " + msa
.getPackageVersion();
108 List
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lp
= msa
.getPcdBuildDefinition().getPcdDataList();
109 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> lpi
= lp
.listIterator();
110 while (lpi
.hasNext()) {
111 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= lpi
.next();
112 String pcdKey
= pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName();
113 if (dynPcdMap
.get(pcdKey
) == null) {
114 ArrayList
<String
> al
= new ArrayList
<String
>();
115 al
.add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
116 dynPcdMap
.put(pcdKey
, al
);
119 dynPcdMap
.get(pcdKey
).add(ModuleInfo
+ " " + pcdData
.getItemType().toString());
126 public ArrayList
<String
> getDynPcdMapValue(String key
) {
127 return dynPcdMap
.get(key
);
130 Constructor to create a new spd file
132 public FpdFileContents() {
134 fpdd
= PlatformSurfaceAreaDocument
.Factory
.newInstance();
135 fpdRoot
= fpdd
.addNewPlatformSurfaceArea();
140 Constructor for existing document object
143 public FpdFileContents(PlatformSurfaceAreaDocument
.PlatformSurfaceArea fpd
) {
145 fpdHdr
= fpdRoot
.getPlatformHeader();
146 fpdPlatformDefs
= fpdRoot
.getPlatformDefinitions();
147 fpdBuildOpts
= fpdRoot
.getBuildOptions();
148 fpdFrameworkModules
= fpdRoot
.getFrameworkModules();
149 fpdDynPcdBuildDefs
= fpdRoot
.getDynamicPcdBuildDefinitions();
150 fpdFlash
= fpdRoot
.getFlash();
154 Constructor based on an existing spd file
156 @param f Existing spd file
158 public FpdFileContents(File f
) {
160 fpdd
= PlatformSurfaceAreaDocument
.Factory
.parse(f
);
161 fpdRoot
= fpdd
.getPlatformSurfaceArea();
162 } catch (Exception e
) {
163 System
.out
.println(e
.toString());
167 public DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
getfpdDynPcdBuildDefs() {
168 if (fpdDynPcdBuildDefs
== null){
169 fpdDynPcdBuildDefs
= fpdRoot
.addNewDynamicPcdBuildDefinitions();
171 return fpdDynPcdBuildDefs
;
174 public FrameworkModulesDocument
.FrameworkModules
getfpdFrameworkModules() {
175 if (fpdFrameworkModules
== null){
176 fpdFrameworkModules
= fpdRoot
.addNewFrameworkModules();
178 return fpdFrameworkModules
;
181 public int getFrameworkModulesCount() {
182 if (getfpdFrameworkModules().getModuleSAList() == null){
185 return getfpdFrameworkModules().getModuleSAList().size();
188 public void getFrameworkModulesInfo(String
[][] saa
) {
189 if (getFrameworkModulesCount() == 0){
193 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
195 while(li
.hasNext()) {
196 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
197 saa
[i
][1] = msa
.getModuleGuid();
198 saa
[i
][2] = msa
.getModuleVersion();
200 saa
[i
][3] = msa
.getPackageGuid();
201 saa
[i
][4] = msa
.getPackageVersion();
202 // saa[i][4] = listToString(msa.getSupArchList());
207 public ModuleSADocument
.ModuleSA
getModuleSA(String key
) {
208 String
[] s
= key
.split(" ");
209 if (getfpdFrameworkModules().getModuleSAList() == null) {
212 ListIterator li
= getfpdFrameworkModules().getModuleSAList().listIterator();
213 while(li
.hasNext()) {
214 ModuleSADocument
.ModuleSA msa
= (ModuleSADocument
.ModuleSA
)li
.next();
215 if (msa
.getModuleGuid().equals(s
[0]) && msa
.getPackageGuid().equals(s
[2])) {
216 if (msa
.getModuleVersion() != null) {
217 if (!msa
.getModuleVersion().equals(s
[1])) {
221 if (msa
.getPackageVersion() != null) {
222 if (!msa
.getPackageVersion().equals(s
[3])) {
231 public void removeModuleSA(int i
) {
232 XmlObject o
= getfpdFrameworkModules();
237 XmlCursor cursor
= o
.newCursor();
238 if (cursor
.toFirstChild()) {
239 for (int j
= 0; j
< i
; ++j
) {
240 cursor
.toNextSibling();
243 // remove pcd from dynPcdMap, if DynamicPcdBuildData exists, remove them too.
245 ModuleSADocument
.ModuleSA moduleSa
= (ModuleSADocument
.ModuleSA
)cursor
.getObject();
246 String moduleInfo
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion() + " " +
247 moduleSa
.getPackageGuid()+ " " + moduleSa
.getPackageVersion();
248 PcdBuildDefinitionDocument
.PcdBuildDefinition pcdBuildDef
= moduleSa
.getPcdBuildDefinition();
249 if (pcdBuildDef
!= null && pcdBuildDef
.getPcdDataList() != null) {
250 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
> li
= pcdBuildDef
.getPcdDataList().listIterator();
251 while(li
.hasNext()) {
252 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
253 maintainDynPcdMap(pcdData
.getCName() + " " + pcdData
.getTokenSpaceGuidCName(), moduleInfo
);
257 if (getFrameworkModulesCount() == 0) {
265 private void maintainDynPcdMap(String pcdKey
, String moduleInfo
) {
267 ArrayList
<String
> al
= dynPcdMap
.get(pcdKey
);
271 String
[] s
= moduleInfo
.split(" ");
272 for(int i
= 0; i
< al
.size(); ++i
){
273 String consumer
= al
.get(i
);
274 if (consumer
.contains(s
[0]) && consumer
.contains(s
[2])){
280 if (al
.size() == 0) {
281 dynPcdMap
.remove(pcdKey
);
282 String
[] s1
= pcdKey
.split(" ");
283 removeDynamicPcdBuildData(s1
[0], s1
[1]);
288 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
290 public int getPcdDataCount(String key
){
291 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
292 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
295 return msa
.getPcdBuildDefinition().getPcdDataList().size();
298 public void getPcdData(String key
, String
[][] saa
) {
299 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
300 if (msa
== null || msa
.getPcdBuildDefinition() == null || msa
.getPcdBuildDefinition().getPcdDataList() == null){
303 ListIterator
<PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
>li
= msa
.getPcdBuildDefinition().getPcdDataList().listIterator();
304 for (int i
= 0; i
< saa
.length
; ++i
) {
305 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= li
.next();
306 saa
[i
][0] = pcdData
.getCName();
307 saa
[i
][1] = pcdData
.getTokenSpaceGuidCName();
308 saa
[i
][2] = pcdData
.getItemType()+"";
309 saa
[i
][3] = pcdData
.getToken().toString();
310 saa
[i
][4] = pcdData
.getMaxDatumSize()+"";
311 saa
[i
][5] = pcdData
.getDatumType()+"";
312 saa
[i
][6] = pcdData
.getValue();
317 public void updatePcdData(String key
, String cName
, String tsGuid
, String itemType
, String maxSize
, String value
){
318 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
319 if (msa
== null || msa
.getPcdBuildDefinition() == null){
323 XmlCursor cursor
= msa
.getPcdBuildDefinition().newCursor();
324 if (cursor
.toFirstChild()){
326 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
327 if (pcdData
.getCName().equals(cName
) && pcdData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
328 pcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
329 if(pcdData
.getDatumType().equals("VOID*")) {
330 pcdData
.setMaxDatumSize(new Integer(maxSize
));
332 pcdData
.setValue(value
);
336 while(cursor
.toNextSibling());
341 /**Get original Pcd info from MSA & SPD files.
342 * @param mi ModuleIdentification from which MSA & SPD come
343 * @param cName PCD cName
344 * @param sa Results: HelpText, Original item type.
347 public boolean getPcdBuildDataInfo(ModuleIdentification mi
, String cName
, String
[] sa
) throws Exception
{
350 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
351 if (msa
.getPcdCoded() == null) {
355 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
356 m
.put("ModuleSurfaceArea", msa
);
357 SurfaceAreaQuery
.setDoc(m
);
358 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
360 // First look through MSA pcd entries.
362 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
363 ListIterator li
= l
.listIterator();
364 while(li
.hasNext()) {
365 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
366 if (!msaPcd
.getCName().equals(cName
)) {
369 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
370 if (spdPcd
== null) {
374 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
377 // Get Pcd help text and original item type.
379 sa
[0] = spdPcd
.getHelpText() + msaPcd
.getHelpText();
380 sa
[1] = msaPcd
.getPcdItemType()+"";
387 // e.printStackTrace();
394 /**Remove PCDBuildDefinition entries from ModuleSA
395 * @param moduleKey identifier of ModuleSA.
396 * @param consumer where these entries come from.
398 public void removePcdData(String moduleKey
, ModuleIdentification consumer
) {
400 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(consumer
);
401 if (msa
.getPcdCoded() == null) {
405 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
406 ListIterator li
= l
.listIterator();
408 while(li
.hasNext()) {
409 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
410 ModuleSADocument
.ModuleSA moduleSA
= getModuleSA(moduleKey
);
411 XmlCursor cursor
= moduleSA
.getPcdBuildDefinition().newCursor();
412 if (cursor
.toFirstChild()) {
413 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
414 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
416 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
420 while (cursor
.toNextSibling()) {
421 pcdData
= (PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData
)cursor
.getObject();
422 if (msaPcd
.getCName().equals(pcdData
.getCName()) && msaPcd
.getTokenSpaceGuidCName().equals(pcdData
.getTokenSpaceGuidCName())) {
423 maintainDynPcdMap(pcdData
.getCName()+" "+pcdData
.getTokenSpaceGuidCName(), moduleKey
);
439 // key for ModuleSA : "ModuleGuid ModuleVer PackageGuid PackageVer"
441 public int getLibraryInstancesCount(String key
) {
442 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
443 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
446 return msa
.getLibraries().getInstanceList().size();
449 public void getLibraryInstances(String key
, String
[][] saa
){
450 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
451 if (msa
== null || msa
.getLibraries() == null || msa
.getLibraries().getInstanceList() == null){
455 ListIterator
<LibrariesDocument
.Libraries
.Instance
> li
= msa
.getLibraries().getInstanceList().listIterator();
456 for (int i
= 0; i
< saa
.length
; ++i
) {
457 LibrariesDocument
.Libraries
.Instance instance
= li
.next();
458 saa
[i
][1] = instance
.getModuleGuid();
459 saa
[i
][2] = instance
.getModuleVersion();
460 saa
[i
][3] = instance
.getPackageGuid();
461 saa
[i
][4] = instance
.getPackageVersion();
465 public void removeLibraryInstance(String key
, int i
) {
466 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
467 if (msa
== null || msa
.getLibraries() == null){
471 XmlCursor cursor
= msa
.getLibraries().newCursor();
472 if (cursor
.toFirstChild()) {
473 for (int j
= 0; j
< i
; ++j
) {
474 cursor
.toNextSibling();
482 public void genLibraryInstance(String mg
, String mv
, String pg
, String pv
, String key
) {
483 ModuleSADocument
.ModuleSA msa
= getModuleSA(key
);
485 msa
= getfpdFrameworkModules().addNewModuleSA();
487 LibrariesDocument
.Libraries libs
= msa
.getLibraries();
489 libs
= msa
.addNewLibraries();
492 LibrariesDocument
.Libraries
.Instance instance
= libs
.addNewInstance();
493 instance
.setModuleGuid(mg
);
494 instance
.setModuleVersion(mv
);
495 instance
.setPackageGuid(pg
);
496 instance
.setPackageVersion(pv
);
500 public String
getFvBinding(String moduleKey
){
501 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
502 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
505 return msa
.getModuleSaBuildOptions().getFvBinding();
508 public void setFvBinding(String moduleKey
, String fvBinding
){
509 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
513 if(msa
.getModuleSaBuildOptions() == null){
514 msa
.addNewModuleSaBuildOptions().setFvBinding(fvBinding
);
517 msa
.getModuleSaBuildOptions().setFvBinding(fvBinding
);
520 public String
getFfsFileNameGuid(String moduleKey
){
521 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
522 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
525 return msa
.getModuleSaBuildOptions().getFfsFileNameGuid();
528 public void setFfsFileNameGuid(String moduleKey
, String fileGuid
){
529 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
533 if(msa
.getModuleSaBuildOptions() == null){
534 msa
.addNewModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
537 msa
.getModuleSaBuildOptions().setFfsFileNameGuid(fileGuid
);
540 public String
getFfsFormatKey(String moduleKey
){
541 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
542 if (msa
== null || msa
.getModuleSaBuildOptions() == null) {
545 return msa
.getModuleSaBuildOptions().getFfsFormatKey();
548 public void setFfsFormatKey(String moduleKey
, String ffsKey
){
549 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
553 if(msa
.getModuleSaBuildOptions() == null){
554 msa
.addNewModuleSaBuildOptions().setFfsFormatKey(ffsKey
);
557 msa
.getModuleSaBuildOptions().setFvBinding(ffsKey
);
560 public void getModuleSAOptions(String moduleKey
, String
[][] saa
) {
561 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
562 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
563 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
567 List
<OptionDocument
.Option
> lOpt
= msa
.getModuleSaBuildOptions().getOptions().getOptionList();
568 ListIterator li
= lOpt
.listIterator();
570 while(li
.hasNext()) {
571 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
572 if (opt
.getBuildTargets() != null) {
573 saa
[i
][0] = listToString(opt
.getBuildTargets());
575 saa
[i
][1] = opt
.getToolChainFamily();
576 if (opt
.getSupArchList() != null){
577 saa
[i
][2] = listToString(opt
.getSupArchList());
580 saa
[i
][3] = opt
.getToolCode();
581 saa
[i
][4] = opt
.getTagName();
582 saa
[i
][5] = opt
.getStringValue();
588 public int getModuleSAOptionsCount(String moduleKey
){
589 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
590 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null
591 || msa
.getModuleSaBuildOptions().getOptions().getOptionList() == null) {
594 return msa
.getModuleSaBuildOptions().getOptions().getOptionList().size();
597 public void genModuleSAOptionsOpt(String moduleKey
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
598 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
599 if (msa
.getModuleSaBuildOptions() == null) {
600 msa
.addNewModuleSaBuildOptions();
602 if (msa
.getModuleSaBuildOptions().getOptions() == null){
603 msa
.getModuleSaBuildOptions().addNewOptions();
605 OptionDocument
.Option opt
= msa
.getModuleSaBuildOptions().getOptions().addNewOption();
606 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
609 public void removeModuleSAOptionsOpt(String moduleKey
, int i
) {
610 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
611 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
614 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
615 XmlCursor cursor
= opts
.newCursor();
616 if (cursor
.toFirstChild()) {
617 for (int j
= 0; j
< i
; ++j
){
618 cursor
.toNextSibling();
625 public void updateModuleSAOptionsOpt(String moduleKey
, int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
626 ModuleSADocument
.ModuleSA msa
= getModuleSA(moduleKey
);
627 if (msa
.getModuleSaBuildOptions() == null || msa
.getModuleSaBuildOptions().getOptions() == null) {
630 OptionsDocument
.Options opts
= msa
.getModuleSaBuildOptions().getOptions();
631 XmlCursor cursor
= opts
.newCursor();
632 if (cursor
.toFirstChild()) {
633 for (int j
= 0; j
< i
; ++j
){
634 cursor
.toNextSibling();
636 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
637 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
642 /**add pcd information of module mi to a ModuleSA.
644 * @param moduleSa if null, generate a new ModuleSA.
646 public void addFrameworkModulesPcdBuildDefs(ModuleIdentification mi
, ModuleSADocument
.ModuleSA moduleSa
) throws Exception
{
647 //ToDo add Arch filter
650 if (moduleSa
== null) {
651 moduleSa
= genModuleSA(mi
);
654 ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= (ModuleSurfaceAreaDocument
.ModuleSurfaceArea
)GlobalData
.getModuleXmlObject(mi
);
655 if (msa
.getPcdCoded() == null) {
659 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
660 m
.put("ModuleSurfaceArea", msa
);
661 SurfaceAreaQuery
.setDoc(m
);
662 PackageIdentification
[] depPkgs
= SurfaceAreaQuery
.getDependencePkg(null);
664 // Implementing InitializePlatformPcdBuildDefinitions
666 List
<PcdCodedDocument
.PcdCoded
.PcdEntry
> l
= msa
.getPcdCoded().getPcdEntryList();
667 ListIterator li
= l
.listIterator();
668 while(li
.hasNext()) {
669 PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
= (PcdCodedDocument
.PcdCoded
.PcdEntry
)li
.next();
670 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= LookupPcdDeclaration(msaPcd
, depPkgs
);
671 if (spdPcd
== null) {
675 throw new PcdDeclNotFound(mi
.getName() + " " + msaPcd
.getCName());
678 // AddItem to ModuleSA PcdBuildDefinitions
680 String defaultVal
= msaPcd
.getDefaultValue() == null ? spdPcd
.getDefaultValue() : msaPcd
.getDefaultValue();
682 genPcdData(msaPcd
.getCName(), spdPcd
.getToken(), msaPcd
.getTokenSpaceGuidCName(), msaPcd
.getPcdItemType().toString(), spdPcd
.getDatumType()+"", defaultVal
, moduleSa
);
687 // e.printStackTrace();
693 private PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
LookupPcdDeclaration (PcdCodedDocument
.PcdCoded
.PcdEntry msaPcd
, PackageIdentification
[] depPkgs
) {
695 Map
<String
, XmlObject
> m
= new HashMap
<String
, XmlObject
>();
696 PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry spdPcd
= null;
697 for (int i
= 0; i
< depPkgs
.length
; ++i
) {
698 m
.put("PackageSurfaceArea", GlobalData
.getPackageXmlObject(depPkgs
[i
]));
699 SurfaceAreaQuery
.setDoc(m
);
700 XmlObject
[] xo
= SurfaceAreaQuery
.getSpdPcdDeclarations();
704 for (int j
= 0; j
< xo
.length
; ++j
) {
705 spdPcd
= (PcdDeclarationsDocument
.PcdDeclarations
.PcdEntry
)xo
[j
];
706 if (msaPcd
.getTokenSpaceGuidCName() == null) {
707 if (spdPcd
.getCName().equals(msaPcd
.getCName())) {
712 if (spdPcd
.getCName().equals(msaPcd
.getCName()) && spdPcd
.getTokenSpaceGuidCName().equals(msaPcd
.getTokenSpaceGuidCName())) {
723 private ModuleSADocument
.ModuleSA
genModuleSA (ModuleIdentification mi
) {
724 PackageIdentification pi
= GlobalData
.getPackageForModule(mi
);
725 ModuleSADocument
.ModuleSA msa
= getfpdFrameworkModules().addNewModuleSA();
726 msa
.setModuleGuid(mi
.getGuid());
727 msa
.setModuleVersion(mi
.getVersion());
728 msa
.setPackageGuid(pi
.getGuid());
729 msa
.setPackageVersion(pi
.getVersion());
734 private void genPcdData (String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
, ModuleSADocument
.ModuleSA moduleSa
)
735 throws PcdItemTypeConflictException
, PcdValueMalFormed
{
736 if (moduleSa
.getPcdBuildDefinition() == null){
737 moduleSa
.addNewPcdBuildDefinition();
740 // constructe pcd to modulesa mapping first.
741 // Attention : for any error condition, remove from map this pcd.
743 ArrayList
<String
> pcdConsumer
= LookupPlatformPcdData(cName
+ " " + tsGuid
);
744 if (pcdConsumer
== null) {
745 pcdConsumer
= new ArrayList
<String
>();
747 String listValue
= moduleSa
.getModuleGuid() + " " + moduleSa
.getModuleVersion()
748 + " " + moduleSa
.getPackageGuid() + " " + moduleSa
.getPackageVersion()
750 pcdConsumer
.add(listValue
);
751 dynPcdMap
.put(cName
+ " " + tsGuid
, pcdConsumer
);
753 // Special dynamic type, if this pcd already exists in other ModuleSA
755 if (itemType
.equals("DYNAMIC")) {
757 ListIterator li
= pcdConsumer
.listIterator();
758 while(li
.hasNext()) {
759 String value
= li
.next().toString();
760 String
[] valuePart
= value
.split(" ");
761 if (!valuePart
[4].equals("DYNAMIC")) {
762 //ToDo error for same pcd, other type than dynamic
763 pcdConsumer
.remove(listValue
);
764 throw new PcdItemTypeConflictException(value
);
769 ListIterator li
= pcdConsumer
.listIterator();
770 while(li
.hasNext()) {
771 String value
= li
.next().toString();
772 String
[] valuePart
= value
.split(" ");
773 if (valuePart
[4].equals("DYNAMIC")) {
774 //ToDo error for same pcd, other type than non-dynamic
775 pcdConsumer
.remove(listValue
);
776 throw new PcdItemTypeConflictException(value
);
781 PcdBuildDefinitionDocument
.PcdBuildDefinition
.PcdData fpdPcd
= moduleSa
.getPcdBuildDefinition().addNewPcdData();
782 fpdPcd
.setCName(cName
);
783 fpdPcd
.setToken(token
);
784 fpdPcd
.setTokenSpaceGuidCName(tsGuid
);
785 fpdPcd
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
786 fpdPcd
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
788 if (itemType
.equals("DYNAMIC") || itemType
.equals("DYNAMIC_EX")) {
789 ArrayList
<String
> al
= LookupDynamicPcdBuildDefinition(cName
+ " " + tsGuid
);
791 // if only one module mapped to this pcd, then the one is myself. so no other module mapped.
792 // so need to add one dyn pcd.
794 if (al
.size() == 1) {
795 addDynamicPcdBuildData(cName
, token
, tsGuid
, itemType
, dataType
, defaultVal
);
799 if (defaultVal
!= null){
800 fpdPcd
.setValue(defaultVal
);
803 if (dataType
.equals("UINT8") || dataType
.equals("UINT16") || dataType
.equals("UINT32") || dataType
.equals("UINT64")) {
804 fpdPcd
.setValue("0");
806 if (dataType
.equals("BOOLEAN")){
807 fpdPcd
.setValue("false");
809 if (dataType
.equals("VOID*")) {
813 if (dataType
.equals("UINT8")){
814 fpdPcd
.setMaxDatumSize(1);
816 if (dataType
.equals("UINT16")) {
817 fpdPcd
.setMaxDatumSize(2);
819 if (dataType
.equals("UINT32")) {
820 fpdPcd
.setMaxDatumSize(4);
822 if (dataType
.equals("UINT64")){
823 fpdPcd
.setMaxDatumSize(8);
825 if (dataType
.equals("BOOLEAN")){
826 fpdPcd
.setMaxDatumSize(1);
828 if (dataType
.equals("VOID*")) {
829 int maxSize
= setMaxSizeForPointer(fpdPcd
.getValue());
830 fpdPcd
.setMaxDatumSize(maxSize
);
835 public int setMaxSizeForPointer(String datum
) throws PcdValueMalFormed
{
839 char ch
= datum
.charAt(0);
843 // For void* type PCD, only three datum is support:
844 // 1) Unicode: string with start char is "L"
845 // 2) Ansci: String is ""
846 // 3) byte array: String start char "{"
849 start
= datum
.indexOf('\"');
850 end
= datum
.lastIndexOf('\"');
852 (end
> datum
.length())||
853 ((start
== end
) && (datum
.length() > 0))) {
854 //ToDo Error handling here
855 throw new PcdValueMalFormed (datum
);
858 strValue
= datum
.substring(start
+ 1, end
);
859 return strValue
.length() * 2;
860 } else if (ch
== '\"'){
861 start
= datum
.indexOf('\"');
862 end
= datum
.lastIndexOf('\"');
864 (end
> datum
.length())||
865 ((start
== end
) && (datum
.length() > 0))) {
866 throw new PcdValueMalFormed (datum
);
868 strValue
= datum
.substring(start
+ 1, end
);
869 return strValue
.length();
870 } else if (ch
=='{') {
871 String
[] strValueArray
;
873 start
= datum
.indexOf('{');
874 end
= datum
.lastIndexOf('}');
875 strValue
= datum
.substring(start
+ 1, end
);
876 strValue
= strValue
.trim();
877 if (strValue
.length() == 0) {
880 strValueArray
= strValue
.split(",");
881 for (int index
= 0; index
< strValueArray
.length
; index
++) {
882 Integer value
= Integer
.decode(strValueArray
[index
].trim());
885 // "[FPD file error] The datum type of PCD %s in %s is VOID*, "+
886 // "it is byte array in fact. But the element of %s exceed the byte range",
887 throw new PcdValueMalFormed (datum
);
890 return strValueArray
.length
;
894 // "[FPD file error] The datum type of PCD %s in %s is VOID*. For VOID* type, you have three format choise:\n "+
895 // "1) UNICODE string: like L\"xxxx\";\r\n"+
896 // "2) ANSIC string: like \"xxx\";\r\n"+
897 // "3) Byte array: like {0x2, 0x45, 0x23}\r\n"+
898 // "but the datum in seems does not following above format!",
899 throw new PcdValueMalFormed (datum
);
904 private ArrayList
<String
> LookupDynamicPcdBuildDefinition(String dynPcdKey
) {
905 ArrayList
<String
> al
= dynPcdMap
.get(dynPcdKey
);
910 private ArrayList
<String
> LookupPlatformPcdData(String pcdKey
) {
912 return dynPcdMap
.get("pcdKey");
915 public int getDynamicPcdBuildDataCount() {
916 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
919 return getfpdDynPcdBuildDefs().getPcdBuildDataList().size();
922 public void getDynamicPcdBuildData(String
[][] saa
) {
923 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null) {
926 List
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> l
= getfpdDynPcdBuildDefs().getPcdBuildDataList();
927 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
> li
= l
.listIterator();
929 while(li
.hasNext()) {
930 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcd
= li
.next();
931 saa
[i
][0] = dynPcd
.getCName();
932 saa
[i
][1] = dynPcd
.getToken().toString();
933 saa
[i
][2] = dynPcd
.getTokenSpaceGuidCName();
934 saa
[i
][3] = dynPcd
.getMaxDatumSize()+"";
935 saa
[i
][4] = dynPcd
.getDatumType().toString();
941 public void addDynamicPcdBuildData(String cName
, Object token
, String tsGuid
, String itemType
, String dataType
, String defaultVal
)
942 throws PcdValueMalFormed
{
943 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData dynPcdData
= getfpdDynPcdBuildDefs().addNewPcdBuildData();
944 dynPcdData
.setItemType(PcdItemTypes
.Enum
.forString(itemType
));
945 dynPcdData
.setCName(cName
);
946 dynPcdData
.setToken(token
);
947 dynPcdData
.setTokenSpaceGuidCName(tsGuid
);
948 dynPcdData
.setDatumType(PcdDataTypes
.Enum
.forString(dataType
));
950 BigInteger bigInt
= new BigInteger("0");
951 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= dynPcdData
.addNewSkuInfo();
952 skuInfo
.setSkuId(bigInt
);
953 if (defaultVal
!= null){
954 skuInfo
.setValue(defaultVal
);
957 if (dataType
.equals("UINT8")){
958 skuInfo
.setValue("0");
960 if (dataType
.equals("UINT16")) {
961 skuInfo
.setValue("0");
963 if (dataType
.equals("UINT32")) {
964 skuInfo
.setValue("0");
966 if (dataType
.equals("UINT64")){
967 skuInfo
.setValue("0");
969 if (dataType
.equals("BOOLEAN")){
970 skuInfo
.setValue("false");
972 if (dataType
.equals("VOID*")) {
973 skuInfo
.setValue("");
976 if (dataType
.equals("UINT8")){
977 dynPcdData
.setMaxDatumSize(1);
979 if (dataType
.equals("UINT16")) {
980 dynPcdData
.setMaxDatumSize(2);
982 if (dataType
.equals("UINT32")) {
983 dynPcdData
.setMaxDatumSize(4);
985 if (dataType
.equals("UINT64")){
986 dynPcdData
.setMaxDatumSize(8);
988 if (dataType
.equals("BOOLEAN")){
989 dynPcdData
.setMaxDatumSize(1);
991 if (dataType
.equals("VOID*")) {
992 int maxSize
= setMaxSizeForPointer(defaultVal
);
993 dynPcdData
.setMaxDatumSize(maxSize
);
997 public void removeDynamicPcdBuildData(String cName
, String tsGuid
) {
998 XmlObject o
= getfpdDynPcdBuildDefs();
1000 XmlCursor cursor
= o
.newCursor();
1001 if (cursor
.toFirstChild()) {
1003 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdBuildData
=
1004 (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1005 if (pcdBuildData
.getCName().equals(cName
) && pcdBuildData
.getTokenSpaceGuidCName().equals(tsGuid
)) {
1007 if (getDynamicPcdBuildDataCount() == 0) {
1015 while (cursor
.toNextSibling());
1020 // Get the Sku Info count of ith dyn pcd element.
1022 public int getDynamicPcdSkuInfoCount(int i
){
1023 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1027 int skuInfoCount
= 0;
1028 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1029 if (cursor
.toFirstChild()) {
1030 for (int j
= 0; j
< i
; ++j
) {
1031 cursor
.toNextSibling();
1033 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1034 if (pcdData
.getSkuInfoList() == null) {
1038 skuInfoCount
= pcdData
.getSkuInfoList().size();
1042 return skuInfoCount
;
1045 public void getDynamicPcdSkuInfos(int i
, String
[][] saa
){
1046 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1050 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1051 if (cursor
.toFirstChild()) {
1052 for (int j
= 0; j
< i
; ++j
) {
1053 cursor
.toNextSibling();
1055 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1056 if (pcdData
.getSkuInfoList() == null) {
1061 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1063 while (li
.hasNext()) {
1064 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1065 saa
[k
][0] = skuInfo
.getSkuId()+"";
1066 saa
[k
][1] = skuInfo
.getVariableName();
1067 saa
[k
][2] = skuInfo
.getVariableGuid();
1068 saa
[k
][3] = skuInfo
.getVariableOffset();
1069 saa
[k
][4] = skuInfo
.getHiiDefaultValue();
1070 saa
[k
][5] = skuInfo
.getVpdOffset();
1071 saa
[k
][6] = skuInfo
.getValue();
1081 public String
getDynamicPcdBuildDataValue(int i
){
1082 String value
= null;
1083 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1087 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1088 if (cursor
.toFirstChild()) {
1089 for (int j
= 0; j
< i
; ++j
) {
1090 cursor
.toNextSibling();
1092 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1093 if (pcdData
.getSkuInfoList() == null) {
1097 value
= pcdData
.getSkuInfoArray(0).getValue();
1104 public String
getDynamicPcdBuildDataVpdOffset(int i
){
1105 String vpdOffset
= null;
1106 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1110 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1111 if (cursor
.toFirstChild()) {
1112 for (int j
= 0; j
< i
; ++j
) {
1113 cursor
.toNextSibling();
1115 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1116 if (pcdData
.getSkuInfoList() == null) {
1120 vpdOffset
= pcdData
.getSkuInfoArray(0).getVpdOffset();
1127 public void removeDynamicPcdBuildDataSkuInfo(int i
) {
1128 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1132 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1133 if (cursor
.toFirstChild()) {
1134 for (int j
= 0; j
< i
; ++j
) {
1135 cursor
.toNextSibling();
1137 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1138 if (pcdData
.getSkuInfoList() == null) {
1143 QName qSkuInfo
= new QName(xmlNs
, "SkuInfo");
1144 cursor
.toChild(qSkuInfo
);
1151 // generate sku info for ith dyn pcd build data.
1153 public void genDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1154 String hiiDefault
, String vpdOffset
, String value
, int i
) {
1155 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1159 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1160 if (cursor
.toFirstChild()) {
1161 for (int j
= 0; j
< i
; ++j
) {
1162 cursor
.toNextSibling();
1164 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1165 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= pcdData
.addNewSkuInfo();
1166 skuInfo
.setSkuId(new BigInteger(id
));
1167 if (varName
!= null){
1168 skuInfo
.setVariableName(varName
);
1169 skuInfo
.setVariableGuid(varGuid
);
1170 skuInfo
.setVariableOffset(varOffset
);
1171 skuInfo
.setHiiDefaultValue(hiiDefault
);
1173 else if (vpdOffset
!= null){
1174 skuInfo
.setVpdOffset(vpdOffset
);
1177 skuInfo
.setValue(value
);
1182 public void updateDynamicPcdBuildDataSkuInfo(String id
, String varName
, String varGuid
, String varOffset
,
1183 String hiiDefault
, String vpdOffset
, String value
, int i
){
1184 if (getfpdDynPcdBuildDefs().getPcdBuildDataList() == null || getfpdDynPcdBuildDefs().getPcdBuildDataList().size() == 0) {
1188 XmlCursor cursor
= getfpdDynPcdBuildDefs().newCursor();
1189 if (cursor
.toFirstChild()) {
1190 for (int j
= 0; j
< i
; ++j
) {
1191 cursor
.toNextSibling();
1193 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData pcdData
= (DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
)cursor
.getObject();
1194 ListIterator
<DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo
> li
= pcdData
.getSkuInfoList().listIterator();
1195 while (li
.hasNext()) {
1196 DynamicPcdBuildDefinitionsDocument
.DynamicPcdBuildDefinitions
.PcdBuildData
.SkuInfo skuInfo
= li
.next();
1197 if (skuInfo
.getSkuId().toString().equals(id
)){
1198 if (varName
!= null){
1199 skuInfo
.setVariableName(varName
);
1200 skuInfo
.setVariableGuid(varGuid
);
1201 skuInfo
.setVariableOffset(varOffset
);
1202 skuInfo
.setHiiDefaultValue(hiiDefault
);
1204 else if (vpdOffset
!= null){
1205 skuInfo
.setVpdOffset(vpdOffset
);
1208 skuInfo
.setValue(value
);
1216 public BuildOptionsDocument
.BuildOptions
getfpdBuildOpts() {
1217 if (fpdBuildOpts
== null) {
1218 fpdBuildOpts
= fpdRoot
.addNewBuildOptions();
1220 return fpdBuildOpts
;
1223 public void genBuildOptionsUserDefAntTask (String id
, String fileName
, String execOrder
) {
1224 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1225 if (udats
== null) {
1226 udats
= getfpdBuildOpts().addNewUserDefinedAntTasks();
1229 AntTaskDocument
.AntTask at
= udats
.addNewAntTask();
1230 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1233 private void setBuildOptionsUserDefAntTask(String id
, String fileName
, String execOrder
, AntTaskDocument
.AntTask at
) {
1234 at
.setId(new Integer(id
));
1235 if (fileName
!= null){
1236 at
.setFilename(fileName
);
1238 if (execOrder
!= null) {
1239 at
.setAntCmdOptions(execOrder
);
1243 public void removeBuildOptionsUserDefAntTask(int i
) {
1244 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1248 XmlCursor cursor
= o
.newCursor();
1249 if (cursor
.toFirstChild()) {
1250 for (int j
= 0; j
< i
; ++j
) {
1251 cursor
.toNextSibling();
1254 if (getBuildOptionsUserDefAntTaskCount() == 0) {
1262 public void updateBuildOptionsUserDefAntTask(int i
, String id
, String fileName
, String execOrder
){
1263 XmlObject o
= getfpdBuildOpts().getUserDefinedAntTasks();
1267 XmlCursor cursor
= o
.newCursor();
1268 if (cursor
.toFirstChild()) {
1269 for (int j
= 0; j
< i
; ++j
) {
1270 cursor
.toNextSibling();
1272 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)cursor
.getObject();
1273 setBuildOptionsUserDefAntTask(id
, fileName
, execOrder
, at
);
1278 public int getBuildOptionsUserDefAntTaskCount() {
1279 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1280 if (udats
== null || udats
.getAntTaskList() == null) {
1284 return udats
.getAntTaskList().size();
1287 public void getBuildOptionsUserDefAntTasks(String
[][] saa
) {
1288 UserDefinedAntTasksDocument
.UserDefinedAntTasks udats
= getfpdBuildOpts().getUserDefinedAntTasks();
1289 if (udats
== null || udats
.getAntTaskList() == null) {
1293 List
<AntTaskDocument
.AntTask
> l
= udats
.getAntTaskList();
1294 ListIterator li
= l
.listIterator();
1296 while (li
.hasNext()) {
1297 AntTaskDocument
.AntTask at
= (AntTaskDocument
.AntTask
)li
.next();
1298 saa
[i
][0] = at
.getId() + "";
1299 saa
[i
][1] = saa
[i
][2] = "";
1300 if (at
.getFilename() != null){
1301 saa
[i
][1] = at
.getFilename();
1303 if (at
.getAntCmdOptions() != null) {
1304 saa
[i
][2] = at
.getAntCmdOptions();
1309 public void genBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1310 OptionsDocument
.Options opts
= getfpdBuildOpts().getOptions();
1312 opts
= getfpdBuildOpts().addNewOptions();
1314 OptionDocument
.Option opt
= opts
.addNewOption();
1315 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1318 private void setBuildOptionsOpt(Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
, OptionDocument
.Option opt
){
1319 opt
.setStringValue(contents
);
1321 opt
.setBuildTargets(buildTargets
);
1322 opt
.setToolChainFamily(toolChain
);
1323 opt
.setTagName(tagName
);
1324 opt
.setToolCode(toolCmd
);
1326 opt
.setSupArchList(archList
);
1329 public void removeBuildOptionsOpt(int i
){
1331 XmlObject o
= getfpdBuildOpts().getOptions();
1336 XmlCursor cursor
= o
.newCursor();
1337 if (cursor
.toFirstChild()) {
1338 for (int j
= 0; j
< i
; ++j
) {
1339 cursor
.toNextSibling();
1342 if (getBuildOptionsOptCount() == 0) {
1350 public void updateBuildOptionsOpt(int i
, Vector
<Object
> buildTargets
, String toolChain
, String tagName
, String toolCmd
, Vector
<Object
> archList
, String contents
) {
1351 XmlObject o
= getfpdBuildOpts().getOptions();
1356 XmlCursor cursor
= o
.newCursor();
1357 if (cursor
.toFirstChild()) {
1358 for (int j
= 0; j
< i
; ++j
) {
1359 cursor
.toNextSibling();
1361 OptionDocument
.Option opt
= (OptionDocument
.Option
)cursor
.getObject();
1362 setBuildOptionsOpt(buildTargets
, toolChain
, tagName
, toolCmd
, archList
, contents
, opt
);
1367 public int getBuildOptionsOptCount(){
1368 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1371 return getfpdBuildOpts().getOptions().getOptionList().size();
1374 public void getBuildOptionsOpts(String
[][] saa
) {
1375 if (getfpdBuildOpts().getOptions() == null || getfpdBuildOpts().getOptions().getOptionList() == null) {
1379 List
<OptionDocument
.Option
> lOpt
= getfpdBuildOpts().getOptions().getOptionList();
1380 ListIterator li
= lOpt
.listIterator();
1382 while(li
.hasNext()) {
1383 OptionDocument
.Option opt
= (OptionDocument
.Option
)li
.next();
1384 if (opt
.getBuildTargets() != null) {
1385 saa
[i
][0] = listToString(opt
.getBuildTargets());
1387 saa
[i
][1] = opt
.getToolChainFamily();
1388 if (opt
.getSupArchList() != null){
1389 saa
[i
][2] = listToString(opt
.getSupArchList());
1392 saa
[i
][3] = opt
.getToolCode();
1393 saa
[i
][4] = opt
.getTagName();
1394 saa
[i
][5] = opt
.getStringValue();
1400 public void genBuildOptionsFfs(String ffsKey
, String type
) {
1401 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1402 ffs
.setFfsKey(ffsKey
);
1404 ffs
.addNewSections().setEncapsulationType(type
);
1408 public void updateBuildOptionsFfsSectionsType(int i
, String type
) {
1409 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getfpdBuildOpts().addNewFfs();
1411 ffs
.addNewSections().setEncapsulationType(type
);
1415 public void genBuildOptionsFfsAttribute(int i
, String name
, String value
) {
1416 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1417 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= ffs
.addNewAttribute();
1418 attrib
.setName(name
);
1419 attrib
.setValue(value
);
1422 /**update jth attribute of ith ffs.
1426 public void updateBuildOptionsFfsAttribute(int i
, int j
, String name
, String value
){
1427 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1428 XmlCursor cursor
= ffs
.newCursor();
1429 QName qAttrib
= new QName(xmlNs
, "Attribute");
1430 if (cursor
.toChild(qAttrib
)) {
1431 for (int k
= 0; k
< j
; ++k
) {
1432 cursor
.toNextSibling(qAttrib
);
1434 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
)cursor
.getObject();
1435 attrib
.setName(name
);
1436 attrib
.setValue(value
);
1441 public void removeBuildOptionsFfsAttribute(int i
, int j
){
1442 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1443 XmlCursor cursor
= ffs
.newCursor();
1444 QName qAttrib
= new QName(xmlNs
, "Attribute");
1445 if (cursor
.toChild(qAttrib
)) {
1446 for (int k
= 0; k
< j
; ++k
) {
1447 cursor
.toNextSibling(qAttrib
);
1454 public void genBuildOptionsFfsSectionsSection(int i
, String sectionType
) {
1455 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1459 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1461 if (sections
== null){
1462 sections
= ffs
.addNewSections();
1464 sections
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(sectionType
));
1467 public void removeBuildOptionsFfsSectionsSection(int i
, int j
) {
1468 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1469 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1470 if (sections
== null) {
1473 XmlCursor cursor
= sections
.newCursor();
1474 QName qSection
= new QName(xmlNs
, "Section");
1475 if (cursor
.toChild(qSection
)) {
1476 for (int k
= 0; k
< j
; ++k
) {
1477 cursor
.toNextSibling(qSection
);
1484 public void updateBuildOptionsFfsSectionsSection(int i
, int j
, String type
){
1485 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1486 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1487 if (sections
== null) {
1490 XmlCursor cursor
= sections
.newCursor();
1491 QName qSection
= new QName(xmlNs
, "Section");
1492 if (cursor
.toChild(qSection
)) {
1493 for (int k
= 0; k
< j
; ++k
) {
1494 cursor
.toNextSibling(qSection
);
1496 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
)cursor
.getObject();
1497 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1502 public void genBuildOptionsFfsSectionsSections(int i
, String encapType
) {
1503 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1507 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1509 if (sections
== null){
1510 sections
= ffs
.addNewSections();
1512 sections
.addNewSections().setEncapsulationType(encapType
);
1515 public void removeBuildOptionsFfsSectionsSections(int i
, int j
) {
1516 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1517 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1518 if (sections
== null) {
1521 XmlCursor cursor
= sections
.newCursor();
1522 QName qSections
= new QName(xmlNs
, "Sections");
1523 if (cursor
.toChild(qSections
)) {
1524 for (int k
= 0; k
< j
; ++k
) {
1525 cursor
.toNextSibling(qSections
);
1532 public void updateBuildOptionsFfsSectionsSections(int i
, int j
, String type
) {
1533 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1534 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1535 if (sections
== null) {
1538 XmlCursor cursor
= sections
.newCursor();
1539 QName qSections
= new QName(xmlNs
, "Sections");
1540 if (cursor
.toChild(qSections
)) {
1541 for (int k
= 0; k
< j
; ++k
) {
1542 cursor
.toNextSibling(qSections
);
1544 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1545 sections2
.setEncapsulationType(type
);
1550 public void genBuildOptionsFfsSectionsSectionsSection(int i
, int j
, String type
) {
1551 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1555 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1556 XmlCursor cursor
= sections
.newCursor();
1557 QName qSections
= new QName(xmlNs
, "Sections");
1558 if (cursor
.toChild(qSections
)){
1559 for (int k
= 0; k
< j
; ++k
) {
1560 cursor
.toNextSibling(qSections
);
1562 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1563 sections2
.addNewSection().setSectionType(EfiSectionType
.Enum
.forString(type
));
1568 public void removeBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
) {
1569 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1570 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1571 if (sections
== null) {
1574 XmlCursor cursor
= sections
.newCursor();
1575 QName qSections
= new QName(xmlNs
, "Sections");
1576 if (cursor
.toChild(qSections
)) {
1577 for (int l
= 0; l
< j
; ++l
) {
1578 cursor
.toNextSibling(qSections
);
1580 if (cursor
.toFirstChild()) {
1582 for (; m
< k
; ++m
) {
1583 cursor
.toNextSibling();
1595 public void updateBuildOptionsFfsSectionsSectionsSection(int i
, int j
, int k
, String type
) {
1596 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1597 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1598 if (sections
== null) {
1601 XmlCursor cursor
= sections
.newCursor();
1602 QName qSections
= new QName(xmlNs
, "Sections");
1603 if (cursor
.toChild(qSections
)) {
1604 for (int l
= 0; l
< j
; ++l
) {
1605 cursor
.toNextSibling(qSections
);
1607 if (cursor
.toFirstChild()) {
1608 for (int m
= 0; m
< k
; ++m
) {
1609 cursor
.toNextSibling();
1611 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
)cursor
.getObject();
1612 section
.setSectionType(EfiSectionType
.Enum
.forString(type
));
1618 public void getBuildOptionsFfsSectionsSectionsSection(int i
, int j
, ArrayList
<String
> al
) {
1619 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1623 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections sections
= ffs
.getSections();
1624 XmlCursor cursor
= sections
.newCursor();
1625 QName qSections
= new QName(xmlNs
, "Sections");
1626 if (cursor
.toChild(qSections
)){
1627 for (int k
= 0; k
< j
; ++k
) {
1628 cursor
.toNextSibling(qSections
);
1630 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2 sections2
= (BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
)cursor
.getObject();
1631 if (sections2
.getSectionList() == null){
1635 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section
> li
= sections2
.getSectionList().listIterator();
1636 while(li
.hasNext()) {
1637 BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
.Section section
= li
.next();
1638 if (section
.isSetSectionType()) {
1639 al
.add(section
.getSectionType().toString());
1648 public int getBuildOptionsFfsCount(){
1649 if (getfpdBuildOpts().getFfsList() == null) {
1652 return getfpdBuildOpts().getFfsList().size();
1655 public void getBuildOptionsFfsKey(String
[][] saa
) {
1656 if (getfpdBuildOpts().getFfsList() == null) {
1659 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
> li
= getfpdBuildOpts().getFfsList().listIterator();
1661 while(li
.hasNext()){
1662 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= li
.next();
1663 saa
[i
][0] = ffs
.getFfsKey();
1668 public void updateBuildOptionsFfsKey(int i
, String key
) {
1669 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1673 /**Get ith FFS key and contents.
1676 public void getBuildOptionsFfs(int i
, String
[] sa
, LinkedHashMap
<String
, String
> ffsAttribMap
, ArrayList
<String
> firstLevelSections
, ArrayList
<String
> firstLevelSection
) {
1677 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1681 sa
[0] = ffs
.getFfsKey();
1682 if (ffs
.getSections() != null) {
1683 if(ffs
.getSections().getEncapsulationType() != null){
1684 sa
[1] = ffs
.getSections().getEncapsulationType();
1686 if (ffs
.getSections().getSectionList() != null){
1687 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Section
> li
= ffs
.getSections().getSectionList().listIterator();
1688 while (li
.hasNext()) {
1689 firstLevelSection
.add(li
.next().getSectionType().toString());
1692 if (ffs
.getSections().getSectionsList() != null) {
1693 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Sections
.Sections2
> li
= ffs
.getSections().getSectionsList().listIterator();
1694 while(li
.hasNext()) {
1695 firstLevelSections
.add(li
.next().getEncapsulationType());
1699 if (ffs
.getAttributeList() != null) {
1700 ListIterator
<BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute
> li
= ffs
.getAttributeList().listIterator();
1701 while(li
.hasNext()) {
1702 BuildOptionsDocument
.BuildOptions
.Ffs
.Attribute attrib
= li
.next();
1703 ffsAttribMap
.put(attrib
.getName(), attrib
.getValue());
1712 private BuildOptionsDocument
.BuildOptions
.Ffs
getFfs(int i
) {
1713 XmlObject o
= getfpdBuildOpts();
1714 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= null;
1716 XmlCursor cursor
= o
.newCursor();
1717 QName qFfs
= new QName(xmlNs
, "Ffs");
1718 if (cursor
.toChild(qFfs
)) {
1719 for (int j
= 0; j
< i
; ++j
) {
1720 cursor
.toNextSibling(qFfs
);
1722 ffs
= (BuildOptionsDocument
.BuildOptions
.Ffs
)cursor
.getObject();
1728 public void removeBuildOptionsFfs(int i
) {
1729 BuildOptionsDocument
.BuildOptions
.Ffs ffs
= getFfs(i
);
1734 XmlCursor cursor
= ffs
.newCursor();
1741 public PlatformDefinitionsDocument
.PlatformDefinitions
getfpdPlatformDefs(){
1742 if (fpdPlatformDefs
== null){
1743 fpdPlatformDefs
= fpdRoot
.addNewPlatformDefinitions();
1745 return fpdPlatformDefs
;
1748 public void getPlatformDefsSupportedArchs(Vector
<Object
> archs
){
1749 if (getfpdPlatformDefs().getSupportedArchitectures() == null) {
1752 ListIterator li
= getfpdPlatformDefs().getSupportedArchitectures().listIterator();
1753 while(li
.hasNext()) {
1754 archs
.add(li
.next());
1758 public void setPlatformDefsSupportedArchs(Vector
<Object
> archs
) {
1759 getfpdPlatformDefs().setSupportedArchitectures(archs
);
1762 public void getPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1763 if (getfpdPlatformDefs().getBuildTargets() == null) {
1766 ListIterator li
= getfpdPlatformDefs().getBuildTargets().listIterator();
1767 while(li
.hasNext()) {
1768 targets
.add(li
.next());
1772 public void setPlatformDefsBuildTargets(Vector
<Object
> targets
) {
1773 getfpdPlatformDefs().setBuildTargets(targets
);
1776 public void genPlatformDefsSkuInfo(String id
, String name
) {
1777 SkuInfoDocument
.SkuInfo skuInfo
= null;
1778 if (getfpdPlatformDefs().getSkuInfo() == null) {
1779 skuInfo
= getfpdPlatformDefs().addNewSkuInfo();
1781 skuInfo
= getfpdPlatformDefs().getSkuInfo();
1782 if (skuInfo
.getUiSkuNameList() == null || skuInfo
.getUiSkuNameList().size() == 0) {
1783 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1784 skuName
.setSkuID(new BigInteger("0"));
1785 skuName
.setStringValue("DEFAULT");
1787 if (id
.equals("0")) {
1790 SkuInfoDocument
.SkuInfo
.UiSkuName skuName
= skuInfo
.addNewUiSkuName();
1791 skuName
.setSkuID(new BigInteger(id
));
1792 skuName
.setStringValue(name
);
1795 public int getPlatformDefsSkuInfoCount(){
1796 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1799 return getfpdPlatformDefs().getSkuInfo().getUiSkuNameList().size();
1802 public void getPlatformDefsSkuInfos(String
[][] saa
){
1803 if (getfpdPlatformDefs().getSkuInfo() == null || getfpdPlatformDefs().getSkuInfo().getUiSkuNameList() == null) {
1807 List
<SkuInfoDocument
.SkuInfo
.UiSkuName
> l
= getfpdPlatformDefs().getSkuInfo().getUiSkuNameList();
1808 ListIterator
<SkuInfoDocument
.SkuInfo
.UiSkuName
> li
= l
.listIterator();
1810 while(li
.hasNext()) {
1811 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= li
.next();
1812 saa
[i
][0] = sku
.getSkuID()+"";
1813 saa
[i
][1] = sku
.getStringValue();
1818 public void removePlatformDefsSkuInfo(int i
) {
1819 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1820 if (skuInfo
== null || i
== 0) {
1824 XmlCursor cursor
= skuInfo
.newCursor();
1825 if (cursor
.toFirstChild()) {
1826 for (int j
= 0; j
< i
; ++j
) {
1827 cursor
.toNextSibling();
1834 public void updatePlatformDefsSkuInfo(int i
, String id
, String name
) {
1835 SkuInfoDocument
.SkuInfo skuInfo
= getfpdPlatformDefs().getSkuInfo();
1836 if (skuInfo
== null || i
== 0) {
1840 XmlCursor cursor
= skuInfo
.newCursor();
1841 if (cursor
.toFirstChild()) {
1842 for (int j
= 0; j
< i
; ++j
) {
1843 cursor
.toNextSibling();
1845 SkuInfoDocument
.SkuInfo
.UiSkuName sku
= (SkuInfoDocument
.SkuInfo
.UiSkuName
)cursor
.getObject();
1846 sku
.setSkuID(new BigInteger(id
));
1847 sku
.setStringValue(name
);
1852 public String
getPlatformDefsInterDir(){
1853 if (getfpdPlatformDefs().getIntermediateDirectories() == null) {
1856 return getfpdPlatformDefs().getIntermediateDirectories().toString();
1859 public void setPlatformDefsInterDir(String interDir
){
1860 getfpdPlatformDefs().setIntermediateDirectories(IntermediateOutputType
.Enum
.forString(interDir
));
1863 public String
getPlatformDefsOutputDir() {
1864 return getfpdPlatformDefs().getOutputDirectory();
1867 public void setPlatformDefsOutputDir(String outputDir
) {
1868 if (outputDir
!= null && outputDir
.length() > 0) {
1869 getfpdPlatformDefs().setOutputDirectory(outputDir
);
1872 XmlCursor cursor
= getfpdPlatformDefs().newCursor();
1873 if (cursor
.toChild(new QName(xmlNs
, "OutputDirectory"))) {
1880 public FlashDocument
.Flash
getfpdFlash() {
1881 if (fpdFlash
== null) {
1882 fpdFlash
= fpdRoot
.addNewFlash();
1887 public void genFlashDefinitionFile(String file
) {
1888 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1890 fdf
= getfpdFlash().addNewFlashDefinitionFile();
1893 fdf
.setStringValue(file
);
1896 public String
getFlashDefinitionFile() {
1897 FlashDefinitionFileDocument
.FlashDefinitionFile fdf
= getfpdFlash().getFlashDefinitionFile();
1902 return fdf
.getStringValue();
1905 public void genFvImagesNameValue(String name
, String value
) {
1907 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1909 fi
= getfpdFlash().addNewFvImages();
1912 FvImagesDocument
.FvImages
.NameValue nv
= fi
.addNewNameValue();
1917 public void removeFvImagesNameValue(int i
){
1919 XmlObject o
= getfpdFlash().getFvImages();
1924 QName qNameValue
= new QName(xmlNs
, "NameValue");
1925 XmlCursor cursor
= o
.newCursor();
1926 if (cursor
.toChild(qNameValue
)) {
1927 for (int j
= 0; j
< i
; ++j
) {
1928 cursor
.toNextSibling(qNameValue
);
1935 public void updateFvImagesNameValue(int i
, String name
, String value
){
1937 XmlObject o
= getfpdFlash().getFvImages();
1942 QName qNameValue
= new QName(xmlNs
, "NameValue");
1943 XmlCursor cursor
= o
.newCursor();
1944 if (cursor
.toChild(qNameValue
)) {
1945 for (int j
= 0; j
< i
; ++j
) {
1946 cursor
.toNextSibling(qNameValue
);
1948 FvImagesDocument
.FvImages
.NameValue nv
= (FvImagesDocument
.FvImages
.NameValue
)cursor
.getObject();
1955 public int getFvImagesNameValueCount() {
1957 FvImagesDocument
.FvImages fi
= null;
1958 if ((fi
= getfpdFlash().getFvImages()) == null || fi
.getNameValueList() == null) {
1961 return fi
.getNameValueList().size();
1964 public void getFvImagesNameValues(String
[][] nv
) {
1966 FvImagesDocument
.FvImages fi
= getfpdFlash().getFvImages();
1970 List
<FvImagesDocument
.FvImages
.NameValue
> l
= fi
.getNameValueList();
1972 ListIterator li
= l
.listIterator();
1973 while (li
.hasNext()) {
1974 FvImagesDocument
.FvImages
.NameValue e
= (FvImagesDocument
.FvImages
.NameValue
) li
1976 nv
[i
][0] = e
.getName();
1977 nv
[i
][1] = e
.getValue();
1983 public void genFvImagesFvImage(String
[] names
, String types
, Map
<String
, String
> options
) {
1985 FvImagesDocument
.FvImages fis
= null;
1986 if ((fis
= getfpdFlash().getFvImages()) == null) {
1987 fis
= getfpdFlash().addNewFvImages();
1991 //gen FvImage with FvImageNames array
1993 FvImagesDocument
.FvImages
.FvImage fi
= fis
.addNewFvImage();
1994 for (int i
= 0; i
< names
.length
; ++i
) {
1995 fi
.addFvImageNames(names
[i
]);
1997 fi
.setType(FvImageTypes
.Enum
.forString(types
));
1998 if (options
!= null){
1999 setFvImagesFvImageFvImageOptions(options
, fi
);
2003 private void setFvImagesFvImageFvImageOptions(Map
<String
, String
> options
, FvImagesDocument
.FvImages
.FvImage fi
){
2004 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions fio
= fi
.getFvImageOptions();
2006 fio
= fi
.addNewFvImageOptions();
2009 Set
<String
> key
= options
.keySet();
2010 Iterator
<String
> i
= key
.iterator();
2011 while (i
.hasNext()) {
2013 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= fio
.addNewNameValue();
2014 String k
= (String
)i
.next();
2017 nv
.setValue((String
)options
.get(k
));
2024 public void removeFvImagesFvImage(int i
) {
2026 XmlObject o
= getfpdFlash().getFvImages();
2031 QName qFvImage
= new QName(xmlNs
, "FvImage");
2032 XmlCursor cursor
= o
.newCursor();
2033 if (cursor
.toChild(qFvImage
)) {
2034 for (int j
= 0; j
< i
; ++j
) {
2035 cursor
.toNextSibling(qFvImage
);
2042 public void updateFvImagesFvImage(int i
, String
[] names
, String types
, Map
<String
, String
> options
){
2044 XmlObject o
= getfpdFlash().getFvImages();
2048 XmlCursor cursor
= o
.newCursor();
2049 QName qFvImage
= new QName(xmlNs
, "FvImage");
2050 if (cursor
.toChild(qFvImage
)) {
2051 for (int j
= 0; j
< i
; ++j
) {
2052 cursor
.toNextSibling(qFvImage
);
2054 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2055 fi
.setType(FvImageTypes
.Enum
.forString(types
));
2058 // remove old FvImageNames before adding new ones
2060 QName qFvImageNames
= new QName(xmlNs
, "FvImageNames");
2061 cursor
.toChild(qFvImageNames
);
2063 while (cursor
.toNextSibling(qFvImageNames
)) {
2067 for (int k
= 0; k
< names
.length
; ++k
) {
2068 fi
.addFvImageNames(names
[k
]);
2071 // remove old FvImageOptions before adding new options
2073 QName qFvImageOptions
= new QName(xmlNs
, "FvImageOptions");
2074 cursor
.toNextSibling(qFvImageOptions
);
2077 setFvImagesFvImageFvImageOptions(options
, fi
);
2082 public int getFvImagesFvImageCount() {
2084 if (getfpdFlash().getFvImages() == null || getfpdFlash().getFvImages().getFvImageList() == null) {
2087 return getfpdFlash().getFvImages().getFvImageList().size();
2090 /**Only Get Fv image setting - name and type.
2093 public void getFvImagesFvImages(String
[][] saa
) {
2095 if (getfpdFlash().getFvImages() == null) {
2098 List
<FvImagesDocument
.FvImages
.FvImage
> l
= getfpdFlash().getFvImages().getFvImageList();
2102 ListIterator li
= l
.listIterator();
2104 while(li
.hasNext()) {
2105 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)li
.next();
2107 // get FvImageNames array, space separated
2109 List
<String
> lfn
= fi
.getFvImageNamesList();
2110 ListIterator lfni
= lfn
.listIterator();
2112 while (lfni
.hasNext()) {
2113 saa
[i
][0] += (String
)lfni
.next();
2116 saa
[i
][0] = saa
[i
][0].trim();
2118 saa
[i
][1] = fi
.getType()+"";
2124 /**Get FvImage Options for FvImage i
2125 * @param i the ith FvImage
2127 public void getFvImagesFvImageOptions(int i
, Map
<String
, String
> m
) {
2128 XmlObject o
= getfpdFlash().getFvImages();
2132 XmlCursor cursor
= o
.newCursor();
2133 QName qFvImage
= new QName(xmlNs
, "FvImage");
2134 if (cursor
.toChild(qFvImage
)) {
2135 for (int j
= 0; j
< i
; ++j
) {
2136 cursor
.toNextSibling(qFvImage
);
2138 FvImagesDocument
.FvImages
.FvImage fi
= (FvImagesDocument
.FvImages
.FvImage
)cursor
.getObject();
2139 if (fi
.getFvImageOptions() == null || fi
.getFvImageOptions().getNameValueList() == null){
2142 ListIterator
<FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue
> li
= fi
.getFvImageOptions().getNameValueList().listIterator();
2143 while(li
.hasNext()){
2144 FvImagesDocument
.FvImages
.FvImage
.FvImageOptions
.NameValue nv
= li
.next();
2145 m
.put(nv
.getName(), nv
.getValue());
2151 Get platform header element
2152 @return PlatformHeaderDocument.PlatformHeader
2154 public PlatformHeaderDocument
.PlatformHeader
getFpdHdr() {
2155 if (fpdHdr
== null) {
2156 fpdHdr
= fpdRoot
.addNewPlatformHeader();
2158 genPlatformDefsSkuInfo("0", "DEFAULT");
2162 public String
getFpdHdrPlatformName() {
2163 return getFpdHdr().getPlatformName();
2166 public String
getFpdHdrGuidValue() {
2167 return getFpdHdr().getGuidValue();
2170 public String
getFpdHdrVer() {
2171 return getFpdHdr().getVersion();
2174 public String
getFpdHdrAbs() {
2175 return getFpdHdr().getAbstract();
2178 public String
getFpdHdrDescription() {
2179 return getFpdHdr().getDescription();
2182 public String
getFpdHdrCopyright() {
2183 return getFpdHdr().getCopyright();
2186 public String
getFpdHdrLicense() {
2187 LicenseDocument
.License l
= getFpdHdr().getLicense();
2191 return l
.getStringValue();
2194 public String
getFpdHdrUrl() {
2195 LicenseDocument
.License l
= getFpdHdr().getLicense();
2202 public String
getFpdHdrSpec() {
2204 return "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2205 // return getFpdHdr().getSpecification();
2208 public void setFpdHdrPlatformName(String name
){
2209 getFpdHdr().setPlatformName(name
);
2212 public void setFpdHdrGuidValue(String guid
){
2213 getFpdHdr().setGuidValue(guid
);
2216 public void setFpdHdrVer(String v
){
2217 getFpdHdr().setVersion(v
);
2220 public void setFpdHdrAbs(String abs
) {
2221 getFpdHdr().setAbstract(abs
);
2224 public void setFpdHdrDescription(String desc
){
2225 getFpdHdr().setDescription(desc
);
2228 public void setFpdHdrCopyright(String cr
) {
2229 getFpdHdr().setCopyright(cr
);
2232 public void setFpdHdrLicense(String license
){
2233 LicenseDocument
.License l
= getFpdHdr().getLicense();
2235 getFpdHdr().addNewLicense().setStringValue(license
);
2238 l
.setStringValue(license
);
2242 public void setFpdHdrUrl(String url
){
2243 LicenseDocument
.License l
= getFpdHdr().getLicense();
2249 public void setFpdHdrSpec(String s
){
2250 s
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
2251 getFpdHdr().setSpecification(s
);
2254 Save the processed xml contents to file
2256 @param fpdFile The file to save xml contents
2257 @throws IOException Exceptions during file operation
2259 public void saveAs(File fpdFile
) throws IOException
{
2261 XmlOptions options
= new XmlOptions();
2263 options
.setCharacterEncoding("UTF-8");
2264 options
.setSavePrettyPrint();
2265 options
.setSavePrettyPrintIndent(2);
2267 fpdd
.save(fpdFile
, options
);
2268 } catch (IOException e
) {
2269 e
.printStackTrace();
2274 private String
listToString(List l
) {
2279 ListIterator li
= l
.listIterator();
2280 while(li
.hasNext()) {
2288 class PcdItemTypeConflictException
extends Exception
{
2293 private static final long serialVersionUID
= 1L;
2294 private String details
= null;
2296 PcdItemTypeConflictException(String info
){
2300 public String
getMessage() {
2305 class PcdDeclNotFound
extends Exception
{
2310 private static final long serialVersionUID
= 1L;
2311 private String details
= null;
2313 PcdDeclNotFound(String info
) {
2317 public String
getMessage() {
2322 class PcdValueMalFormed
extends Exception
{
2327 private static final long serialVersionUID
= 1L;
2328 private String details
= null;
2330 PcdValueMalFormed(String info
) {
2334 public String
getMessage() {