]>
Commit | Line | Data |
---|---|---|
1 | /** @file\r | |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation\r | |
4 | All rights reserved. This program and the accompanying materials\r | |
5 | are licensed and made available under the terms and conditions of the BSD License\r | |
6 | which accompanies this distribution. The full text of the license may be found at\r | |
7 | http://opensource.org/licenses/bsd-license.php\r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
11 | \r | |
12 | **/\r | |
13 | package org.tianocore.migration;\r | |
14 | \r | |
15 | import java.io.*;\r | |
16 | import java.util.*;\r | |
17 | \r | |
18 | import org.tianocore.UsageTypes;\r | |
19 | \r | |
20 | /*\r | |
21 | Class ModuleInfo is built for scanning the source files, it contains all the needed\r | |
22 | information and all the temporary data.\r | |
23 | */\r | |
24 | public final class ModuleInfo {\r | |
25 | ModuleInfo(String modulepath) throws Exception {\r | |
26 | this.modulepath = modulepath;\r | |
27 | this.temppath = MigrationTool.getTempDir(this.modulepath);\r | |
28 | }\r | |
29 | \r | |
30 | public final String modulepath;\r | |
31 | public final String temppath;\r | |
32 | \r | |
33 | private MsaOwner msaowner = MsaOwner.initNewMsaOwner();\r | |
34 | \r | |
35 | public String modulename = null;\r | |
36 | public String guidvalue = null;\r | |
37 | public String moduletype = null;\r | |
38 | public String entrypoint = null;\r | |
39 | \r | |
40 | public final Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h\r | |
41 | public final Set<String> preprocessedccodes = new HashSet<String>();\r | |
42 | public final Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this\r | |
43 | public final Set<String> infincludes = new HashSet<String>();\r | |
44 | public final Set<String> infsources = new HashSet<String>();\r | |
45 | \r | |
46 | public final Set<String> hashfuncc = new HashSet<String>();\r | |
47 | public final Set<String> hashfuncd = new HashSet<String>();\r | |
48 | public final Set<String> hashnonlocalfunc = new HashSet<String>();\r | |
49 | public final Set<String> hashnonlocalmacro = new HashSet<String>();\r | |
50 | public final Set<String> hashEFIcall = new HashSet<String>();\r | |
51 | public final Set<String> hashr8only = new HashSet<String>();\r | |
52 | public final Set<String> hashmacro = new HashSet<String>();\r | |
53 | \r | |
54 | public final Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer \r | |
55 | public final Set<String> guids = new HashSet<String>();\r | |
56 | public final Set<String> protocols = new HashSet<String>();\r | |
57 | public final Set<String> ppis = new HashSet<String>();\r | |
58 | \r | |
59 | //-----------------------------------------------------------------------------------//\r | |
60 | \r | |
61 | public final boolean addProtocol (String proname, UsageTypes.Enum usage) {\r | |
62 | //protocols.add(proname);\r | |
63 | return msaowner.addProtocol(proname, usage);\r | |
64 | }\r | |
65 | \r | |
66 | public final boolean addPpi (String ppiname, UsageTypes.Enum usage) {\r | |
67 | //ppis.add(ppiname);\r | |
68 | return msaowner.addPpi(ppiname, usage);\r | |
69 | }\r | |
70 | \r | |
71 | public final boolean addGuid (String guidname, UsageTypes.Enum usage) {\r | |
72 | //guids.add(guidname);\r | |
73 | return msaowner.addGuid(guidname, usage);\r | |
74 | }\r | |
75 | \r | |
76 | public final boolean addLibraryClass(String name, UsageTypes.Enum usage) {\r | |
77 | //hashrequiredr9libs.add(name);\r | |
78 | return msaowner.addLibraryClass(name, usage);\r | |
79 | }\r | |
80 | \r | |
81 | //-----------------------------------------------------------------------------------//\r | |
82 | \r | |
83 | public final String getModuleType() {\r | |
84 | if (moduletype.contains("PEI")) {\r | |
85 | return "PEIM";\r | |
86 | } else {\r | |
87 | return "DXE_DRIVER";\r | |
88 | }\r | |
89 | }\r | |
90 | \r | |
91 | public final void enroll(String filepath) throws Exception {\r | |
92 | String temp = null;\r | |
93 | if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || \r | |
94 | filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni")) {\r | |
95 | localmodulesources.add(filepath.replace(modulepath + File.separator, ""));\r | |
96 | } else if (filepath.contains(".inf") || filepath.contains(".msa")) {\r | |
97 | temp = filepath.replace(modulepath + File.separator, "");\r | |
98 | if (!temp.contains(File.separator)) { // .inf in subdirectory is not regarded\r | |
99 | msaorinf.add(temp);\r | |
100 | }\r | |
101 | }\r | |
102 | }\r | |
103 | \r | |
104 | public static final boolean isModule(String path) {\r | |
105 | String[] list = new File(path).list();\r | |
106 | for (int i = 0 ; i < list.length ; i++) {\r | |
107 | if (!new File(list[i]).isDirectory()) {\r | |
108 | if (list[i].contains(".inf") || list[i].contains(".msa")) {\r | |
109 | return true;\r | |
110 | }\r | |
111 | }\r | |
112 | }\r | |
113 | return false;\r | |
114 | }\r | |
115 | \r | |
116 | public final MsaOwner getMsaOwner() {\r | |
117 | return msaowner;\r | |
118 | }\r | |
119 | } |