]> git.proxmox.com Git - mirror_edk2.git/blob - Tools/Source/MigrationTools/org/tianocore/migration/MsaOwner.java
Remove empty attributes for build option.
[mirror_edk2.git] / Tools / Source / MigrationTools / org / tianocore / migration / MsaOwner.java
1 package org.tianocore.migration;
2
3 import java.util.*;
4
5 import org.tianocore.*;
6 import org.tianocore.SupportedArchitectures.Enum;
7
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";
22
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;
27
28 private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance();
29
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;
41
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>();
45
46 //-----------------------------msaheader-------------------------------------//
47 private final boolean installProtocols () {
48 if (mapprotocols.isEmpty()) {
49 return false;
50 }
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()));
58 }
59 return true;
60 }
61
62 public final boolean addProtocols (String protocol, UsageTypes.Enum usage) {
63 if (mapprotocols.containsKey(protocol)) {
64 return false;
65 } else {
66 mapprotocols.put(protocol, usage);
67 return true;
68 }
69 }
70
71 private final boolean installHashFilename () {
72 if (mapfilenames.isEmpty()) {
73 return false;
74 }
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);
84 }
85 return true;
86 }
87
88 public final boolean addSourceFile (String filename, Enum arch) { // dummy & null how to imply?
89 if (mapfilenames.containsKey(filename)) {
90 return false;
91 } else {
92 mapfilenames.put(filename, arch);
93 return true;
94 }
95 }
96
97 // entry point todo
98
99 public final boolean setupExternSpecification () {
100 addExternSpecification("EFI_SPECIFICATION_VERSION 0x00020000");
101 addExternSpecification("EDK_RELEASE_VERSION 0x00020000");
102 return true;
103 }
104
105 public final boolean addExternSpecification (String specification) {
106 if (externs.getSpecificationList().contains(specification)) {
107 return false;
108 } else {
109 externs.addSpecification(specification);
110 return true;
111 }
112 }
113
114 public final boolean setupPackageDependencies() {
115 addPackage("5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec");
116 addPackage("68169ab0-d41b-4009-9060-292c253ac43d");
117 return true;
118 }
119
120 public final boolean addPackage (String guid) {
121 if (packagedependencies.getPackageList().contains(guid)) {
122 return false;
123 } else {
124 packagedependencies.addNewPackage().setPackageGuid(guid);
125 return true;
126 }
127 }
128
129 public final boolean setupModuleDefinitions () { //????????? give this job to moduleinfo
130 moduledefinitions.setBinaryModule(false);
131 moduledefinitions.setOutputFileBasename(msaheader.getModuleName());
132 return true;
133 }
134 public final boolean addSupportedArchitectures (Enum arch) {
135 if (listarch.contains(arch)) {
136 return false;
137 } else {
138 listarch.add(arch);
139 return true;
140 }
141 }
142
143 public final boolean addSpecification (String specification) {
144 if (msaheader.getSpecification() == null) {
145 if (specification == null) {
146 msaheader.setSpecification(SPECIFICATION);
147 } else {
148 msaheader.setSpecification(specification);
149 }
150 return true;
151 } else {
152 MigrationTool.ui.println ("Warning: Duplicate Specification");
153 return false;
154 }
155 }
156
157 public final boolean addLicense (String licensecontent) {
158 if (msaheader.getLicense() == null) {
159 license = msaheader.addNewLicense();
160 if (licensecontent == null) {
161 license.setStringValue(LICENSE);
162 } else {
163 license.setStringValue(licensecontent);
164 }
165 return true;
166 } else {
167 MigrationTool.ui.println ("Warning: Duplicate License");
168 return false;
169 }
170 }
171
172 public final boolean addDescription (String description) {
173 if (msaheader.getDescription() == null) {
174 if (description == null) {
175 msaheader.setDescription(DESCRIPTION);
176 } else {
177 msaheader.setDescription(description);
178 }
179 return true;
180 } else {
181 MigrationTool.ui.println ("Warning: Duplicate Description");
182 return false;
183 }
184 }
185
186 public final boolean addAbstract (String abs) {
187 if (msaheader.getAbstract() == null) {
188 if (abs == null) {
189 msaheader.setAbstract(ABSTRACT + msaheader.getModuleName());
190 } else {
191 msaheader.setVersion(abs);
192 }
193 return true;
194 } else {
195 MigrationTool.ui.println ("Warning: Duplicate Abstract");
196 return false;
197 }
198 }
199
200 public final boolean addVersion (String version) {
201 if (msaheader.getVersion() == null) {
202 if (version == null) {
203 msaheader.setVersion(VERSION);
204 } else {
205 msaheader.setVersion(version);
206 }
207 return true;
208 } else {
209 MigrationTool.ui.println ("Warning: Duplicate Version");
210 return false;
211 }
212 }
213
214 public final boolean addCopyRight (String copyright) {
215 if (msaheader.getCopyright() == null) {
216 if (copyright == null) {
217 msaheader.setCopyright(COPYRIGHT);
218 } else {
219 msaheader.setCopyright(copyright);
220 }
221 return true;
222 } else {
223 MigrationTool.ui.println ("Warning: Duplicate CopyRight");
224 return false;
225 }
226 }
227
228 public final boolean addModuleType (String moduletype) {
229 if (msaheader.getModuleType() == null) {
230 msaheader.setModuleType(ModuleTypeDef.Enum.forString(moduletype));
231 return true;
232 } else {
233 MigrationTool.ui.println ("Warning: Duplicate ModuleType");
234 return false;
235 }
236 }
237
238 public final boolean addGuidValue (String guidvalue) {
239 if (msaheader.getGuidValue() == null) {
240 msaheader.setGuidValue(guidvalue);
241 return true;
242 } else {
243 MigrationTool.ui.println ("Warning: Duplicate GuidValue");
244 return false;
245 }
246 }
247
248 public final boolean addModuleName (String modulename) {
249 if (msaheader.getModuleName() == null) {
250 msaheader.setModuleName(modulename);
251 return true;
252 } else {
253 MigrationTool.ui.println ("Warning: Duplicate ModuleName");
254 return false;
255 }
256 }
257 //-----------------------------msaheader-------------------------------------//
258
259 public final void addSourceFiles (String filename, int arch) {
260
261 }
262
263 private final MsaOwner init () {
264 msa = msadoc.addNewModuleSurfaceArea();
265 msaheader = msa.addNewMsaHeader();
266 moduledefinitions = msa.addNewModuleDefinitions();
267 moduledefinitions.setSupportedArchitectures(listarch);
268
269 sourcefiles = msa.addNewSourceFiles();
270 packagedependencies = msa.addNewPackageDependencies();
271 libclassdefs = msa.addNewLibraryClassDefinitions();
272 externs = msa.addNewExterns();
273 return this;
274 }
275
276 public static final MsaOwner initNewMsaOwner() {
277 return new MsaOwner().init();
278 }
279 }