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-------------------------------------//
47 private final boolean installProtocols () {
48 if (mapprotocols
.isEmpty()) {
51 Set
<String
> setprotocols
= mapprotocols
.keySet();
52 ProtocolsDocument
.Protocols
.Protocol protocol
;
53 Iterator
<String
> it
= setprotocols
.iterator();
54 while (it
.hasNext()) {
55 protocol
= protocols
.addNewProtocol();
56 protocol
.setProtocolCName(it
.next());
57 protocol
.setUsage(mapprotocols
.get(protocol
.getProtocolCName()));
62 public final boolean addProtocols (String protocol
, UsageTypes
.Enum usage
) {
63 if (mapprotocols
.containsKey(protocol
)) {
66 mapprotocols
.put(protocol
, usage
);
71 private final boolean installHashFilename () {
72 if (mapfilenames
.isEmpty()) {
75 Set
<String
> setfilename
= mapfilenames
.keySet();
76 FilenameDocument
.Filename filename
;
77 List
<Enum
> arch
= new ArrayList
<Enum
>();
78 Iterator
<String
> it
= setfilename
.iterator();
79 while (it
.hasNext()) {
80 filename
= sourcefiles
.addNewFilename();
81 filename
.setStringValue(it
.next());
82 arch
.add(mapfilenames
.get(filename
.getStringValue()));
83 filename
.setSupArchList(arch
);
88 public final boolean addSourceFile (String filename
, Enum arch
) { // dummy & null how to imply?
89 if (mapfilenames
.containsKey(filename
)) {
92 mapfilenames
.put(filename
, arch
);
99 public final boolean setupExternSpecification () {
100 addExternSpecification("EFI_SPECIFICATION_VERSION 0x00020000");
101 addExternSpecification("EDK_RELEASE_VERSION 0x00020000");
105 public final boolean addExternSpecification (String specification
) {
106 if (externs
.getSpecificationList().contains(specification
)) {
109 externs
.addSpecification(specification
);
114 public final boolean setupPackageDependencies() {
115 addPackage("5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec");
116 addPackage("68169ab0-d41b-4009-9060-292c253ac43d");
120 public final boolean addPackage (String guid
) {
121 if (packagedependencies
.getPackageList().contains(guid
)) {
124 packagedependencies
.addNewPackage().setPackageGuid(guid
);
129 public final boolean setupModuleDefinitions () { //????????? give this job to moduleinfo
130 moduledefinitions
.setBinaryModule(false);
131 moduledefinitions
.setOutputFileBasename(msaheader
.getModuleName());
134 public final boolean addSupportedArchitectures (Enum arch
) {
135 if (listarch
.contains(arch
)) {
143 public final boolean addSpecification (String specification
) {
144 if (msaheader
.getSpecification() == null) {
145 if (specification
== null) {
146 msaheader
.setSpecification(SPECIFICATION
);
148 msaheader
.setSpecification(specification
);
152 MigrationTool
.ui
.println ("Warning: Duplicate Specification");
157 public final boolean addLicense (String licensecontent
) {
158 if (msaheader
.getLicense() == null) {
159 license
= msaheader
.addNewLicense();
160 if (licensecontent
== null) {
161 license
.setStringValue(LICENSE
);
163 license
.setStringValue(licensecontent
);
167 MigrationTool
.ui
.println ("Warning: Duplicate License");
172 public final boolean addDescription (String description
) {
173 if (msaheader
.getDescription() == null) {
174 if (description
== null) {
175 msaheader
.setDescription(DESCRIPTION
);
177 msaheader
.setDescription(description
);
181 MigrationTool
.ui
.println ("Warning: Duplicate Description");
186 public final boolean addAbstract (String abs
) {
187 if (msaheader
.getAbstract() == null) {
189 msaheader
.setAbstract(ABSTRACT
+ msaheader
.getModuleName());
191 msaheader
.setVersion(abs
);
195 MigrationTool
.ui
.println ("Warning: Duplicate Abstract");
200 public final boolean addVersion (String version
) {
201 if (msaheader
.getVersion() == null) {
202 if (version
== null) {
203 msaheader
.setVersion(VERSION
);
205 msaheader
.setVersion(version
);
209 MigrationTool
.ui
.println ("Warning: Duplicate Version");
214 public final boolean addCopyRight (String copyright
) {
215 if (msaheader
.getCopyright() == null) {
216 if (copyright
== null) {
217 msaheader
.setCopyright(COPYRIGHT
);
219 msaheader
.setCopyright(copyright
);
223 MigrationTool
.ui
.println ("Warning: Duplicate CopyRight");
228 public final boolean addModuleType (String moduletype
) {
229 if (msaheader
.getModuleType() == null) {
230 msaheader
.setModuleType(ModuleTypeDef
.Enum
.forString(moduletype
));
233 MigrationTool
.ui
.println ("Warning: Duplicate ModuleType");
238 public final boolean addGuidValue (String guidvalue
) {
239 if (msaheader
.getGuidValue() == null) {
240 msaheader
.setGuidValue(guidvalue
);
243 MigrationTool
.ui
.println ("Warning: Duplicate GuidValue");
248 public final boolean addModuleName (String modulename
) {
249 if (msaheader
.getModuleName() == null) {
250 msaheader
.setModuleName(modulename
);
253 MigrationTool
.ui
.println ("Warning: Duplicate ModuleName");
257 //-----------------------------msaheader-------------------------------------//
259 public final void addSourceFiles (String filename
, int arch
) {
263 private final MsaOwner
init () {
264 msa
= msadoc
.addNewModuleSurfaceArea();
265 msaheader
= msa
.addNewMsaHeader();
266 moduledefinitions
= msa
.addNewModuleDefinitions();
267 moduledefinitions
.setSupportedArchitectures(listarch
);
269 sourcefiles
= msa
.addNewSourceFiles();
270 packagedependencies
= msa
.addNewPackageDependencies();
271 libclassdefs
= msa
.addNewLibraryClassDefinitions();
272 externs
= msa
.addNewExterns();
276 public static final MsaOwner
initNewMsaOwner() {
277 return new MsaOwner().init();