1 package org
.tianocore
.migration
;
5 import org
.tianocore
.*;
6 import org
.tianocore
.SupportedArchitectures
.Enum
;
8 public class MsaOwner
{
9 public static final String COPYRIGHT
= "Copyright (c) 2006, Intel Corporation";
10 public static final String VERSION
= "1.0";
11 public static final String ABSTRACT
= "Component name for module ";
12 public static final String DESCRIPTION
= "FIX ME!";
13 public static final String LICENSE
= "All rights reserved.\n" +
14 " This software and associated documentation (if any) is furnished\n" +
15 " under a license and may only be used or copied in accordance\n" +
16 " with the terms of the license. Except as permitted by such\n" +
17 " license, no part of this software or documentation may be\n" +
18 " reproduced, stored in a retrieval system, or transmitted in any\n" +
19 " form or by any means without the express written consent of\n" +
20 " Intel Corporation.";
21 public static final String SPECIFICATION
= "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";
23 public static final Enum IA32
= SupportedArchitectures
.IA_32
;
24 public static final Enum X64
= SupportedArchitectures
.X_64
;
25 public static final Enum IPF
= SupportedArchitectures
.IPF
;
26 public static final Enum EBC
= SupportedArchitectures
.EBC
;
28 private ModuleSurfaceAreaDocument msadoc
= ModuleSurfaceAreaDocument
.Factory
.newInstance();
30 private ModuleSurfaceAreaDocument
.ModuleSurfaceArea msa
= null;
31 private MsaHeaderDocument
.MsaHeader msaheader
= null;
32 private LicenseDocument
.License license
= null;
33 private ModuleDefinitionsDocument
.ModuleDefinitions moduledefinitions
= null;
34 private SourceFilesDocument
.SourceFiles sourcefiles
= null; //found local .h files are not written
35 private GuidsDocument
.Guids guids
= null;
36 private ProtocolsDocument
.Protocols protocols
= null;
37 private PPIsDocument
.PPIs ppis
= null;
38 private PackageDependenciesDocument
.PackageDependencies packagedependencies
= null;
39 private LibraryClassDefinitionsDocument
.LibraryClassDefinitions libclassdefs
= null;
40 private ExternsDocument
.Externs externs
= null;
42 private List
<Enum
> listarch
= new ArrayList
<Enum
>();
43 //private Map<String, Enum> mapfilenames = new HashMap<String, Enum>(); //this need to be installed manually when msa is to be written
44 //private Map<String, UsageTypes.Enum> mapprotocols = new HashMap<String, UsageTypes.Enum>();
46 //-----------------------------msaheader-------------------------------------//
48 public final boolean addLibraryClass (String name
, UsageTypes
.Enum usage
) {
49 Iterator
<LibraryClassDocument
.LibraryClass
> classit
= libclassdefs
.getLibraryClassList().iterator();
50 while (classit
.hasNext()) {
51 if (classit
.next().getKeyword() == name
) {
52 MigrationTool
.ui
.println ("Warning: Duplicate LibraryClass");
57 LibraryClassDocument
.LibraryClass classname
;
58 List
<UsageTypes
.Enum
> arch
= new ArrayList
<UsageTypes
.Enum
>();
59 classname
= libclassdefs
.addNewLibraryClass();
60 classname
.setKeyword(name
);
62 classname
.setSupArchList(arch
);
66 public final boolean addGuid (String guidname
, UsageTypes
.Enum usage
) {
68 guids
= msa
.addNewGuids();
71 Iterator
<GuidsDocument
.Guids
.GuidCNames
> guidit
= guids
.getGuidCNamesList().iterator();
72 while (guidit
.hasNext()) {
73 if (guidit
.next().getGuidCName() == guidname
) {
74 MigrationTool
.ui
.println ("Warning: Duplicate Guid");
79 GuidsDocument
.Guids
.GuidCNames guid
;
80 List
<UsageTypes
.Enum
> arch
= new ArrayList
<UsageTypes
.Enum
>();
81 guid
= guids
.addNewGuidCNames();
82 guid
.setGuidCName(guidname
);
84 guid
.setSupArchList(arch
);
89 public final boolean addPpi (String ppiname
, UsageTypes
.Enum usage
) {
91 ppis
= msa
.addNewPPIs();
94 Iterator
<PPIsDocument
.PPIs
.Ppi
> ppiit
= ppis
.getPpiList().iterator();
95 while (ppiit
.hasNext()) {
96 if (ppiit
.next().getPpiCName() == ppiname
) {
97 MigrationTool
.ui
.println ("Warning: Duplicate Ppi");
102 PPIsDocument
.PPIs
.Ppi ppi
;
103 List
<UsageTypes
.Enum
> arch
= new ArrayList
<UsageTypes
.Enum
>();
104 ppi
= ppis
.addNewPpi();
105 ppi
.setPpiCName(ppiname
);
107 ppi
.setSupArchList(arch
);
112 private final boolean installProtocols () {
113 if (mapprotocols.isEmpty()) {
116 Set<String> setprotocols = mapprotocols.keySet();
117 ProtocolsDocument.Protocols.Protocol protocol;
118 Iterator<String> it = setprotocols.iterator();
119 while (it.hasNext()) {
120 protocol = protocols.addNewProtocol();
121 protocol.setProtocolCName(it.next());
122 protocol.setUsage(mapprotocols.get(protocol.getProtocolCName()));
127 public final boolean addProtocols (String protocol, UsageTypes.Enum usage) {
128 if (mapprotocols.containsKey(protocol)) {
131 mapprotocols.put(protocol, usage);
136 public final boolean addProtocol (String proname
, UsageTypes
.Enum usage
) {
137 if (protocols
== null) {
138 protocols
= msa
.addNewProtocols();
141 Iterator
<ProtocolsDocument
.Protocols
.Protocol
> proit
= protocols
.getProtocolList().iterator();
142 while (proit
.hasNext()) {
143 if (proit
.next().getProtocolCName() == proname
) {
144 MigrationTool
.ui
.println ("Warning: Duplicate Protocol");
149 ProtocolsDocument
.Protocols
.Protocol protocol
;
150 List
<UsageTypes
.Enum
> arch
= new ArrayList
<UsageTypes
.Enum
>();
151 protocol
= protocols
.addNewProtocol();
152 protocol
.setProtocolCName(proname
);
154 protocol
.setSupArchList(arch
);
159 private final boolean installHashFilename () {
160 if (mapfilenames.isEmpty()) {
163 Set<String> setfilename = mapfilenames.keySet();
164 FilenameDocument.Filename filename;
165 List<Enum> arch = new ArrayList<Enum>();
166 Iterator<String> it = setfilename.iterator();
167 while (it.hasNext()) {
168 filename = sourcefiles.addNewFilename();
169 filename.setStringValue(it.next());
170 arch.add(mapfilenames.get(filename.getStringValue()));
171 filename.setSupArchList(arch);
176 public final boolean addSourceFile (String filename, Enum arch) { // dummy & null how to imply?
177 if (mapfilenames.containsKey(filename)) {
180 mapfilenames.put(filename, arch);
185 public final boolean addSourceFile (String name
, Enum en
) {
186 Iterator
<FilenameDocument
.Filename
> fileit
= sourcefiles
.getFilenameList().iterator();
187 while (fileit
.hasNext()) {
188 if (fileit
.next().getStringValue() == name
) {
189 MigrationTool
.ui
.println ("Warning: Duplicate SourceFileName");
194 FilenameDocument
.Filename filename
;
195 List
<Enum
> arch
= new ArrayList
<Enum
>();
196 filename
= sourcefiles
.addNewFilename();
197 filename
.setStringValue(name
);
199 filename
.setSupArchList(arch
);
205 public final boolean setupExternSpecification () {
206 addExternSpecification("EFI_SPECIFICATION_VERSION 0x00020000");
207 addExternSpecification("EDK_RELEASE_VERSION 0x00020000");
211 public final boolean addExternSpecification (String specification
) {
212 if (externs
.getSpecificationList().contains(specification
)) {
215 externs
.addSpecification(specification
);
220 public final boolean setupPackageDependencies() {
221 addPackage("5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec");
222 addPackage("68169ab0-d41b-4009-9060-292c253ac43d");
226 public final boolean addPackage (String guid
) {
227 if (packagedependencies
.getPackageList().contains(guid
)) {
230 packagedependencies
.addNewPackage().setPackageGuid(guid
);
235 public final boolean setupModuleDefinitions () { //????????? give this job to moduleinfo
236 moduledefinitions
.setBinaryModule(false);
237 moduledefinitions
.setOutputFileBasename(msaheader
.getModuleName());
240 public final boolean addSupportedArchitectures (Enum arch
) {
241 if (listarch
.contains(arch
)) {
249 public final boolean addSpecification (String specification
) {
250 if (msaheader
.getSpecification() == null) {
251 if (specification
== null) {
252 msaheader
.setSpecification(SPECIFICATION
);
254 msaheader
.setSpecification(specification
);
258 MigrationTool
.ui
.println ("Warning: Duplicate Specification");
263 public final boolean addLicense (String licensecontent
) {
264 if (msaheader
.getLicense() == null) {
265 license
= msaheader
.addNewLicense();
266 if (licensecontent
== null) {
267 license
.setStringValue(LICENSE
);
269 license
.setStringValue(licensecontent
);
273 MigrationTool
.ui
.println ("Warning: Duplicate License");
278 public final boolean addDescription (String description
) {
279 if (msaheader
.getDescription() == null) {
280 if (description
== null) {
281 msaheader
.setDescription(DESCRIPTION
);
283 msaheader
.setDescription(description
);
287 MigrationTool
.ui
.println ("Warning: Duplicate Description");
292 public final boolean addAbstract (String abs
) {
293 if (msaheader
.getAbstract() == null) {
295 msaheader
.setAbstract(ABSTRACT
+ msaheader
.getModuleName());
297 msaheader
.setVersion(abs
);
301 MigrationTool
.ui
.println ("Warning: Duplicate Abstract");
306 public final boolean addVersion (String version
) {
307 if (msaheader
.getVersion() == null) {
308 if (version
== null) {
309 msaheader
.setVersion(VERSION
);
311 msaheader
.setVersion(version
);
315 MigrationTool
.ui
.println ("Warning: Duplicate Version");
320 public final boolean addCopyRight (String copyright
) {
321 if (msaheader
.getCopyright() == null) {
322 if (copyright
== null) {
323 msaheader
.setCopyright(COPYRIGHT
);
325 msaheader
.setCopyright(copyright
);
329 MigrationTool
.ui
.println ("Warning: Duplicate CopyRight");
334 public final boolean addModuleType (String moduletype
) {
335 if (msaheader
.getModuleType() == null) {
336 msaheader
.setModuleType(ModuleTypeDef
.Enum
.forString(moduletype
));
339 MigrationTool
.ui
.println ("Warning: Duplicate ModuleType");
344 public final boolean addGuidValue (String guidvalue
) {
345 if (msaheader
.getGuidValue() == null) {
346 msaheader
.setGuidValue(guidvalue
);
349 MigrationTool
.ui
.println ("Warning: Duplicate GuidValue");
354 public final boolean addModuleName (String modulename
) {
355 if (msaheader
.getModuleName() == null) {
356 msaheader
.setModuleName(modulename
);
359 MigrationTool
.ui
.println ("Warning: Duplicate ModuleName");
363 //-----------------------------msaheader-------------------------------------//
365 public final void addSourceFiles (String filename
, int arch
) {
369 private final MsaOwner
init () {
370 msa
= msadoc
.addNewModuleSurfaceArea();
371 msaheader
= msa
.addNewMsaHeader();
372 moduledefinitions
= msa
.addNewModuleDefinitions();
373 moduledefinitions
.setSupportedArchitectures(listarch
);
375 sourcefiles
= msa
.addNewSourceFiles();
376 packagedependencies
= msa
.addNewPackageDependencies();
377 libclassdefs
= msa
.addNewLibraryClassDefinitions();
378 externs
= msa
.addNewExterns();
382 public static final MsaOwner
initNewMsaOwner() {
383 return new MsaOwner().init();