]>
Commit | Line | Data |
---|---|---|
b0282412 | 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 | |
0dc8c589 | 13 | package org.tianocore.migration;\r |
14 | \r | |
15 | import java.io.*;\r | |
16 | import java.util.*;\r | |
0dc8c589 | 17 | \r |
323e2ffc | 18 | import org.tianocore.UsageTypes;\r |
8270b34d | 19 | import org.tianocore.SupportedArchitectures.Enum;\r |
323e2ffc | 20 | \r |
0dc8c589 | 21 | /*\r |
27e0221a | 22 | Class ModuleInfo is built for scanning the source files, it contains all the needed\r |
0dc8c589 | 23 | information and all the temporary data.\r |
24 | */\r | |
1eac75f9 | 25 | public final class ModuleInfo {\r |
27e0221a | 26 | ModuleInfo(String modulepath) throws Exception {\r |
27 | this.modulepath = modulepath;\r | |
df87de9b | 28 | this.temppath = MigrationTool.getTempDir(this.modulepath);\r |
27e0221a | 29 | }\r |
5ea254f6 | 30 | \r |
27e0221a | 31 | public final String modulepath;\r |
df87de9b | 32 | public final String temppath;\r |
27e0221a | 33 | \r |
1ea59929 | 34 | private MsaOwner msaowner = MsaOwner.initNewMsaOwner();\r |
6ef5feb5 | 35 | \r |
27e0221a | 36 | public String modulename = null;\r |
37 | public String guidvalue = null;\r | |
38 | public String moduletype = null;\r | |
39 | public String entrypoint = null;\r | |
db0e6906 | 40 | public String license = null;\r |
27e0221a | 41 | \r |
42 | public final Set<String> localmodulesources = new HashSet<String>(); //contains both .c and .h\r | |
43 | public final Set<String> preprocessedccodes = new HashSet<String>();\r | |
44 | public final Set<String> msaorinf = new HashSet<String>(); //only a little, hash may be too big for this\r | |
39e5e412 | 45 | public final Set<String> infincludes = new HashSet<String>();\r |
46 | public final Set<String> infsources = new HashSet<String>();\r | |
27e0221a | 47 | \r |
48 | public final Set<String> hashfuncc = new HashSet<String>();\r | |
49 | public final Set<String> hashfuncd = new HashSet<String>();\r | |
50 | public final Set<String> hashnonlocalfunc = new HashSet<String>();\r | |
51 | public final Set<String> hashnonlocalmacro = new HashSet<String>();\r | |
52 | public final Set<String> hashEFIcall = new HashSet<String>();\r | |
53 | public final Set<String> hashr8only = new HashSet<String>();\r | |
9f98dbb7 | 54 | public final Set<String> hashmacro = new HashSet<String>();\r |
27e0221a | 55 | \r |
56 | public final Set<String> hashrequiredr9libs = new HashSet<String>(); // hashrequiredr9libs is now all added in SourceFileReplacer \r | |
323e2ffc | 57 | public final Set<String> guids = new HashSet<String>();\r |
58 | public final Set<String> protocols = new HashSet<String>();\r | |
59 | public final Set<String> ppis = new HashSet<String>();\r | |
60 | \r | |
61 | //-----------------------------------------------------------------------------------//\r | |
23e3b888 | 62 | \r |
8270b34d | 63 | //addModuleType\r |
64 | //addGuidValue\r | |
65 | //addModuleName\r | |
66 | \r | |
67 | public final boolean addSourceFile (String filename, Enum en) {\r | |
68 | localmodulesources.add(filename);\r | |
69 | return msaowner.addSourceFile(filename, en);\r | |
70 | }\r | |
71 | \r | |
323e2ffc | 72 | public final boolean addProtocol (String proname, UsageTypes.Enum usage) {\r |
8270b34d | 73 | protocols.add(proname);\r |
1ea59929 | 74 | return msaowner.addProtocol(proname, usage);\r |
323e2ffc | 75 | }\r |
76 | \r | |
77 | public final boolean addPpi (String ppiname, UsageTypes.Enum usage) {\r | |
8270b34d | 78 | ppis.add(ppiname);\r |
1ea59929 | 79 | return msaowner.addPpi(ppiname, usage);\r |
323e2ffc | 80 | }\r |
81 | \r | |
82 | public final boolean addGuid (String guidname, UsageTypes.Enum usage) {\r | |
8270b34d | 83 | guids.add(guidname);\r |
1ea59929 | 84 | return msaowner.addGuid(guidname, usage);\r |
323e2ffc | 85 | }\r |
86 | \r | |
87 | public final boolean addLibraryClass(String name, UsageTypes.Enum usage) {\r | |
8270b34d | 88 | //\r |
89 | // This section is only for adding library classes, this functionality should be inside MsaOwner!!!\r | |
90 | //\r | |
91 | //if (!hashrequiredr9libs.contains(name)) {\r | |
92 | msaowner.addLibraryClass(name, usage);\r | |
93 | //}\r | |
94 | //\r | |
95 | hashrequiredr9libs.add(name);\r | |
96 | return true;\r | |
323e2ffc | 97 | }\r |
98 | \r | |
99 | //-----------------------------------------------------------------------------------//\r | |
100 | \r | |
27e0221a | 101 | public final String getModuleType() {\r |
102 | if (moduletype.contains("PEI")) {\r | |
103 | return "PEIM";\r | |
104 | } else {\r | |
105 | return "DXE_DRIVER";\r | |
106 | }\r | |
107 | }\r | |
108 | \r | |
109 | public final void enroll(String filepath) throws Exception {\r | |
110 | String temp = null;\r | |
3c82f1a5 | 111 | if (filepath.contains(".inf") || filepath.contains(".msa")) {\r |
27e0221a | 112 | temp = filepath.replace(modulepath + File.separator, "");\r |
113 | if (!temp.contains(File.separator)) { // .inf in subdirectory is not regarded\r | |
114 | msaorinf.add(temp);\r | |
115 | }\r | |
3c82f1a5 | 116 | } else if (filepath.contains(".c") || filepath.contains(".C") || filepath.contains(".h") || \r |
117 | filepath.contains(".H") || filepath.contains(".dxs") || filepath.contains(".uni") ||\r | |
118 | filepath.contains(".s") || filepath.contains(".S") || filepath.contains(".i") ||\r | |
119 | filepath.contains(".asm")) {\r | |
120 | addSourceFile(filepath.replace(modulepath + File.separator, ""), null);\r | |
121 | } \r | |
27e0221a | 122 | }\r |
23e3b888 | 123 | \r |
27e0221a | 124 | public static final boolean isModule(String path) {\r |
125 | String[] list = new File(path).list();\r | |
126 | for (int i = 0 ; i < list.length ; i++) {\r | |
127 | if (!new File(list[i]).isDirectory()) {\r | |
128 | if (list[i].contains(".inf") || list[i].contains(".msa")) {\r | |
129 | return true;\r | |
130 | }\r | |
131 | }\r | |
132 | }\r | |
133 | return false;\r | |
134 | }\r | |
1ea59929 | 135 | \r |
136 | public final MsaOwner getMsaOwner() {\r | |
137 | return msaowner;\r | |
138 | }\r | |
e6a5df3b | 139 | } |