]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | GlobalData class. \r | |
3 | \r | |
4 | GlobalData provide initializing, instoring, querying and update global data.\r | |
5 | It is a bridge to intercommunicate between multiple component, such as AutoGen,\r | |
6 | PCD and so on. \r | |
7 | \r | |
8 | Copyright (c) 2006, Intel Corporation\r | |
9 | All rights reserved. This program and the accompanying materials\r | |
10 | are licensed and made available under the terms and conditions of the BSD License\r | |
11 | which accompanies this distribution. The full text of the license may be found at\r | |
12 | http://opensource.org/licenses/bsd-license.php\r | |
13 | \r | |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
16 | **/\r | |
17 | package org.tianocore.build.global;\r | |
18 | \r | |
19 | import java.io.File;\r | |
250258de | 20 | import java.util.ArrayList;\r |
878ddf1f | 21 | import java.util.HashMap;\r |
22 | import java.util.HashSet;\r | |
23 | import java.util.Iterator;\r | |
24 | import java.util.List;\r | |
25 | import java.util.Map;\r | |
26 | import java.util.Set;\r | |
27 | \r | |
28 | import org.apache.tools.ant.BuildException;\r | |
29 | import org.apache.xmlbeans.XmlObject;\r | |
250258de | 30 | import org.tianocore.FilenameDocument;\r |
31 | import org.tianocore.FilenameDocument.Filename;\r | |
878ddf1f | 32 | import org.tianocore.FrameworkDatabaseDocument;\r |
33 | import org.tianocore.MsaFilesDocument;\r | |
250258de | 34 | import org.tianocore.MsaFilesDocument.MsaFiles.MsaFile;\r |
878ddf1f | 35 | import org.tianocore.MsaHeaderDocument.MsaHeader;\r |
36 | import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;\r | |
250258de | 37 | import org.tianocore.PackageListDocument;\r |
38 | import org.tianocore.PackageSurfaceAreaDocument;\r | |
878ddf1f | 39 | import org.tianocore.build.autogen.CommonDefinition;\r |
40 | import org.tianocore.build.fpd.FpdParserTask;\r | |
250258de | 41 | import org.tianocore.build.pcd.entity.MemoryDatabaseManager;\r |
878ddf1f | 42 | \r |
43 | /**\r | |
44 | GlobalData provide initializing, instoring, querying and update global data.\r | |
45 | It is a bridge to intercommunicate between multiple component, such as AutoGen,\r | |
46 | PCD and so on. \r | |
47 | \r | |
48 | <p>Note that all global information are initialized incrementally. All data will \r | |
49 | parse and record only it is necessary during build time. </p>\r | |
50 | \r | |
51 | @since GenBuild 1.0\r | |
52 | **/\r | |
53 | public class GlobalData {\r | |
54 | \r | |
55 | ///\r | |
56 | /// means no surface area information for module\r | |
57 | ///\r | |
58 | public static final int NO_SA = 0;\r | |
59 | \r | |
60 | ///\r | |
61 | /// means only MSA\r | |
62 | ///\r | |
63 | public static final int ONLY_MSA = 1;\r | |
64 | \r | |
65 | ///\r | |
66 | /// means only Library MSA\r | |
67 | ///\r | |
68 | public static final int ONLY_LIBMSA = 2;\r | |
69 | \r | |
70 | ///\r | |
71 | /// means both MSA and MBD\r | |
72 | ///\r | |
73 | public static final int MSA_AND_MBD = 3;\r | |
74 | \r | |
75 | ///\r | |
76 | /// means both Library MSA and Library MBD\r | |
77 | ///\r | |
78 | public static final int LIBMSA_AND_LIBMBD = 4;\r | |
79 | \r | |
80 | ///\r | |
81 | /// Be used to ensure Global data will be initialized only once.\r | |
82 | ///\r | |
83 | public static boolean globalFlag = false;\r | |
84 | \r | |
85 | ///\r | |
86 | /// Record current WORKSPACE Directory\r | |
87 | ///\r | |
88 | private static String workspaceDir = "";\r | |
89 | \r | |
90 | ///\r | |
91 | /// Two columns: Package Name (Key), Package Path(ralative to WORKSPACE)\r | |
92 | ///\r | |
93 | private static final Map<String, String> packageInfo = new HashMap<String, String>();\r | |
94 | \r | |
95 | ///\r | |
96 | /// spdTable\r | |
97 | /// Key: Package Name, Value: SPD detail info\r | |
98 | ///\r | |
99 | private static final Map<String, Spd> spdTable = new HashMap<String, Spd>();\r | |
100 | \r | |
101 | ///\r | |
102 | /// Three columns:\r | |
103 | /// 1. Module Name | BaseName (Key)\r | |
104 | /// 2. Module Path + Msa file name (relative to Package)\r | |
105 | /// 3. Package Name (This module belong to which package)\r | |
106 | ///\r | |
107 | private static final Map<String, String[]> moduleInfo = new HashMap<String, String[]>();\r | |
108 | \r | |
109 | ///\r | |
110 | /// List all libraries for current build module\r | |
111 | /// Key: Library BaseName, Value: output library path+name\r | |
112 | ///\r | |
113 | private static final Map<String, String> libraries = new HashMap<String, String>();\r | |
114 | \r | |
115 | ///\r | |
116 | /// Store every module's relative library instances BaseName\r | |
117 | /// Key: Module BaseName, Value: All library instances module depends on.\r | |
118 | ///\r | |
119 | private static final Map<String, Set<String> > moduleLibraryMap = new HashMap<String, Set<String> >();\r | |
120 | \r | |
121 | ///\r | |
122 | /// Key: Module BaseName, Value: original MSA info\r | |
123 | ///\r | |
124 | private static final Map<String, Map<String, XmlObject> > nativeMsa = new HashMap<String, Map<String, XmlObject> >();\r | |
125 | \r | |
126 | ///\r | |
127 | /// Key: Module BaseName, Value: original MBD info\r | |
128 | ///\r | |
129 | private static final Map<String, Map<String, XmlObject> > nativeMbd = new HashMap<String, Map<String, XmlObject> >();\r | |
130 | \r | |
131 | ///\r | |
132 | /// Two columns: Module Name or Base Name as Key\r | |
133 | /// Value is a HashMap with overridden data from MSA/MBD or/and Platform\r | |
134 | ///\r | |
135 | private static final Map<String, Map<String, XmlObject> > parsedModules = new HashMap<String, Map<String, XmlObject> >();\r | |
136 | \r | |
137 | ///\r | |
138 | /// List all built Module; Value is Module BaseName + Arch. TBD\r | |
139 | ///\r | |
140 | private static final Set<String> builtModules = new HashSet<String>();\r | |
141 | \r | |
142 | ///\r | |
143 | /// Library instance information table which recored the library and it's\r | |
144 | /// constructor and distructor function\r | |
145 | ///\r | |
146 | private static final Map<String, String[]> libInstanceInfo = new HashMap<String, String[]>();\r | |
147 | \r | |
148 | ///\r | |
149 | /// PCD memory database stored all PCD information which collected from FPD,MSA and SPD.\r | |
150 | ///\r | |
151 | private static final MemoryDatabaseManager pcdDbManager = new MemoryDatabaseManager();\r | |
152 | \r | |
153 | /**\r | |
154 | Query the module's absolute path with module base name. \r | |
155 | \r | |
156 | @param moduleName the base name of the module\r | |
157 | @return the absolute module path\r | |
158 | **/\r | |
159 | public synchronized static String getModulePath(String moduleName) {\r | |
160 | String[] info = moduleInfo.get(moduleName);\r | |
161 | String packagePath = (String) packageInfo.get(info[1]);\r | |
162 | File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);\r | |
163 | return convertFile.getParent();\r | |
164 | }\r | |
165 | \r | |
166 | /**\r | |
167 | Query the module's absolute MSA file path with module base name. \r | |
168 | \r | |
169 | @param moduleName the base name of the module\r | |
170 | @return the absolute MSA file name\r | |
171 | @throws BuildException\r | |
172 | Base name is not registered in any SPD files\r | |
173 | **/\r | |
174 | private synchronized static String getMsaFilename(String moduleName) throws BuildException {\r | |
175 | String[] info = moduleInfo.get(moduleName);\r | |
176 | if (info == null) {\r | |
177 | throw new BuildException("Module base name [" + moduleName + "] can't found in all SPD.");\r | |
178 | }\r | |
179 | String packagePath = (String) packageInfo.get(info[1]);\r | |
180 | File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);\r | |
181 | return convertFile.getPath();\r | |
182 | }\r | |
183 | \r | |
184 | /**\r | |
185 | Query the module's absolute MBD file path with module base name. \r | |
186 | \r | |
187 | @param moduleName the base name of the module\r | |
188 | @return the absolute MBD file name\r | |
189 | @throws BuildException\r | |
190 | Base name is not registered in any SPD files\r | |
191 | **/\r | |
192 | private synchronized static String getMbdFilename(String moduleName) throws BuildException {\r | |
193 | String[] info = moduleInfo.get(moduleName);\r | |
194 | if (info == null) {\r | |
195 | throw new BuildException("Info: Module base name [" + moduleName + "] can't found in all SPD.");\r | |
196 | }\r | |
197 | String packagePath = (String) packageInfo.get(info[1]);\r | |
198 | File convertFile = new File(workspaceDir + File.separatorChar + packagePath + File.separatorChar + info[0]);\r | |
199 | return convertFile.getPath().substring(0, convertFile.getPath().length() - 4) + ".mbd";\r | |
200 | }\r | |
201 | \r | |
202 | /**\r | |
203 | Get the current WORKSPACE Directory. \r | |
204 | @return current workspace directory\r | |
205 | **/\r | |
206 | public synchronized static String getWorkspacePath() {\r | |
207 | return workspaceDir;\r | |
208 | }\r | |
209 | \r | |
210 | /**\r | |
211 | Query package relative path to WORKSPACE_DIR with package name. \r | |
212 | \r | |
213 | @param packageName the name of the package\r | |
214 | @return the path relative to WORKSPACE_DIR \r | |
215 | **/\r | |
216 | public synchronized static String getPackagePath(String packageName) {\r | |
217 | return (String) packageInfo.get(packageName);\r | |
218 | }\r | |
219 | \r | |
220 | /**\r | |
221 | Query package (which the module belongs to) relative path to WORSPACE_DIR. \r | |
222 | \r | |
223 | @param moduleName the base name of the module\r | |
224 | @return the relative path to WORKSPACE_DIR of the package which the module belongs to\r | |
225 | **/\r | |
226 | public synchronized static String getPackagePathForModule(String moduleName) {\r | |
227 | String[] info = moduleInfo.get(moduleName);\r | |
228 | String packagePath = (String) packageInfo.get(info[1]);\r | |
229 | return packagePath;\r | |
230 | }\r | |
231 | \r | |
232 | /**\r | |
233 | Query the package name which the module belongs to with the module's base name.\r | |
234 | \r | |
235 | @param moduleName the base name of the module\r | |
236 | @return the package name which the module belongs to\r | |
237 | **/\r | |
238 | public synchronized static String getPackageNameForModule(String moduleName) {\r | |
239 | return moduleInfo.get(moduleName)[1];\r | |
240 | }\r | |
241 | \r | |
242 | /**\r | |
243 | Parse framework database (DB) and all SPD files listed in DB to initialize\r | |
244 | the environment for next build. This method will only be executed only once\r | |
245 | in the whole build process. \r | |
246 | \r | |
247 | @param workspaceDatabaseFile the file name of framework database\r | |
248 | @param workspaceDir current workspace directory path\r | |
249 | @throws BuildException\r | |
250 | Framework Dababase or SPD or MSA file is not valid\r | |
251 | **/\r | |
252 | public synchronized static void initInfo(String workspaceDatabaseFile, String workspaceDir) throws BuildException {\r | |
253 | if (globalFlag) {\r | |
254 | return;\r | |
255 | }\r | |
256 | globalFlag = true;\r | |
257 | GlobalData.workspaceDir = workspaceDir;\r | |
258 | File dbFile = new File(workspaceDir + File.separatorChar + workspaceDatabaseFile);\r | |
259 | try {\r | |
260 | FrameworkDatabaseDocument db = (FrameworkDatabaseDocument) XmlObject.Factory.parse(dbFile);\r | |
261 | List<PackageListDocument.PackageList.Package> packages = db.getFrameworkDatabase().getPackageList()\r | |
262 | .getPackageList();\r | |
263 | Iterator iter = packages.iterator();\r | |
264 | while (iter.hasNext()) {\r | |
265 | PackageListDocument.PackageList.Package packageItem = (PackageListDocument.PackageList.Package) iter\r | |
266 | .next();\r | |
267 | String name = packageItem.getPackageNameArray(0).getStringValue();\r | |
268 | String path = packageItem.getPathArray(0).getStringValue();\r | |
269 | packageInfo.put(name, path);\r | |
270 | File spdFile = new File(workspaceDir + File.separatorChar + path + File.separatorChar + name + ".spd");\r | |
271 | initPackageInfo(spdFile.getPath(), name);\r | |
272 | // \r | |
273 | // SPD Parse.\r | |
274 | //\r | |
275 | PackageSurfaceAreaDocument spdDoc = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(spdFile);\r | |
276 | Spd spd = new Spd(spdDoc, path);\r | |
277 | spdTable.put(name, spd);\r | |
278 | \r | |
279 | }\r | |
280 | } catch (Exception e) {\r | |
281 | throw new BuildException("Parse workspace Database [" + dbFile.getPath() + "] Error.\n" + e.getMessage());\r | |
282 | }\r | |
283 | }\r | |
284 | \r | |
285 | /**\r | |
286 | Parse every MSA files, get base name from MSA Header. And record those\r | |
287 | values to ModuleInfo.\r | |
288 | \r | |
289 | @param packageFilename the file name of the package\r | |
290 | @param packageName the name of the package\r | |
291 | @throws BuildException\r | |
292 | SPD or MSA file is not valid\r | |
293 | **/\r | |
294 | private synchronized static void initPackageInfo(String packageFilename, String packageName) throws BuildException {\r | |
295 | File packageFile = new File(packageFilename);\r | |
296 | try {\r | |
297 | PackageSurfaceAreaDocument spd = (PackageSurfaceAreaDocument) XmlObject.Factory.parse(packageFile);\r | |
20391ab0 | 298 | List<String> msaFilenameList;\r |
250258de | 299 | \r |
878ddf1f | 300 | List<MsaFilesDocument.MsaFiles.MsaFile> msasList = spd.getPackageSurfaceArea().getMsaFiles()\r |
301 | .getMsaFileList();\r | |
250258de | 302 | if (msasList.size() == 0) {\r |
303 | msaFilenameList = spd.getPackageSurfaceArea().getMsaFiles().getFilenameList();\r | |
304 | } else {\r | |
20391ab0 | 305 | msaFilenameList = new ArrayList<String>(msasList.size());\r |
250258de | 306 | Iterator msasIter = msasList.iterator();\r |
307 | while (msasIter.hasNext()) {\r | |
308 | MsaFilesDocument.MsaFiles.MsaFile msaFile = (MsaFilesDocument.MsaFiles.MsaFile)msasIter.next();\r | |
20391ab0 | 309 | msaFilenameList.add(msaFile.getFilename().getStringValue());\r |
250258de | 310 | }\r |
311 | }\r | |
312 | \r | |
313 | Iterator msaFilenameIter = msaFilenameList.iterator();\r | |
314 | while (msaFilenameIter.hasNext()) {\r | |
20391ab0 | 315 | String filename = (String)msaFilenameIter.next();\r |
878ddf1f | 316 | File msaFile = new File(workspaceDir + File.separatorChar + GlobalData.getPackagePath(packageName)\r |
250258de | 317 | + File.separatorChar + filename);\r |
878ddf1f | 318 | SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r |
319 | Map<String, XmlObject> map = surfaceAreaParser.parseFile(msaFile);\r | |
320 | String baseName = "";\r | |
321 | XmlObject header = null;\r | |
322 | if ((header = map.get("MsaHeader")) != null) {\r | |
250258de | 323 | if (((MsaHeader) header).isSetBaseName()) {\r |
324 | baseName = ((MsaHeader) header).getBaseName().getStringValue();\r | |
325 | } else {\r | |
326 | baseName = ((MsaHeader) header).getModuleName();\r | |
327 | }\r | |
878ddf1f | 328 | } else if ((header = map.get("MsaLibHeader")) != null) {\r |
329 | baseName = ((MsaLibHeader) header).getBaseName().getStringValue();\r | |
330 | } else {\r | |
331 | continue;\r | |
332 | }\r | |
333 | nativeMsa.put(baseName, map);\r | |
250258de | 334 | String[] info = { filename, packageName };\r |
878ddf1f | 335 | moduleInfo.put(baseName, info);\r |
336 | }\r | |
337 | } catch (Exception e) {\r | |
338 | throw new BuildException("Parse package description file [" + packageFile.getPath() + "] Error.\n"\r | |
339 | + e.getMessage());\r | |
340 | }\r | |
341 | }\r | |
342 | \r | |
343 | /**\r | |
344 | Query the libraries which the module depends on.\r | |
345 | \r | |
346 | @param moduleName the base name of the module\r | |
347 | @return the libraries which the module depends on\r | |
348 | **/\r | |
61746a87 | 349 | public synchronized static String[] getModuleLibrary(String moduleName, String arch) {\r |
350 | Set<String> set = moduleLibraryMap.get(moduleName + "-" + arch);\r | |
878ddf1f | 351 | return set.toArray(new String[set.size()]);\r |
352 | }\r | |
353 | \r | |
354 | /**\r | |
355 | Register module's library list which it depends on for later use. \r | |
356 | \r | |
357 | @param moduleName the base name of the module\r | |
358 | @param libraryList the libraries which the module depends on\r | |
359 | **/\r | |
61746a87 | 360 | public synchronized static void addModuleLibrary(String moduleName, String arch, Set<String> libraryList) {\r |
361 | moduleLibraryMap.put(moduleName + "-" + arch, libraryList);\r | |
878ddf1f | 362 | }\r |
363 | \r | |
364 | /**\r | |
365 | Query the library absolute file name with library name. \r | |
366 | \r | |
367 | @param library the base name of the library\r | |
368 | @return the library absolute file name\r | |
369 | **/\r | |
61746a87 | 370 | public synchronized static String getLibrary(String library, String arch) {\r |
371 | return libraries.get(library + "-" + arch);\r | |
878ddf1f | 372 | }\r |
373 | \r | |
374 | /**\r | |
375 | Register library absolute file name for later use.\r | |
376 | \r | |
377 | @param library the base name of the library\r | |
378 | @param resultPath the library absolute file name\r | |
379 | **/\r | |
61746a87 | 380 | public synchronized static void addLibrary(String library, String arch, String resultPath) {\r |
381 | libraries.put(library + "-" + arch, resultPath);\r | |
878ddf1f | 382 | }\r |
383 | \r | |
384 | /**\r | |
385 | Whether the module with ARCH has built in the previous build. \r | |
386 | \r | |
387 | @param moduleName the base name of the module\r | |
388 | @param arch current build ARCH\r | |
389 | @return true if the module has built in previous, otherwise return false\r | |
390 | **/\r | |
391 | public synchronized static boolean isModuleBuilt(String moduleName, String arch) {\r | |
392 | return builtModules.contains(moduleName + "-" + arch);\r | |
393 | }\r | |
394 | \r | |
395 | /**\r | |
396 | Register the module with ARCH has built. \r | |
397 | \r | |
398 | @param moduleName the base name of the module\r | |
399 | @param arch current build ARCH\r | |
400 | **/\r | |
401 | public synchronized static void registerBuiltModule(String moduleName, String arch) {\r | |
402 | builtModules.add(moduleName + "-" + arch);\r | |
403 | }\r | |
404 | \r | |
405 | /**\r | |
406 | Whether the module's surface area has parsed in the previous build.\r | |
407 | \r | |
408 | @param moduleName the base name of the module\r | |
409 | @return true if the module's surface area has parsed in previous, otherwise\r | |
410 | return false\r | |
411 | **/\r | |
412 | public synchronized static boolean isModuleParsed(String moduleName) {\r | |
413 | return parsedModules.containsKey(moduleName);\r | |
414 | }\r | |
415 | \r | |
416 | /**\r | |
417 | Query overrided module surface area information. If current is Package\r | |
418 | or Platform build, also include the information from FPD file. \r | |
419 | \r | |
420 | <p>Note that surface area parsing is incremental. That means the method will \r | |
421 | only to parse the MSA and MBD files when never parsed before. </p>\r | |
422 | \r | |
423 | @param moduleName the base name of the module\r | |
424 | @return the overrided module surface area information\r | |
425 | @throws BuildException\r | |
426 | MSA or MBD is not valid\r | |
427 | **/\r | |
428 | public synchronized static Map<String, XmlObject> getDoc(String moduleName) throws BuildException {\r | |
429 | if (parsedModules.containsKey(moduleName)) {\r | |
430 | return parsedModules.get(moduleName);\r | |
431 | }\r | |
432 | Map<String, XmlObject> msaMap = getNativeMsa(moduleName);\r | |
433 | Map<String, XmlObject> mbdMap = getNativeMbd(moduleName);\r | |
434 | OverrideProcess op = new OverrideProcess();\r | |
435 | Map<String, XmlObject> map = op.override(mbdMap, msaMap);\r | |
436 | //\r | |
437 | // IF IT IS A PALTFORM BUILD, OVERRIDE FROM PLATFORM\r | |
438 | //\r | |
439 | if (FpdParserTask.platformBuildOptions != null) {\r | |
440 | Map<String, XmlObject> platformMap = new HashMap<String, XmlObject>();\r | |
441 | platformMap.put("BuildOptions", FpdParserTask.platformBuildOptions);\r | |
442 | Map<String, XmlObject> overrideMap = op.override(platformMap, OverrideProcess.deal(map));\r | |
443 | GlobalData.registerModule(moduleName, overrideMap);\r | |
444 | return overrideMap;\r | |
445 | } else {\r | |
446 | parsedModules.put(moduleName, map);\r | |
447 | return map;\r | |
448 | }\r | |
449 | }\r | |
450 | \r | |
451 | /**\r | |
452 | Query the native MSA information with module base name. \r | |
453 | \r | |
454 | <p>Note that MSA parsing is incremental. That means the method will \r | |
455 | only to parse the MSA files when never parsed before. </p>\r | |
456 | \r | |
457 | @param moduleName the base name of the module\r | |
458 | @return the native MSA information\r | |
459 | @throws BuildException\r | |
460 | MSA file is not valid\r | |
461 | **/\r | |
462 | public synchronized static Map<String, XmlObject> getNativeMsa(String moduleName) throws BuildException {\r | |
463 | if (nativeMsa.containsKey(moduleName)) {\r | |
464 | return nativeMsa.get(moduleName);\r | |
465 | }\r | |
466 | String msaFilename = getMsaFilename(moduleName);\r | |
467 | File msaFile = new File(msaFilename);\r | |
468 | if (!msaFile.exists()) {\r | |
469 | throw new BuildException("Info: Surface Area file [" + msaFile.getPath() + "] can't found.");\r | |
470 | }\r | |
471 | SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r | |
472 | Map<String, XmlObject> map = surfaceAreaParser.parseFile(msaFile);\r | |
473 | nativeMsa.put(moduleName, map);\r | |
474 | return map;\r | |
475 | }\r | |
476 | \r | |
477 | /**\r | |
478 | Query the native MBD information with module base name. \r | |
479 | \r | |
480 | <p>Note that MBD parsing is incremental. That means the method will \r | |
481 | only to parse the MBD files when never parsed before. </p>\r | |
482 | \r | |
483 | @param moduleName the base name of the module\r | |
484 | @return the native MBD information\r | |
485 | @throws BuildException\r | |
486 | MBD file is not valid\r | |
487 | **/\r | |
488 | public synchronized static Map<String, XmlObject> getNativeMbd(String moduleName) throws BuildException {\r | |
489 | if (nativeMbd.containsKey(moduleName)) {\r | |
490 | return nativeMbd.get(moduleName);\r | |
491 | }\r | |
492 | String mbdFilename = getMbdFilename(moduleName);\r | |
493 | File mbdFile = new File(mbdFilename);\r | |
494 | if (!mbdFile.exists()) {\r | |
250258de | 495 | return null;\r |
496 | //throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found.");\r | |
878ddf1f | 497 | }\r |
498 | SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r | |
499 | Map<String, XmlObject> map = surfaceAreaParser.parseFile(mbdFile);\r | |
500 | nativeMbd.put(moduleName, map);\r | |
501 | return map;\r | |
502 | }\r | |
503 | \r | |
504 | /**\r | |
505 | Register module overrided surface area information. If has existed, then update.\r | |
506 | \r | |
507 | @param moduleName the base name of the module\r | |
508 | @param map the overrided surface area information\r | |
509 | **/\r | |
510 | public synchronized static void registerModule(String moduleName, Map<String, XmlObject> map) {\r | |
511 | parsedModules.put(moduleName, map);\r | |
512 | }\r | |
513 | \r | |
514 | /**\r | |
515 | * \r | |
516 | * @param protocolName\r | |
517 | * @return\r | |
518 | */\r | |
519 | public synchronized static String[] getProtocolInfoGuid(String protocolName) {\r | |
520 | Set set = spdTable.keySet();\r | |
521 | Iterator iter = set.iterator();\r | |
522 | String[] cNameGuid = null;\r | |
523 | \r | |
524 | while (iter.hasNext()) {\r | |
525 | Spd spd = (Spd) spdTable.get(iter.next());\r | |
526 | cNameGuid = spd.getProtocolNameGuidArray(protocolName);\r | |
527 | if (cNameGuid != null) {\r | |
528 | break;\r | |
529 | }\r | |
530 | }\r | |
531 | return cNameGuid;\r | |
532 | }\r | |
533 | \r | |
534 | public synchronized static String[] getPpiInfoGuid(String ppiName) {\r | |
535 | Set set = spdTable.keySet();\r | |
536 | Iterator iter = set.iterator();\r | |
537 | String[] cNameGuid = null;\r | |
538 | \r | |
539 | while (iter.hasNext()) {\r | |
540 | Spd spd = (Spd) spdTable.get(iter.next());\r | |
541 | cNameGuid = spd.getPpiCnameGuidArray(ppiName);\r | |
542 | \r | |
543 | if (cNameGuid != null) {\r | |
544 | break;\r | |
545 | }\r | |
546 | }\r | |
547 | return cNameGuid;\r | |
548 | }\r | |
549 | \r | |
550 | /**\r | |
551 | * \r | |
552 | * @param guidName\r | |
553 | * @return\r | |
554 | */\r | |
555 | public synchronized static String[] getGuidInfoGuid(String guidName) {\r | |
556 | String[] cNameGuid = null;\r | |
557 | Set set = spdTable.keySet();\r | |
558 | Iterator iter = set.iterator();\r | |
559 | \r | |
560 | while (iter.hasNext()) {\r | |
561 | Spd spd = (Spd) spdTable.get(iter.next());\r | |
562 | cNameGuid = spd.getGuidNameArray(guidName);\r | |
563 | if (cNameGuid != null) {\r | |
564 | break;\r | |
565 | }\r | |
566 | }\r | |
567 | return cNameGuid;\r | |
568 | }\r | |
569 | \r | |
570 | public synchronized static String getLibClassIncluder(String libName) {\r | |
571 | String libIncluder = null;\r | |
572 | Set set = spdTable.keySet();\r | |
573 | Iterator iter = set.iterator();\r | |
574 | \r | |
575 | while (iter.hasNext()) {\r | |
576 | String packageName = (String) iter.next();\r | |
577 | Spd spd = (Spd) spdTable.get(packageName);\r | |
578 | libIncluder = spd.getLibClassIncluder(libName);\r | |
579 | String packagePath = spd.packagePath;\r | |
580 | if (packagePath != null) {\r | |
581 | packagePath = packagePath.replace('\\', File.separatorChar);\r | |
582 | packagePath = packagePath.replace('/', File.separatorChar);\r | |
583 | } else {\r | |
584 | packagePath = packageName;\r | |
585 | }\r | |
586 | if (libIncluder != null) {\r | |
587 | libIncluder = libIncluder.replace('\\', File.separatorChar);\r | |
588 | libIncluder = libIncluder.replace('/', File.separatorChar);\r | |
589 | libIncluder = packageName + File.separatorChar + libIncluder;\r | |
590 | break;\r | |
591 | }\r | |
592 | }\r | |
593 | return libIncluder;\r | |
594 | }\r | |
595 | \r | |
596 | public synchronized static String getModuleInfoByPackageName(String packageName, String moduleType) {\r | |
597 | Spd spd;\r | |
598 | String includeFile = null;\r | |
599 | String includeStr = "";\r | |
600 | String cleanPath = "";\r | |
601 | \r | |
602 | spd = (Spd) spdTable.get(packageName);\r | |
603 | includeFile = spd.getModuleTypeIncluder(moduleType);\r | |
604 | if (includeFile != null) {\r | |
605 | includeFile = includeFile.replace('\\', File.separatorChar);\r | |
606 | includeFile = includeFile.replace('/', File.separatorChar);\r | |
607 | includeStr = CommonDefinition.include + " <" + includeStr;\r | |
608 | cleanPath = spd.packagePath;\r | |
609 | cleanPath = cleanPath.replace('\\', File.separatorChar);\r | |
610 | cleanPath = cleanPath.replace('/', File.separatorChar);\r | |
611 | \r | |
612 | if (cleanPath.charAt(spd.packagePath.length() - 1) != File.separatorChar) {\r | |
613 | cleanPath = cleanPath + File.separatorChar;\r | |
614 | }\r | |
615 | includeStr = includeStr + cleanPath;\r | |
616 | includeStr = includeStr + includeFile;\r | |
617 | includeStr = includeStr + ">\r\n";\r | |
618 | }\r | |
619 | \r | |
620 | return includeStr;\r | |
621 | }\r | |
622 | \r | |
623 | public synchronized static void setLibInstanceInfo(String libName, String libConstructor, String libDesturctor) {\r | |
624 | String[] libConsDes = new String[2];\r | |
625 | libConsDes[0] = libConstructor;\r | |
626 | libConsDes[1] = libDesturctor;\r | |
627 | \r | |
628 | libInstanceInfo.put(libName, libConsDes);\r | |
629 | }\r | |
630 | \r | |
631 | public synchronized static boolean isHaveLibInstance(String libName) {\r | |
632 | return libInstanceInfo.containsKey(libName);\r | |
633 | }\r | |
634 | \r | |
635 | public synchronized static String getLibInstanceConstructor(String libName) {\r | |
636 | String[] libInstanceValue;\r | |
637 | libInstanceValue = libInstanceInfo.get(libName);\r | |
638 | if (libInstanceValue != null) {\r | |
639 | return libInstanceValue[0];\r | |
640 | } else {\r | |
641 | return null;\r | |
642 | }\r | |
643 | }\r | |
644 | \r | |
645 | public synchronized static String getLibInstanceDestructor(String libName) {\r | |
646 | String[] libInstanceValue;\r | |
647 | libInstanceValue = libInstanceInfo.get(libName);\r | |
648 | if (libInstanceValue != null) {\r | |
649 | return libInstanceValue[1];\r | |
650 | } else {\r | |
651 | return null;\r | |
652 | }\r | |
653 | }\r | |
654 | \r | |
655 | public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {\r | |
656 | return pcdDbManager;\r | |
657 | }\r | |
658 | }\r |