]> git.proxmox.com Git - mirror_edk2.git/blame - Tools/Source/GenBuild/org/tianocore/build/global/GlobalData.java
added the support for new schema and old schema at the same time
[mirror_edk2.git] / Tools / Source / GenBuild / org / tianocore / build / global / GlobalData.java
CommitLineData
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
8Copyright (c) 2006, Intel Corporation\r
9All rights reserved. This program and the accompanying materials\r
10are licensed and made available under the terms and conditions of the BSD License\r
11which accompanies this distribution. The full text of the license may be found at\r
12http://opensource.org/licenses/bsd-license.php\r
13\r
14THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
15WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
16**/\r
17package org.tianocore.build.global;\r
18\r
19import java.io.File;\r
250258de 20import java.util.ArrayList;\r
878ddf1f 21import java.util.HashMap;\r
22import java.util.HashSet;\r
23import java.util.Iterator;\r
24import java.util.List;\r
25import java.util.Map;\r
26import java.util.Set;\r
27\r
28import org.apache.tools.ant.BuildException;\r
29import org.apache.xmlbeans.XmlObject;\r
250258de 30import org.tianocore.FilenameDocument;\r
31import org.tianocore.FilenameDocument.Filename;\r
878ddf1f 32import org.tianocore.FrameworkDatabaseDocument;\r
33import org.tianocore.MsaFilesDocument;\r
250258de 34import org.tianocore.MsaFilesDocument.MsaFiles.MsaFile;\r
878ddf1f 35import org.tianocore.MsaHeaderDocument.MsaHeader;\r
36import org.tianocore.MsaLibHeaderDocument.MsaLibHeader;\r
250258de 37import org.tianocore.PackageListDocument;\r
38import org.tianocore.PackageSurfaceAreaDocument;\r
878ddf1f 39import org.tianocore.build.autogen.CommonDefinition;\r
40import org.tianocore.build.fpd.FpdParserTask;\r
250258de 41import 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
53public 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
250258de 298 List<FilenameDocument.Filename> msaFilenameList;\r
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
305 msaFilenameList = new ArrayList<FilenameDocument.Filename>(msasList.size());\r
306 Iterator msasIter = msasList.iterator();\r
307 while (msasIter.hasNext()) {\r
308 MsaFilesDocument.MsaFiles.MsaFile msaFile = (MsaFilesDocument.MsaFiles.MsaFile)msasIter.next();\r
309 msaFilenameList.add(msaFile.getFilename());\r
310 }\r
311 }\r
312\r
313 Iterator msaFilenameIter = msaFilenameList.iterator();\r
314 while (msaFilenameIter.hasNext()) {\r
315 FilenameDocument.Filename msaFilename = (FilenameDocument.Filename)msaFilenameIter.next();\r
316 String filename = msaFilename.getStringValue();\r
878ddf1f 317 File msaFile = new File(workspaceDir + File.separatorChar + GlobalData.getPackagePath(packageName)\r
250258de 318 + File.separatorChar + filename);\r
878ddf1f 319 SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r
320 Map<String, XmlObject> map = surfaceAreaParser.parseFile(msaFile);\r
321 String baseName = "";\r
322 XmlObject header = null;\r
323 if ((header = map.get("MsaHeader")) != null) {\r
250258de 324 if (((MsaHeader) header).isSetBaseName()) {\r
325 baseName = ((MsaHeader) header).getBaseName().getStringValue();\r
326 } else {\r
327 baseName = ((MsaHeader) header).getModuleName();\r
328 }\r
878ddf1f 329 } else if ((header = map.get("MsaLibHeader")) != null) {\r
330 baseName = ((MsaLibHeader) header).getBaseName().getStringValue();\r
331 } else {\r
332 continue;\r
333 }\r
334 nativeMsa.put(baseName, map);\r
250258de 335 String[] info = { filename, packageName };\r
878ddf1f 336 moduleInfo.put(baseName, info);\r
337 }\r
338 } catch (Exception e) {\r
339 throw new BuildException("Parse package description file [" + packageFile.getPath() + "] Error.\n"\r
340 + e.getMessage());\r
341 }\r
342 }\r
343\r
344 /**\r
345 Query the libraries which the module depends on.\r
346 \r
347 @param moduleName the base name of the module\r
348 @return the libraries which the module depends on\r
349 **/\r
61746a87 350 public synchronized static String[] getModuleLibrary(String moduleName, String arch) {\r
351 Set<String> set = moduleLibraryMap.get(moduleName + "-" + arch);\r
878ddf1f 352 return set.toArray(new String[set.size()]);\r
353 }\r
354\r
355 /**\r
356 Register module's library list which it depends on for later use. \r
357 \r
358 @param moduleName the base name of the module\r
359 @param libraryList the libraries which the module depends on\r
360 **/\r
61746a87 361 public synchronized static void addModuleLibrary(String moduleName, String arch, Set<String> libraryList) {\r
362 moduleLibraryMap.put(moduleName + "-" + arch, libraryList);\r
878ddf1f 363 }\r
364\r
365 /**\r
366 Query the library absolute file name with library name. \r
367 \r
368 @param library the base name of the library\r
369 @return the library absolute file name\r
370 **/\r
61746a87 371 public synchronized static String getLibrary(String library, String arch) {\r
372 return libraries.get(library + "-" + arch);\r
878ddf1f 373 }\r
374\r
375 /**\r
376 Register library absolute file name for later use.\r
377 \r
378 @param library the base name of the library\r
379 @param resultPath the library absolute file name\r
380 **/\r
61746a87 381 public synchronized static void addLibrary(String library, String arch, String resultPath) {\r
382 libraries.put(library + "-" + arch, resultPath);\r
878ddf1f 383 }\r
384\r
385 /**\r
386 Whether the module with ARCH has built in the previous build. \r
387 \r
388 @param moduleName the base name of the module\r
389 @param arch current build ARCH\r
390 @return true if the module has built in previous, otherwise return false\r
391 **/\r
392 public synchronized static boolean isModuleBuilt(String moduleName, String arch) {\r
393 return builtModules.contains(moduleName + "-" + arch);\r
394 }\r
395\r
396 /**\r
397 Register the module with ARCH has built. \r
398 \r
399 @param moduleName the base name of the module\r
400 @param arch current build ARCH\r
401 **/\r
402 public synchronized static void registerBuiltModule(String moduleName, String arch) {\r
403 builtModules.add(moduleName + "-" + arch);\r
404 }\r
405\r
406 /**\r
407 Whether the module's surface area has parsed in the previous build.\r
408 \r
409 @param moduleName the base name of the module\r
410 @return true if the module's surface area has parsed in previous, otherwise\r
411 return false\r
412 **/\r
413 public synchronized static boolean isModuleParsed(String moduleName) {\r
414 return parsedModules.containsKey(moduleName);\r
415 }\r
416\r
417 /**\r
418 Query overrided module surface area information. If current is Package\r
419 or Platform build, also include the information from FPD file. \r
420 \r
421 <p>Note that surface area parsing is incremental. That means the method will \r
422 only to parse the MSA and MBD files when never parsed before. </p>\r
423 \r
424 @param moduleName the base name of the module\r
425 @return the overrided module surface area information\r
426 @throws BuildException\r
427 MSA or MBD is not valid\r
428 **/\r
429 public synchronized static Map<String, XmlObject> getDoc(String moduleName) throws BuildException {\r
430 if (parsedModules.containsKey(moduleName)) {\r
431 return parsedModules.get(moduleName);\r
432 }\r
433 Map<String, XmlObject> msaMap = getNativeMsa(moduleName);\r
434 Map<String, XmlObject> mbdMap = getNativeMbd(moduleName);\r
435 OverrideProcess op = new OverrideProcess();\r
436 Map<String, XmlObject> map = op.override(mbdMap, msaMap);\r
437 //\r
438 // IF IT IS A PALTFORM BUILD, OVERRIDE FROM PLATFORM\r
439 //\r
440 if (FpdParserTask.platformBuildOptions != null) {\r
441 Map<String, XmlObject> platformMap = new HashMap<String, XmlObject>();\r
442 platformMap.put("BuildOptions", FpdParserTask.platformBuildOptions);\r
443 Map<String, XmlObject> overrideMap = op.override(platformMap, OverrideProcess.deal(map));\r
444 GlobalData.registerModule(moduleName, overrideMap);\r
445 return overrideMap;\r
446 } else {\r
447 parsedModules.put(moduleName, map);\r
448 return map;\r
449 }\r
450 }\r
451\r
452 /**\r
453 Query the native MSA information with module base name. \r
454 \r
455 <p>Note that MSA parsing is incremental. That means the method will \r
456 only to parse the MSA files when never parsed before. </p>\r
457 \r
458 @param moduleName the base name of the module\r
459 @return the native MSA information\r
460 @throws BuildException\r
461 MSA file is not valid\r
462 **/\r
463 public synchronized static Map<String, XmlObject> getNativeMsa(String moduleName) throws BuildException {\r
464 if (nativeMsa.containsKey(moduleName)) {\r
465 return nativeMsa.get(moduleName);\r
466 }\r
467 String msaFilename = getMsaFilename(moduleName);\r
468 File msaFile = new File(msaFilename);\r
469 if (!msaFile.exists()) {\r
470 throw new BuildException("Info: Surface Area file [" + msaFile.getPath() + "] can't found.");\r
471 }\r
472 SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r
473 Map<String, XmlObject> map = surfaceAreaParser.parseFile(msaFile);\r
474 nativeMsa.put(moduleName, map);\r
475 return map;\r
476 }\r
477 \r
478 /**\r
479 Query the native MBD information with module base name. \r
480 \r
481 <p>Note that MBD parsing is incremental. That means the method will \r
482 only to parse the MBD files when never parsed before. </p>\r
483 \r
484 @param moduleName the base name of the module\r
485 @return the native MBD information\r
486 @throws BuildException\r
487 MBD file is not valid\r
488 **/\r
489 public synchronized static Map<String, XmlObject> getNativeMbd(String moduleName) throws BuildException {\r
490 if (nativeMbd.containsKey(moduleName)) {\r
491 return nativeMbd.get(moduleName);\r
492 }\r
493 String mbdFilename = getMbdFilename(moduleName);\r
494 File mbdFile = new File(mbdFilename);\r
495 if (!mbdFile.exists()) {\r
250258de 496 return null;\r
497 //throw new BuildException("Info: Surface Area file [" + mbdFile.getPath() + "] can't found.");\r
878ddf1f 498 }\r
499 SurfaceAreaParser surfaceAreaParser = new SurfaceAreaParser();\r
500 Map<String, XmlObject> map = surfaceAreaParser.parseFile(mbdFile);\r
501 nativeMbd.put(moduleName, map);\r
502 return map;\r
503 }\r
504\r
505 /**\r
506 Register module overrided surface area information. If has existed, then update.\r
507 \r
508 @param moduleName the base name of the module\r
509 @param map the overrided surface area information\r
510 **/\r
511 public synchronized static void registerModule(String moduleName, Map<String, XmlObject> map) {\r
512 parsedModules.put(moduleName, map);\r
513 }\r
514\r
515 /**\r
516 * \r
517 * @param protocolName\r
518 * @return\r
519 */\r
520 public synchronized static String[] getProtocolInfoGuid(String protocolName) {\r
521 Set set = spdTable.keySet();\r
522 Iterator iter = set.iterator();\r
523 String[] cNameGuid = null;\r
524\r
525 while (iter.hasNext()) {\r
526 Spd spd = (Spd) spdTable.get(iter.next());\r
527 cNameGuid = spd.getProtocolNameGuidArray(protocolName);\r
528 if (cNameGuid != null) {\r
529 break;\r
530 }\r
531 }\r
532 return cNameGuid;\r
533 }\r
534\r
535 public synchronized static String[] getPpiInfoGuid(String ppiName) {\r
536 Set set = spdTable.keySet();\r
537 Iterator iter = set.iterator();\r
538 String[] cNameGuid = null;\r
539\r
540 while (iter.hasNext()) {\r
541 Spd spd = (Spd) spdTable.get(iter.next());\r
542 cNameGuid = spd.getPpiCnameGuidArray(ppiName);\r
543\r
544 if (cNameGuid != null) {\r
545 break;\r
546 }\r
547 }\r
548 return cNameGuid;\r
549 }\r
550\r
551 /**\r
552 * \r
553 * @param guidName\r
554 * @return\r
555 */\r
556 public synchronized static String[] getGuidInfoGuid(String guidName) {\r
557 String[] cNameGuid = null;\r
558 Set set = spdTable.keySet();\r
559 Iterator iter = set.iterator();\r
560\r
561 while (iter.hasNext()) {\r
562 Spd spd = (Spd) spdTable.get(iter.next());\r
563 cNameGuid = spd.getGuidNameArray(guidName);\r
564 if (cNameGuid != null) {\r
565 break;\r
566 }\r
567 }\r
568 return cNameGuid;\r
569 }\r
570\r
571 public synchronized static String getLibClassIncluder(String libName) {\r
572 String libIncluder = null;\r
573 Set set = spdTable.keySet();\r
574 Iterator iter = set.iterator();\r
575\r
576 while (iter.hasNext()) {\r
577 String packageName = (String) iter.next();\r
578 Spd spd = (Spd) spdTable.get(packageName);\r
579 libIncluder = spd.getLibClassIncluder(libName);\r
580 String packagePath = spd.packagePath;\r
581 if (packagePath != null) {\r
582 packagePath = packagePath.replace('\\', File.separatorChar);\r
583 packagePath = packagePath.replace('/', File.separatorChar);\r
584 } else {\r
585 packagePath = packageName;\r
586 }\r
587 if (libIncluder != null) {\r
588 libIncluder = libIncluder.replace('\\', File.separatorChar);\r
589 libIncluder = libIncluder.replace('/', File.separatorChar);\r
590 libIncluder = packageName + File.separatorChar + libIncluder;\r
591 break;\r
592 }\r
593 }\r
594 return libIncluder;\r
595 }\r
596\r
597 public synchronized static String getModuleInfoByPackageName(String packageName, String moduleType) {\r
598 Spd spd;\r
599 String includeFile = null;\r
600 String includeStr = "";\r
601 String cleanPath = "";\r
602\r
603 spd = (Spd) spdTable.get(packageName);\r
604 includeFile = spd.getModuleTypeIncluder(moduleType);\r
605 if (includeFile != null) {\r
606 includeFile = includeFile.replace('\\', File.separatorChar);\r
607 includeFile = includeFile.replace('/', File.separatorChar);\r
608 includeStr = CommonDefinition.include + " <" + includeStr;\r
609 cleanPath = spd.packagePath;\r
610 cleanPath = cleanPath.replace('\\', File.separatorChar);\r
611 cleanPath = cleanPath.replace('/', File.separatorChar);\r
612\r
613 if (cleanPath.charAt(spd.packagePath.length() - 1) != File.separatorChar) {\r
614 cleanPath = cleanPath + File.separatorChar;\r
615 }\r
616 includeStr = includeStr + cleanPath;\r
617 includeStr = includeStr + includeFile;\r
618 includeStr = includeStr + ">\r\n";\r
619 }\r
620\r
621 return includeStr;\r
622 }\r
623\r
624 public synchronized static void setLibInstanceInfo(String libName, String libConstructor, String libDesturctor) {\r
625 String[] libConsDes = new String[2];\r
626 libConsDes[0] = libConstructor;\r
627 libConsDes[1] = libDesturctor;\r
628\r
629 libInstanceInfo.put(libName, libConsDes);\r
630 }\r
631\r
632 public synchronized static boolean isHaveLibInstance(String libName) {\r
633 return libInstanceInfo.containsKey(libName);\r
634 }\r
635\r
636 public synchronized static String getLibInstanceConstructor(String libName) {\r
637 String[] libInstanceValue;\r
638 libInstanceValue = libInstanceInfo.get(libName);\r
639 if (libInstanceValue != null) {\r
640 return libInstanceValue[0];\r
641 } else {\r
642 return null;\r
643 }\r
644 }\r
645\r
646 public synchronized static String getLibInstanceDestructor(String libName) {\r
647 String[] libInstanceValue;\r
648 libInstanceValue = libInstanceInfo.get(libName);\r
649 if (libInstanceValue != null) {\r
650 return libInstanceValue[1];\r
651 } else {\r
652 return null;\r
653 }\r
654 }\r
655\r
656 public synchronized static MemoryDatabaseManager getPCDMemoryDBManager() {\r
657 return pcdDbManager;\r
658 }\r
659}\r