]>
Commit | Line | Data |
---|---|---|
6ef5feb5 | 1 | package org.tianocore.migration;\r |
2 | \r | |
fd16b4dd | 3 | import java.util.*;\r |
4 | \r | |
5c55f71c | 5 | import org.tianocore.*;\r |
fd16b4dd | 6 | import org.tianocore.SupportedArchitectures.Enum;\r |
5c55f71c | 7 | \r |
8 | public class MsaOwner {\r | |
9 | public static final String COPYRIGHT = "Copyright (c) 2006, Intel Corporation";\r | |
10 | public static final String VERSION = "1.0";\r | |
11 | public static final String ABSTRACT = "Component name for module ";\r | |
12 | public static final String DESCRIPTION = "FIX ME!";\r | |
13 | public static final String LICENSE = "All rights reserved.\n" +\r | |
14 | " This software and associated documentation (if any) is furnished\n" +\r | |
15 | " under a license and may only be used or copied in accordance\n" +\r | |
16 | " with the terms of the license. Except as permitted by such\n" +\r | |
17 | " license, no part of this software or documentation may be\n" +\r | |
18 | " reproduced, stored in a retrieval system, or transmitted in any\n" +\r | |
19 | " form or by any means without the express written consent of\n" +\r | |
20 | " Intel Corporation.";\r | |
21 | public static final String SPECIFICATION = "FRAMEWORK_BUILD_PACKAGING_SPECIFICATION 0x00000052";\r | |
22 | \r | |
fd16b4dd | 23 | public static final Enum IA32 = SupportedArchitectures.IA_32;\r |
24 | public static final Enum X64 = SupportedArchitectures.X_64;\r | |
25 | public static final Enum IPF = SupportedArchitectures.IPF;\r | |
26 | public static final Enum EBC = SupportedArchitectures.EBC;\r | |
27 | \r | |
5c55f71c | 28 | private ModuleSurfaceAreaDocument msadoc = ModuleSurfaceAreaDocument.Factory.newInstance();\r |
29 | \r | |
30 | private ModuleSurfaceAreaDocument.ModuleSurfaceArea msa = null;\r | |
31 | private MsaHeaderDocument.MsaHeader msaheader = null;\r | |
32 | private LicenseDocument.License license = null;\r | |
fd16b4dd | 33 | private ModuleDefinitionsDocument.ModuleDefinitions moduledefinitions = null;\r |
5c55f71c | 34 | private SourceFilesDocument.SourceFiles sourcefiles = null; //found local .h files are not written\r |
35 | private GuidsDocument.Guids guids = null;\r | |
36 | private ProtocolsDocument.Protocols protocols = null;\r | |
37 | private PPIsDocument.PPIs ppis = null;\r | |
fd16b4dd | 38 | private PackageDependenciesDocument.PackageDependencies packagedependencies = null;\r |
5c55f71c | 39 | private LibraryClassDefinitionsDocument.LibraryClassDefinitions libclassdefs = null;\r |
40 | private ExternsDocument.Externs externs = null;\r | |
fd16b4dd | 41 | \r |
42 | private List<Enum> listarch = new ArrayList<Enum>();\r | |
43 | private Map<String, Enum> mapfilenames = new HashMap<String, Enum>(); //this need to be installed manually when msa is to be written\r | |
44 | private Map<String, UsageTypes.Enum> mapprotocols = new HashMap<String, UsageTypes.Enum>();\r | |
5c55f71c | 45 | \r |
46 | //-----------------------------msaheader-------------------------------------//\r | |
fd16b4dd | 47 | private final boolean installProtocols () {\r |
48 | if (mapprotocols.isEmpty()) {\r | |
49 | return false;\r | |
50 | }\r | |
51 | Set<String> setprotocols = mapprotocols.keySet();\r | |
52 | ProtocolsDocument.Protocols.Protocol protocol;\r | |
53 | Iterator<String> it = setprotocols.iterator();\r | |
54 | while (it.hasNext()) {\r | |
55 | protocol = protocols.addNewProtocol();\r | |
56 | protocol.setProtocolCName(it.next());\r | |
57 | protocol.setUsage(mapprotocols.get(protocol.getProtocolCName()));\r | |
58 | }\r | |
59 | return true;\r | |
60 | }\r | |
61 | \r | |
62 | public final boolean addProtocols (String protocol, UsageTypes.Enum usage) {\r | |
63 | if (mapprotocols.containsKey(protocol)) {\r | |
64 | return false;\r | |
65 | } else {\r | |
66 | mapprotocols.put(protocol, usage);\r | |
67 | return true;\r | |
68 | }\r | |
69 | }\r | |
70 | \r | |
71 | private final boolean installHashFilename () {\r | |
72 | if (mapfilenames.isEmpty()) {\r | |
73 | return false;\r | |
74 | }\r | |
75 | Set<String> setfilename = mapfilenames.keySet();\r | |
76 | FilenameDocument.Filename filename;\r | |
77 | List<Enum> arch = new ArrayList<Enum>();\r | |
78 | Iterator<String> it = setfilename.iterator();\r | |
79 | while (it.hasNext()) {\r | |
80 | filename = sourcefiles.addNewFilename();\r | |
81 | filename.setStringValue(it.next());\r | |
82 | arch.add(mapfilenames.get(filename.getStringValue()));\r | |
83 | filename.setSupArchList(arch);\r | |
84 | }\r | |
85 | return true;\r | |
86 | }\r | |
87 | \r | |
88 | public final boolean addSourceFile (String filename, Enum arch) { // dummy & null how to imply?\r | |
89 | if (mapfilenames.containsKey(filename)) {\r | |
90 | return false;\r | |
91 | } else {\r | |
92 | mapfilenames.put(filename, arch);\r | |
93 | return true;\r | |
94 | }\r | |
95 | }\r | |
96 | \r | |
97 | // entry point todo\r | |
98 | \r | |
99 | public final boolean setupExternSpecification () {\r | |
100 | addExternSpecification("EFI_SPECIFICATION_VERSION 0x00020000");\r | |
101 | addExternSpecification("EDK_RELEASE_VERSION 0x00020000");\r | |
102 | return true;\r | |
103 | }\r | |
104 | \r | |
105 | public final boolean addExternSpecification (String specification) {\r | |
106 | if (externs.getSpecificationList().contains(specification)) {\r | |
107 | return false;\r | |
108 | } else {\r | |
109 | externs.addSpecification(specification);\r | |
110 | return true;\r | |
111 | }\r | |
112 | }\r | |
113 | \r | |
114 | public final boolean setupPackageDependencies() {\r | |
115 | addPackage("5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec");\r | |
116 | addPackage("68169ab0-d41b-4009-9060-292c253ac43d");\r | |
117 | return true;\r | |
118 | }\r | |
119 | \r | |
120 | public final boolean addPackage (String guid) {\r | |
121 | if (packagedependencies.getPackageList().contains(guid)) {\r | |
122 | return false;\r | |
123 | } else {\r | |
124 | packagedependencies.addNewPackage().setPackageGuid(guid);\r | |
125 | return true;\r | |
126 | }\r | |
127 | }\r | |
128 | \r | |
129 | public final boolean setupModuleDefinitions () { //????????? give this job to moduleinfo\r | |
130 | moduledefinitions.setBinaryModule(false);\r | |
131 | moduledefinitions.setOutputFileBasename(msaheader.getModuleName());\r | |
132 | return true;\r | |
133 | }\r | |
134 | public final boolean addSupportedArchitectures (Enum arch) {\r | |
135 | if (listarch.contains(arch)) {\r | |
136 | return false;\r | |
137 | } else {\r | |
138 | listarch.add(arch);\r | |
139 | return true;\r | |
140 | }\r | |
141 | }\r | |
142 | \r | |
5c55f71c | 143 | public final boolean addSpecification (String specification) {\r |
144 | if (msaheader.getSpecification() == null) {\r | |
145 | if (specification == null) {\r | |
146 | msaheader.setSpecification(SPECIFICATION);\r | |
147 | } else {\r | |
148 | msaheader.setSpecification(specification);\r | |
149 | }\r | |
150 | return true;\r | |
151 | } else {\r | |
152 | MigrationTool.ui.println ("Warning: Duplicate Specification");\r | |
153 | return false;\r | |
154 | }\r | |
155 | }\r | |
156 | \r | |
157 | public final boolean addLicense (String licensecontent) {\r | |
158 | if (msaheader.getLicense() == null) {\r | |
159 | license = msaheader.addNewLicense();\r | |
160 | if (licensecontent == null) {\r | |
161 | license.setStringValue(LICENSE);\r | |
162 | } else {\r | |
163 | license.setStringValue(licensecontent);\r | |
164 | }\r | |
165 | return true;\r | |
166 | } else {\r | |
167 | MigrationTool.ui.println ("Warning: Duplicate License");\r | |
168 | return false;\r | |
169 | }\r | |
170 | }\r | |
171 | \r | |
172 | public final boolean addDescription (String description) {\r | |
173 | if (msaheader.getDescription() == null) {\r | |
174 | if (description == null) {\r | |
175 | msaheader.setDescription(DESCRIPTION);\r | |
176 | } else {\r | |
177 | msaheader.setDescription(description);\r | |
178 | }\r | |
179 | return true;\r | |
180 | } else {\r | |
181 | MigrationTool.ui.println ("Warning: Duplicate Description");\r | |
182 | return false;\r | |
183 | }\r | |
184 | }\r | |
185 | \r | |
186 | public final boolean addAbstract (String abs) {\r | |
187 | if (msaheader.getAbstract() == null) {\r | |
188 | if (abs == null) {\r | |
189 | msaheader.setAbstract(ABSTRACT + msaheader.getModuleName());\r | |
190 | } else {\r | |
191 | msaheader.setVersion(abs);\r | |
192 | }\r | |
193 | return true;\r | |
194 | } else {\r | |
195 | MigrationTool.ui.println ("Warning: Duplicate Abstract");\r | |
196 | return false;\r | |
197 | }\r | |
198 | }\r | |
199 | \r | |
200 | public final boolean addVersion (String version) {\r | |
201 | if (msaheader.getVersion() == null) {\r | |
202 | if (version == null) {\r | |
203 | msaheader.setVersion(VERSION);\r | |
204 | } else {\r | |
205 | msaheader.setVersion(version);\r | |
206 | }\r | |
207 | return true;\r | |
208 | } else {\r | |
209 | MigrationTool.ui.println ("Warning: Duplicate Version");\r | |
210 | return false;\r | |
211 | }\r | |
212 | }\r | |
213 | \r | |
214 | public final boolean addCopyRight (String copyright) {\r | |
215 | if (msaheader.getCopyright() == null) {\r | |
216 | if (copyright == null) {\r | |
217 | msaheader.setCopyright(COPYRIGHT);\r | |
218 | } else {\r | |
219 | msaheader.setCopyright(copyright);\r | |
220 | }\r | |
221 | return true;\r | |
222 | } else {\r | |
223 | MigrationTool.ui.println ("Warning: Duplicate CopyRight");\r | |
224 | return false;\r | |
225 | }\r | |
226 | }\r | |
227 | \r | |
228 | public final boolean addModuleType (String moduletype) {\r | |
229 | if (msaheader.getModuleType() == null) {\r | |
230 | msaheader.setModuleType(ModuleTypeDef.Enum.forString(moduletype));\r | |
231 | return true;\r | |
232 | } else {\r | |
233 | MigrationTool.ui.println ("Warning: Duplicate ModuleType");\r | |
234 | return false;\r | |
235 | }\r | |
236 | }\r | |
237 | \r | |
238 | public final boolean addGuidValue (String guidvalue) {\r | |
239 | if (msaheader.getGuidValue() == null) {\r | |
240 | msaheader.setGuidValue(guidvalue);\r | |
241 | return true;\r | |
242 | } else {\r | |
243 | MigrationTool.ui.println ("Warning: Duplicate GuidValue");\r | |
244 | return false;\r | |
245 | }\r | |
246 | }\r | |
247 | \r | |
248 | public final boolean addModuleName (String modulename) {\r | |
249 | if (msaheader.getModuleName() == null) {\r | |
250 | msaheader.setModuleName(modulename);\r | |
251 | return true;\r | |
252 | } else {\r | |
253 | MigrationTool.ui.println ("Warning: Duplicate ModuleName");\r | |
254 | return false;\r | |
255 | }\r | |
256 | }\r | |
257 | //-----------------------------msaheader-------------------------------------//\r | |
258 | \r | |
259 | public final void addSourceFiles (String filename, int arch) {\r | |
260 | \r | |
261 | }\r | |
262 | \r | |
263 | private final MsaOwner init () {\r | |
264 | msa = msadoc.addNewModuleSurfaceArea();\r | |
265 | msaheader = msa.addNewMsaHeader();\r | |
fd16b4dd | 266 | moduledefinitions = msa.addNewModuleDefinitions();\r |
267 | moduledefinitions.setSupportedArchitectures(listarch);\r | |
268 | \r | |
5c55f71c | 269 | sourcefiles = msa.addNewSourceFiles();\r |
fd16b4dd | 270 | packagedependencies = msa.addNewPackageDependencies();\r |
5c55f71c | 271 | libclassdefs = msa.addNewLibraryClassDefinitions();\r |
272 | externs = msa.addNewExterns();\r | |
273 | return this;\r | |
274 | }\r | |
275 | \r | |
276 | public static final MsaOwner initNewMsaOwner() {\r | |
277 | return new MsaOwner().init();\r | |
278 | }\r | |
279 | } |